Chromium Code Reviews| 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 17b3700eb2addf2f9fdd7fbc30857ee4d09f500c..cc9178bd16d836dc883f722859242178bd34d94f 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 |
|
Lei Zhang
2012/08/30 18:15:31
Keep in mind there's a long term goal to make scri
Scott Byer
2012/08/30 18:22:12
I think the key to keeping the condition would be
|
| + // 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(); |