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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 page_size, content_area, frame->getPrintPageShrink(page_number)); | 190 page_size, content_area, frame->getPrintPageShrink(page_number)); |
191 DCHECK(device); | 191 DCHECK(device); |
192 // The printPage method may take a reference to the canvas we pass down, so it | 192 // The printPage method may take a reference to the canvas we pass down, so it |
193 // can't be a stack object. | 193 // can't be a stack object. |
194 SkRefPtr<skia::VectorCanvas> canvas = new skia::VectorCanvas(device); | 194 SkRefPtr<skia::VectorCanvas> canvas = new skia::VectorCanvas(device); |
195 canvas->unref(); // SkRefPtr and new both took a reference. | 195 canvas->unref(); // SkRefPtr and new both took a reference. |
196 if (is_preview) { | 196 if (is_preview) { |
197 printing::MetafileSkiaWrapper::SetMetafileOnCanvas(canvas.get(), metafile); | 197 printing::MetafileSkiaWrapper::SetMetafileOnCanvas(canvas.get(), metafile); |
198 printing::MetafileSkiaWrapper::SetDraftMode(canvas.get(), | 198 printing::MetafileSkiaWrapper::SetDraftMode(canvas.get(), |
199 is_print_ready_metafile_sent_); | 199 is_print_ready_metafile_sent_); |
| 200 printing::MetafileSkiaWrapper::SetIsPreviewMetafile(canvas.get(), |
| 201 is_preview); |
200 } | 202 } |
201 | 203 |
202 float webkit_scale_factor = frame->printPage(page_number, canvas.get()); | 204 float webkit_scale_factor = frame->printPage(page_number, canvas.get()); |
203 | 205 |
204 if (params.display_header_footer) { | 206 if (params.display_header_footer) { |
205 // |page_number| is 0-based, so 1 is added. | 207 // |page_number| is 0-based, so 1 is added. |
206 PrintHeaderAndFooter(canvas.get(), page_number + 1, | 208 PrintHeaderAndFooter(canvas.get(), page_number + 1, |
207 print_preview_context_.total_page_count(), | 209 print_preview_context_.total_page_count(), |
208 webkit_scale_factor, page_layout_in_points, | 210 webkit_scale_factor, page_layout_in_points, |
209 *header_footer_info_); | 211 *header_footer_info_); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 shared_buf.Unmap(); | 302 shared_buf.Unmap(); |
301 return false; | 303 return false; |
302 } | 304 } |
303 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), shared_mem_handle); | 305 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), shared_mem_handle); |
304 shared_buf.Unmap(); | 306 shared_buf.Unmap(); |
305 | 307 |
306 Send(new PrintHostMsg_DuplicateSection(routing_id(), *shared_mem_handle, | 308 Send(new PrintHostMsg_DuplicateSection(routing_id(), *shared_mem_handle, |
307 shared_mem_handle)); | 309 shared_mem_handle)); |
308 return true; | 310 return true; |
309 } | 311 } |
OLD | NEW |