move pdf viewer behind feature flag
This commit is contained in:
parent
c1908147a9
commit
4b39d17e5f
21 changed files with 159 additions and 63 deletions
|
@ -7,7 +7,6 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "atom/common/atom_constants.h"
|
|
||||||
#include "atom/common/atom_version.h"
|
#include "atom/common/atom_version.h"
|
||||||
#include "atom/common/chrome_version.h"
|
#include "atom/common/chrome_version.h"
|
||||||
#include "atom/common/options_switches.h"
|
#include "atom/common/options_switches.h"
|
||||||
|
@ -20,7 +19,6 @@
|
||||||
#include "content/public/common/pepper_plugin_info.h"
|
#include "content/public/common/pepper_plugin_info.h"
|
||||||
#include "content/public/common/user_agent.h"
|
#include "content/public/common/user_agent.h"
|
||||||
#include "media/media_features.h"
|
#include "media/media_features.h"
|
||||||
#include "pdf/pdf.h"
|
|
||||||
#include "ppapi/shared_impl/ppapi_permissions.h"
|
#include "ppapi/shared_impl/ppapi_permissions.h"
|
||||||
#include "third_party/widevine/cdm/stub/widevine_cdm_version.h"
|
#include "third_party/widevine/cdm/stub/widevine_cdm_version.h"
|
||||||
#include "ui/base/l10n/l10n_util.h"
|
#include "ui/base/l10n/l10n_util.h"
|
||||||
|
@ -30,6 +28,11 @@
|
||||||
#include "chrome/common/widevine_cdm_constants.h"
|
#include "chrome/common/widevine_cdm_constants.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(ENABLE_PDF_VIEWER)
|
||||||
|
#include "atom/common/atom_constants.h"
|
||||||
|
#include "pdf/pdf.h"
|
||||||
|
#endif // defined(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -111,6 +114,7 @@ content::PepperPluginInfo CreateWidevineCdmInfo(const base::FilePath& path,
|
||||||
}
|
}
|
||||||
#endif // defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_LIBRARY_CDMS)
|
#endif // defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_LIBRARY_CDMS)
|
||||||
|
|
||||||
|
#if defined(ENABLE_PDF_VIEWER)
|
||||||
void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) {
|
void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) {
|
||||||
content::PepperPluginInfo pdf_info;
|
content::PepperPluginInfo pdf_info;
|
||||||
pdf_info.is_internal = true;
|
pdf_info.is_internal = true;
|
||||||
|
@ -129,6 +133,7 @@ void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) {
|
||||||
pdf_info.permissions = ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV;
|
pdf_info.permissions = ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV;
|
||||||
plugins->push_back(pdf_info);
|
plugins->push_back(pdf_info);
|
||||||
}
|
}
|
||||||
|
#endif // defined(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
void ConvertStringWithSeparatorToVector(std::vector<std::string>* vec,
|
void ConvertStringWithSeparatorToVector(std::vector<std::string>* vec,
|
||||||
const char* separator,
|
const char* separator,
|
||||||
|
@ -220,7 +225,9 @@ void AtomContentClient::AddPepperPlugins(
|
||||||
#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_LIBRARY_CDMS)
|
#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_LIBRARY_CDMS)
|
||||||
AddWidevineCdmFromCommandLine(plugins);
|
AddWidevineCdmFromCommandLine(plugins);
|
||||||
#endif // defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_LIBRARY_CDMS)
|
#endif // defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_LIBRARY_CDMS)
|
||||||
|
#if defined(ENABLE_PDF_VIEWER)
|
||||||
ComputeBuiltInPlugins(plugins);
|
ComputeBuiltInPlugins(plugins);
|
||||||
|
#endif // defined(ENABLE_PDF_VIEWER)
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
#include "atom/browser/atom_access_token_store.h"
|
#include "atom/browser/atom_access_token_store.h"
|
||||||
#include "atom/browser/atom_browser_client.h"
|
#include "atom/browser/atom_browser_client.h"
|
||||||
#include "atom/browser/atom_browser_context.h"
|
#include "atom/browser/atom_browser_context.h"
|
||||||
#include "atom/browser/atom_web_ui_controller_factory.h"
|
|
||||||
#include "atom/browser/bridge_task_runner.h"
|
#include "atom/browser/bridge_task_runner.h"
|
||||||
#include "atom/browser/browser.h"
|
#include "atom/browser/browser.h"
|
||||||
#include "atom/browser/javascript_environment.h"
|
#include "atom/browser/javascript_environment.h"
|
||||||
|
@ -33,6 +32,10 @@
|
||||||
#include "ui/events/devices/x11/touch_factory_x11.h"
|
#include "ui/events/devices/x11/touch_factory_x11.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(ENABLE_PDF_VIEWER)
|
||||||
|
#include "atom/browser/atom_web_ui_controller_factory.h"
|
||||||
|
#endif // defined(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -186,8 +189,10 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() {
|
||||||
base::Bind(&v8::Isolate::LowMemoryNotification,
|
base::Bind(&v8::Isolate::LowMemoryNotification,
|
||||||
base::Unretained(js_env_->isolate())));
|
base::Unretained(js_env_->isolate())));
|
||||||
|
|
||||||
|
#if defined(ENABLE_PDF_VIEWER)
|
||||||
content::WebUIControllerFactory::RegisterFactory(
|
content::WebUIControllerFactory::RegisterFactory(
|
||||||
AtomWebUIControllerFactory::GetInstance());
|
AtomWebUIControllerFactory::GetInstance());
|
||||||
|
#endif // defined(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
brightray::BrowserMainParts::PreMainMessageLoopRun();
|
brightray::BrowserMainParts::PreMainMessageLoopRun();
|
||||||
bridge_task_runner_->MessageLoopIsReady();
|
bridge_task_runner_->MessageLoopIsReady();
|
||||||
|
|
|
@ -8,17 +8,13 @@
|
||||||
#include "atom/browser/login_handler.h"
|
#include "atom/browser/login_handler.h"
|
||||||
#include "atom/browser/web_contents_permission_helper.h"
|
#include "atom/browser/web_contents_permission_helper.h"
|
||||||
#include "atom/browser/web_contents_preferences.h"
|
#include "atom/browser/web_contents_preferences.h"
|
||||||
#include "atom/common/atom_constants.h"
|
|
||||||
#include "atom/common/platform_util.h"
|
#include "atom/common/platform_util.h"
|
||||||
#include "base/strings/stringprintf.h"
|
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "content/public/browser/browser_thread.h"
|
#include "content/public/browser/browser_thread.h"
|
||||||
#include "content/public/browser/download_manager.h"
|
#include "content/public/browser/download_manager.h"
|
||||||
#include "content/public/browser/render_frame_host.h"
|
#include "content/public/browser/render_frame_host.h"
|
||||||
#include "content/public/browser/stream_info.h"
|
|
||||||
#include "net/base/escape.h"
|
#include "net/base/escape.h"
|
||||||
#include "net/ssl/client_cert_store.h"
|
#include "net/ssl/client_cert_store.h"
|
||||||
#include "net/url_request/url_request.h"
|
|
||||||
#include "url/gurl.h"
|
#include "url/gurl.h"
|
||||||
|
|
||||||
#if defined(USE_NSS_CERTS)
|
#if defined(USE_NSS_CERTS)
|
||||||
|
@ -29,6 +25,14 @@
|
||||||
#include "net/ssl/client_cert_store_mac.h"
|
#include "net/ssl/client_cert_store_mac.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(ENABLE_PDF_VIEWER)
|
||||||
|
#include "atom/common/atom_constants.h"
|
||||||
|
#include "base/strings/stringprintf.h"
|
||||||
|
#include "content/public/browser/stream_info.h"
|
||||||
|
#include "net/url_request/url_request.h"
|
||||||
|
#endif // defined(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
|
|
||||||
using content::BrowserThread;
|
using content::BrowserThread;
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
@ -65,6 +69,7 @@ void HandleExternalProtocolInUI(
|
||||||
url);
|
url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(ENABLE_PDF_VIEWER)
|
||||||
void OnPdfResourceIntercepted(
|
void OnPdfResourceIntercepted(
|
||||||
const GURL& original_url,
|
const GURL& original_url,
|
||||||
int render_process_host_id,
|
int render_process_host_id,
|
||||||
|
@ -102,6 +107,7 @@ void OnPdfResourceIntercepted(
|
||||||
params.frame_tree_node_id = frame_host->GetFrameTreeNodeId();
|
params.frame_tree_node_id = frame_host->GetFrameTreeNodeId();
|
||||||
web_contents->GetController().LoadURLWithParams(params);
|
web_contents->GetController().LoadURLWithParams(params);
|
||||||
}
|
}
|
||||||
|
#endif // defined(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -145,6 +151,7 @@ bool AtomResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream(
|
||||||
const std::string& mime_type,
|
const std::string& mime_type,
|
||||||
GURL* origin,
|
GURL* origin,
|
||||||
std::string* payload) {
|
std::string* payload) {
|
||||||
|
#if defined(ENABLE_PDF_VIEWER)
|
||||||
const content::ResourceRequestInfo* info =
|
const content::ResourceRequestInfo* info =
|
||||||
content::ResourceRequestInfo::ForRequest(request);
|
content::ResourceRequestInfo::ForRequest(request);
|
||||||
|
|
||||||
|
@ -164,6 +171,7 @@ bool AtomResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream(
|
||||||
info->GetWebContentsGetterForRequest()));
|
info->GetWebContentsGetterForRequest()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#endif // defined(ENABLE_PDF_VIEWER)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,14 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#if defined(ENABLE_PDF_VIEWER)
|
||||||
#include "atom/browser/ui/webui/pdf_viewer_ui.h"
|
#include "atom/browser/ui/webui/pdf_viewer_ui.h"
|
||||||
#include "atom/common/atom_constants.h"
|
#include "atom/common/atom_constants.h"
|
||||||
#include "base/strings/string_split.h"
|
#include "base/strings/string_split.h"
|
||||||
#include "base/strings/string_util.h"
|
#include "base/strings/string_util.h"
|
||||||
#include "content/public/browser/web_contents.h"
|
#include "content/public/browser/web_contents.h"
|
||||||
#include "net/base/escape.h"
|
#include "net/base/escape.h"
|
||||||
|
#endif // defined(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
|
@ -27,9 +29,11 @@ AtomWebUIControllerFactory::~AtomWebUIControllerFactory() {}
|
||||||
content::WebUI::TypeID AtomWebUIControllerFactory::GetWebUIType(
|
content::WebUI::TypeID AtomWebUIControllerFactory::GetWebUIType(
|
||||||
content::BrowserContext* browser_context,
|
content::BrowserContext* browser_context,
|
||||||
const GURL& url) const {
|
const GURL& url) const {
|
||||||
|
#if defined(ENABLE_PDF_VIEWER)
|
||||||
if (url.host() == kPdfViewerUIHost) {
|
if (url.host() == kPdfViewerUIHost) {
|
||||||
return const_cast<AtomWebUIControllerFactory*>(this);
|
return const_cast<AtomWebUIControllerFactory*>(this);
|
||||||
}
|
}
|
||||||
|
#endif // defined(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
return content::WebUI::kNoWebUI;
|
return content::WebUI::kNoWebUI;
|
||||||
}
|
}
|
||||||
|
@ -49,6 +53,7 @@ bool AtomWebUIControllerFactory::UseWebUIBindingsForURL(
|
||||||
content::WebUIController*
|
content::WebUIController*
|
||||||
AtomWebUIControllerFactory::CreateWebUIControllerForURL(content::WebUI* web_ui,
|
AtomWebUIControllerFactory::CreateWebUIControllerForURL(content::WebUI* web_ui,
|
||||||
const GURL& url) const {
|
const GURL& url) const {
|
||||||
|
#if defined(ENABLE_PDF_VIEWER)
|
||||||
if (url.host() == kPdfViewerUIHost) {
|
if (url.host() == kPdfViewerUIHost) {
|
||||||
base::StringPairs toplevel_params;
|
base::StringPairs toplevel_params;
|
||||||
base::SplitStringIntoKeyValuePairs(url.query(), '=', '&', &toplevel_params);
|
base::SplitStringIntoKeyValuePairs(url.query(), '=', '&', &toplevel_params);
|
||||||
|
@ -70,6 +75,7 @@ AtomWebUIControllerFactory::CreateWebUIControllerForURL(content::WebUI* web_ui,
|
||||||
auto browser_context = web_ui->GetWebContents()->GetBrowserContext();
|
auto browser_context = web_ui->GetWebContents()->GetBrowserContext();
|
||||||
return new PdfViewerUI(browser_context, web_ui, src);
|
return new PdfViewerUI(browser_context, web_ui, src);
|
||||||
}
|
}
|
||||||
|
#endif // defined(ENABLE_PDF_VIEWER)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#ifndef ENABLE_PDF_VIEWER
|
||||||
|
#error("This header can only be used when enable_pdf_viewer gyp flag is enabled")
|
||||||
|
#endif // defined(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
#include "atom/browser/ui/webui/pdf_viewer_handler.h"
|
#include "atom/browser/ui/webui/pdf_viewer_handler.h"
|
||||||
|
|
||||||
#include "atom/common/atom_constants.h"
|
#include "atom/common/atom_constants.h"
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#ifndef ENABLE_PDF_VIEWER
|
||||||
|
#error("This header can only be used when enable_pdf_viewer gyp flag is enabled")
|
||||||
|
#endif // defined(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
#ifndef ATOM_BROWSER_UI_WEBUI_PDF_VIEWER_HANDLER_H_
|
#ifndef ATOM_BROWSER_UI_WEBUI_PDF_VIEWER_HANDLER_H_
|
||||||
#define ATOM_BROWSER_UI_WEBUI_PDF_VIEWER_HANDLER_H_
|
#define ATOM_BROWSER_UI_WEBUI_PDF_VIEWER_HANDLER_H_
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#ifndef ENABLE_PDF_VIEWER
|
||||||
|
#error("This header can only be used when enable_pdf_viewer gyp flag is enabled")
|
||||||
|
#endif // defined(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
#include "atom/browser/ui/webui/pdf_viewer_ui.h"
|
#include "atom/browser/ui/webui/pdf_viewer_ui.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#ifndef ENABLE_PDF_VIEWER
|
||||||
|
#error("This header can only be used when enable_pdf_viewer gyp flag is enabled")
|
||||||
|
#endif // defined(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
#ifndef ATOM_BROWSER_UI_WEBUI_PDF_VIEWER_UI_H_
|
#ifndef ATOM_BROWSER_UI_WEBUI_PDF_VIEWER_UI_H_
|
||||||
#define ATOM_BROWSER_UI_WEBUI_PDF_VIEWER_UI_H_
|
#define ATOM_BROWSER_UI_WEBUI_PDF_VIEWER_UI_H_
|
||||||
|
|
||||||
|
|
|
@ -24,11 +24,13 @@ const char kSecureProtocolDescription[] =
|
||||||
"The connection to this site is using a strong protocol version "
|
"The connection to this site is using a strong protocol version "
|
||||||
"and cipher suite.";
|
"and cipher suite.";
|
||||||
|
|
||||||
|
#if defined(ENABLE_PDF_VIEWER)
|
||||||
const char kPdfPluginMimeType[] = "application/x-google-chrome-pdf";
|
const char kPdfPluginMimeType[] = "application/x-google-chrome-pdf";
|
||||||
const char kPdfPluginPath[] = "chrome://pdf-viewer/";
|
const char kPdfPluginPath[] = "chrome://pdf-viewer/";
|
||||||
const char kPdfPluginSrc[] = "src";
|
const char kPdfPluginSrc[] = "src";
|
||||||
|
|
||||||
const char kPdfViewerUIOrigin[] = "chrome://pdf-viewer/";
|
const char kPdfViewerUIOrigin[] = "chrome://pdf-viewer/";
|
||||||
const char kPdfViewerUIHost[] = "pdf-viewer";
|
const char kPdfViewerUIHost[] = "pdf-viewer";
|
||||||
|
#endif // defined(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -20,6 +20,7 @@ extern const char kValidCertificateDescription[];
|
||||||
extern const char kSecureProtocol[];
|
extern const char kSecureProtocol[];
|
||||||
extern const char kSecureProtocolDescription[];
|
extern const char kSecureProtocolDescription[];
|
||||||
|
|
||||||
|
#if defined(ENABLE_PDF_VIEWER)
|
||||||
// The MIME type used for the PDF plugin.
|
// The MIME type used for the PDF plugin.
|
||||||
extern const char kPdfPluginMimeType[];
|
extern const char kPdfPluginMimeType[];
|
||||||
extern const char kPdfPluginPath[];
|
extern const char kPdfPluginPath[];
|
||||||
|
@ -28,6 +29,7 @@ extern const char kPdfPluginSrc[];
|
||||||
// Constants for PDF viewer webui.
|
// Constants for PDF viewer webui.
|
||||||
extern const char kPdfViewerUIOrigin[];
|
extern const char kPdfViewerUIOrigin[];
|
||||||
extern const char kPdfViewerUIHost[];
|
extern const char kPdfViewerUIHost[];
|
||||||
|
#endif // defined(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include "atom/common/api/atom_bindings.h"
|
#include "atom/common/api/atom_bindings.h"
|
||||||
#include "atom/common/api/event_emitter_caller.h"
|
#include "atom/common/api/event_emitter_caller.h"
|
||||||
#include "atom/common/asar/asar_util.h"
|
#include "atom/common/asar/asar_util.h"
|
||||||
#include "atom/common/atom_constants.h"
|
|
||||||
#include "atom/common/node_bindings.h"
|
#include "atom/common/node_bindings.h"
|
||||||
#include "atom/common/options_switches.h"
|
#include "atom/common/options_switches.h"
|
||||||
#include "atom/renderer/api/atom_api_renderer_ipc.h"
|
#include "atom/renderer/api/atom_api_renderer_ipc.h"
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "atom/common/atom_constants.h"
|
|
||||||
#include "atom/common/color_util.h"
|
#include "atom/common/color_util.h"
|
||||||
#include "atom/common/native_mate_converters/value_converter.h"
|
#include "atom/common/native_mate_converters/value_converter.h"
|
||||||
#include "atom/common/options_switches.h"
|
#include "atom/common/options_switches.h"
|
||||||
|
@ -44,6 +43,10 @@
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(ENABLE_PDF_VIEWER)
|
||||||
|
#include "atom/common/atom_constants.h"
|
||||||
|
#endif // defined(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -153,9 +156,11 @@ void RendererClientBase::RenderFrameCreated(
|
||||||
// This is required for widevine plugin detection provided during runtime.
|
// This is required for widevine plugin detection provided during runtime.
|
||||||
blink::ResetPluginCache();
|
blink::ResetPluginCache();
|
||||||
|
|
||||||
|
#if defined(ENABLE_PDF_VIEWER)
|
||||||
// Allow access to file scheme from pdf viewer.
|
// Allow access to file scheme from pdf viewer.
|
||||||
blink::WebSecurityPolicy::AddOriginAccessWhitelistEntry(
|
blink::WebSecurityPolicy::AddOriginAccessWhitelistEntry(
|
||||||
GURL(kPdfViewerUIOrigin), "file", "", true);
|
GURL(kPdfViewerUIOrigin), "file", "", true);
|
||||||
|
#endif // defined(ENABLE_PDF_VIEWER)
|
||||||
}
|
}
|
||||||
|
|
||||||
void RendererClientBase::RenderViewCreated(content::RenderView* render_view) {
|
void RendererClientBase::RenderViewCreated(content::RenderView* render_view) {
|
||||||
|
@ -192,7 +197,9 @@ bool RendererClientBase::OverrideCreatePlugin(
|
||||||
blink::WebPlugin** plugin) {
|
blink::WebPlugin** plugin) {
|
||||||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||||
if (params.mime_type.Utf8() == content::kBrowserPluginMimeType ||
|
if (params.mime_type.Utf8() == content::kBrowserPluginMimeType ||
|
||||||
|
#if defined(ENABLE_PDF_VIEWER)
|
||||||
params.mime_type.Utf8() == kPdfPluginMimeType ||
|
params.mime_type.Utf8() == kPdfPluginMimeType ||
|
||||||
|
#endif // defined(ENABLE_PDF_VIEWER)
|
||||||
command_line->HasSwitch(switches::kEnablePlugins))
|
command_line->HasSwitch(switches::kEnablePlugins))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -5,12 +5,10 @@
|
||||||
#include "chrome/renderer/pepper/chrome_renderer_pepper_host_factory.h"
|
#include "chrome/renderer/pepper/chrome_renderer_pepper_host_factory.h"
|
||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/memory/ptr_util.h"
|
|
||||||
#include "chrome/renderer/pepper/pepper_flash_font_file_host.h"
|
#include "chrome/renderer/pepper/pepper_flash_font_file_host.h"
|
||||||
#include "chrome/renderer/pepper/pepper_flash_fullscreen_host.h"
|
#include "chrome/renderer/pepper/pepper_flash_fullscreen_host.h"
|
||||||
#include "chrome/renderer/pepper/pepper_flash_menu_host.h"
|
#include "chrome/renderer/pepper/pepper_flash_menu_host.h"
|
||||||
#include "chrome/renderer/pepper/pepper_flash_renderer_host.h"
|
#include "chrome/renderer/pepper/pepper_flash_renderer_host.h"
|
||||||
#include "components/pdf/renderer/pepper_pdf_host.h"
|
|
||||||
#include "content/public/renderer/renderer_ppapi_host.h"
|
#include "content/public/renderer/renderer_ppapi_host.h"
|
||||||
#include "ppapi/host/ppapi_host.h"
|
#include "ppapi/host/ppapi_host.h"
|
||||||
#include "ppapi/host/resource_host.h"
|
#include "ppapi/host/resource_host.h"
|
||||||
|
@ -18,6 +16,11 @@
|
||||||
#include "ppapi/proxy/ppapi_messages.h"
|
#include "ppapi/proxy/ppapi_messages.h"
|
||||||
#include "ppapi/shared_impl/ppapi_permissions.h"
|
#include "ppapi/shared_impl/ppapi_permissions.h"
|
||||||
|
|
||||||
|
#if defined(ENABLE_PDF_VIEWER)
|
||||||
|
#include "base/memory/ptr_util.h"
|
||||||
|
#include "components/pdf/renderer/pepper_pdf_host.h"
|
||||||
|
#endif // defined(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
using ppapi::host::ResourceHost;
|
using ppapi::host::ResourceHost;
|
||||||
|
|
||||||
ChromeRendererPepperHostFactory::ChromeRendererPepperHostFactory(
|
ChromeRendererPepperHostFactory::ChromeRendererPepperHostFactory(
|
||||||
|
@ -81,6 +84,7 @@ std::unique_ptr<ResourceHost> ChromeRendererPepperHostFactory::CreateResourceHos
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(ENABLE_PDF_VIEWER)
|
||||||
if (host_->GetPpapiHost()->permissions().HasPermission(
|
if (host_->GetPpapiHost()->permissions().HasPermission(
|
||||||
ppapi::PERMISSION_PRIVATE)) {
|
ppapi::PERMISSION_PRIVATE)) {
|
||||||
switch (message.type()) {
|
switch (message.type()) {
|
||||||
|
@ -89,6 +93,7 @@ std::unique_ptr<ResourceHost> ChromeRendererPepperHostFactory::CreateResourceHos
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // defined(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
return std::unique_ptr<ResourceHost>();
|
return std::unique_ptr<ResourceHost>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#ifndef ENABLE_PDF_VIEWER
|
||||||
|
#error("This header can only be used when enable_pdf_viewer gyp flag is enabled")
|
||||||
|
#endif // defined(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
#include "components/pdf/renderer/pepper_pdf_host.h"
|
#include "components/pdf/renderer/pepper_pdf_host.h"
|
||||||
|
|
||||||
#include "atom/common/api/api_messages.h"
|
#include "atom/common/api/api_messages.h"
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#ifndef ENABLE_PDF_VIEWER
|
||||||
|
#error("This header can only be used when enable_pdf_viewer gyp flag is enabled")
|
||||||
|
#endif // defined(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
#ifndef COMPONENTS_PDF_RENDERER_PEPPER_PDF_HOST_H_
|
#ifndef COMPONENTS_PDF_RENDERER_PEPPER_PDF_HOST_H_
|
||||||
#define COMPONENTS_PDF_RENDERER_PEPPER_PDF_HOST_H_
|
#define COMPONENTS_PDF_RENDERER_PEPPER_PDF_HOST_H_
|
||||||
|
|
||||||
|
|
19
electron.gyp
19
electron.gyp
|
@ -28,7 +28,12 @@
|
||||||
'ENABLE_OSR',
|
'ENABLE_OSR',
|
||||||
],
|
],
|
||||||
}], # enable_osr==1
|
}], # enable_osr==1
|
||||||
['enable_run_as_node', {
|
['enable_pdf_viewer==1', {
|
||||||
|
'defines': [
|
||||||
|
'ENABLE_PDF_VIEWER',
|
||||||
|
],
|
||||||
|
}], # enable_pdf_viewer
|
||||||
|
['enable_run_as_node==1', {
|
||||||
'defines': [
|
'defines': [
|
||||||
'ENABLE_RUN_AS_NODE',
|
'ENABLE_RUN_AS_NODE',
|
||||||
],
|
],
|
||||||
|
@ -243,7 +248,6 @@
|
||||||
'type': 'static_library',
|
'type': 'static_library',
|
||||||
'dependencies': [
|
'dependencies': [
|
||||||
'atom_js2c',
|
'atom_js2c',
|
||||||
'vendor/pdf_viewer/pdf_viewer.gyp:pdf_viewer',
|
|
||||||
'brightray/brightray.gyp:brightray',
|
'brightray/brightray.gyp:brightray',
|
||||||
'vendor/node/node.gyp:node_lib',
|
'vendor/node/node.gyp:node_lib',
|
||||||
],
|
],
|
||||||
|
@ -313,6 +317,11 @@
|
||||||
'brightray/brightray.gyp:brightray',
|
'brightray/brightray.gyp:brightray',
|
||||||
],
|
],
|
||||||
'conditions': [
|
'conditions': [
|
||||||
|
['enable_pdf_viewer==1', {
|
||||||
|
'dependencies': [
|
||||||
|
'vendor/pdf_viewer/pdf_viewer.gyp:pdf_viewer',
|
||||||
|
],
|
||||||
|
}], # enable_pdf_viewer
|
||||||
['libchromiumcontent_component', {
|
['libchromiumcontent_component', {
|
||||||
'link_settings': {
|
'link_settings': {
|
||||||
'libraries': [ '<@(libchromiumcontent_v8_libraries)' ],
|
'libraries': [ '<@(libchromiumcontent_v8_libraries)' ],
|
||||||
|
@ -614,7 +623,6 @@
|
||||||
'<(libchromiumcontent_dir)/icudtl.dat',
|
'<(libchromiumcontent_dir)/icudtl.dat',
|
||||||
'<(libchromiumcontent_dir)/natives_blob.bin',
|
'<(libchromiumcontent_dir)/natives_blob.bin',
|
||||||
'<(libchromiumcontent_dir)/snapshot_blob.bin',
|
'<(libchromiumcontent_dir)/snapshot_blob.bin',
|
||||||
'<(PRODUCT_DIR)/pdf_viewer_resources.pak',
|
|
||||||
],
|
],
|
||||||
'xcode_settings': {
|
'xcode_settings': {
|
||||||
'ATOM_BUNDLE_ID': 'com.<(company_abbr).<(project_name).framework',
|
'ATOM_BUNDLE_ID': 'com.<(company_abbr).<(project_name).framework',
|
||||||
|
@ -682,6 +690,11 @@
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
'conditions': [
|
'conditions': [
|
||||||
|
['enable_pdf_viewer==1', {
|
||||||
|
'mac_bundle_resources': [
|
||||||
|
'<(PRODUCT_DIR)/pdf_viewer_resources.pak',
|
||||||
|
],
|
||||||
|
}], # enable_pdf_viewer
|
||||||
['mas_build==0', {
|
['mas_build==0', {
|
||||||
'link_settings': {
|
'link_settings': {
|
||||||
'libraries': [
|
'libraries': [
|
||||||
|
|
|
@ -3,9 +3,11 @@
|
||||||
'variables': {
|
'variables': {
|
||||||
'variables': {
|
'variables': {
|
||||||
'enable_osr%': 0, # FIXME(alexeykuzmin)
|
'enable_osr%': 0, # FIXME(alexeykuzmin)
|
||||||
|
'enable_pdf_viewer%': 0,
|
||||||
'enable_run_as_node%': 1,
|
'enable_run_as_node%': 1,
|
||||||
},
|
},
|
||||||
'enable_osr%': '<(enable_osr)',
|
'enable_osr%': '<(enable_osr)',
|
||||||
|
'enable_pdf_viewer%': '<(enable_pdf_viewer)',
|
||||||
'enable_run_as_node%': '<(enable_run_as_node)',
|
'enable_run_as_node%': '<(enable_run_as_node)',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -354,10 +354,6 @@
|
||||||
'atom/browser/ui/views/submenu_button.h',
|
'atom/browser/ui/views/submenu_button.h',
|
||||||
'atom/browser/ui/views/win_frame_view.cc',
|
'atom/browser/ui/views/win_frame_view.cc',
|
||||||
'atom/browser/ui/views/win_frame_view.h',
|
'atom/browser/ui/views/win_frame_view.h',
|
||||||
'atom/browser/ui/webui/pdf_viewer_handler.cc',
|
|
||||||
'atom/browser/ui/webui/pdf_viewer_handler.h',
|
|
||||||
'atom/browser/ui/webui/pdf_viewer_ui.cc',
|
|
||||||
'atom/browser/ui/webui/pdf_viewer_ui.h',
|
|
||||||
'atom/browser/ui/win/atom_desktop_native_widget_aura.cc',
|
'atom/browser/ui/win/atom_desktop_native_widget_aura.cc',
|
||||||
'atom/browser/ui/win/atom_desktop_native_widget_aura.h',
|
'atom/browser/ui/win/atom_desktop_native_widget_aura.h',
|
||||||
'atom/browser/ui/win/atom_desktop_window_tree_host_win.cc',
|
'atom/browser/ui/win/atom_desktop_window_tree_host_win.cc',
|
||||||
|
@ -644,8 +640,6 @@
|
||||||
'chromium_src/chrome/renderer/tts_dispatcher.cc',
|
'chromium_src/chrome/renderer/tts_dispatcher.cc',
|
||||||
'chromium_src/chrome/renderer/tts_dispatcher.h',
|
'chromium_src/chrome/renderer/tts_dispatcher.h',
|
||||||
'chromium_src/chrome/utility/utility_message_handler.h',
|
'chromium_src/chrome/utility/utility_message_handler.h',
|
||||||
'chromium_src/components/pdf/renderer/pepper_pdf_host.cc',
|
|
||||||
'chromium_src/components/pdf/renderer/pepper_pdf_host.h',
|
|
||||||
'chromium_src/extensions/browser/app_window/size_constraints.cc',
|
'chromium_src/extensions/browser/app_window/size_constraints.cc',
|
||||||
'chromium_src/extensions/browser/app_window/size_constraints.h',
|
'chromium_src/extensions/browser/app_window/size_constraints.h',
|
||||||
'chromium_src/extensions/common/url_pattern.cc',
|
'chromium_src/extensions/common/url_pattern.cc',
|
||||||
|
@ -731,7 +725,17 @@
|
||||||
'atom/browser/osr/osr_view_proxy.h',
|
'atom/browser/osr/osr_view_proxy.h',
|
||||||
],
|
],
|
||||||
}], # enable_osr==1
|
}], # enable_osr==1
|
||||||
['enable_run_as_node', {
|
['enable_pdf_viewer==1', {
|
||||||
|
'lib_sources': [
|
||||||
|
'atom/browser/ui/webui/pdf_viewer_handler.cc',
|
||||||
|
'atom/browser/ui/webui/pdf_viewer_handler.h',
|
||||||
|
'atom/browser/ui/webui/pdf_viewer_ui.cc',
|
||||||
|
'atom/browser/ui/webui/pdf_viewer_ui.h',
|
||||||
|
'chromium_src/components/pdf/renderer/pepper_pdf_host.cc',
|
||||||
|
'chromium_src/components/pdf/renderer/pepper_pdf_host.h',
|
||||||
|
],
|
||||||
|
}], # enable_pdf_viewer
|
||||||
|
['enable_run_as_node==1', {
|
||||||
'lib_sources': [
|
'lib_sources': [
|
||||||
'atom/app/node_main.cc',
|
'atom/app/node_main.cc',
|
||||||
'atom/app/node_main.h',
|
'atom/app/node_main.h',
|
||||||
|
|
|
@ -189,9 +189,13 @@ def execute_stdout(argv, env=os.environ, cwd=None):
|
||||||
def electron_gyp():
|
def electron_gyp():
|
||||||
SOURCE_ROOT = os.path.abspath(os.path.join(__file__, '..', '..', '..'))
|
SOURCE_ROOT = os.path.abspath(os.path.join(__file__, '..', '..', '..'))
|
||||||
gyp = os.path.join(SOURCE_ROOT, 'electron.gyp')
|
gyp = os.path.join(SOURCE_ROOT, 'electron.gyp')
|
||||||
|
features_gyp = os.path.join(SOURCE_ROOT, 'features.gypi')
|
||||||
|
obj = {}
|
||||||
with open(gyp) as f:
|
with open(gyp) as f:
|
||||||
obj = eval(f.read());
|
obj = eval(f.read())['variables']
|
||||||
return obj['variables']
|
with open(features_gyp) as g:
|
||||||
|
obj.update(eval(g.read())['variables']['variables'])
|
||||||
|
return obj
|
||||||
|
|
||||||
|
|
||||||
def get_electron_version():
|
def get_electron_version():
|
||||||
|
|
|
@ -28,6 +28,7 @@ SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||||
|
|
||||||
PROJECT_NAME = electron_gyp()['project_name%']
|
PROJECT_NAME = electron_gyp()['project_name%']
|
||||||
PRODUCT_NAME = electron_gyp()['product_name%']
|
PRODUCT_NAME = electron_gyp()['product_name%']
|
||||||
|
PDF_VIEWER_ENABLED = electron_gyp()['enable_pdf_viewer%']
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -35,6 +36,7 @@ def main():
|
||||||
|
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
config = args.configuration
|
config = args.configuration
|
||||||
|
os.environ['PDF_VIEWER_ENABLED'] = str(PDF_VIEWER_ENABLED)
|
||||||
|
|
||||||
if args.verbose:
|
if args.verbose:
|
||||||
enable_verbose_mode()
|
enable_verbose_mode()
|
||||||
|
|
|
@ -1018,52 +1018,58 @@ describe('chromium feature', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('PDF Viewer', () => {
|
describe('PDF Viewer', () => {
|
||||||
const pdfSource = url.format({
|
before(function () {
|
||||||
pathname: path.join(fixtures, 'assets', 'cat.pdf').replace(/\\/g, '/'),
|
if (!parseInt(process.env.PDF_VIEWER_ENABLED)) {
|
||||||
protocol: 'file',
|
return this.skip()
|
||||||
slashes: true
|
}
|
||||||
})
|
|
||||||
const pdfSourceWithParams = url.format({
|
|
||||||
pathname: path.join(fixtures, 'assets', 'cat.pdf').replace(/\\/g, '/'),
|
|
||||||
query: {
|
|
||||||
a: 1,
|
|
||||||
b: 2
|
|
||||||
},
|
|
||||||
protocol: 'file',
|
|
||||||
slashes: true
|
|
||||||
})
|
|
||||||
|
|
||||||
function createBrowserWindow ({plugins, preload}) {
|
const pdfSource = url.format({
|
||||||
w = new BrowserWindow({
|
pathname: path.join(fixtures, 'assets', 'cat.pdf').replace(/\\/g, '/'),
|
||||||
show: false,
|
protocol: 'file',
|
||||||
webPreferences: {
|
slashes: true
|
||||||
preload: path.join(fixtures, 'module', preload),
|
|
||||||
plugins: plugins
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
const pdfSourceWithParams = url.format({
|
||||||
|
pathname: path.join(fixtures, 'assets', 'cat.pdf').replace(/\\/g, '/'),
|
||||||
function testPDFIsLoadedInSubFrame (page, preloadFile, done) {
|
query: {
|
||||||
const pagePath = url.format({
|
a: 1,
|
||||||
pathname: path.join(fixtures, 'pages', page).replace(/\\/g, '/'),
|
b: 2
|
||||||
|
},
|
||||||
protocol: 'file',
|
protocol: 'file',
|
||||||
slashes: true
|
slashes: true
|
||||||
})
|
})
|
||||||
|
|
||||||
createBrowserWindow({plugins: true, preload: preloadFile})
|
function createBrowserWindow ({plugins, preload}) {
|
||||||
ipcMain.once('pdf-loaded', (event, state) => {
|
w = new BrowserWindow({
|
||||||
assert.equal(state, 'success')
|
show: false,
|
||||||
done()
|
webPreferences: {
|
||||||
})
|
preload: path.join(fixtures, 'module', preload),
|
||||||
w.webContents.on('page-title-updated', () => {
|
plugins: plugins
|
||||||
const parsedURL = url.parse(w.webContents.getURL(), true)
|
}
|
||||||
assert.equal(parsedURL.protocol, 'chrome:')
|
})
|
||||||
assert.equal(parsedURL.hostname, 'pdf-viewer')
|
}
|
||||||
assert.equal(parsedURL.query.src, pagePath)
|
|
||||||
assert.equal(w.webContents.getTitle(), 'cat.pdf')
|
function testPDFIsLoadedInSubFrame (page, preloadFile, done) {
|
||||||
})
|
const pagePath = url.format({
|
||||||
w.webContents.loadURL(pagePath)
|
pathname: path.join(fixtures, 'pages', page).replace(/\\/g, '/'),
|
||||||
}
|
protocol: 'file',
|
||||||
|
slashes: true
|
||||||
|
})
|
||||||
|
|
||||||
|
createBrowserWindow({plugins: true, preload: preloadFile})
|
||||||
|
ipcMain.once('pdf-loaded', (event, state) => {
|
||||||
|
assert.equal(state, 'success')
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
w.webContents.on('page-title-updated', () => {
|
||||||
|
const parsedURL = url.parse(w.webContents.getURL(), true)
|
||||||
|
assert.equal(parsedURL.protocol, 'chrome:')
|
||||||
|
assert.equal(parsedURL.hostname, 'pdf-viewer')
|
||||||
|
assert.equal(parsedURL.query.src, pagePath)
|
||||||
|
assert.equal(w.webContents.getTitle(), 'cat.pdf')
|
||||||
|
})
|
||||||
|
w.webContents.loadURL(pagePath)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
it('opens when loading a pdf resource as top level navigation', (done) => {
|
it('opens when loading a pdf resource as top level navigation', (done) => {
|
||||||
createBrowserWindow({plugins: true, preload: 'preload-pdf-loaded.js'})
|
createBrowserWindow({plugins: true, preload: 'preload-pdf-loaded.js'})
|
||||||
|
|
Loading…
Reference in a new issue