Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(368)

Side by Side Diff: components/printing/renderer/print_web_view_helper.h

Issue 2780433002: add print to pdf for headless (Closed)
Patch Set: improve comments as suggested Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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: PrintHostMsg_DidPrintPage messages for all pages contain the same
116 // page and content area, which may lead to bug when these two parameters
117 // are different per page.
118 virtual bool UseSingleMetafile();
119 #endif
111 }; 120 };
112 121
113 PrintWebViewHelper(content::RenderFrame* render_frame, 122 PrintWebViewHelper(content::RenderFrame* render_frame,
114 std::unique_ptr<Delegate> delegate); 123 std::unique_ptr<Delegate> delegate);
115 ~PrintWebViewHelper() override; 124 ~PrintWebViewHelper() override;
116 125
117 // Minimum valid value for scaling. Since scaling is originally an integer 126 // 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 127 // representing a percentage, it should never be less than this if it is
119 // valid. 128 // valid.
120 static constexpr double kEpsilon = 0.01f; 129 static constexpr double kEpsilon = 0.01f;
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 void PrintPages(); 285 void PrintPages();
277 bool PrintPagesNative(blink::WebLocalFrame* frame, int page_count); 286 bool PrintPagesNative(blink::WebLocalFrame* frame, int page_count);
278 void FinishFramePrinting(); 287 void FinishFramePrinting();
279 // Render the frame for printing. 288 // Render the frame for printing.
280 bool RenderPagesForPrint(blink::WebLocalFrame* frame, 289 bool RenderPagesForPrint(blink::WebLocalFrame* frame,
281 const blink::WebNode& node); 290 const blink::WebNode& node);
282 #endif // BUILDFLAG(ENABLE_BASIC_PRINTING) 291 #endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
283 292
284 // Prints the page listed in |params|. 293 // Prints the page listed in |params|.
285 #if defined(OS_MACOSX) 294 #if defined(OS_MACOSX)
286 void PrintPageInternal(const PrintMsg_PrintPage_Params& params, 295 void PrintPagesInternal(const PrintMsg_PrintPage_Params& params,
287 blink::WebLocalFrame* frame); 296 blink::WebLocalFrame* frame,
297 const std::vector<int>& printed_pages);
288 #else 298 #else
289 void PrintPageInternal(const PrintMsg_PrintPage_Params& params, 299 void PrintPageInternal(const PrintMsg_PrintPage_Params& params,
290 blink::WebLocalFrame* frame, 300 blink::WebLocalFrame* frame,
291 PdfMetafileSkia* metafile, 301 PdfMetafileSkia* metafile,
292 gfx::Size* page_size_in_dpi, 302 gfx::Size* page_size_in_dpi,
293 gfx::Rect* content_area_in_dpi, 303 gfx::Rect* content_area_in_dpi,
294 gfx::Rect* printable_area_in_dpi); 304 gfx::Rect* printable_area_in_dpi);
295 #endif // defined(OS_MACOSX) 305 #endif // defined(OS_MACOSX)
296 306
297 // Platform specific helper function for rendering page(s) to |metafile|. 307 // Platform specific helper function for rendering page(s) to |metafile|.
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 base::Closure on_stop_loading_closure_; 549 base::Closure on_stop_loading_closure_;
540 550
541 base::WeakPtrFactory<PrintWebViewHelper> weak_ptr_factory_; 551 base::WeakPtrFactory<PrintWebViewHelper> weak_ptr_factory_;
542 552
543 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); 553 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper);
544 }; 554 };
545 555
546 } // namespace printing 556 } // namespace printing
547 557
548 #endif // COMPONENTS_PRINTING_RENDERER_PRINT_WEB_VIEW_HELPER_H_ 558 #endif // COMPONENTS_PRINTING_RENDERER_PRINT_WEB_VIEW_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698