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