From 0fda727e08d2f785ce127fba39c4ce69955fa934 Mon Sep 17 00:00:00 2001 From: "sverrir@google.com" Date: Fri, 26 Jun 2009 15:49:33 +0000 Subject: Restrict how often javascript can annoy the user with the print dialog. If a page continuously calls print() through javascript and the user cancels the printing no other printer dialog will be shown for 15 seconds. Also removed "Print failed" notification when the user cancels printing (since this should be obvious to the user). BUG=http://crbug.com/7880 TEST=See bug. Review URL: http://codereview.chromium.org/146052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19362 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/renderer/print_web_view_helper.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'chrome/renderer/print_web_view_helper.h') diff --git a/chrome/renderer/print_web_view_helper.h b/chrome/renderer/print_web_view_helper.h index c2a02c2..77079fd 100644 --- a/chrome/renderer/print_web_view_helper.h +++ b/chrome/renderer/print_web_view_helper.h @@ -8,6 +8,7 @@ #include #include "base/scoped_ptr.h" +#include "base/time.h" #include "webkit/glue/webview_delegate.h" namespace gfx { @@ -31,11 +32,12 @@ struct ViewMsg_PrintPages_Params; class PrintWebViewHelper : public WebViewDelegate { public: explicit PrintWebViewHelper(RenderView * render_view) - : render_view_(render_view) {} + : render_view_(render_view), + user_cancelled_scripted_print_count_(0) {} virtual ~PrintWebViewHelper() {} - void SyncPrint(WebFrame* frame); + void Print(WebFrame* frame, bool script_initiated); // Is there a background print in progress? bool IsPrinting() { @@ -97,6 +99,8 @@ class PrintWebViewHelper : public WebViewDelegate { RenderView* render_view_; scoped_ptr print_web_view_; scoped_ptr print_pages_params_; + base::Time last_cancelled_script_print_; + int user_cancelled_scripted_print_count_; private: DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); -- cgit v1.1