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

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

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

Powered by Google App Engine
This is Rietveld 408576698