Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8520)

Unified Diff: chrome/renderer/printing/print_web_view_helper.cc

Issue 791133006: Delegates for the printing component (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Using initialisation parameters instead of delegate methods Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/printing/print_web_view_helper.cc
diff --git a/chrome/renderer/printing/print_web_view_helper.cc b/chrome/renderer/printing/print_web_view_helper.cc
index d50f076af6e752024875635ad9e468bee841069b..71dc4818842eb2d63d95a1df03ae5593e9d234aa 100644
--- a/chrome/renderer/printing/print_web_view_helper.cc
+++ b/chrome/renderer/printing/print_web_view_helper.cc
@@ -7,7 +7,6 @@
#include <string>
#include "base/auto_reset.h"
-#include "base/command_line.h"
#include "base/json/json_writer.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
@@ -16,11 +15,8 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
-#include "chrome/common/chrome_switches.h"
#include "chrome/common/print_messages.h"
dgn 2015/01/05 22:45:48 Will move to //components/printing/common/print_me
-#include "chrome/common/render_messages.h"
#include "chrome/grit/browser_resources.h"
dgn 2015/01/05 22:45:48 The used variable will be moved to //components/pr
-#include "chrome/renderer/prerender/prerender_helper.h"
#include "content/public/common/web_preferences.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_thread.h"
@@ -47,7 +43,6 @@
#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)
@@ -55,6 +50,8 @@ using content::WebPreferences;
namespace printing {
+static const char kPdfExtensionId[] = "mhjfbmdgcfjbbpaeojofohoefgiehjai";
Lei Zhang 2015/01/06 04:11:32 Can we pass this in, instead of duplicating the va
dgn 2015/01/06 16:35:31 Done.
+
namespace {
enum PrintPreviewHelperEvents {
@@ -415,7 +412,7 @@ blink::WebElement GetPdfElement(blink::WebLocalFrame* frame) {
#if defined(ENABLE_EXTENSIONS)
GURL url = frame->document().url();
if (url.SchemeIs(extensions::kExtensionScheme) &&
- url.host() == extension_misc::kPdfExtensionId) {
+ url.host() == kPdfExtensionId) {
// <object> with id="plugin" is created in
// chrome/browser/resources/pdf/pdf.js.
auto plugin_element = frame->document().getElementById("plugin");
@@ -790,7 +787,11 @@ void PrepareFrameAndViewForPrint::FinishPrinting() {
on_ready_.Reset();
}
-PrintWebViewHelper::PrintWebViewHelper(content::RenderView* render_view)
+PrintWebViewHelper::PrintWebViewHelper(
+ content::RenderView* render_view,
+ const bool out_of_process_pdf_enabled,
+ const bool print_preview_disabled,
+ Delegate* delegate)
: content::RenderViewObserver(render_view),
content::RenderViewObserverTracker<PrintWebViewHelper>(render_view),
reset_prep_frame_view_(false),
@@ -799,12 +800,13 @@ PrintWebViewHelper::PrintWebViewHelper(content::RenderView* render_view)
is_scripted_printing_blocked_(false),
notify_browser_of_print_failure_(true),
print_for_preview_(false),
+ out_of_process_pdf_enabled_(out_of_process_pdf_enabled),
+ delegate_(delegate),
print_node_in_progress_(false),
is_loading_(false),
is_scripted_preview_delayed_(false),
weak_ptr_factory_(this) {
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kDisablePrintPreview)) {
+ if (print_preview_disabled) {
DisablePreview();
}
}
@@ -845,11 +847,8 @@ void PrintWebViewHelper::PrintPage(blink::WebLocalFrame* frame,
DCHECK(frame);
// Allow Prerendering to cancel this print request if necessary.
- if (prerender::PrerenderHelper::IsPrerendering(
- render_view()->GetMainRenderFrame())) {
- Send(new ChromeViewHostMsg_CancelPrerenderForPrinting(routing_id()));
+ if (delegate_->CancelPrerender(render_view(), routing_id()))
return;
- }
if (!IsScriptInitiatedPrintAllowed(frame, user_initiated))
return;
@@ -906,8 +905,7 @@ void PrintWebViewHelper::OnPrintForPrintPreview(
// the element with ID "pdf-viewer" if it isn't an iframe.
blink::WebLocalFrame* plugin_frame = pdf_element.document().frame();
blink::WebElement plugin_element = pdf_element;
- if (switches::OutOfProcessPdfEnabled() &&
- pdf_element.hasHTMLTagName("iframe")) {
+ if (out_of_process_pdf_enabled_ && pdf_element.hasHTMLTagName("iframe")) {
plugin_frame = blink::WebLocalFrame::fromFrameOwnerElement(pdf_element);
plugin_element = GetPdfElement(plugin_frame);
if (plugin_element.isNull()) {

Powered by Google App Engine
This is Rietveld 408576698