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/file_descriptor_posix.h" | 7 #include "base/file_descriptor_posix.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "chrome/common/print_messages.h" | 11 #include "chrome/common/print_messages.h" |
12 #include "content/renderer/render_view.h" | 12 #include "content/renderer/render_view.h" |
13 #include "printing/metafile.h" | 13 #include "printing/metafile.h" |
14 #include "printing/metafile_impl.h" | 14 #include "printing/metafile_impl.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 "skia/ext/platform_device.h" |
17 #include "skia/ext/vector_canvas.h" | 18 #include "skia/ext/vector_canvas.h" |
18 #include "third_party/skia/include/core/SkRefCnt.h" | 19 #include "third_party/skia/include/core/SkRefCnt.h" |
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
20 | 21 |
21 #if !defined(OS_CHROMEOS) | 22 #if !defined(OS_CHROMEOS) |
22 #include "base/process_util.h" | 23 #include "base/process_util.h" |
23 #endif // !defined(OS_CHROMEOS) | 24 #endif // !defined(OS_CHROMEOS) |
24 | 25 |
25 using WebKit::WebFrame; | 26 using WebKit::WebFrame; |
26 using WebKit::WebNode; | 27 using WebKit::WebNode; |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 | 202 |
202 SkDevice* device = metafile->StartPageForVectorCanvas( | 203 SkDevice* device = metafile->StartPageForVectorCanvas( |
203 page_size, content_area, 1.0f); | 204 page_size, content_area, 1.0f); |
204 if (!device) | 205 if (!device) |
205 return; | 206 return; |
206 | 207 |
207 // The printPage method take a reference to the canvas we pass down, so it | 208 // The printPage method take a reference to the canvas we pass down, so it |
208 // can't be a stack object. | 209 // can't be a stack object. |
209 SkRefPtr<skia::VectorCanvas> canvas = new skia::VectorCanvas(device); | 210 SkRefPtr<skia::VectorCanvas> canvas = new skia::VectorCanvas(device); |
210 canvas->unref(); // SkRefPtr and new both took a reference. | 211 canvas->unref(); // SkRefPtr and new both took a reference. |
211 printing::MetafileSkiaWrapper::SetMetafileOnCanvas(canvas.get(), metafile); | 212 printing::MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile); |
212 printing::MetafileSkiaWrapper::SetDraftMode(canvas.get(), | 213 skia::SetIsDraftMode(*canvas, is_print_ready_metafile_sent_); |
213 is_print_ready_metafile_sent_); | |
214 frame->printPage(params.page_number, canvas.get()); | 214 frame->printPage(params.page_number, canvas.get()); |
215 | 215 |
216 if (params.params.display_header_footer) { | 216 if (params.params.display_header_footer) { |
217 // |page_number| is 0-based, so 1 is added. | 217 // |page_number| is 0-based, so 1 is added. |
218 // The scale factor on Linux is 1. | 218 // The scale factor on Linux is 1. |
219 PrintHeaderAndFooter(canvas.get(), params.page_number + 1, | 219 PrintHeaderAndFooter(canvas.get(), params.page_number + 1, |
220 print_preview_context_.total_page_count(), 1, | 220 print_preview_context_.total_page_count(), 1, |
221 page_layout_in_points, *header_footer_info_); | 221 page_layout_in_points, *header_footer_info_); |
222 } | 222 } |
223 | 223 |
224 // Done printing. Close the device context to retrieve the compiled metafile. | 224 // Done printing. Close the device context to retrieve the compiled metafile. |
225 if (!metafile->FinishPage()) | 225 if (!metafile->FinishPage()) |
226 NOTREACHED() << "metafile failed"; | 226 NOTREACHED() << "metafile failed"; |
227 } | 227 } |
OLD | NEW |