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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
| 70 class Delegate { |
| 71 public: |
| 72 virtual ~Delegate() {} |
| 73 virtual bool CancelPrerender(content::RenderView* render_view, |
| 74 int routing_id) = 0; |
| 75 }; |
| 76 |
| 77 PrintWebViewHelper(content::RenderView* render_view, |
| 78 bool out_of_process_pdf_enabled, |
| 79 bool print_preview_disabled, |
| 80 const std::string& pdf_extension_id, |
| 81 Delegate* delegate); |
70 ~PrintWebViewHelper() override; | 82 ~PrintWebViewHelper() override; |
71 | 83 |
72 // Disable print preview and switch to system dialog printing even if full | 84 // Disable print preview and switch to system dialog printing even if full |
73 // printing is build-in. This method is used by CEF. | 85 // printing is build-in. This method is used by CEF. |
74 static void DisablePreview(); | 86 static void DisablePreview(); |
75 | 87 |
76 bool IsPrintingEnabled(); | 88 bool IsPrintingEnabled(); |
77 | 89 |
78 void PrintNode(const blink::WebNode& node); | 90 void PrintNode(const blink::WebNode& node); |
79 | 91 |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 // Used for scripted initiated printing blocking. | 332 // Used for scripted initiated printing blocking. |
321 bool is_scripted_printing_blocked_; | 333 bool is_scripted_printing_blocked_; |
322 | 334 |
323 // Let the browser process know of a printing failure. Only set to false when | 335 // 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. | 336 // the failure came from the browser in the first place. |
325 bool notify_browser_of_print_failure_; | 337 bool notify_browser_of_print_failure_; |
326 | 338 |
327 // True, when printing from print preview. | 339 // True, when printing from print preview. |
328 bool print_for_preview_; | 340 bool print_for_preview_; |
329 | 341 |
| 342 // Whether the content to print could be nested in an iframe. |
| 343 const bool out_of_process_pdf_enabled_; |
| 344 |
| 345 // Used to test if the nested iframe holding the content to print is the |
| 346 // pdf extension. Only used when |ENABLE_EXTENSIONS| is defined. |
| 347 const std::string& pdf_extension_id_; |
| 348 |
| 349 // Used to check the prerendering status. |
| 350 Delegate* const delegate_; |
| 351 |
330 // Keeps track of the state of print preview between messages. | 352 // Keeps track of the state of print preview between messages. |
331 // TODO(vitalybuka): Create PrintPreviewContext when needed and delete after | 353 // TODO(vitalybuka): Create PrintPreviewContext when needed and delete after |
332 // use. Now it's interaction with various messages is confusing. | 354 // use. Now it's interaction with various messages is confusing. |
333 class PrintPreviewContext { | 355 class PrintPreviewContext { |
334 public: | 356 public: |
335 PrintPreviewContext(); | 357 PrintPreviewContext(); |
336 ~PrintPreviewContext(); | 358 ~PrintPreviewContext(); |
337 | 359 |
338 // Initializes the print preview context. Need to be called to set | 360 // Initializes the print preview context. Need to be called to set |
339 // the |web_frame| / |web_node| to generate the print preview for. | 361 // 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_; | 488 base::Closure on_stop_loading_closure_; |
467 | 489 |
468 base::WeakPtrFactory<PrintWebViewHelper> weak_ptr_factory_; | 490 base::WeakPtrFactory<PrintWebViewHelper> weak_ptr_factory_; |
469 | 491 |
470 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 492 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
471 }; | 493 }; |
472 | 494 |
473 } // namespace printing | 495 } // namespace printing |
474 | 496 |
475 #endif // CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ | 497 #endif // CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ |
OLD | NEW |