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

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

Issue 550033002: Fixed print_web_view_helper for CEF. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mon Sep 8 02:31:11 PDT 2014 Created 6 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
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_PRINTING_PRINT_WEB_VIEW_HELPER_H_ 5 #ifndef CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_
6 #define CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ 6 #define CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 blink::WebLocalFrame* frame_; 59 blink::WebLocalFrame* frame_;
60 }; 60 };
61 61
62 // PrintWebViewHelper handles most of the printing grunt work for RenderView. 62 // PrintWebViewHelper handles most of the printing grunt work for RenderView.
63 // We plan on making print asynchronous and that will require copying the DOM 63 // We plan on making print asynchronous and that will require copying the DOM
64 // of the document and creating a new WebView with the contents. 64 // of the document and creating a new WebView with the contents.
65 class PrintWebViewHelper 65 class PrintWebViewHelper
66 : public content::RenderViewObserver, 66 : public content::RenderViewObserver,
67 public content::RenderViewObserverTracker<PrintWebViewHelper> { 67 public content::RenderViewObserverTracker<PrintWebViewHelper> {
68 public: 68 public:
69 explicit PrintWebViewHelper(content::RenderView* render_view); 69 PrintWebViewHelper(content::RenderView* render_view,
70 bool preview_enabled,
71 bool scripted_print_throttling_disabled);
70 virtual ~PrintWebViewHelper(); 72 virtual ~PrintWebViewHelper();
71 73
72 bool IsPrintingEnabled(); 74 bool IsPrintingEnabled();
73 75
74 void PrintNode(const blink::WebNode& node); 76 void PrintNode(const blink::WebNode& node);
75 77
76 private: 78 private:
77 friend class PrintWebViewHelperTestBase; 79 friend class PrintWebViewHelperTestBase;
78 FRIEND_TEST_ALL_PREFIXES(PrintWebViewHelperPreviewTest, 80 FRIEND_TEST_ALL_PREFIXES(PrintWebViewHelperPreviewTest,
79 BlockScriptInitiatedPrinting); 81 BlockScriptInitiatedPrinting);
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 bool GetPrintFrame(blink::WebLocalFrame** frame); 279 bool GetPrintFrame(blink::WebLocalFrame** frame);
278 280
279 // Script Initiated Printing ------------------------------------------------ 281 // Script Initiated Printing ------------------------------------------------
280 282
281 // Return true if script initiated printing is currently 283 // Return true if script initiated printing is currently
282 // allowed. |user_initiated| should be true when a user event triggered the 284 // allowed. |user_initiated| should be true when a user event triggered the
283 // script, most likely by pressing a print button on the page. 285 // script, most likely by pressing a print button on the page.
284 bool IsScriptInitiatedPrintAllowed(blink::WebFrame* frame, 286 bool IsScriptInitiatedPrintAllowed(blink::WebFrame* frame,
285 bool user_initiated); 287 bool user_initiated);
286 288
287 // Shows scripted print preview when options from plugin are available. 289 // Returns true if script initiated printing occurs too often.
290 bool IsScriptInitiatedPrintTooFrequent(blink::WebFrame* frame);
291
292 // Reset the counter for script initiated printing.
293 // Scripted printing will be allowed to continue.
294 void ResetScriptedPrintCount();
295
296 // Increment the counter for script initiated printing.
297 // Scripted printing will be blocked for a limited amount of time.
298 void IncrementScriptedPrintCount();
299
300 // Shows scripted print preview when options from plugin are availible.
288 void ShowScriptedPrintPreview(); 301 void ShowScriptedPrintPreview();
289 302
290 void RequestPrintPreview(PrintPreviewRequestType type); 303 void RequestPrintPreview(PrintPreviewRequestType type);
291 304
292 // Checks whether print preview should continue or not. 305 // Checks whether print preview should continue or not.
293 // Returns true if canceling, false if continuing. 306 // Returns true if cancelling, false if continuing.
294 bool CheckForCancel(); 307 bool CheckForCancel();
295 308
296 // Notifies the browser a print preview page has been rendered. 309 // Notifies the browser a print preview page has been rendered.
297 // |page_number| is 0-based. 310 // |page_number| is 0-based.
298 // For a valid |page_number| with modifiable content, 311 // For a valid |page_number| with modifiable content,
299 // |metafile| is the rendered page. Otherwise |metafile| is NULL. 312 // |metafile| is the rendered page. Otherwise |metafile| is NULL.
300 // Returns true if print preview should continue, false on failure. 313 // Returns true if print preview should continue, false on failure.
301 bool PreviewPageRendered(int page_number, Metafile* metafile); 314 bool PreviewPageRendered(int page_number, Metafile* metafile);
302 315
303 void SetPrintPagesParams(const PrintMsg_PrintPages_Params& settings); 316 void SetPrintPagesParams(const PrintMsg_PrintPages_Params& settings);
304 317
305 // WebView used only to print the selection. 318 // WebView used only to print the selection.
306 scoped_ptr<PrepareFrameAndViewForPrint> prep_frame_view_; 319 scoped_ptr<PrepareFrameAndViewForPrint> prep_frame_view_;
307 bool reset_prep_frame_view_; 320 bool reset_prep_frame_view_;
308 321
309 scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_; 322 scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_;
323 bool is_preview_enabled_;
324 bool is_scripted_print_throttling_disabled_;
310 bool is_print_ready_metafile_sent_; 325 bool is_print_ready_metafile_sent_;
311 bool ignore_css_margins_; 326 bool ignore_css_margins_;
327
312 // Used for scripted initiated printing blocking. 328 // Used for scripted initiated printing blocking.
329 base::Time last_cancelled_script_print_;
330 int user_cancelled_scripted_print_count_;
313 bool is_scripted_printing_blocked_; 331 bool is_scripted_printing_blocked_;
314 332
315 // Let the browser process know of a printing failure. Only set to false when 333 // Let the browser process know of a printing failure. Only set to false when
316 // the failure came from the browser in the first place. 334 // the failure came from the browser in the first place.
317 bool notify_browser_of_print_failure_; 335 bool notify_browser_of_print_failure_;
318 336
319 // True, when printing from print preview. 337 // True, when printing from print preview.
320 bool print_for_preview_; 338 bool print_for_preview_;
321 339
322 // Keeps track of the state of print preview between messages. 340 // Keeps track of the state of print preview between messages.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 // hangs because RequestPrintPreview is called before DidStopLoading() is 456 // hangs because RequestPrintPreview is called before DidStopLoading() is
439 // called. This is a store for the RequestPrintPreview() call and its 457 // called. This is a store for the RequestPrintPreview() call and its
440 // parameters so that it can be invoked after DidStopLoading. 458 // parameters so that it can be invoked after DidStopLoading.
441 base::Closure on_stop_loading_closure_; 459 base::Closure on_stop_loading_closure_;
442 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); 460 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper);
443 }; 461 };
444 462
445 } // namespace printing 463 } // namespace printing
446 464
447 #endif // CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ 465 #endif // CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/printing/print_web_view_helper.cc » ('j') | chrome/renderer/printing/print_web_view_helper.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698