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

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 only 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
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | chrome/renderer/print_web_view_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 const printing::PageSizeMargins& page_layout_in_points, 324 const printing::PageSizeMargins& page_layout_in_points,
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
335 bool IsScriptInitiatedPrintAllowed(WebKit::WebFrame* frame); 335 // allowed. |user_initiated| should be true when a user event triggered the
336 // script, most likely by pressing a print button on the page.
337 bool IsScriptInitiatedPrintAllowed(WebKit::WebFrame* frame,
338 bool user_initiated);
336 339
337 // Returns true if script initiated printing occurs too often. 340 // Returns true if script initiated printing occurs too often.
338 bool IsScriptInitiatedPrintTooFrequent(WebKit::WebFrame* frame); 341 bool IsScriptInitiatedPrintTooFrequent(WebKit::WebFrame* frame);
339 342
340 // Reset the counter for script initiated printing. 343 // Reset the counter for script initiated printing.
341 // Scripted printing will be allowed to continue. 344 // Scripted printing will be allowed to continue.
342 void ResetScriptedPrintCount(); 345 void ResetScriptedPrintCount();
343 346
344 // Increment the counter for script initiated printing. 347 // Increment the counter for script initiated printing.
345 // Scripted printing will be blocked for a limited amount of time. 348 // 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, 359 // For a valid |page_number| with modifiable content,
357 // |metafile| is the rendered page. Otherwise |metafile| is NULL. 360 // |metafile| is the rendered page. Otherwise |metafile| is NULL.
358 // Returns true if print preview should continue, false on failure. 361 // Returns true if print preview should continue, false on failure.
359 bool PreviewPageRendered(int page_number, printing::Metafile* metafile); 362 bool PreviewPageRendered(int page_number, printing::Metafile* metafile);
360 363
361 // WebView used only to print the selection. 364 // WebView used only to print the selection.
362 WebKit::WebView* print_web_view_; 365 WebKit::WebView* print_web_view_;
363 366
364 scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_; 367 scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_;
365 bool is_preview_enabled_; 368 bool is_preview_enabled_;
369 bool is_scripted_print_throttling_disabled_;
366 bool is_print_ready_metafile_sent_; 370 bool is_print_ready_metafile_sent_;
367 bool ignore_css_margins_; 371 bool ignore_css_margins_;
368 372
369 // Used for scripted initiated printing blocking. 373 // Used for scripted initiated printing blocking.
370 base::Time last_cancelled_script_print_; 374 base::Time last_cancelled_script_print_;
371 int user_cancelled_scripted_print_count_; 375 int user_cancelled_scripted_print_count_;
372 bool is_scripted_printing_blocked_; 376 bool is_scripted_printing_blocked_;
373 377
374 // Let the browser process know of a printing failure. Only set to false when 378 // 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. 379 // 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_; 484 enum PrintPreviewErrorBuckets error_;
481 485
482 State state_; 486 State state_;
483 }; 487 };
484 488
485 PrintPreviewContext print_preview_context_; 489 PrintPreviewContext print_preview_context_;
486 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); 490 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper);
487 }; 491 };
488 492
489 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ 493 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | chrome/renderer/print_web_view_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698