Index: chrome/renderer/printing/chrome_print_web_view_helper_delegate.cc |
diff --git a/chrome/renderer/printing/chrome_print_web_view_helper_delegate.cc b/chrome/renderer/printing/chrome_print_web_view_helper_delegate.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..710d2d2fa6381fe5533e36a64782fc8ddfcbd4c3 |
--- /dev/null |
+++ b/chrome/renderer/printing/chrome_print_web_view_helper_delegate.cc |
@@ -0,0 +1,78 @@ |
+// Copyright (c) 2014 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/printing/chrome_print_web_view_helper_delegate.h" |
+ |
+#include "base/command_line.h" |
+#include "base/json/json_writer.h" |
+#include "chrome/common/chrome_switches.h" |
+#include "chrome/common/render_messages.h" |
+#include "chrome/grit/browser_resources.h" |
+#include "chrome/renderer/prerender/prerender_helper.h" |
+#include "content/public/renderer/render_view.h" |
+#include "ipc/ipc_message.h" |
+#include "third_party/WebKit/public/web/WebLocalFrame.h" |
+#include "ui/base/resource/resource_bundle.h" |
+ |
+#if defined(ENABLE_EXTENSIONS) |
+#include "chrome/common/extensions/extension_constants.h" |
+#include "extensions/common/constants.h" |
+#endif // defined(ENABLE_EXTENSIONS) |
+ |
+namespace printing { |
+ |
+ChromePrintWebViewHelperDelegate::ChromePrintWebViewHelperDelegate() |
+ : PrintWebViewHelperDelegate() { |
+} |
+ |
+ChromePrintWebViewHelperDelegate::~ChromePrintWebViewHelperDelegate() { |
+} |
+ |
+IPC::Message* ChromePrintWebViewHelperDelegate::GetScriptedPrintCancelMessage( |
+ content::RenderView* render_view, int routing_id) { |
+ if (!prerender::PrerenderHelper::IsPrerendering( |
+ render_view->GetMainRenderFrame())) |
Vitaly Buka (NO REVIEWS)
2015/01/05 19:57:03
there is content::RenderView::Send
please rename G
dgn
2015/01/05 22:45:47
I'm not sure to understand the second part of the
|
+ return nullptr; |
+ |
+ return new ChromeViewHostMsg_CancelPrerenderForPrinting(routing_id); |
+} |
+ |
+bool ChromePrintWebViewHelperDelegate::OutOfProcessPdfEnabled() { |
+ return switches::OutOfProcessPdfEnabled(); |
Vitaly Buka (NO REVIEWS)
2015/01/05 19:57:03
OutOfProcessPdfEnabled and PrintPreviewDisabled sh
dgn
2015/01/05 22:45:47
Done.
|
+} |
+ |
+// Return the PDF object element if |frame| is the out of process PDF extension. |
+blink::WebElement ChromePrintWebViewHelperDelegate::GetPdfElement( |
+ blink::WebLocalFrame* frame) { |
+#if defined(ENABLE_EXTENSIONS) |
+ GURL url = frame->document().url(); |
+ if (url.SchemeIs(extensions::kExtensionScheme) && |
Vitaly Buka (NO REVIEWS)
2015/01/05 19:57:03
seems ChromePrintWebViewHelperDelegate::GetPdfElem
dgn
2015/01/05 22:45:47
Done.
|
+ url.host() == extension_misc::kPdfExtensionId) { |
+ // <object> with id="plugin" is created in |
+ // chrome/browser/resources/pdf/pdf.js. |
+ auto plugin_element = frame->document().getElementById("plugin"); |
+ if (!plugin_element.isNull()) { |
+ return plugin_element; |
+ } |
+ NOTREACHED(); |
+ } |
+#endif // defined(ENABLE_EXTENSIONS) |
+ return blink::WebElement(); |
+} |
+ |
+base::StringValue ChromePrintWebViewHelperDelegate::GetPrintPreviewHtml() { |
dgn
2014/12/30 17:15:48
Will probably end up with the whole function in th
Vitaly Buka (NO REVIEWS)
2015/01/05 19:57:03
seems ChromePrintWebViewHelperDelegate::GetPrintPr
dgn
2015/01/05 22:45:47
Done.
|
+#if defined(ENABLE_PRINT_PREVIEW) |
+ return base::StringValue( |
+ ResourceBundle::GetSharedInstance().GetLocalizedString( |
+ IDR_PRINT_PREVIEW_PAGE)); |
+#endif |
+ return base::StringValue(""); |
+} |
+ |
+bool ChromePrintWebViewHelperDelegate::PrintPreviewDisabled() { |
+ return CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kDisablePrintPreview); |
+} |
+ |
+} // namespace printing |