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 <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
101 // The default implementation returns |true|. | 101 // The default implementation returns |true|. |
102 virtual bool IsAskPrintSettingsEnabled(); | 102 virtual bool IsAskPrintSettingsEnabled(); |
103 | 103 |
104 // If false, window.print() won't do anything. | 104 // If false, window.print() won't do anything. |
105 // The default implementation returns |true|. | 105 // The default implementation returns |true|. |
106 virtual bool IsScriptedPrintEnabled(); | 106 virtual bool IsScriptedPrintEnabled(); |
107 | 107 |
108 // Returns true if printing is overridden and the default behavior should be | 108 // Returns true if printing is overridden and the default behavior should be |
109 // skipped for |frame|. | 109 // skipped for |frame|. |
110 virtual bool OverridePrint(blink::WebLocalFrame* frame) = 0; | 110 virtual bool OverridePrint(blink::WebLocalFrame* frame) = 0; |
111 | |
112 #if defined(OS_MACOSX) | |
113 // If true, all the printed pages are returned in the first | |
114 // PrintHostMsg_DidPrintPage metafile, like on Linux and Windows. | |
115 // NOTE: This option only returns one set of page size and content area, | |
Lei Zhang
2017/04/07 04:09:42
NOTE: PrintHostMsg_DidPrintPage messages for all p
| |
116 // which may lead to bug when these two parameters are different per page. | |
117 virtual bool UseSingleMetafile(); | |
118 #endif | |
111 }; | 119 }; |
112 | 120 |
113 PrintWebViewHelper(content::RenderFrame* render_frame, | 121 PrintWebViewHelper(content::RenderFrame* render_frame, |
114 std::unique_ptr<Delegate> delegate); | 122 std::unique_ptr<Delegate> delegate); |
115 ~PrintWebViewHelper() override; | 123 ~PrintWebViewHelper() override; |
116 | 124 |
117 // Minimum valid value for scaling. Since scaling is originally an integer | 125 // Minimum valid value for scaling. Since scaling is originally an integer |
118 // representing a percentage, it should never be less than this if it is | 126 // representing a percentage, it should never be less than this if it is |
119 // valid. | 127 // valid. |
120 static constexpr double kEpsilon = 0.01f; | 128 static constexpr double kEpsilon = 0.01f; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
276 void PrintPages(); | 284 void PrintPages(); |
277 bool PrintPagesNative(blink::WebLocalFrame* frame, int page_count); | 285 bool PrintPagesNative(blink::WebLocalFrame* frame, int page_count); |
278 void FinishFramePrinting(); | 286 void FinishFramePrinting(); |
279 // Render the frame for printing. | 287 // Render the frame for printing. |
280 bool RenderPagesForPrint(blink::WebLocalFrame* frame, | 288 bool RenderPagesForPrint(blink::WebLocalFrame* frame, |
281 const blink::WebNode& node); | 289 const blink::WebNode& node); |
282 #endif // BUILDFLAG(ENABLE_BASIC_PRINTING) | 290 #endif // BUILDFLAG(ENABLE_BASIC_PRINTING) |
283 | 291 |
284 // Prints the page listed in |params|. | 292 // Prints the page listed in |params|. |
285 #if defined(OS_MACOSX) | 293 #if defined(OS_MACOSX) |
286 void PrintPageInternal(const PrintMsg_PrintPage_Params& params, | 294 void PrintPagesInternal(const PrintMsg_PrintPage_Params& params, |
287 blink::WebLocalFrame* frame); | 295 blink::WebLocalFrame* frame, |
296 const std::vector<int>& printed_pages); | |
288 #else | 297 #else |
289 void PrintPageInternal(const PrintMsg_PrintPage_Params& params, | 298 void PrintPageInternal(const PrintMsg_PrintPage_Params& params, |
290 blink::WebLocalFrame* frame, | 299 blink::WebLocalFrame* frame, |
291 PdfMetafileSkia* metafile, | 300 PdfMetafileSkia* metafile, |
292 gfx::Size* page_size_in_dpi, | 301 gfx::Size* page_size_in_dpi, |
293 gfx::Rect* content_area_in_dpi, | 302 gfx::Rect* content_area_in_dpi, |
294 gfx::Rect* printable_area_in_dpi); | 303 gfx::Rect* printable_area_in_dpi); |
295 #endif // defined(OS_MACOSX) | 304 #endif // defined(OS_MACOSX) |
296 | 305 |
297 // Platform specific helper function for rendering page(s) to |metafile|. | 306 // Platform specific helper function for rendering page(s) to |metafile|. |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
539 base::Closure on_stop_loading_closure_; | 548 base::Closure on_stop_loading_closure_; |
540 | 549 |
541 base::WeakPtrFactory<PrintWebViewHelper> weak_ptr_factory_; | 550 base::WeakPtrFactory<PrintWebViewHelper> weak_ptr_factory_; |
542 | 551 |
543 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 552 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
544 }; | 553 }; |
545 | 554 |
546 } // namespace printing | 555 } // namespace printing |
547 | 556 |
548 #endif // COMPONENTS_PRINTING_RENDERER_PRINT_WEB_VIEW_HELPER_H_ | 557 #endif // COMPONENTS_PRINTING_RENDERER_PRINT_WEB_VIEW_HELPER_H_ |
OLD | NEW |