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

Side by Side Diff: components/printing/renderer/print_web_view_helper_mac.mm

Issue 2806083002: Remove PrintMsg_PrintPage_Params. (Closed)
Patch Set: rebase 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 #include "components/printing/renderer/print_web_view_helper.h" 5 #include "components/printing/renderer/print_web_view_helper.h"
6 6
7 #import <AppKit/AppKit.h> 7 #import <AppKit/AppKit.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/scoped_nsautorelease_pool.h" 10 #include "base/mac/scoped_nsautorelease_pool.h"
(...skipping 10 matching lines...) Expand all
21 #if BUILDFLAG(ENABLE_BASIC_PRINTING) 21 #if BUILDFLAG(ENABLE_BASIC_PRINTING)
22 bool PrintWebViewHelper::PrintPagesNative(blink::WebLocalFrame* frame, 22 bool PrintWebViewHelper::PrintPagesNative(blink::WebLocalFrame* frame,
23 int page_count) { 23 int page_count) {
24 const PrintMsg_PrintPages_Params& params = *print_pages_params_; 24 const PrintMsg_PrintPages_Params& params = *print_pages_params_;
25 const PrintMsg_Print_Params& print_params = params.params; 25 const PrintMsg_Print_Params& print_params = params.params;
26 26
27 std::vector<int> printed_pages = GetPrintedPages(params, page_count); 27 std::vector<int> printed_pages = GetPrintedPages(params, page_count);
28 if (printed_pages.empty()) 28 if (printed_pages.empty())
29 return false; 29 return false;
30 30
31 PrintMsg_PrintPage_Params page_params;
32 page_params.params = print_params;
33
34 if (delegate_->UseSingleMetafile()) { 31 if (delegate_->UseSingleMetafile()) {
35 PrintPagesInternal(page_params, frame, printed_pages); 32 PrintPagesInternal(print_params, printed_pages, frame);
36 return true; 33 return true;
37 } 34 }
38 35
39 for (int page_number : printed_pages) 36 for (int page_number : printed_pages)
40 PrintPagesInternal(page_params, frame, std::vector<int>{page_number}); 37 PrintPagesInternal(print_params, std::vector<int>{page_number}, frame);
41 return true; 38 return true;
42 } 39 }
43 #endif // BUILDFLAG(ENABLE_BASIC_PRINTING) 40 #endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
44 41
45 void PrintWebViewHelper::PrintPagesInternal( 42 void PrintWebViewHelper::PrintPagesInternal(
46 const PrintMsg_PrintPage_Params& params, 43 const PrintMsg_Print_Params& params,
47 blink::WebLocalFrame* frame, 44 const std::vector<int>& printed_pages,
48 const std::vector<int>& printed_pages) { 45 blink::WebLocalFrame* frame) {
49 PdfMetafileSkia metafile(PDF_SKIA_DOCUMENT_TYPE); 46 PdfMetafileSkia metafile(PDF_SKIA_DOCUMENT_TYPE);
50 CHECK(metafile.Init()); 47 CHECK(metafile.Init());
51 48
52 gfx::Size page_size_in_dpi; 49 gfx::Size page_size_in_dpi;
53 gfx::Rect content_area_in_dpi; 50 gfx::Rect content_area_in_dpi;
54 for (int page_number : printed_pages) { 51 for (int page_number : printed_pages) {
55 RenderPage(params.params, page_number, frame, false, &metafile, 52 RenderPage(params, page_number, frame, false, &metafile, &page_size_in_dpi,
56 &page_size_in_dpi, &content_area_in_dpi); 53 &content_area_in_dpi);
57 } 54 }
58 metafile.FinishDocument(); 55 metafile.FinishDocument();
59 56
60 PrintHostMsg_DidPrintPage_Params page_params; 57 PrintHostMsg_DidPrintPage_Params page_params;
61 page_params.data_size = metafile.GetDataSize(); 58 page_params.data_size = metafile.GetDataSize();
62 page_params.document_cookie = params.params.document_cookie; 59 page_params.document_cookie = params.document_cookie;
63 page_params.page_size = page_size_in_dpi; 60 page_params.page_size = page_size_in_dpi;
64 page_params.content_area = content_area_in_dpi; 61 page_params.content_area = content_area_in_dpi;
65 62
66 // Ask the browser to create the shared memory for us. 63 // Ask the browser to create the shared memory for us.
67 if (!CopyMetafileDataToSharedMem(metafile, 64 if (!CopyMetafileDataToSharedMem(metafile,
68 &(page_params.metafile_data_handle))) { 65 &(page_params.metafile_data_handle))) {
69 // TODO(thestig): Fail and return false instead. 66 // TODO(thestig): Fail and return false instead.
70 page_params.data_size = 0; 67 page_params.data_size = 0;
71 } 68 }
72 69
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) 157 #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
161 RenderPageContent(frame, page_number, canvas_area, content_area, 158 RenderPageContent(frame, page_number, canvas_area, content_area,
162 scale_factor, static_cast<blink::WebCanvas*>(canvas)); 159 scale_factor, static_cast<blink::WebCanvas*>(canvas));
163 } 160 }
164 161
165 // Done printing. Close the device context to retrieve the compiled metafile. 162 // Done printing. Close the device context to retrieve the compiled metafile.
166 metafile->FinishPage(); 163 metafile->FinishPage();
167 } 164 }
168 165
169 } // namespace printing 166 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698