| 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 COMPONENTS_PRINTING_RENDERER_PRINT_WEB_VIEW_HELPER_H_ | 5 #ifndef COMPONENTS_PRINTING_RENDERER_PRINT_WEB_VIEW_HELPER_H_ |
| 6 #define COMPONENTS_PRINTING_RENDERER_PRINT_WEB_VIEW_HELPER_H_ | 6 #define COMPONENTS_PRINTING_RENDERER_PRINT_WEB_VIEW_HELPER_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 8 #include <vector> | 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/callback.h" | 11 #include "base/callback.h" |
| 11 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "base/memory/shared_memory.h" | 14 #include "base/memory/shared_memory.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 18 #include "content/public/renderer/render_view_observer.h" | 18 #include "content/public/renderer/render_view_observer.h" |
| 19 #include "content/public/renderer/render_view_observer_tracker.h" | 19 #include "content/public/renderer/render_view_observer_tracker.h" |
| 20 #include "printing/pdf_metafile_skia.h" | 20 #include "printing/pdf_metafile_skia.h" |
| 21 #include "third_party/WebKit/public/platform/WebCanvas.h" | 21 #include "third_party/WebKit/public/platform/WebCanvas.h" |
| 22 #include "third_party/WebKit/public/web/WebNode.h" | 22 #include "third_party/WebKit/public/web/WebNode.h" |
| 23 #include "third_party/WebKit/public/web/WebPrintParams.h" | 23 #include "third_party/WebKit/public/web/WebPrintParams.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // If false, window.print() won't do anything. | 101 // If false, window.print() won't do anything. |
| 102 // The default implementation returns |true|. | 102 // The default implementation returns |true|. |
| 103 virtual bool IsScriptedPrintEnabled(); | 103 virtual bool IsScriptedPrintEnabled(); |
| 104 | 104 |
| 105 // Returns true if printing is overridden and the default behavior should be | 105 // Returns true if printing is overridden and the default behavior should be |
| 106 // skipped for |frame|. | 106 // skipped for |frame|. |
| 107 virtual bool OverridePrint(blink::WebLocalFrame* frame) = 0; | 107 virtual bool OverridePrint(blink::WebLocalFrame* frame) = 0; |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 PrintWebViewHelper(content::RenderView* render_view, | 110 PrintWebViewHelper(content::RenderView* render_view, |
| 111 scoped_ptr<Delegate> delegate); | 111 std::unique_ptr<Delegate> delegate); |
| 112 ~PrintWebViewHelper() override; | 112 ~PrintWebViewHelper() override; |
| 113 | 113 |
| 114 // Disable print preview and switch to system dialog printing even if full | 114 // Disable print preview and switch to system dialog printing even if full |
| 115 // printing is build-in. This method is used by CEF. | 115 // printing is build-in. This method is used by CEF. |
| 116 static void DisablePreview(); | 116 static void DisablePreview(); |
| 117 | 117 |
| 118 bool IsPrintingEnabled(); | 118 bool IsPrintingEnabled(); |
| 119 | 119 |
| 120 void PrintNode(const blink::WebNode& node); | 120 void PrintNode(const blink::WebNode& node); |
| 121 | 121 |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 // |page_number| is 0-based. | 357 // |page_number| is 0-based. |
| 358 // For a valid |page_number| with modifiable content, | 358 // For a valid |page_number| with modifiable content, |
| 359 // |metafile| is the rendered page. Otherwise |metafile| is NULL. | 359 // |metafile| is the rendered page. Otherwise |metafile| is NULL. |
| 360 // Returns true if print preview should continue, false on failure. | 360 // Returns true if print preview should continue, false on failure. |
| 361 bool PreviewPageRendered(int page_number, PdfMetafileSkia* metafile); | 361 bool PreviewPageRendered(int page_number, PdfMetafileSkia* metafile); |
| 362 #endif // defined(ENABLE_PRINT_PREVIEW) | 362 #endif // defined(ENABLE_PRINT_PREVIEW) |
| 363 | 363 |
| 364 void SetPrintPagesParams(const PrintMsg_PrintPages_Params& settings); | 364 void SetPrintPagesParams(const PrintMsg_PrintPages_Params& settings); |
| 365 | 365 |
| 366 // WebView used only to print the selection. | 366 // WebView used only to print the selection. |
| 367 scoped_ptr<PrepareFrameAndViewForPrint> prep_frame_view_; | 367 std::unique_ptr<PrepareFrameAndViewForPrint> prep_frame_view_; |
| 368 bool reset_prep_frame_view_; | 368 bool reset_prep_frame_view_; |
| 369 | 369 |
| 370 scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_; | 370 std::unique_ptr<PrintMsg_PrintPages_Params> print_pages_params_; |
| 371 bool is_print_ready_metafile_sent_; | 371 bool is_print_ready_metafile_sent_; |
| 372 bool ignore_css_margins_; | 372 bool ignore_css_margins_; |
| 373 | 373 |
| 374 // Used for scripted initiated printing blocking. | 374 // Used for scripted initiated printing blocking. |
| 375 bool is_scripted_printing_blocked_; | 375 bool is_scripted_printing_blocked_; |
| 376 | 376 |
| 377 // Let the browser process know of a printing failure. Only set to false when | 377 // Let the browser process know of a printing failure. Only set to false when |
| 378 // the failure came from the browser in the first place. | 378 // the failure came from the browser in the first place. |
| 379 bool notify_browser_of_print_failure_; | 379 bool notify_browser_of_print_failure_; |
| 380 | 380 |
| 381 // True, when printing from print preview. | 381 // True, when printing from print preview. |
| 382 bool print_for_preview_; | 382 bool print_for_preview_; |
| 383 | 383 |
| 384 // Used to check the prerendering status. | 384 // Used to check the prerendering status. |
| 385 const scoped_ptr<Delegate> delegate_; | 385 const std::unique_ptr<Delegate> delegate_; |
| 386 | 386 |
| 387 // Keeps track of the state of print preview between messages. | 387 // Keeps track of the state of print preview between messages. |
| 388 // TODO(vitalybuka): Create PrintPreviewContext when needed and delete after | 388 // TODO(vitalybuka): Create PrintPreviewContext when needed and delete after |
| 389 // use. Now it's interaction with various messages is confusing. | 389 // use. Now it's interaction with various messages is confusing. |
| 390 class PrintPreviewContext { | 390 class PrintPreviewContext { |
| 391 public: | 391 public: |
| 392 PrintPreviewContext(); | 392 PrintPreviewContext(); |
| 393 ~PrintPreviewContext(); | 393 ~PrintPreviewContext(); |
| 394 | 394 |
| 395 // Initializes the print preview context. Need to be called to set | 395 // Initializes the print preview context. Need to be called to set |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 DONE // Finished rendering. | 459 DONE // Finished rendering. |
| 460 }; | 460 }; |
| 461 | 461 |
| 462 // Reset some of the internal rendering context. | 462 // Reset some of the internal rendering context. |
| 463 void ClearContext(); | 463 void ClearContext(); |
| 464 | 464 |
| 465 // Specifies what to render for print preview. | 465 // Specifies what to render for print preview. |
| 466 FrameReference source_frame_; | 466 FrameReference source_frame_; |
| 467 blink::WebNode source_node_; | 467 blink::WebNode source_node_; |
| 468 | 468 |
| 469 scoped_ptr<PrepareFrameAndViewForPrint> prep_frame_view_; | 469 std::unique_ptr<PrepareFrameAndViewForPrint> prep_frame_view_; |
| 470 scoped_ptr<PdfMetafileSkia> metafile_; | 470 std::unique_ptr<PdfMetafileSkia> metafile_; |
| 471 | 471 |
| 472 // Total page count in the renderer. | 472 // Total page count in the renderer. |
| 473 int total_page_count_; | 473 int total_page_count_; |
| 474 | 474 |
| 475 // The current page to render. | 475 // The current page to render. |
| 476 int current_page_index_; | 476 int current_page_index_; |
| 477 | 477 |
| 478 // List of page indices that need to be rendered. | 478 // List of page indices that need to be rendered. |
| 479 std::vector<int> pages_to_render_; | 479 std::vector<int> pages_to_render_; |
| 480 | 480 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 base::Closure on_stop_loading_closure_; | 524 base::Closure on_stop_loading_closure_; |
| 525 | 525 |
| 526 base::WeakPtrFactory<PrintWebViewHelper> weak_ptr_factory_; | 526 base::WeakPtrFactory<PrintWebViewHelper> weak_ptr_factory_; |
| 527 | 527 |
| 528 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 528 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
| 529 }; | 529 }; |
| 530 | 530 |
| 531 } // namespace printing | 531 } // namespace printing |
| 532 | 532 |
| 533 #endif // COMPONENTS_PRINTING_RENDERER_PRINT_WEB_VIEW_HELPER_H_ | 533 #endif // COMPONENTS_PRINTING_RENDERER_PRINT_WEB_VIEW_HELPER_H_ |
| OLD | NEW |