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

Side by Side Diff: components/printing/renderer/print_web_view_helper.cc

Issue 2601763002: WebFrame cleanup: Move addMessageToConsole to WebLocalFrame (Closed)
Patch Set: Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/printing/renderer/print_web_view_helper.h" 5 #include "components/printing/renderer/print_web_view_helper.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 } 912 }
913 913
914 PrintWebViewHelper::~PrintWebViewHelper() { 914 PrintWebViewHelper::~PrintWebViewHelper() {
915 } 915 }
916 916
917 // static 917 // static
918 void PrintWebViewHelper::DisablePreview() { 918 void PrintWebViewHelper::DisablePreview() {
919 g_is_preview_enabled = false; 919 g_is_preview_enabled = false;
920 } 920 }
921 921
922 bool PrintWebViewHelper::IsScriptInitiatedPrintAllowed(blink::WebFrame* frame, 922 bool PrintWebViewHelper::IsScriptInitiatedPrintAllowed(
923 bool user_initiated) { 923 blink::WebLocalFrame* frame,
924 bool user_initiated) {
924 if (!is_printing_enabled_ || !delegate_->IsScriptedPrintEnabled()) 925 if (!is_printing_enabled_ || !delegate_->IsScriptedPrintEnabled())
925 return false; 926 return false;
926 927
927 // If preview is enabled, then the print dialog is tab modal, and the user 928 // If preview is enabled, then the print dialog is tab modal, and the user
928 // can always close the tab on a mis-behaving page (the system print dialog 929 // can always close the tab on a mis-behaving page (the system print dialog
929 // is app modal). If the print was initiated through user action, don't 930 // is app modal). If the print was initiated through user action, don't
930 // throttle. Or, if the command line flag to skip throttling has been set. 931 // throttle. Or, if the command line flag to skip throttling has been set.
931 return user_initiated || g_is_preview_enabled || 932 return user_initiated || g_is_preview_enabled ||
932 scripting_throttler_.IsAllowed(frame); 933 scripting_throttler_.IsAllowed(frame);
933 } 934 }
(...skipping 1366 matching lines...) Expand 10 before | Expand all | Expand 10 after
2300 void PrintWebViewHelper::SetPrintPagesParams( 2301 void PrintWebViewHelper::SetPrintPagesParams(
2301 const PrintMsg_PrintPages_Params& settings) { 2302 const PrintMsg_PrintPages_Params& settings) {
2302 print_pages_params_.reset(new PrintMsg_PrintPages_Params(settings)); 2303 print_pages_params_.reset(new PrintMsg_PrintPages_Params(settings));
2303 Send(new PrintHostMsg_DidGetDocumentCookie(routing_id(), 2304 Send(new PrintHostMsg_DidGetDocumentCookie(routing_id(),
2304 settings.params.document_cookie)); 2305 settings.params.document_cookie));
2305 } 2306 }
2306 2307
2307 PrintWebViewHelper::ScriptingThrottler::ScriptingThrottler() : count_(0) { 2308 PrintWebViewHelper::ScriptingThrottler::ScriptingThrottler() : count_(0) {
2308 } 2309 }
2309 2310
2310 bool PrintWebViewHelper::ScriptingThrottler::IsAllowed(blink::WebFrame* frame) { 2311 bool PrintWebViewHelper::ScriptingThrottler::IsAllowed(
2312 blink::WebLocalFrame* frame) {
2311 const int kMinSecondsToIgnoreJavascriptInitiatedPrint = 2; 2313 const int kMinSecondsToIgnoreJavascriptInitiatedPrint = 2;
2312 const int kMaxSecondsToIgnoreJavascriptInitiatedPrint = 32; 2314 const int kMaxSecondsToIgnoreJavascriptInitiatedPrint = 32;
2313 bool too_frequent = false; 2315 bool too_frequent = false;
2314 2316
2315 // Check if there is script repeatedly trying to print and ignore it if too 2317 // Check if there is script repeatedly trying to print and ignore it if too
2316 // frequent. The first 3 times, we use a constant wait time, but if this 2318 // frequent. The first 3 times, we use a constant wait time, but if this
2317 // gets excessive, we switch to exponential wait time. So for a page that 2319 // gets excessive, we switch to exponential wait time. So for a page that
2318 // calls print() in a loop the user will need to cancel the print dialog 2320 // calls print() in a loop the user will need to cancel the print dialog
2319 // after: [2, 2, 2, 4, 8, 16, 32, 32, ...] seconds. 2321 // after: [2, 2, 2, 4, 8, 16, 32, 32, ...] seconds.
2320 // This gives the user time to navigate from the page. 2322 // This gives the user time to navigate from the page.
(...skipping 22 matching lines...) Expand all
2343 blink::WebConsoleMessage::LevelWarning, message)); 2345 blink::WebConsoleMessage::LevelWarning, message));
2344 return false; 2346 return false;
2345 } 2347 }
2346 2348
2347 void PrintWebViewHelper::ScriptingThrottler::Reset() { 2349 void PrintWebViewHelper::ScriptingThrottler::Reset() {
2348 // Reset counter on successful print. 2350 // Reset counter on successful print.
2349 count_ = 0; 2351 count_ = 0;
2350 } 2352 }
2351 2353
2352 } // namespace printing 2354 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698