OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 print_preview_context_.metafile()->GetMetafileForCurrentPage()); | 175 print_preview_context_.metafile()->GetMetafileForCurrentPage()); |
176 } | 176 } |
177 return PreviewPageRendered(page_number, draft_metafile.get()); | 177 return PreviewPageRendered(page_number, draft_metafile.get()); |
178 } | 178 } |
179 | 179 |
180 Metafile* PrintWebViewHelper::RenderPage( | 180 Metafile* PrintWebViewHelper::RenderPage( |
181 const PrintMsg_Print_Params& params, float* scale_factor, int page_number, | 181 const PrintMsg_Print_Params& params, float* scale_factor, int page_number, |
182 bool is_preview, WebFrame* frame, Metafile* metafile) { | 182 bool is_preview, WebFrame* frame, Metafile* metafile) { |
183 printing::PageSizeMargins page_layout_in_points; | 183 printing::PageSizeMargins page_layout_in_points; |
184 GetPageSizeAndMarginsInPoints(frame, page_number, params, | 184 GetPageSizeAndMarginsInPoints(frame, page_number, params, |
185 &page_layout_in_points); | 185 &page_layout_in_points, |
186 | 186 default_margins_requested_); |
187 int width; | 187 int width; |
188 int height; | 188 int height; |
189 if (is_preview) { | 189 if (is_preview) { |
190 int dpi = static_cast<int>(params.dpi); | 190 int dpi = static_cast<int>(params.dpi); |
191 int desired_dpi = printing::kPointsPerInch; | 191 int desired_dpi = printing::kPointsPerInch; |
192 width = ConvertUnit(params.page_size.width(), dpi, desired_dpi); | 192 width = ConvertUnit(params.page_size.width(), dpi, desired_dpi); |
193 height = ConvertUnit(params.page_size.height(), dpi, desired_dpi); | 193 height = ConvertUnit(params.page_size.height(), dpi, desired_dpi); |
194 } else { | 194 } else { |
195 // Since WebKit extends the page width depending on the magical scale factor | 195 // Since WebKit extends the page width depending on the magical scale factor |
196 // we make sure the canvas covers the worst case scenario (x2.0 currently). | 196 // we make sure the canvas covers the worst case scenario (x2.0 currently). |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 shared_buf.Unmap(); | 320 shared_buf.Unmap(); |
321 return false; | 321 return false; |
322 } | 322 } |
323 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), shared_mem_handle); | 323 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), shared_mem_handle); |
324 shared_buf.Unmap(); | 324 shared_buf.Unmap(); |
325 | 325 |
326 Send(new PrintHostMsg_DuplicateSection(routing_id(), *shared_mem_handle, | 326 Send(new PrintHostMsg_DuplicateSection(routing_id(), *shared_mem_handle, |
327 shared_mem_handle)); | 327 shared_mem_handle)); |
328 return true; | 328 return true; |
329 } | 329 } |
OLD | NEW |