OLD | NEW |
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 "chrome/renderer/print_web_view_helper.h" | 5 #include "chrome/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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 // Ask the browser to create the shared memory for us. | 49 // Ask the browser to create the shared memory for us. |
50 if (!CopyMetafileDataToSharedMem(&metafile, | 50 if (!CopyMetafileDataToSharedMem(&metafile, |
51 &(page_params.metafile_data_handle))) { | 51 &(page_params.metafile_data_handle))) { |
52 page_params.data_size = 0; | 52 page_params.data_size = 0; |
53 } | 53 } |
54 | 54 |
55 Send(new PrintHostMsg_DidPrintPage(routing_id(), page_params)); | 55 Send(new PrintHostMsg_DidPrintPage(routing_id(), page_params)); |
56 } | 56 } |
57 | 57 |
58 bool PrintWebViewHelper::RenderPreviewPage(int page_number) { | 58 bool PrintWebViewHelper::RenderPreviewPage( |
59 PrintMsg_Print_Params printParams = print_preview_context_.print_params(); | 59 int page_number, |
| 60 const PrintMsg_Print_Params& print_params) { |
| 61 PrintMsg_Print_Params printParams = print_params; |
60 scoped_ptr<printing::Metafile> draft_metafile; | 62 scoped_ptr<printing::Metafile> draft_metafile; |
61 printing::Metafile* initial_render_metafile = | 63 printing::Metafile* initial_render_metafile = |
62 print_preview_context_.metafile(); | 64 print_preview_context_.metafile(); |
63 | 65 |
64 #if defined(USE_SKIA) | 66 #if defined(USE_SKIA) |
65 bool render_to_draft = print_preview_context_.IsModifiable() && | 67 bool render_to_draft = print_preview_context_.IsModifiable() && |
66 is_print_ready_metafile_sent_; | 68 is_print_ready_metafile_sent_; |
67 #else | 69 #else |
68 // If the page needs to be in both draft metafile and print ready metafile, | 70 // If the page needs to be in both draft metafile and print ready metafile, |
69 // we should always render to the draft metafile first and then copy that | 71 // we should always render to the draft metafile first and then copy that |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 | 177 |
176 // For CoreGraphics, print in the margins before printing in the content | 178 // For CoreGraphics, print in the margins before printing in the content |
177 // area so that we don't spill over. Webkit draws a white background in the | 179 // area so that we don't spill over. Webkit draws a white background in the |
178 // content area and this acts as a clip. | 180 // content area and this acts as a clip. |
179 // TODO(aayushkumar): Combine the calls to PrintHeaderAndFooter once we | 181 // TODO(aayushkumar): Combine the calls to PrintHeaderAndFooter once we |
180 // can draw in the margins safely in Skia in any order. | 182 // can draw in the margins safely in Skia in any order. |
181 if (print_pages_params_->params.display_header_footer) { | 183 if (print_pages_params_->params.display_header_footer) { |
182 PrintHeaderAndFooter(canvas_ptr, page_number + 1, | 184 PrintHeaderAndFooter(canvas_ptr, page_number + 1, |
183 print_preview_context_.total_page_count(), | 185 print_preview_context_.total_page_count(), |
184 scale_factor, page_layout_in_points, | 186 scale_factor, page_layout_in_points, |
185 *header_footer_info_); | 187 *header_footer_info_, params); |
186 } | 188 } |
187 #endif // !USE_SKIA | 189 #endif // !USE_SKIA |
188 | 190 |
189 frame->printPage(page_number, canvas_ptr); | 191 frame->printPage(page_number, canvas_ptr); |
190 | 192 |
191 #if defined(USE_SKIA) | 193 #if defined(USE_SKIA) |
192 if (print_pages_params_->params.display_header_footer) { | 194 if (print_pages_params_->params.display_header_footer) { |
193 // |page_number| is 0-based, so 1 is added. | 195 // |page_number| is 0-based, so 1 is added. |
194 PrintHeaderAndFooter(canvas_ptr, page_number + 1, | 196 PrintHeaderAndFooter(canvas_ptr, page_number + 1, |
195 print_preview_context_.total_page_count(), | 197 print_preview_context_.total_page_count(), |
196 scale_factor, page_layout_in_points, | 198 scale_factor, page_layout_in_points, |
197 *header_footer_info_); | 199 *header_footer_info_, params); |
198 } | 200 } |
199 #endif // defined(USE_SKIA) | 201 #endif // defined(USE_SKIA) |
200 } | 202 } |
201 | 203 |
202 // Done printing. Close the device context to retrieve the compiled metafile. | 204 // Done printing. Close the device context to retrieve the compiled metafile. |
203 metafile->FinishPage(); | 205 metafile->FinishPage(); |
204 } | 206 } |
OLD | NEW |