Skip to content

Commit

Permalink
M110: Add kPDFExtensionPluginPath constant
Browse files Browse the repository at this point in the history
Adds a new kPDFExtensionPluginPath constant to ChromeContentClient,
consolidating uses of the PDF extension URL as a base::FilePath literal.

To avoid confusion, this change also renames the existing kPDFPluginPath
constant to kPDFInternalPluginPath.

(cherry picked from commit 82c8a91)

Bug: 1404260, 1405531
Change-Id: I4674ab78b59c3b06ff1dea871b65d9307029bcf3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4148187
Auto-Submit: K. Moon <kmoon@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Commit-Queue: K. Moon <kmoon@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1090400}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4156891
Cr-Commit-Position: refs/branch-heads/5481@{#246}
Cr-Branched-From: 130f3e4-refs/heads/main@{#1084008}
  • Loading branch information
kmoon-work authored and Chromium LUCI CQ committed Jan 12, 2023
1 parent 1d558f0 commit 8706747
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 20 deletions.
23 changes: 11 additions & 12 deletions chrome/browser/plugins/plugin_info_host_impl_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ using ::testing::Field;
using ::testing::IsEmpty;
using ::testing::SizeIs;

#if BUILDFLAG(ENABLE_PDF)
constexpr base::FilePath::CharType kPdfViewerExtensionPath[] =
FILE_PATH_LITERAL("chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/");
#endif // BUILDFLAG(ENABLE_PDF)

} // namespace

class PluginInfoHostImplTest : public InProcessBrowserTest {
Expand Down Expand Up @@ -124,13 +119,16 @@ IN_PROC_BROWSER_TEST_F(PluginInfoHostImplTest, CoverAllPlugins) {
#endif // BUILDFLAG_ENABLE_NACL)

#if BUILDFLAG(ENABLE_PDF)
EXPECT_THAT(plugins,
Contains(Field("path", &WebPluginInfo::path,
base::FilePath(kPdfViewerExtensionPath))));
EXPECT_THAT(
plugins,
Contains(Field("path", &WebPluginInfo::path,
base::FilePath(ChromeContentClient ::kPDFPluginPath))));
Contains(
Field("path", &WebPluginInfo::path,
base::FilePath(ChromeContentClient::kPDFExtensionPluginPath))));
EXPECT_THAT(
plugins,
Contains(
Field("path", &WebPluginInfo::path,
base::FilePath(ChromeContentClient ::kPDFInternalPluginPath))));
expected_plugin_count += 2;
#endif // BUILDFLAG(ENABLE_PDF)

Expand Down Expand Up @@ -282,7 +280,8 @@ IN_PROC_BROWSER_TEST_F(PluginInfoHostImplTest,

// `WebPluginInfo` fields.
EXPECT_EQ(kPluginName, plugin_info->plugin.name);
EXPECT_EQ(base::FilePath(kPdfViewerExtensionPath), plugin_info->plugin.path);
EXPECT_EQ(base::FilePath(ChromeContentClient::kPDFExtensionPluginPath),
plugin_info->plugin.path);
EXPECT_EQ(u"", plugin_info->plugin.version);
EXPECT_EQ(u"", plugin_info->plugin.desc);
EXPECT_EQ(WebPluginInfo::PLUGIN_TYPE_BROWSER_PLUGIN,
Expand Down Expand Up @@ -338,7 +337,7 @@ IN_PROC_BROWSER_TEST_F(PluginInfoHostImplTest,

// `WebPluginInfo` fields.
EXPECT_EQ(kPluginName, plugin_info->plugin.name);
EXPECT_EQ(base::FilePath(ChromeContentClient::kPDFPluginPath),
EXPECT_EQ(base::FilePath(ChromeContentClient::kPDFInternalPluginPath),
plugin_info->plugin.path);
EXPECT_EQ(u"", plugin_info->plugin.version);
EXPECT_EQ(u"Portable Document Format", plugin_info->plugin.desc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void PluginsLoadedCallback(

void CheckPdfPluginForRenderFrame(content::RenderFrameHost* frame) {
static const base::FilePath kPdfInternalPluginPath(
ChromeContentClient::kPDFPluginPath);
ChromeContentClient::kPDFInternalPluginPath);

content::WebPluginInfo pdf_internal_plugin_info;
ASSERT_TRUE(content::PluginService::GetInstance()->GetPluginInfoByPath(
Expand Down Expand Up @@ -230,8 +230,7 @@ IN_PROC_BROWSER_TEST_F(PrintPreviewDialogControllerBrowserTest,
// Get the PDF plugin info.
content::WebPluginInfo pdf_external_plugin_info;
ASSERT_TRUE(content::PluginService::GetInstance()->GetPluginInfoByPath(
base::FilePath(FILE_PATH_LITERAL(
"chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/")),
base::FilePath(ChromeContentClient::kPDFExtensionPluginPath),
&pdf_external_plugin_info));

// Disable the PDF plugin.
Expand Down
2 changes: 1 addition & 1 deletion chrome/common/chrome_content_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ void ChromeContentClient::AddPlugins(
pdf_info.is_out_of_process = true;
pdf_info.name = ChromeContentClient::kPDFInternalPluginName;
pdf_info.description = kPDFPluginDescription;
pdf_info.path = base::FilePath(ChromeContentClient::kPDFPluginPath);
pdf_info.path = base::FilePath(ChromeContentClient::kPDFInternalPluginPath);
content::WebPluginMimeType pdf_mime_type(
pdf::kInternalPluginMimeType, kPDFPluginExtension, kPDFPluginDescription);
pdf_info.mime_types.push_back(pdf_mime_type);
Expand Down
3 changes: 2 additions & 1 deletion chrome/common/chrome_content_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class ChromeContentClient : public content::ContentClient {

static const char kPDFExtensionPluginName[];
static const char kPDFInternalPluginName[];
static const base::FilePath::CharType kPDFPluginPath[];
static const base::FilePath::CharType kPDFExtensionPluginPath[];
static const base::FilePath::CharType kPDFInternalPluginPath[];

ChromeContentClient();
~ChromeContentClient() override;
Expand Down
4 changes: 3 additions & 1 deletion chrome/common/chrome_content_client_constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ const char ChromeContentClient::kPDFInternalPluginName[] =
"Chromium PDF Plugin";
#endif

const base::FilePath::CharType ChromeContentClient::kPDFPluginPath[] =
const base::FilePath::CharType ChromeContentClient::kPDFExtensionPluginPath[] =
FILE_PATH_LITERAL("chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/");
const base::FilePath::CharType ChromeContentClient::kPDFInternalPluginPath[] =
FILE_PATH_LITERAL("internal-pdf-viewer");
2 changes: 1 addition & 1 deletion chrome/renderer/chrome_content_renderer_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,7 @@ bool ChromeContentRendererClient::IsOriginIsolatedPepperPlugin(
// The kPpapiInProcess switch should only be used by tests. In particular,
// we expect that the PDF plugin should always be isolated in the product
// (and that the switch won't interfere with PDF isolation).
CHECK_NE(ChromeContentClient::kPDFPluginPath, plugin_path.value());
CHECK_NE(ChromeContentClient::kPDFInternalPluginPath, plugin_path.value());

return false;
}
Expand Down
2 changes: 1 addition & 1 deletion chrome/renderer/pepper/pepper_uma_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const char* const kAllowedHistogramPrefixes[] = {
};

const base::FilePath::CharType* const kAllowedPluginBaseNames[] = {
ChromeContentClient::kPDFPluginPath,
ChromeContentClient::kPDFInternalPluginPath,
};

std::string HashPrefix(const std::string& histogram) {
Expand Down

0 comments on commit 8706747

Please sign in to comment.