refactor: remove references to non-existent webui (#20867)

This commit is contained in:
Jeremy Apthorp 2019-11-04 09:50:31 -08:00 committed by GitHub
parent f645ca015f
commit 85647dfced
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 395 additions and 174 deletions

View file

@ -4,6 +4,7 @@ import("//build/config/win/manifest.gni")
import("//components/spellcheck/spellcheck_build_features.gni") import("//components/spellcheck/spellcheck_build_features.gni")
import("//content/public/app/mac_helpers.gni") import("//content/public/app/mac_helpers.gni")
import("//pdf/features.gni") import("//pdf/features.gni")
import("//ppapi/buildflags/buildflags.gni")
import("//printing/buildflags/buildflags.gni") import("//printing/buildflags/buildflags.gni")
import("//testing/test.gni") import("//testing/test.gni")
import("//third_party/ffmpeg/ffmpeg_options.gni") import("//third_party/ffmpeg/ffmpeg_options.gni")
@ -579,8 +580,12 @@ source_set("electron_lib") {
deps += [ "//third_party/crashpad/crashpad/client" ] deps += [ "//third_party/crashpad/crashpad/client" ]
} }
if (enable_pdf) { if (enable_plugins) {
deps += [ "//pdf" ] deps += [ "chromium_src:plugins" ]
sources += [
"shell/renderer/pepper_helper.cc",
"shell/renderer/pepper_helper.h",
]
} }
if (enable_run_as_node) { if (enable_run_as_node) {
@ -664,10 +669,6 @@ source_set("electron_lib") {
] ]
} }
if (enable_pepper_flash) {
deps += [ "components/pepper_flash" ]
}
public_deps += [ "shell/common/extensions/api:extensions_features" ] public_deps += [ "shell/common/extensions/api:extensions_features" ]
deps += [ deps += [
"//components/pref_registry", "//components/pref_registry",
@ -681,6 +682,22 @@ source_set("electron_lib") {
if (enable_electron_extensions) { if (enable_electron_extensions) {
sources += filenames.lib_sources_extensions sources += filenames.lib_sources_extensions
} }
if (enable_pdf) {
# Printing depends on some //pdf code, so it needs to be built even if the
# pdf viewer isn't enabled.
deps += [ "//pdf" ]
}
if (enable_pdf_viewer) {
deps += [
"//components/pdf/browser",
"//components/pdf/renderer",
]
sources += [
"shell/browser/electron_pdf_web_contents_helper_client.cc",
"shell/browser/electron_pdf_web_contents_helper_client.h",
]
}
} }
electron_paks("packed_resources") { electron_paks("packed_resources") {

View file

@ -227,6 +227,79 @@ static_library("chrome") {
} }
} }
source_set("plugins") {
sources = []
deps = []
libs = []
# browser side
sources += [
"//chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.cc",
"//chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h",
"//chrome/browser/renderer_host/pepper/pepper_broker_message_filter.cc",
"//chrome/browser/renderer_host/pepper/pepper_broker_message_filter.h",
"//chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.cc",
"//chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.h",
]
deps += [
"//media:media_buildflags",
"//ppapi/buildflags",
"//ppapi/proxy:ipc",
"//services/device/public/mojom",
]
if (enable_pepper_flash) {
sources += [
"//chrome/browser/renderer_host/pepper/pepper_flash_browser_host.cc",
"//chrome/browser/renderer_host/pepper/pepper_flash_browser_host.h",
"//chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.cc",
"//chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.h",
"//chrome/browser/renderer_host/pepper/pepper_flash_drm_host.cc",
"//chrome/browser/renderer_host/pepper/pepper_flash_drm_host.h",
]
if (is_mac) {
sources += [
"//chrome/browser/renderer_host/pepper/monitor_finder_mac.h",
"//chrome/browser/renderer_host/pepper/monitor_finder_mac.mm",
]
libs += [ "CoreGraphics.framework" ]
}
if (is_linux) {
deps += [ "//components/services/font/public/cpp" ]
}
}
# renderer side
sources += [
"//chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc",
"//chrome/renderer/pepper/chrome_renderer_pepper_host_factory.h",
"//chrome/renderer/pepper/pepper_shared_memory_message_filter.cc",
"//chrome/renderer/pepper/pepper_shared_memory_message_filter.h",
]
if (enable_pepper_flash) {
sources += [
"//chrome/renderer/pepper/pepper_flash_drm_renderer_host.cc",
"//chrome/renderer/pepper/pepper_flash_drm_renderer_host.h",
"//chrome/renderer/pepper/pepper_flash_font_file_host.cc",
"//chrome/renderer/pepper/pepper_flash_font_file_host.h",
"//chrome/renderer/pepper/pepper_flash_fullscreen_host.cc",
"//chrome/renderer/pepper/pepper_flash_fullscreen_host.h",
"//chrome/renderer/pepper/pepper_flash_menu_host.cc",
"//chrome/renderer/pepper/pepper_flash_menu_host.h",
"//chrome/renderer/pepper/pepper_flash_renderer_host.cc",
"//chrome/renderer/pepper/pepper_flash_renderer_host.h",
]
}
deps += [
"//components/strings",
"//media:media_buildflags",
"//ppapi/host",
"//ppapi/proxy",
"//ppapi/proxy:ipc",
"//ppapi/shared_impl",
"//skia",
]
}
# This source set is just so we don't have to depend on all of //chrome/browser # This source set is just so we don't have to depend on all of //chrome/browser
# You may have to add new files here during the upgrade if //chrome/browser/spellchecker # You may have to add new files here during the upgrade if //chrome/browser/spellchecker
# gets more files # gets more files

View file

@ -1,62 +0,0 @@
# Copyright (c) 2018 GitHub, Inc.
# Use of this source code is governed by the MIT license that can be
# found in the LICENSE file.
component("pepper_flash") {
visibility = [ "//electron:electron_lib" ]
defines = [ "IS_PEPPER_FLASH_IMPL" ]
sources = [
"//chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.cc",
"//chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h",
"//chrome/browser/renderer_host/pepper/pepper_broker_message_filter.cc",
"//chrome/browser/renderer_host/pepper/pepper_broker_message_filter.h",
"//chrome/browser/renderer_host/pepper/pepper_flash_browser_host.cc",
"//chrome/browser/renderer_host/pepper/pepper_flash_browser_host.h",
"//chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.cc",
"//chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.h",
"//chrome/browser/renderer_host/pepper/pepper_flash_drm_host.cc",
"//chrome/browser/renderer_host/pepper/pepper_flash_drm_host.h",
"//chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.cc",
"//chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.h",
"//chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc",
"//chrome/renderer/pepper/chrome_renderer_pepper_host_factory.h",
"//chrome/renderer/pepper/pepper_flash_drm_renderer_host.cc",
"//chrome/renderer/pepper/pepper_flash_drm_renderer_host.h",
"//chrome/renderer/pepper/pepper_flash_font_file_host.cc",
"//chrome/renderer/pepper/pepper_flash_font_file_host.h",
"//chrome/renderer/pepper/pepper_flash_fullscreen_host.cc",
"//chrome/renderer/pepper/pepper_flash_fullscreen_host.h",
"//chrome/renderer/pepper/pepper_flash_menu_host.cc",
"//chrome/renderer/pepper/pepper_flash_menu_host.h",
"//chrome/renderer/pepper/pepper_flash_renderer_host.cc",
"//chrome/renderer/pepper/pepper_flash_renderer_host.h",
"//chrome/renderer/pepper/pepper_helper.cc",
"//chrome/renderer/pepper/pepper_helper.h",
"//chrome/renderer/pepper/pepper_shared_memory_message_filter.cc",
"//chrome/renderer/pepper/pepper_shared_memory_message_filter.h",
]
deps = [
"//content/public/browser",
"//content/public/renderer",
"//media:media_buildflags",
"//ppapi/host",
"//ppapi/proxy",
"//ppapi/proxy:ipc",
"//ppapi/shared_impl",
"//services/device/public/mojom",
"//skia",
"//third_party/adobe/flash:flapper_version_h",
"//ui/base",
"//ui/base/clipboard",
]
if (is_mac) {
sources += [
"//chrome/browser/renderer_host/pepper/monitor_finder_mac.h",
"//chrome/browser/renderer_host/pepper/monitor_finder_mac.mm",
]
libs = [ "CoreGraphics.framework" ]
}
if (is_linux) {
deps += [ "//components/services/font/public/cpp" ]
}
}

View file

@ -558,6 +558,8 @@ filenames = {
"shell/renderer/content_settings_observer.h", "shell/renderer/content_settings_observer.h",
"shell/renderer/electron_api_service_impl.cc", "shell/renderer/electron_api_service_impl.cc",
"shell/renderer/electron_api_service_impl.h", "shell/renderer/electron_api_service_impl.h",
"shell/renderer/electron_renderer_pepper_host_factory.cc",
"shell/renderer/electron_renderer_pepper_host_factory.h",
"shell/renderer/atom_sandboxed_renderer_client.cc", "shell/renderer/atom_sandboxed_renderer_client.cc",
"shell/renderer/atom_sandboxed_renderer_client.h", "shell/renderer/atom_sandboxed_renderer_client.h",
"shell/renderer/guest_view_container.cc", "shell/renderer/guest_view_container.cc",

View file

@ -8,7 +8,6 @@ blink_world_context.patch
can_create_window.patch can_create_window.patch
disable_hidden.patch disable_hidden.patch
dom_storage_limits.patch dom_storage_limits.patch
out_of_process_instance.patch
render_widget_host_view_base.patch render_widget_host_view_base.patch
render_widget_host_view_mac.patch render_widget_host_view_mac.patch
thread_capabilities.patch thread_capabilities.patch
@ -21,7 +20,7 @@ blink-worker-enable-csp-in-file-scheme.patch
disable-redraw-lock.patch disable-redraw-lock.patch
v8_context_snapshot_generator.patch v8_context_snapshot_generator.patch
boringssl_build_gn.patch boringssl_build_gn.patch
pepper_flash.patch pepper_plugin_support.patch
no_cache_storage_check.patch no_cache_storage_check.patch
blink_fix_prototype_assert.patch blink_fix_prototype_assert.patch
libgtkui_export.patch libgtkui_export.patch

View file

@ -1,21 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: deepak1556 <hop2deep@gmail.com>
Date: Thu, 20 Sep 2018 17:46:17 -0700
Subject: out_of_process_instance.patch
diff --git a/pdf/out_of_process_instance.cc b/pdf/out_of_process_instance.cc
index 7be737cdf0f58bcdb91cb8cbedc8ff43fe74aa9a..aadf4f2980318ab0fcf75c2f1615e10a0f71aa37 100644
--- a/pdf/out_of_process_instance.cc
+++ b/pdf/out_of_process_instance.cc
@@ -486,7 +486,9 @@ bool OutOfProcessInstance::Init(uint32_t argc,
std::string document_url = document_url_var.AsString();
base::StringPiece document_url_piece(document_url);
is_print_preview_ = IsPrintPreviewUrl(document_url_piece);
- if (!document_url_piece.starts_with(kChromeExtension) && !is_print_preview_)
+ if (!document_url_piece.starts_with(kChromeExtension) &&
+ !document_url_piece.starts_with("chrome://pdf-viewer") &&
+ !is_print_preview_)
return false;
// Check if the plugin is full frame. This is passed in from JS.

View file

@ -1,32 +1,11 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: deepak1556 <hop2deep@gmail.com> From: deepak1556 <hop2deep@gmail.com>
Date: Thu, 20 Sep 2018 17:48:09 -0700 Date: Thu, 20 Sep 2018 17:46:17 -0700
Subject: pepper_flash.patch Subject: pepper plugin support
Allows building chrome pepper flash integration for Electron. This tweaks Chrome's pepper flash and PDF plugin support to make it
usable from Electron.
diff --git a/chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h b/chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h
index 735da93c3cabb8c6139971295740ba14a30d1b69..533f53fbc42397608e3762e370cc935c045ce3f1 100644
--- a/chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h
+++ b/chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_RENDERER_HOST_PEPPER_CHROME_BROWSER_PEPPER_HOST_FACTORY_H_
#define CHROME_BROWSER_RENDERER_HOST_PEPPER_CHROME_BROWSER_PEPPER_HOST_FACTORY_H_
+#include "base/component_export.h"
#include "base/macros.h"
#include "ppapi/host/host_factory.h"
@@ -12,7 +13,8 @@ namespace content {
class BrowserPpapiHost;
} // namespace content
-class ChromeBrowserPepperHostFactory : public ppapi::host::HostFactory {
+class COMPONENT_EXPORT(PEPPER_FLASH) ChromeBrowserPepperHostFactory
+ : public ppapi::host::HostFactory {
public:
// Non-owning pointer to the filter must outlive this class.
explicit ChromeBrowserPepperHostFactory(content::BrowserPpapiHost* host);
diff --git a/chrome/browser/renderer_host/pepper/pepper_broker_message_filter.cc b/chrome/browser/renderer_host/pepper/pepper_broker_message_filter.cc diff --git a/chrome/browser/renderer_host/pepper/pepper_broker_message_filter.cc b/chrome/browser/renderer_host/pepper/pepper_broker_message_filter.cc
index 37245c48cacbc5db164c61e4499f34ee83e0fce7..0fef12892e965e319e45f5dd1a9c5c9fc606aa9a 100644 index 37245c48cacbc5db164c61e4499f34ee83e0fce7..0fef12892e965e319e45f5dd1a9c5c9fc606aa9a 100644
--- a/chrome/browser/renderer_host/pepper/pepper_broker_message_filter.cc --- a/chrome/browser/renderer_host/pepper/pepper_broker_message_filter.cc
@ -405,29 +384,42 @@ index b36248debee4f5e0503e7611f7d1c47d59650f5b..7af31ee0d2cbb4c8fc7cd41c356305d6
DISALLOW_COPY_AND_ASSIGN(PepperIsolatedFileSystemMessageFilter); DISALLOW_COPY_AND_ASSIGN(PepperIsolatedFileSystemMessageFilter);
}; };
diff --git a/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc b/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc diff --git a/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc b/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc
index d63e90b6c5079ab3237c4bad3d5e63ce2f99c657..c98a7bd07ddd9527fc67b05b24463ed4b05ec316 100644 index d63e90b6c5079ab3237c4bad3d5e63ce2f99c657..f1d4503d1f72df67ffcc73000a8a2ad3e2c93327 100644
--- a/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc --- a/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc
+++ b/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc +++ b/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc
@@ -10,8 +10,10 @@ @@ -10,8 +10,13 @@
#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"
+#if 0 +#if 0
#include "chrome/renderer/pepper/pepper_uma_host.h" #include "chrome/renderer/pepper/pepper_uma_host.h"
+#endif
+#include "electron/buildflags/buildflags.h"
+#if BUILDFLAG(ENABLE_PDF_VIEWER)
#include "components/pdf/renderer/pepper_pdf_host.h" #include "components/pdf/renderer/pepper_pdf_host.h"
+#endif +#endif
#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"
@@ -86,6 +88,7 @@ ChromeRendererPepperHostFactory::CreateResourceHost( @@ -86,6 +91,7 @@ ChromeRendererPepperHostFactory::CreateResourceHost(
} }
} }
+#if 0 +#if BUILDFLAG(ENABLE_PDF_VIEWER)
if (host_->GetPpapiHost()->permissions().HasPermission( if (host_->GetPpapiHost()->permissions().HasPermission(
ppapi::PERMISSION_PDF)) { ppapi::PERMISSION_PDF)) {
switch (message.type()) { switch (message.type()) {
@@ -104,6 +107,7 @@ ChromeRendererPepperHostFactory::CreateResourceHost( @@ -94,7 +100,9 @@ ChromeRendererPepperHostFactory::CreateResourceHost(
}
}
}
+#endif
+#if 0
// Permissions for the following interfaces will be checked at the
// time of the corresponding instance's method calls. Currently these
// interfaces are available only for whitelisted apps which may not have
@@ -104,6 +112,7 @@ ChromeRendererPepperHostFactory::CreateResourceHost(
return std::make_unique<PepperUMAHost>(host_, instance, resource); return std::make_unique<PepperUMAHost>(host_, instance, resource);
} }
} }

View file

@ -32,9 +32,10 @@
#endif // defined(WIDEVINE_CDM_AVAILABLE) #endif // defined(WIDEVINE_CDM_AVAILABLE)
#if BUILDFLAG(ENABLE_PDF_VIEWER) #if BUILDFLAG(ENABLE_PDF_VIEWER)
#include "pdf/pdf.h" #include "pdf/pdf.h" // nogncheck
#include "shell/common/atom_constants.h" #include "pdf/pdf_ppapi.h" // nogncheck
#endif // BUILDFLAG(ENABLE_PDF_VIEWER) #include "shell/common/atom_constants.h" // nogncheck
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
#if BUILDFLAG(ENABLE_PLUGINS) #if BUILDFLAG(ENABLE_PLUGINS)
#include "content/public/common/pepper_plugin_info.h" #include "content/public/common/pepper_plugin_info.h"
@ -153,7 +154,7 @@ void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) {
pdf_info.is_out_of_process = true; pdf_info.is_out_of_process = true;
pdf_info.name = "Chromium PDF Viewer"; pdf_info.name = "Chromium PDF Viewer";
pdf_info.description = "Portable Document Format"; pdf_info.description = "Portable Document Format";
pdf_info.path = base::FilePath::FromUTF8Unsafe(kPdfPluginPath); pdf_info.path = base::FilePath(FILE_PATH_LITERAL("internal-pdf-viewer"));
content::WebPluginMimeType pdf_mime_type(kPdfPluginMimeType, "pdf", content::WebPluginMimeType pdf_mime_type(kPdfPluginMimeType, "pdf",
"Portable Document Format"); "Portable Document Format");
pdf_info.mime_types.push_back(pdf_mime_type); pdf_info.mime_types.push_back(pdf_mime_type);
@ -162,7 +163,7 @@ void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) {
chrome_pdf::PPP_InitializeModule; chrome_pdf::PPP_InitializeModule;
pdf_info.internal_entry_points.shutdown_module = pdf_info.internal_entry_points.shutdown_module =
chrome_pdf::PPP_ShutdownModule; chrome_pdf::PPP_ShutdownModule;
pdf_info.permissions = ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV; pdf_info.permissions = ppapi::PERMISSION_PDF | ppapi::PERMISSION_DEV;
plugins->push_back(pdf_info); plugins->push_back(pdf_info);
#endif // BUILDFLAG(ENABLE_PDF_VIEWER) #endif // BUILDFLAG(ENABLE_PDF_VIEWER)
} }

View file

@ -6,17 +6,8 @@
#include <string> #include <string>
#include "electron/buildflags/buildflags.h"
#if BUILDFLAG(ENABLE_PDF_VIEWER)
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "net/base/escape.h"
#include "shell/browser/ui/webui/pdf_viewer_ui.h"
#include "shell/common/atom_constants.h"
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "electron/buildflags/buildflags.h"
#include "shell/browser/ui/devtools_ui.h" #include "shell/browser/ui/devtools_ui.h"
namespace electron { namespace electron {
@ -39,11 +30,6 @@ AtomWebUIControllerFactory::~AtomWebUIControllerFactory() = default;
content::WebUI::TypeID AtomWebUIControllerFactory::GetWebUIType( content::WebUI::TypeID AtomWebUIControllerFactory::GetWebUIType(
content::BrowserContext* browser_context, content::BrowserContext* browser_context,
const GURL& url) { const GURL& url) {
#if BUILDFLAG(ENABLE_PDF_VIEWER)
if (url.host() == kPdfViewerUIHost) {
return const_cast<AtomWebUIControllerFactory*>(this);
}
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
if (url.host() == kChromeUIDevToolsBundledHost) { if (url.host() == kChromeUIDevToolsBundledHost) {
return const_cast<AtomWebUIControllerFactory*>(this); return const_cast<AtomWebUIControllerFactory*>(this);
} }
@ -66,29 +52,6 @@ bool AtomWebUIControllerFactory::UseWebUIBindingsForURL(
std::unique_ptr<content::WebUIController> std::unique_ptr<content::WebUIController>
AtomWebUIControllerFactory::CreateWebUIControllerForURL(content::WebUI* web_ui, AtomWebUIControllerFactory::CreateWebUIControllerForURL(content::WebUI* web_ui,
const GURL& url) { const GURL& url) {
#if BUILDFLAG(ENABLE_PDF_VIEWER)
if (url.host() == kPdfViewerUIHost) {
base::StringPairs toplevel_params;
base::SplitStringIntoKeyValuePairs(url.query(), '=', '&', &toplevel_params);
std::string src;
const net::UnescapeRule::Type unescape_rules =
net::UnescapeRule::SPACES | net::UnescapeRule::PATH_SEPARATORS |
net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS |
net::UnescapeRule::REPLACE_PLUS_WITH_SPACE;
for (const auto& param : toplevel_params) {
if (param.first == kPdfPluginSrc) {
src = net::UnescapeURLComponent(param.second, unescape_rules);
}
}
if (url.has_ref()) {
src = src + '#' + url.ref();
}
auto browser_context = web_ui->GetWebContents()->GetBrowserContext();
return new PdfViewerUI(browser_context, web_ui, src);
}
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
if (url.host() == kChromeUIDevToolsBundledHost) { if (url.host() == kChromeUIDevToolsBundledHost) {
auto* browser_context = web_ui->GetWebContents()->GetBrowserContext(); auto* browser_context = web_ui->GetWebContents()->GetBrowserContext();
return std::make_unique<DevToolsUI>(browser_context, web_ui); return std::make_unique<DevToolsUI>(browser_context, web_ui);

View file

@ -59,6 +59,11 @@
#include "chrome/browser/picture_in_picture/picture_in_picture_window_manager.h" #include "chrome/browser/picture_in_picture/picture_in_picture_window_manager.h"
#endif #endif
#if BUILDFLAG(ENABLE_PDF_VIEWER)
#include "components/pdf/browser/pdf_web_contents_helper.h" // nogncheck
#include "shell/browser/electron_pdf_web_contents_helper_client.h"
#endif
using content::BrowserThread; using content::BrowserThread;
namespace electron { namespace electron {
@ -198,6 +203,11 @@ void CommonWebContentsDelegate::InitWithWebContents(
browser_context->GetUserAgent()); browser_context->GetUserAgent());
#endif #endif
#if BUILDFLAG(ENABLE_PDF_VIEWER)
pdf::PDFWebContentsHelper::CreateForWebContentsWithClient(
web_contents, std::make_unique<ElectronPDFWebContentsHelperClient>());
#endif
// Determien whether the WebContents is offscreen. // Determien whether the WebContents is offscreen.
auto* web_preferences = WebContentsPreferences::From(web_contents); auto* web_preferences = WebContentsPreferences::From(web_contents);
offscreen_ = offscreen_ =

View file

@ -0,0 +1,20 @@
// Copyright (c) 2015 Slack Technologies, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "shell/browser/electron_pdf_web_contents_helper_client.h"
ElectronPDFWebContentsHelperClient::ElectronPDFWebContentsHelperClient() {}
ElectronPDFWebContentsHelperClient::~ElectronPDFWebContentsHelperClient() =
default;
void ElectronPDFWebContentsHelperClient::UpdateContentRestrictions(
content::WebContents* contents,
int content_restrictions) {}
void ElectronPDFWebContentsHelperClient::OnPDFHasUnsupportedFeature(
content::WebContents* contents) {}
void ElectronPDFWebContentsHelperClient::OnSaveURL(
content::WebContents* contents) {}
void ElectronPDFWebContentsHelperClient::SetPluginCanSave(
content::WebContents* contents,
bool can_save) {}

View file

@ -0,0 +1,28 @@
// Copyright (c) 2015 Slack Technologies, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef SHELL_BROWSER_ELECTRON_PDF_WEB_CONTENTS_HELPER_CLIENT_H_
#define SHELL_BROWSER_ELECTRON_PDF_WEB_CONTENTS_HELPER_CLIENT_H_
#include "components/pdf/browser/pdf_web_contents_helper_client.h"
namespace content {
class WebContents;
}
class ElectronPDFWebContentsHelperClient
: public pdf::PDFWebContentsHelperClient {
public:
ElectronPDFWebContentsHelperClient();
~ElectronPDFWebContentsHelperClient() override;
private:
// pdf::PDFWebContentsHelperClient
void UpdateContentRestrictions(content::WebContents* contents,
int content_restrictions) override;
void OnPDFHasUnsupportedFeature(content::WebContents* contents) override;
void OnSaveURL(content::WebContents* contents) override;
void SetPluginCanSave(content::WebContents* contents, bool can_save) override;
};
#endif // SHELL_BROWSER_ELECTRON_PDF_WEB_CONTENTS_HELPER_CLIENT_H_

View file

@ -0,0 +1,107 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "shell/renderer/electron_renderer_pepper_host_factory.h"
#include <memory>
#include <string>
#include "base/logging.h"
#include "content/public/renderer/renderer_ppapi_host.h"
#include "ppapi/host/dispatch_host_message.h"
#include "ppapi/host/ppapi_host.h"
#include "ppapi/host/resource_host.h"
#include "ppapi/proxy/ppapi_message_utils.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/shared_impl/ppapi_permissions.h"
using ppapi::host::ResourceHost;
// Stub class which ignores all messages
class PepperUMAHost : public ppapi::host::ResourceHost {
public:
PepperUMAHost(content::RendererPpapiHost* host,
PP_Instance instance,
PP_Resource resource)
: ResourceHost(host->GetPpapiHost(), instance, resource) {}
~PepperUMAHost() override = default;
// ppapi::host::ResourceMessageHandler implementation.
int32_t OnResourceMessageReceived(
const IPC::Message& msg,
ppapi::host::HostMessageContext* context) override {
PPAPI_BEGIN_MESSAGE_MAP(PepperUMAHost, msg)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_UMA_HistogramCustomTimes,
OnHistogramCustomTimes)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_UMA_HistogramCustomCounts,
OnHistogramCustomCounts)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_UMA_HistogramEnumeration,
OnHistogramEnumeration)
PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(
PpapiHostMsg_UMA_IsCrashReportingEnabled, OnIsCrashReportingEnabled)
PPAPI_END_MESSAGE_MAP()
return PP_ERROR_FAILED;
}
private:
int32_t OnHistogramCustomTimes(ppapi::host::HostMessageContext* context,
const std::string& name,
int64_t sample,
int64_t min,
int64_t max,
uint32_t bucket_count) {
return PP_OK;
}
int32_t OnHistogramCustomCounts(ppapi::host::HostMessageContext* context,
const std::string& name,
int32_t sample,
int32_t min,
int32_t max,
uint32_t bucket_count) {
return PP_OK;
}
int32_t OnHistogramEnumeration(ppapi::host::HostMessageContext* context,
const std::string& name,
int32_t sample,
int32_t boundary_value) {
return PP_OK;
}
int32_t OnIsCrashReportingEnabled(ppapi::host::HostMessageContext* context) {
return PP_OK;
}
};
ElectronRendererPepperHostFactory::ElectronRendererPepperHostFactory(
content::RendererPpapiHost* host)
: host_(host) {}
ElectronRendererPepperHostFactory::~ElectronRendererPepperHostFactory() {}
std::unique_ptr<ResourceHost>
ElectronRendererPepperHostFactory::CreateResourceHost(
ppapi::host::PpapiHost* host,
PP_Resource resource,
PP_Instance instance,
const IPC::Message& message) {
DCHECK_EQ(host_->GetPpapiHost(), host);
// Make sure the plugin is giving us a valid instance for this resource.
if (!host_->IsValidInstance(instance))
return nullptr;
// Permissions for the following interfaces will be checked at the
// time of the corresponding instance's method calls. Currently these
// interfaces are available only for whitelisted apps which may not have
// access to the other private interfaces.
switch (message.type()) {
case PpapiHostMsg_UMA_Create::ID: {
return std::make_unique<PepperUMAHost>(host_, instance, resource);
}
}
return nullptr;
}

View file

@ -0,0 +1,37 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SHELL_RENDERER_ELECTRON_RENDERER_PEPPER_HOST_FACTORY_H_
#define SHELL_RENDERER_ELECTRON_RENDERER_PEPPER_HOST_FACTORY_H_
#include <memory>
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "ppapi/host/host_factory.h"
namespace content {
class RendererPpapiHost;
}
class ElectronRendererPepperHostFactory : public ppapi::host::HostFactory {
public:
explicit ElectronRendererPepperHostFactory(content::RendererPpapiHost* host);
~ElectronRendererPepperHostFactory() override;
// HostFactory.
std::unique_ptr<ppapi::host::ResourceHost> CreateResourceHost(
ppapi::host::PpapiHost* host,
PP_Resource resource,
PP_Instance instance,
const IPC::Message& message) override;
private:
// Not owned by this object.
content::RendererPpapiHost* host_;
DISALLOW_COPY_AND_ASSIGN(ElectronRendererPepperHostFactory);
};
#endif // SHELL_RENDERER_ELECTRON_RENDERER_PEPPER_HOST_FACTORY_H_

View file

@ -0,0 +1,33 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "shell/renderer/pepper_helper.h"
#include <memory>
#include "chrome/renderer/pepper/chrome_renderer_pepper_host_factory.h"
#include "chrome/renderer/pepper/pepper_shared_memory_message_filter.h"
#include "content/public/renderer/renderer_ppapi_host.h"
#include "electron/shell/renderer/electron_renderer_pepper_host_factory.h"
#include "ppapi/host/ppapi_host.h"
PepperHelper::PepperHelper(content::RenderFrame* render_frame)
: RenderFrameObserver(render_frame) {}
PepperHelper::~PepperHelper() {}
void PepperHelper::DidCreatePepperPlugin(content::RendererPpapiHost* host) {
// TODO(brettw) figure out how to hook up the host factory. It needs some
// kind of filter-like system to allow dynamic additions.
host->GetPpapiHost()->AddHostFactoryFilter(
std::make_unique<ChromeRendererPepperHostFactory>(host));
host->GetPpapiHost()->AddHostFactoryFilter(
std::make_unique<ElectronRendererPepperHostFactory>(host));
host->GetPpapiHost()->AddInstanceMessageFilter(
std::make_unique<PepperSharedMemoryMessageFilter>(host));
}
void PepperHelper::OnDestruct() {
delete this;
}

View file

@ -0,0 +1,28 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SHELL_RENDERER_PEPPER_HELPER_H_
#define SHELL_RENDERER_PEPPER_HELPER_H_
#include "base/compiler_specific.h"
#include "base/component_export.h"
#include "base/macros.h"
#include "content/public/renderer/render_frame_observer.h"
// This class listens for Pepper creation events from the RenderFrame and
// attaches the parts required for plugin support.
class PepperHelper : public content::RenderFrameObserver {
public:
explicit PepperHelper(content::RenderFrame* render_frame);
~PepperHelper() override;
// RenderFrameObserver.
void DidCreatePepperPlugin(content::RendererPpapiHost* host) override;
void OnDestruct() override;
private:
DISALLOW_COPY_AND_ASSIGN(PepperHelper);
};
#endif // SHELL_RENDERER_PEPPER_HELPER_H_

View file

@ -55,9 +55,9 @@
#include "shell/common/atom_constants.h" #include "shell/common/atom_constants.h"
#endif // BUILDFLAG(ENABLE_PDF_VIEWER) #endif // BUILDFLAG(ENABLE_PDF_VIEWER)
#if BUILDFLAG(ENABLE_PEPPER_FLASH) #if BUILDFLAG(ENABLE_PLUGINS)
#include "chrome/renderer/pepper/pepper_helper.h" #include "shell/renderer/pepper_helper.h"
#endif // BUILDFLAG(ENABLE_PEPPER_FLASH) #endif // BUILDFLAG(ENABLE_PLUGINS)
#if BUILDFLAG(ENABLE_PRINTING) #if BUILDFLAG(ENABLE_PRINTING)
#include "components/printing/renderer/print_render_frame_helper.h" #include "components/printing/renderer/print_render_frame_helper.h"
@ -227,7 +227,7 @@ void RendererClientBase::RenderFrameCreated(
new AutofillAgent(render_frame, new AutofillAgent(render_frame,
render_frame->GetAssociatedInterfaceRegistry()); render_frame->GetAssociatedInterfaceRegistry());
#endif #endif
#if BUILDFLAG(ENABLE_PEPPER_FLASH) #if BUILDFLAG(ENABLE_PLUGINS)
new PepperHelper(render_frame); new PepperHelper(render_frame);
#endif #endif
new ContentSettingsObserver(render_frame); new ContentSettingsObserver(render_frame);
@ -244,12 +244,6 @@ void RendererClientBase::RenderFrameCreated(
base::BindRepeating(&ElectronApiServiceImpl::BindTo, base::BindRepeating(&ElectronApiServiceImpl::BindTo,
service->GetWeakPtr())); service->GetWeakPtr()));
#if BUILDFLAG(ENABLE_PDF_VIEWER)
// Allow access to file scheme from pdf viewer.
blink::WebSecurityPolicy::AddOriginAccessWhitelistEntry(
GURL(kPdfViewerUIOrigin), "file", "", true);
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
content::RenderView* render_view = render_frame->GetRenderView(); content::RenderView* render_view = render_frame->GetRenderView();
if (render_frame->IsMainFrame() && render_view) { if (render_frame->IsMainFrame() && render_view) {
blink::WebView* webview = render_view->GetWebView(); blink::WebView* webview = render_view->GetWebView();