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/callback.h" | 10 #include "base/callback.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 namespace blink { | 33 namespace blink { |
34 class WebFrame; | 34 class WebFrame; |
35 class WebView; | 35 class WebView; |
36 } | 36 } |
37 | 37 |
38 namespace printing { | 38 namespace printing { |
39 | 39 |
40 struct PageSizeMargins; | 40 struct PageSizeMargins; |
41 class PrepareFrameAndViewForPrint; | 41 class PrepareFrameAndViewForPrint; |
| 42 class PrintWebViewHelperDelegate; |
42 | 43 |
43 // Stores reference to frame using WebVew and unique name. | 44 // Stores reference to frame using WebVew and unique name. |
44 // Workaround to modal dialog issue on Linux. crbug.com/236147. | 45 // Workaround to modal dialog issue on Linux. crbug.com/236147. |
45 // If WebFrame someday supports WeakPtr, we should use it here. | 46 // If WebFrame someday supports WeakPtr, we should use it here. |
46 class FrameReference { | 47 class FrameReference { |
47 public: | 48 public: |
48 explicit FrameReference(blink::WebLocalFrame* frame); | 49 explicit FrameReference(blink::WebLocalFrame* frame); |
49 FrameReference(); | 50 FrameReference(); |
50 ~FrameReference(); | 51 ~FrameReference(); |
51 | 52 |
52 void Reset(blink::WebLocalFrame* frame); | 53 void Reset(blink::WebLocalFrame* frame); |
53 | 54 |
54 blink::WebLocalFrame* GetFrame(); | 55 blink::WebLocalFrame* GetFrame(); |
55 blink::WebView* view(); | 56 blink::WebView* view(); |
56 | 57 |
57 private: | 58 private: |
58 blink::WebView* view_; | 59 blink::WebView* view_; |
59 blink::WebLocalFrame* frame_; | 60 blink::WebLocalFrame* frame_; |
60 }; | 61 }; |
61 | 62 |
62 // PrintWebViewHelper handles most of the printing grunt work for RenderView. | 63 // PrintWebViewHelper handles most of the printing grunt work for RenderView. |
63 // We plan on making print asynchronous and that will require copying the DOM | 64 // 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. | 65 // of the document and creating a new WebView with the contents. |
65 class PrintWebViewHelper | 66 class PrintWebViewHelper |
66 : public content::RenderViewObserver, | 67 : public content::RenderViewObserver, |
67 public content::RenderViewObserverTracker<PrintWebViewHelper> { | 68 public content::RenderViewObserverTracker<PrintWebViewHelper> { |
68 public: | 69 public: |
69 explicit PrintWebViewHelper(content::RenderView* render_view); | 70 explicit PrintWebViewHelper(content::RenderView* render_view, |
| 71 scoped_ptr<PrintWebViewHelperDelegate> delegate); |
70 ~PrintWebViewHelper() override; | 72 ~PrintWebViewHelper() override; |
71 | 73 |
72 // Disable print preview and switch to system dialog printing even if full | 74 // Disable print preview and switch to system dialog printing even if full |
73 // printing is build-in. This method is used by CEF. | 75 // printing is build-in. This method is used by CEF. |
74 static void DisablePreview(); | 76 static void DisablePreview(); |
75 | 77 |
76 bool IsPrintingEnabled(); | 78 bool IsPrintingEnabled(); |
77 | 79 |
78 void PrintNode(const blink::WebNode& node); | 80 void PrintNode(const blink::WebNode& node); |
79 | 81 |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 // Used for scripted initiated printing blocking. | 322 // Used for scripted initiated printing blocking. |
321 bool is_scripted_printing_blocked_; | 323 bool is_scripted_printing_blocked_; |
322 | 324 |
323 // Let the browser process know of a printing failure. Only set to false when | 325 // Let the browser process know of a printing failure. Only set to false when |
324 // the failure came from the browser in the first place. | 326 // the failure came from the browser in the first place. |
325 bool notify_browser_of_print_failure_; | 327 bool notify_browser_of_print_failure_; |
326 | 328 |
327 // True, when printing from print preview. | 329 // True, when printing from print preview. |
328 bool print_for_preview_; | 330 bool print_for_preview_; |
329 | 331 |
| 332 scoped_ptr<PrintWebViewHelperDelegate> delegate_; |
| 333 |
330 // Keeps track of the state of print preview between messages. | 334 // Keeps track of the state of print preview between messages. |
331 // TODO(vitalybuka): Create PrintPreviewContext when needed and delete after | 335 // TODO(vitalybuka): Create PrintPreviewContext when needed and delete after |
332 // use. Now it's interaction with various messages is confusing. | 336 // use. Now it's interaction with various messages is confusing. |
333 class PrintPreviewContext { | 337 class PrintPreviewContext { |
334 public: | 338 public: |
335 PrintPreviewContext(); | 339 PrintPreviewContext(); |
336 ~PrintPreviewContext(); | 340 ~PrintPreviewContext(); |
337 | 341 |
338 // Initializes the print preview context. Need to be called to set | 342 // Initializes the print preview context. Need to be called to set |
339 // the |web_frame| / |web_node| to generate the print preview for. | 343 // the |web_frame| / |web_node| to generate the print preview for. |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 base::Closure on_stop_loading_closure_; | 470 base::Closure on_stop_loading_closure_; |
467 | 471 |
468 base::WeakPtrFactory<PrintWebViewHelper> weak_ptr_factory_; | 472 base::WeakPtrFactory<PrintWebViewHelper> weak_ptr_factory_; |
469 | 473 |
470 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 474 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
471 }; | 475 }; |
472 | 476 |
473 } // namespace printing | 477 } // namespace printing |
474 | 478 |
475 #endif // CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ | 479 #endif // CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ |
OLD | NEW |