OLD | NEW |
---|---|
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/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/shared_memory.h" | 12 #include "base/memory/shared_memory.h" |
13 #include "base/memory/weak_ptr.h" | |
13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
14 #include "content/public/renderer/render_view_observer.h" | 15 #include "content/public/renderer/render_view_observer.h" |
15 #include "content/public/renderer/render_view_observer_tracker.h" | 16 #include "content/public/renderer/render_view_observer_tracker.h" |
16 #include "printing/metafile_impl.h" | 17 #include "printing/metafile_impl.h" |
17 #include "third_party/WebKit/public/platform/WebCanvas.h" | 18 #include "third_party/WebKit/public/platform/WebCanvas.h" |
18 #include "third_party/WebKit/public/web/WebNode.h" | 19 #include "third_party/WebKit/public/web/WebNode.h" |
19 #include "third_party/WebKit/public/web/WebPrintParams.h" | 20 #include "third_party/WebKit/public/web/WebPrintParams.h" |
20 #include "ui/gfx/size.h" | 21 #include "ui/gfx/size.h" |
21 | 22 |
22 struct PrintMsg_Print_Params; | 23 struct PrintMsg_Print_Params; |
(...skipping 30 matching lines...) Expand all Loading... | |
53 private: | 54 private: |
54 WebKit::WebView* view_; | 55 WebKit::WebView* view_; |
55 WebKit::WebString frame_name_; | 56 WebKit::WebString frame_name_; |
56 }; | 57 }; |
57 | 58 |
58 // PrintWebViewHelper handles most of the printing grunt work for RenderView. | 59 // PrintWebViewHelper handles most of the printing grunt work for RenderView. |
59 // We plan on making print asynchronous and that will require copying the DOM | 60 // We plan on making print asynchronous and that will require copying the DOM |
60 // of the document and creating a new WebView with the contents. | 61 // of the document and creating a new WebView with the contents. |
61 class PrintWebViewHelper | 62 class PrintWebViewHelper |
62 : public content::RenderViewObserver, | 63 : public content::RenderViewObserver, |
63 public content::RenderViewObserverTracker<PrintWebViewHelper> { | 64 public content::RenderViewObserverTracker<PrintWebViewHelper>, |
65 public base::SupportsWeakPtr<PrintWebViewHelper> { | |
Lei Zhang
2013/09/03 20:07:26
A couple weeks ago, there was a "let's kill Suppor
Vitaly Buka (NO REVIEWS)
2013/09/04 01:49:49
Done.
| |
64 public: | 66 public: |
65 explicit PrintWebViewHelper(content::RenderView* render_view); | 67 explicit PrintWebViewHelper(content::RenderView* render_view); |
66 virtual ~PrintWebViewHelper(); | 68 virtual ~PrintWebViewHelper(); |
67 | 69 |
68 bool IsPrintingEnabled(); | 70 bool IsPrintingEnabled(); |
69 | 71 |
70 void PrintNode(const WebKit::WebNode& node); | 72 void PrintNode(const WebKit::WebNode& node); |
71 | 73 |
72 private: | 74 private: |
73 friend class PrintWebViewHelperTestBase; | 75 friend class PrintWebViewHelperTestBase; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 enum PrintPreviewRequestType { | 107 enum PrintPreviewRequestType { |
106 PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME, | 108 PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME, |
107 PRINT_PREVIEW_USER_INITIATED_SELECTION, | 109 PRINT_PREVIEW_USER_INITIATED_SELECTION, |
108 PRINT_PREVIEW_USER_INITIATED_CONTEXT_NODE, | 110 PRINT_PREVIEW_USER_INITIATED_CONTEXT_NODE, |
109 PRINT_PREVIEW_SCRIPTED // triggered by window.print(). | 111 PRINT_PREVIEW_SCRIPTED // triggered by window.print(). |
110 }; | 112 }; |
111 | 113 |
112 // RenderViewObserver implementation. | 114 // RenderViewObserver implementation. |
113 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 115 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
114 virtual void PrintPage(WebKit::WebFrame* frame, bool user_initiated) OVERRIDE; | 116 virtual void PrintPage(WebKit::WebFrame* frame, bool user_initiated) OVERRIDE; |
117 virtual void DidStartLoading() OVERRIDE; | |
118 virtual void DidStopLoading() OVERRIDE; | |
115 | 119 |
116 // Message handlers --------------------------------------------------------- | 120 // Message handlers --------------------------------------------------------- |
117 | 121 |
118 // Print the document. | 122 // Print the document. |
119 void OnPrintPages(); | 123 void OnPrintPages(); |
120 | 124 |
121 // Print the document with the print preview frame/node. | 125 // Print the document with the print preview frame/node. |
122 void OnPrintForSystemDialog(); | 126 void OnPrintForSystemDialog(); |
123 | 127 |
124 // Get |page_size| and |content_area| information from | 128 // Get |page_size| and |content_area| information from |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
319 bool IsScriptInitiatedPrintTooFrequent(WebKit::WebFrame* frame); | 323 bool IsScriptInitiatedPrintTooFrequent(WebKit::WebFrame* frame); |
320 | 324 |
321 // Reset the counter for script initiated printing. | 325 // Reset the counter for script initiated printing. |
322 // Scripted printing will be allowed to continue. | 326 // Scripted printing will be allowed to continue. |
323 void ResetScriptedPrintCount(); | 327 void ResetScriptedPrintCount(); |
324 | 328 |
325 // Increment the counter for script initiated printing. | 329 // Increment the counter for script initiated printing. |
326 // Scripted printing will be blocked for a limited amount of time. | 330 // Scripted printing will be blocked for a limited amount of time. |
327 void IncrementScriptedPrintCount(); | 331 void IncrementScriptedPrintCount(); |
328 | 332 |
333 // Shows scripted print preview when options from plugin are availible. | |
334 void ShowScriptedPrintPreview(); | |
335 | |
329 void RequestPrintPreview(PrintPreviewRequestType type); | 336 void RequestPrintPreview(PrintPreviewRequestType type); |
330 | 337 |
331 // Checks whether print preview should continue or not. | 338 // Checks whether print preview should continue or not. |
332 // Returns true if cancelling, false if continuing. | 339 // Returns true if cancelling, false if continuing. |
333 bool CheckForCancel(); | 340 bool CheckForCancel(); |
334 | 341 |
335 // Notifies the browser a print preview page has been rendered. | 342 // Notifies the browser a print preview page has been rendered. |
336 // |page_number| is 0-based. | 343 // |page_number| is 0-based. |
337 // For a valid |page_number| with modifiable content, | 344 // For a valid |page_number| with modifiable content, |
338 // |metafile| is the rendered page. Otherwise |metafile| is NULL. | 345 // |metafile| is the rendered page. Otherwise |metafile| is NULL. |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
471 base::TimeDelta document_render_time_; | 478 base::TimeDelta document_render_time_; |
472 base::TimeTicks begin_time_; | 479 base::TimeTicks begin_time_; |
473 | 480 |
474 enum PrintPreviewErrorBuckets error_; | 481 enum PrintPreviewErrorBuckets error_; |
475 | 482 |
476 State state_; | 483 State state_; |
477 }; | 484 }; |
478 | 485 |
479 bool print_node_in_progress_; | 486 bool print_node_in_progress_; |
480 PrintPreviewContext print_preview_context_; | 487 PrintPreviewContext print_preview_context_; |
488 bool is_loading_; | |
489 bool is_scripted_preview_delayed_; | |
481 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 490 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
482 }; | 491 }; |
483 | 492 |
484 } // namespace printing | 493 } // namespace printing |
485 | 494 |
486 #endif // CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ | 495 #endif // CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ |
OLD | NEW |