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

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

Issue 2780433002: add print to pdf for headless (Closed)
Patch Set: fix typo 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. This is the behavior in linux and
115 // windows.
Lei Zhang 2017/04/06 10:23:00 It's good to capitalize Windows to distinguish it
jzfeng 2017/04/07 03:24:06 Done.
116 virtual bool UseSingleMetafile();
117 #endif
111 }; 118 };
112 119
113 PrintWebViewHelper(content::RenderFrame* render_frame, 120 PrintWebViewHelper(content::RenderFrame* render_frame,
114 std::unique_ptr<Delegate> delegate); 121 std::unique_ptr<Delegate> delegate);
115 ~PrintWebViewHelper() override; 122 ~PrintWebViewHelper() override;
116 123
117 // Minimum valid value for scaling. Since scaling is originally an integer 124 // 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 125 // representing a percentage, it should never be less than this if it is
119 // valid. 126 // valid.
120 static constexpr double kEpsilon = 0.01f; 127 static constexpr double kEpsilon = 0.01f;
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 void PrintPages(); 283 void PrintPages();
277 bool PrintPagesNative(blink::WebLocalFrame* frame, int page_count); 284 bool PrintPagesNative(blink::WebLocalFrame* frame, int page_count);
278 void FinishFramePrinting(); 285 void FinishFramePrinting();
279 // Render the frame for printing. 286 // Render the frame for printing.
280 bool RenderPagesForPrint(blink::WebLocalFrame* frame, 287 bool RenderPagesForPrint(blink::WebLocalFrame* frame,
281 const blink::WebNode& node); 288 const blink::WebNode& node);
282 #endif // BUILDFLAG(ENABLE_BASIC_PRINTING) 289 #endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
283 290
284 // Prints the page listed in |params|. 291 // Prints the page listed in |params|.
285 #if defined(OS_MACOSX) 292 #if defined(OS_MACOSX)
286 void PrintPageInternal(const PrintMsg_PrintPage_Params& params, 293 void PrintPagesInternal(const PrintMsg_PrintPage_Params& params,
287 blink::WebLocalFrame* frame); 294 blink::WebLocalFrame* frame,
295 const std::vector<int>& printed_pages);
288 #else 296 #else
289 void PrintPageInternal(const PrintMsg_PrintPage_Params& params, 297 void PrintPageInternal(const PrintMsg_PrintPage_Params& params,
290 blink::WebLocalFrame* frame, 298 blink::WebLocalFrame* frame,
291 PdfMetafileSkia* metafile, 299 PdfMetafileSkia* metafile,
292 gfx::Size* page_size_in_dpi, 300 gfx::Size* page_size_in_dpi,
293 gfx::Rect* content_area_in_dpi, 301 gfx::Rect* content_area_in_dpi,
294 gfx::Rect* printable_area_in_dpi); 302 gfx::Rect* printable_area_in_dpi);
295 #endif // defined(OS_MACOSX) 303 #endif // defined(OS_MACOSX)
296 304
297 // Platform specific helper function for rendering page(s) to |metafile|. 305 // 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_; 547 base::Closure on_stop_loading_closure_;
540 548
541 base::WeakPtrFactory<PrintWebViewHelper> weak_ptr_factory_; 549 base::WeakPtrFactory<PrintWebViewHelper> weak_ptr_factory_;
542 550
543 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); 551 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper);
544 }; 552 };
545 553
546 } // namespace printing 554 } // namespace printing
547 555
548 #endif // COMPONENTS_PRINTING_RENDERER_PRINT_WEB_VIEW_HELPER_H_ 556 #endif // COMPONENTS_PRINTING_RENDERER_PRINT_WEB_VIEW_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698