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

Unified Diff: chrome/renderer/print_web_view_helper.cc

Issue 9762004: Block scripted printing. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 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') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « chrome/renderer/print_web_view_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698