From e767c59da252e0338cf43dd5142bfa69f4a27536 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Mon, 23 Jan 2017 18:50:30 +0530 Subject: [PATCH] enable pdf plugin by default --- atom/app/atom_content_client.cc | 7 ++++--- atom/common/atom_constants.cc | 3 +++ atom/common/atom_constants.h | 4 ++++ atom/renderer/atom_renderer_client.cc | 7 +++++-- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/atom/app/atom_content_client.cc b/atom/app/atom_content_client.cc index e34685458cf3..bebb2cc4a0eb 100644 --- a/atom/app/atom_content_client.cc +++ b/atom/app/atom_content_client.cc @@ -8,6 +8,7 @@ #include #include "atom/browser/ui/webui/pdf_viewer_ui.h" +#include "atom/common/atom_constants.h" #include "atom/common/atom_version.h" #include "atom/common/chrome_version.h" #include "atom/common/options_switches.h" @@ -116,9 +117,9 @@ void ComputeBuiltInPlugins(std::vector* plugins) { pdf_info.is_out_of_process = true; pdf_info.name = "Chromium PDF Viewer"; pdf_info.description = "Portable Document Format"; - pdf_info.path = base::FilePath::FromUTF8Unsafe(PdfViewerUI::kOrigin); - content::WebPluginMimeType pdf_mime_type("application/x-google-chrome-pdf", - "pdf", "Portable Document Format"); + pdf_info.path = base::FilePath::FromUTF8Unsafe(kPdfPluginPath); + content::WebPluginMimeType pdf_mime_type(kPdfPluginMimeType, "pdf", + "Portable Document Format"); pdf_info.mime_types.push_back(pdf_mime_type); pdf_info.internal_entry_points.get_interface = chrome_pdf::PPP_GetInterface; pdf_info.internal_entry_points.initialize_module = diff --git a/atom/common/atom_constants.cc b/atom/common/atom_constants.cc index f66c947aa24c..e8a7c2f7aa62 100644 --- a/atom/common/atom_constants.cc +++ b/atom/common/atom_constants.cc @@ -24,4 +24,7 @@ const char kSecureProtocolDescription[] = "The connection to this site is using a strong protocol version " "and cipher suite."; +const char kPdfPluginMimeType[] = "application/x-google-chrome-pdf"; +const char kPdfPluginPath[] = "chrome://pdf-viewer/"; + } // namespace atom diff --git a/atom/common/atom_constants.h b/atom/common/atom_constants.h index b67b7b2e4ae5..24186cf92cea 100644 --- a/atom/common/atom_constants.h +++ b/atom/common/atom_constants.h @@ -20,6 +20,10 @@ extern const char kValidCertificateDescription[]; extern const char kSecureProtocol[]; extern const char kSecureProtocolDescription[]; +// The MIME type used for the PDF plugin. +extern const char kPdfPluginMimeType[]; +extern const char kPdfPluginPath[]; + } // namespace atom #endif // ATOM_COMMON_ATOM_CONSTANTS_H_ diff --git a/atom/renderer/atom_renderer_client.cc b/atom/renderer/atom_renderer_client.cc index 1db52bd7cbcb..b0742e5c26e8 100644 --- a/atom/renderer/atom_renderer_client.cc +++ b/atom/renderer/atom_renderer_client.cc @@ -12,6 +12,7 @@ #include "atom/common/api/api_messages.h" #include "atom/common/api/atom_bindings.h" #include "atom/common/api/event_emitter_caller.h" +#include "atom/common/atom_constants.h" #include "atom/common/color_util.h" #include "atom/common/native_mate_converters/value_converter.h" #include "atom/common/node_bindings.h" @@ -274,8 +275,9 @@ void AtomRendererClient::RenderFrameCreated( // This is required for widevine plugin detection provided during runtime. blink::resetPluginCache(); - blink::WebSecurityPolicy::addOriginAccessWhitelistEntry( - GURL("chrome://pdf-viewer/"), "file", "", true); + // Allow access to file scheme from pdf viewer. + blink::WebSecurityPolicy::addOriginAccessWhitelistEntry(GURL(kPdfPluginPath), + "file", "", true); // Parse --secure-schemes=scheme1,scheme2 std::vector secure_schemes_list = @@ -342,6 +344,7 @@ bool AtomRendererClient::OverrideCreatePlugin( blink::WebPlugin** plugin) { base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); if (params.mimeType.utf8() == content::kBrowserPluginMimeType || + params.mimeType.utf8() == kPdfPluginMimeType || command_line->HasSwitch(switches::kEnablePlugins)) return false;