| Index: chrome/renderer/print_web_view_helper.cc
|
| ===================================================================
|
| --- chrome/renderer/print_web_view_helper.cc (revision 127745)
|
| +++ chrome/renderer/print_web_view_helper.cc (working copy)
|
| @@ -657,11 +657,19 @@
|
| ignore_css_margins_(false),
|
| fit_to_page_(true),
|
| user_cancelled_scripted_print_count_(0),
|
| + is_scripted_printing_blocked_(false),
|
| notify_browser_of_print_failure_(true) {
|
| }
|
|
|
| PrintWebViewHelper::~PrintWebViewHelper() {}
|
|
|
| +bool PrintWebViewHelper::IsScriptInitiatedPrintAllowed(
|
| + WebKit::WebFrame* frame) {
|
| + if (is_scripted_printing_blocked_)
|
| + return false;
|
| + return !IsScriptInitiatedPrintTooFrequent(frame);
|
| +}
|
| +
|
| // Prints |frame| which called window.print().
|
| void PrintWebViewHelper::PrintPage(WebKit::WebFrame* frame) {
|
| DCHECK(frame);
|
| @@ -672,7 +680,7 @@
|
| return;
|
| }
|
|
|
| - if (IsScriptInitiatedPrintTooFrequent(frame))
|
| + if (!IsScriptInitiatedPrintAllowed(frame))
|
| return;
|
| IncrementScriptedPrintCount();
|
|
|
| @@ -699,6 +707,8 @@
|
| ResetScriptedPrintCount)
|
| IPC_MESSAGE_HANDLER(PrintMsg_PreviewPrintingRequestCancelled,
|
| DisplayPrintJobError)
|
| + IPC_MESSAGE_HANDLER(PrintMsg_SetScriptedPrintingBlocked,
|
| + SetScriptedPrintBlocked)
|
| IPC_MESSAGE_UNHANDLED(handled = false)
|
| IPC_END_MESSAGE_MAP()
|
| return handled;
|
| @@ -976,6 +986,10 @@
|
| DidFinishPrinting(success ? OK : FAIL_PRINT);
|
| }
|
|
|
| +void PrintWebViewHelper::SetScriptedPrintBlocked(bool blocked) {
|
| + is_scripted_printing_blocked_ = blocked;
|
| +}
|
| +
|
| void PrintWebViewHelper::OnPrintNodeUnderContextMenu() {
|
| const WebNode& context_menu_node = render_view()->GetContextMenuNode();
|
| PrintNode(context_menu_node);
|
|
|