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

Side by Side Diff: components/printing/renderer/print_web_view_helper_pdf_win.cc

Issue 1556463003: Mark printing code as basic printing and/or print preview code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "components/printing/renderer/print_web_view_helper.h" 5 #include "components/printing/renderer/print_web_view_helper.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/process/process_handle.h" 12 #include "base/process/process_handle.h"
13 #include "components/printing/common/print_messages.h" 13 #include "components/printing/common/print_messages.h"
14 #include "content/public/renderer/render_thread.h" 14 #include "content/public/renderer/render_thread.h"
15 #include "printing/metafile_skia_wrapper.h" 15 #include "printing/metafile_skia_wrapper.h"
16 #include "printing/page_size_margins.h" 16 #include "printing/page_size_margins.h"
17 #include "printing/pdf_metafile_skia.h" 17 #include "printing/pdf_metafile_skia.h"
18 #include "printing/units.h" 18 #include "printing/units.h"
19 #include "third_party/WebKit/public/web/WebLocalFrame.h" 19 #include "third_party/WebKit/public/web/WebLocalFrame.h"
20 20
21 namespace printing { 21 namespace printing {
22 22
23 using blink::WebFrame; 23 #if defined(ENABLE_PRINT_PREVIEW)
24
25 bool PrintWebViewHelper::RenderPreviewPage( 24 bool PrintWebViewHelper::RenderPreviewPage(
26 int page_number, 25 int page_number,
27 const PrintMsg_Print_Params& print_params) { 26 const PrintMsg_Print_Params& print_params) {
28 PrintMsg_PrintPage_Params page_params; 27 PrintMsg_PrintPage_Params page_params;
29 page_params.params = print_params; 28 page_params.params = print_params;
30 page_params.page_number = page_number; 29 page_params.page_number = page_number;
31 scoped_ptr<PdfMetafileSkia> draft_metafile; 30 scoped_ptr<PdfMetafileSkia> draft_metafile;
32 PdfMetafileSkia* initial_render_metafile = print_preview_context_.metafile(); 31 PdfMetafileSkia* initial_render_metafile = print_preview_context_.metafile();
33 if (print_preview_context_.IsModifiable() && is_print_ready_metafile_sent_) { 32 if (print_preview_context_.IsModifiable() && is_print_ready_metafile_sent_) {
34 draft_metafile.reset(new PdfMetafileSkia); 33 draft_metafile.reset(new PdfMetafileSkia);
(...skipping 11 matching lines...) Expand all
46 if (draft_metafile.get()) { 45 if (draft_metafile.get()) {
47 draft_metafile->FinishDocument(); 46 draft_metafile->FinishDocument();
48 } else if (print_preview_context_.IsModifiable() && 47 } else if (print_preview_context_.IsModifiable() &&
49 print_preview_context_.generate_draft_pages()) { 48 print_preview_context_.generate_draft_pages()) {
50 DCHECK(!draft_metafile.get()); 49 DCHECK(!draft_metafile.get());
51 draft_metafile = 50 draft_metafile =
52 print_preview_context_.metafile()->GetMetafileForCurrentPage(); 51 print_preview_context_.metafile()->GetMetafileForCurrentPage();
53 } 52 }
54 return PreviewPageRendered(page_number, draft_metafile.get()); 53 return PreviewPageRendered(page_number, draft_metafile.get());
55 } 54 }
55 #endif // defined(ENABLE_PRINT_PREVIEW)
56 56
57 #if defined(ENABLE_BASIC_PRINTING)
57 bool PrintWebViewHelper::PrintPagesNative(blink::WebFrame* frame, 58 bool PrintWebViewHelper::PrintPagesNative(blink::WebFrame* frame,
58 int page_count) { 59 int page_count) {
59 PdfMetafileSkia metafile; 60 PdfMetafileSkia metafile;
60 if (!metafile.Init()) 61 if (!metafile.Init())
61 return false; 62 return false;
62 63
63 const PrintMsg_PrintPages_Params& params = *print_pages_params_; 64 const PrintMsg_PrintPages_Params& params = *print_pages_params_;
64 std::vector<int> printed_pages = GetPrintedPages(params, page_count); 65 std::vector<int> printed_pages = GetPrintedPages(params, page_count);
65 if (printed_pages.empty()) 66 if (printed_pages.empty())
66 return false; 67 return false;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 for (size_t i = 0; i < printed_pages.size(); ++i) { 99 for (size_t i = 0; i < printed_pages.size(); ++i) {
99 printed_page_params.page_number = printed_pages[i]; 100 printed_page_params.page_number = printed_pages[i];
100 printed_page_params.page_size = page_size_in_dpi[i]; 101 printed_page_params.page_size = page_size_in_dpi[i];
101 printed_page_params.content_area = content_area_in_dpi[i]; 102 printed_page_params.content_area = content_area_in_dpi[i];
102 Send(new PrintHostMsg_DidPrintPage(routing_id(), printed_page_params)); 103 Send(new PrintHostMsg_DidPrintPage(routing_id(), printed_page_params));
103 // Send the rest of the pages with an invalid metafile handle. 104 // Send the rest of the pages with an invalid metafile handle.
104 printed_page_params.metafile_data_handle = base::SharedMemoryHandle(); 105 printed_page_params.metafile_data_handle = base::SharedMemoryHandle();
105 } 106 }
106 return true; 107 return true;
107 } 108 }
109 #endif // defined(ENABLE_BASIC_PRINTING)
108 110
109 void PrintWebViewHelper::PrintPageInternal( 111 void PrintWebViewHelper::PrintPageInternal(
110 const PrintMsg_PrintPage_Params& params, 112 const PrintMsg_PrintPage_Params& params,
111 WebFrame* frame, 113 blink::WebFrame* frame,
112 PdfMetafileSkia* metafile, 114 PdfMetafileSkia* metafile,
113 gfx::Size* page_size_in_dpi, 115 gfx::Size* page_size_in_dpi,
114 gfx::Rect* content_area_in_dpi) { 116 gfx::Rect* content_area_in_dpi) {
115 PageSizeMargins page_layout_in_points; 117 PageSizeMargins page_layout_in_points;
116 double css_scale_factor = 1.0f; 118 double css_scale_factor = 1.0f;
117 ComputePageLayoutInPointsForCss(frame, params.page_number, params.params, 119 ComputePageLayoutInPointsForCss(frame, params.page_number, params.params,
118 ignore_css_margins_, &css_scale_factor, 120 ignore_css_margins_, &css_scale_factor,
119 &page_layout_in_points); 121 &page_layout_in_points);
120 gfx::Size page_size; 122 gfx::Size page_size;
121 gfx::Rect content_area; 123 gfx::Rect content_area;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 shared_mem_handle)) { 191 shared_mem_handle)) {
190 return false; 192 return false;
191 } 193 }
192 194
193 Send(new PrintHostMsg_DuplicateSection(routing_id(), *shared_mem_handle, 195 Send(new PrintHostMsg_DuplicateSection(routing_id(), *shared_mem_handle,
194 shared_mem_handle)); 196 shared_mem_handle));
195 return true; 197 return true;
196 } 198 }
197 199
198 } // namespace printing 200 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698