summaryrefslogtreecommitdiff
path: root/chromium/chrome/renderer/plugins/pdf_plugin_placeholder.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-03-05 14:36:22 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-03-05 14:37:32 +0100
commit28db9b54de6402bd38770ecc1d620255e9d1e78f (patch)
tree469a957ff6b9b6d0ee9fb4074b9139cbaa050443 /chromium/chrome/renderer/plugins/pdf_plugin_placeholder.cc
parent3239a38a9b35d29e483b7bd67b786b4f9d109908 (diff)
parent248b70b82a40964d5594eb04feca0fa36716185d (diff)
downloadqtwebengine-chromium-28db9b54de6402bd38770ecc1d620255e9d1e78f.tar.gz
Merge remote-tracking branch 'origin/upstream-master' into 79-based
Conflicts: chromium/chrome/common/pref_names.cc chromium/chrome/common/pref_names.h Change-Id: I9be20fb8dfd946e3db1fa298dce076db5fd1f397
Diffstat (limited to 'chromium/chrome/renderer/plugins/pdf_plugin_placeholder.cc')
-rw-r--r--chromium/chrome/renderer/plugins/pdf_plugin_placeholder.cc56
1 files changed, 56 insertions, 0 deletions
diff --git a/chromium/chrome/renderer/plugins/pdf_plugin_placeholder.cc b/chromium/chrome/renderer/plugins/pdf_plugin_placeholder.cc
new file mode 100644
index 00000000000..1a506d03253
--- /dev/null
+++ b/chromium/chrome/renderer/plugins/pdf_plugin_placeholder.cc
@@ -0,0 +1,56 @@
+// Copyright 2017 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 "chrome/renderer/plugins/pdf_plugin_placeholder.h"
+
+#include "base/command_line.h"
+#include "chrome/common/pdf_util.h"
+#include "chrome/common/render_messages.h"
+#include "content/public/common/content_switches.h"
+#include "content/public/renderer/render_thread.h"
+#include "gin/object_template_builder.h"
+
+gin::WrapperInfo PDFPluginPlaceholder::kWrapperInfo = {gin::kEmbedderNativeGin};
+
+// static
+PDFPluginPlaceholder* PDFPluginPlaceholder::CreatePDFPlaceholder(
+ content::RenderFrame* render_frame,
+ const blink::WebPluginParams& params) {
+ std::string html_data = GetPDFPlaceholderHTML(params.url);
+ return new PDFPluginPlaceholder(render_frame, params, html_data);
+}
+
+PDFPluginPlaceholder::PDFPluginPlaceholder(content::RenderFrame* render_frame,
+ const blink::WebPluginParams& params,
+ const std::string& html_data)
+ : plugins::PluginPlaceholderBase(render_frame, params, html_data) {}
+
+PDFPluginPlaceholder::~PDFPluginPlaceholder() {}
+
+v8::Local<v8::Value> PDFPluginPlaceholder::GetV8Handle(v8::Isolate* isolate) {
+ return gin::CreateHandle(isolate, this).ToV8();
+}
+
+gin::ObjectTemplateBuilder PDFPluginPlaceholder::GetObjectTemplateBuilder(
+ v8::Isolate* isolate) {
+ gin::ObjectTemplateBuilder builder =
+ gin::Wrappable<PDFPluginPlaceholder>::GetObjectTemplateBuilder(isolate)
+ .SetMethod<void (PDFPluginPlaceholder::*)()>(
+ "openPDF", &PDFPluginPlaceholder::OpenPDFCallback);
+
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnablePluginPlaceholderTesting)) {
+ builder.SetMethod<void (PDFPluginPlaceholder::*)()>(
+ "notifyPlaceholderReadyForTesting",
+ &PDFPluginPlaceholder::NotifyPlaceholderReadyForTestingCallback);
+ }
+
+ return builder;
+}
+
+void PDFPluginPlaceholder::OpenPDFCallback() {
+ ReportPDFLoadStatus(PDFLoadStatus::kViewPdfClickedInPdfPluginPlaceholder);
+ content::RenderThread::Get()->Send(
+ new ChromeViewHostMsg_OpenPDF(routing_id(), GetPluginParams().url));
+}