[unseasoned-pdf] Create PdfViewWebPlugin
Creates the unseasoned plugin (PdfViewWebPlugin) instead of the Pepper plugin (OutOfProcessInstance) when the `enable_pdf_unseasoned` buildflag is set. Up until this change, developers working on unseasoning the PDF viewer needed to patch in an equivalent change temporarily. This is tedious and error-prone, so we want to commit this code into the repository. This change creates the plugin in the PDF viewer extension process, which is not secure. This will be fixed by a new process model for the PDF viewer (crbug.com/1123621), but we don't want to block on that work. To minimize the security risk, the new plugin must be enabled at compile-time using a buildflag; this code is meant for developers-only. The plugin is created in ChromeContentRendererClient::CreatePlugin() directly, rather than going through the plugin registry, which only can handle Pepper plugins. The new plugin acts as a drop-in replacement for the Pepper plugin. Bug: 1123629 Change-Id: Ib4644f037a9d6df0410f82f7d8338d6907c79d80 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2310870 Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Tommy Li <tommycli@chromium.org> Reviewed-by: Filip Gorski <fgorski@chromium.org> Commit-Queue: K. Moon <kmoon@chromium.org> Cr-Commit-Position: refs/heads/master@{#860020}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
1e19c3c8d2
commit
6ffc02a9be
@ -206,6 +206,8 @@ static_library("renderer") {
|
||||
"//media/capture",
|
||||
"//mojo/public/cpp/bindings",
|
||||
"//net",
|
||||
"//pdf:buildflags",
|
||||
"//pdf:pdf_view_web_plugin",
|
||||
"//ppapi/buildflags",
|
||||
"//printing/buildflags",
|
||||
"//services/metrics/public/cpp:metrics_cpp",
|
||||
|
@ -75,6 +75,7 @@ include_rules = [
|
||||
"+google_apis",
|
||||
"+media/base",
|
||||
"+media/mojo",
|
||||
"+pdf/pdf_view_web_plugin.h",
|
||||
"+ppapi/shared_impl",
|
||||
"+services/network/public/cpp",
|
||||
"+services/network/public/mojom",
|
||||
|
@ -127,6 +127,7 @@
|
||||
#include "mojo/public/cpp/bindings/generic_pending_receiver.h"
|
||||
#include "mojo/public/cpp/bindings/remote.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "pdf/buildflags.h"
|
||||
#include "ppapi/buildflags/buildflags.h"
|
||||
#include "printing/buildflags/buildflags.h"
|
||||
#include "services/network/public/cpp/is_potentially_trustworthy.h"
|
||||
@ -194,6 +195,10 @@
|
||||
#include "third_party/blink/public/web/web_view.h"
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(ENABLE_PDF_UNSEASONED)
|
||||
#include "pdf/pdf_view_web_plugin.h"
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(ENABLE_PLUGINS)
|
||||
#include "chrome/common/plugin_utils.h"
|
||||
#include "chrome/renderer/plugins/chrome_plugin_placeholder.h"
|
||||
@ -986,6 +991,16 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
|
||||
break;
|
||||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_PDF_UNSEASONED)
|
||||
if (info.name ==
|
||||
ASCIIToUTF16(ChromeContentClient::kPDFInternalPluginName)) {
|
||||
// Create unseasoned PDF plugin directly, for development purposes.
|
||||
// TODO(crbug.com/1123621): Implement a more permanent solution once
|
||||
// the new PDF viewer process model is approved and in place.
|
||||
return new chrome_pdf::PdfViewWebPlugin(params);
|
||||
}
|
||||
#endif // BUILDFLAG(ENABLE_PDF_UNSEASONED)
|
||||
|
||||
return render_frame->CreatePlugin(info, params);
|
||||
}
|
||||
case chrome::mojom::PluginStatus::kDisabled: {
|
||||
|
19
pdf/BUILD.gn
19
pdf/BUILD.gn
@ -13,7 +13,10 @@ import("//v8/gni/v8.gni")
|
||||
# Generate a buildflag header for compile-time checking of PDF support.
|
||||
buildflag_header("buildflags") {
|
||||
header = "buildflags.h"
|
||||
flags = [ "ENABLE_PDF=$enable_pdf" ]
|
||||
flags = [
|
||||
"ENABLE_PDF=$enable_pdf",
|
||||
"ENABLE_PDF_UNSEASONED=$enable_pdf_unseasoned",
|
||||
]
|
||||
}
|
||||
|
||||
if (enable_pdf) {
|
||||
@ -49,7 +52,6 @@ if (enable_pdf) {
|
||||
":internal",
|
||||
":out_of_process_instance",
|
||||
":pdf",
|
||||
":pdf_view_web_plugin",
|
||||
"//base",
|
||||
"//ppapi/cpp:objects",
|
||||
"//ppapi/cpp/private:internal_module",
|
||||
@ -276,12 +278,14 @@ if (enable_pdf) {
|
||||
}
|
||||
|
||||
# Eventual replacement for out_of_process_instance.
|
||||
source_set("pdf_view_web_plugin") {
|
||||
visibility = [ ":*" ]
|
||||
static_library("pdf_view_web_plugin") {
|
||||
visibility = [
|
||||
":*",
|
||||
"//chrome/renderer",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"pdf_view_web_plugin.cc",
|
||||
"pdf_view_web_plugin.h",
|
||||
"post_message_receiver.cc",
|
||||
"post_message_receiver.h",
|
||||
"post_message_sender.cc",
|
||||
@ -290,6 +294,8 @@ if (enable_pdf) {
|
||||
|
||||
configs += [ ":pdf_common_config" ]
|
||||
|
||||
public = [ "pdf_view_web_plugin.h" ]
|
||||
|
||||
deps = [
|
||||
":accessibility_structs",
|
||||
":internal",
|
||||
@ -376,6 +382,7 @@ if (enable_pdf) {
|
||||
":out_of_process_instance",
|
||||
":pdf",
|
||||
":pdf_test_utils",
|
||||
":pdf_view_web_plugin",
|
||||
":ppapi_migration",
|
||||
"//base",
|
||||
"//base:i18n",
|
||||
@ -419,4 +426,6 @@ if (enable_pdf) {
|
||||
}
|
||||
group("pdf_ppapi") {
|
||||
}
|
||||
group("pdf_view_web_plugin") {
|
||||
}
|
||||
}
|
||||
|
@ -10,4 +10,12 @@ import("//build/config/chromecast_build.gni")
|
||||
|
||||
declare_args() {
|
||||
enable_pdf = !is_android && !is_ios && !is_chromecast
|
||||
|
||||
# Enable additional code for the Pepper-free PDF viewer.
|
||||
#
|
||||
# This argument enables additional code paths that are only useful during the
|
||||
# PDF viewer's migration from Pepper. This argument is intended to guard code
|
||||
# meant only for developers, and will be phased out before launch in favor of
|
||||
# a run-time feature flag.
|
||||
enable_pdf_unseasoned = false
|
||||
}
|
||||
|
Reference in New Issue
Block a user