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

Side by Side Diff: chrome/renderer/print_web_view_helper.h

Issue 10890054: Reign in print throttling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to start review Created 8 years, 3 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 | Annotate | Revision Log
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 #ifndef CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ 5 #ifndef CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_
6 #define CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ 6 #define CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 }; 131 };
132 132
133 enum PrintPreviewRequestType { 133 enum PrintPreviewRequestType {
134 PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME, 134 PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME,
135 PRINT_PREVIEW_USER_INITIATED_CONTEXT_NODE, 135 PRINT_PREVIEW_USER_INITIATED_CONTEXT_NODE,
136 PRINT_PREVIEW_SCRIPTED // triggered by window.print(). 136 PRINT_PREVIEW_SCRIPTED // triggered by window.print().
137 }; 137 };
138 138
139 // RenderViewObserver implementation. 139 // RenderViewObserver implementation.
140 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 140 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
141 virtual void PrintPage(WebKit::WebFrame* frame) OVERRIDE; 141 virtual void PrintPage(WebKit::WebFrame* frame, bool user_initiated) OVERRIDE;
142 142
143 // Message handlers --------------------------------------------------------- 143 // Message handlers ---------------------------------------------------------
144 144
145 // Print the document. 145 // Print the document.
146 void OnPrintPages(); 146 void OnPrintPages();
147 147
148 // Print the document with the print preview frame/node. 148 // Print the document with the print preview frame/node.
149 void OnPrintForSystemDialog(); 149 void OnPrintForSystemDialog();
150 150
151 // Get |page_size| and |content_area| information from 151 // Get |page_size| and |content_area| information from
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 const base::DictionaryValue& header_footer_info); 325 const base::DictionaryValue& header_footer_info);
326 326
327 bool GetPrintFrame(WebKit::WebFrame** frame); 327 bool GetPrintFrame(WebKit::WebFrame** frame);
328 328
329 // This reports the current time - |start_time| as the time to render a page. 329 // This reports the current time - |start_time| as the time to render a page.
330 void ReportPreviewPageRenderTime(base::TimeTicks start_time); 330 void ReportPreviewPageRenderTime(base::TimeTicks start_time);
331 331
332 // Script Initiated Printing ------------------------------------------------ 332 // Script Initiated Printing ------------------------------------------------
333 333
334 // Return true if script initiated printing is currently allowed. 334 // Return true if script initiated printing is currently allowed.
335 bool IsScriptInitiatedPrintAllowed(WebKit::WebFrame* frame); 335 bool IsScriptInitiatedPrintAllowed(WebKit::WebFrame* frame,
336 bool user_initiated);
Jói 2012/08/30 18:05:22 On a method with this name, it feels weird to have
Scott Byer 2012/08/30 23:32:24 Done.
336 337
337 // Returns true if script initiated printing occurs too often. 338 // Returns true if script initiated printing occurs too often.
338 bool IsScriptInitiatedPrintTooFrequent(WebKit::WebFrame* frame); 339 bool IsScriptInitiatedPrintTooFrequent(WebKit::WebFrame* frame);
339 340
340 // Reset the counter for script initiated printing. 341 // Reset the counter for script initiated printing.
341 // Scripted printing will be allowed to continue. 342 // Scripted printing will be allowed to continue.
342 void ResetScriptedPrintCount(); 343 void ResetScriptedPrintCount();
343 344
344 // Increment the counter for script initiated printing. 345 // Increment the counter for script initiated printing.
345 // Scripted printing will be blocked for a limited amount of time. 346 // Scripted printing will be blocked for a limited amount of time.
(...skipping 10 matching lines...) Expand all
356 // For a valid |page_number| with modifiable content, 357 // For a valid |page_number| with modifiable content,
357 // |metafile| is the rendered page. Otherwise |metafile| is NULL. 358 // |metafile| is the rendered page. Otherwise |metafile| is NULL.
358 // Returns true if print preview should continue, false on failure. 359 // Returns true if print preview should continue, false on failure.
359 bool PreviewPageRendered(int page_number, printing::Metafile* metafile); 360 bool PreviewPageRendered(int page_number, printing::Metafile* metafile);
360 361
361 // WebView used only to print the selection. 362 // WebView used only to print the selection.
362 WebKit::WebView* print_web_view_; 363 WebKit::WebView* print_web_view_;
363 364
364 scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_; 365 scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_;
365 bool is_preview_enabled_; 366 bool is_preview_enabled_;
367 bool is_scripted_print_throttling_disabled_;
366 bool is_print_ready_metafile_sent_; 368 bool is_print_ready_metafile_sent_;
367 bool ignore_css_margins_; 369 bool ignore_css_margins_;
368 370
369 // Used for scripted initiated printing blocking. 371 // Used for scripted initiated printing blocking.
370 base::Time last_cancelled_script_print_; 372 base::Time last_cancelled_script_print_;
371 int user_cancelled_scripted_print_count_; 373 int user_cancelled_scripted_print_count_;
372 bool is_scripted_printing_blocked_; 374 bool is_scripted_printing_blocked_;
373 375
374 // Let the browser process know of a printing failure. Only set to false when 376 // Let the browser process know of a printing failure. Only set to false when
375 // the failure came from the browser in the first place. 377 // the failure came from the browser in the first place.
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 enum PrintPreviewErrorBuckets error_; 482 enum PrintPreviewErrorBuckets error_;
481 483
482 State state_; 484 State state_;
483 }; 485 };
484 486
485 PrintPreviewContext print_preview_context_; 487 PrintPreviewContext print_preview_context_;
486 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); 488 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper);
487 }; 489 };
488 490
489 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ 491 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698