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

Unified Diff: chrome/renderer/print_web_view_helper.cc

Issue 10890054: Reign in print throttling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase only Created 8 years, 3 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
« no previous file with comments | « chrome/renderer/print_web_view_helper.h ('k') | chrome/renderer/print_web_view_helper_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/print_web_view_helper.cc
diff --git a/chrome/renderer/print_web_view_helper.cc b/chrome/renderer/print_web_view_helper.cc
index ccf77894d8609e8c1d64c9ccf366caf7ca4308d2..5ba2c8036817a3b36d5b52af139a5ea3347e393d 100644
--- a/chrome/renderer/print_web_view_helper.cc
+++ b/chrome/renderer/print_web_view_helper.cc
@@ -527,6 +527,11 @@ bool IsPrintPreviewEnabled() {
switches::kRendererPrintPreview);
}
+bool IsPrintThrottlingDisabled() {
+ return CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kDisableScriptedPrintThrottling);
+}
+
} // namespace
// static - Not anonymous so that platform implementations can use it.
@@ -717,6 +722,7 @@ PrintWebViewHelper::PrintWebViewHelper(content::RenderView* render_view)
content::RenderViewObserverTracker<PrintWebViewHelper>(render_view),
print_web_view_(NULL),
is_preview_enabled_(IsPrintPreviewEnabled()),
+ is_scripted_print_throttling_disabled_(IsPrintThrottlingDisabled()),
is_print_ready_metafile_sent_(false),
ignore_css_margins_(false),
user_cancelled_scripted_print_count_(0),
@@ -728,14 +734,23 @@ PrintWebViewHelper::PrintWebViewHelper(content::RenderView* render_view)
PrintWebViewHelper::~PrintWebViewHelper() {}
bool PrintWebViewHelper::IsScriptInitiatedPrintAllowed(
- WebKit::WebFrame* frame) {
+ WebKit::WebFrame* frame, bool user_initiated) {
if (is_scripted_printing_blocked_)
return false;
- return !IsScriptInitiatedPrintTooFrequent(frame);
+ // If preview is enabled, then the print dialog is tab modal, and the user
+ // can always close the tab on a mis-behaving page (the system print dialog
+ // is app modal). If the print was initiated through user action, don't
+ // throttle. Or, if the command line flag to skip throttling has been set.
+ if (!is_scripted_print_throttling_disabled_ &&
+ !is_preview_enabled_ &&
+ !user_initiated)
+ return !IsScriptInitiatedPrintTooFrequent(frame);
+ return true;
}
// Prints |frame| which called window.print().
-void PrintWebViewHelper::PrintPage(WebKit::WebFrame* frame) {
+void PrintWebViewHelper::PrintPage(WebKit::WebFrame* frame,
+ bool user_initiated) {
DCHECK(frame);
// Allow Prerendering to cancel this print request if necessary.
@@ -744,7 +759,7 @@ void PrintWebViewHelper::PrintPage(WebKit::WebFrame* frame) {
return;
}
- if (!IsScriptInitiatedPrintAllowed(frame))
+ if (!IsScriptInitiatedPrintAllowed(frame, user_initiated))
return;
IncrementScriptedPrintCount();
« no previous file with comments | « chrome/renderer/print_web_view_helper.h ('k') | chrome/renderer/print_web_view_helper_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698