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" |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 if (!device) | 202 if (!device) |
203 return; | 203 return; |
204 | 204 |
205 // The printPage method take a reference to the canvas we pass down, so it | 205 // The printPage method take a reference to the canvas we pass down, so it |
206 // can't be a stack object. | 206 // can't be a stack object. |
207 SkRefPtr<skia::VectorCanvas> canvas = new skia::VectorCanvas(device); | 207 SkRefPtr<skia::VectorCanvas> canvas = new skia::VectorCanvas(device); |
208 canvas->unref(); // SkRefPtr and new both took a reference. | 208 canvas->unref(); // SkRefPtr and new both took a reference. |
209 printing::MetafileSkiaWrapper::SetMetafileOnCanvas(canvas.get(), metafile); | 209 printing::MetafileSkiaWrapper::SetMetafileOnCanvas(canvas.get(), metafile); |
210 frame->printPage(params.page_number, canvas.get()); | 210 frame->printPage(params.page_number, canvas.get()); |
211 | 211 |
212 // TODO(myhuang): We should render the header and the footer. | 212 if (params.params.display_header_footer) { |
| 213 // |page_number| is 0-based, so 1 is added. |
| 214 // The scale factor on Linux is 1. |
| 215 PrintHeaderAndFooter(device, canvas.get(), params.page_number + 1, |
| 216 print_preview_context_.total_page_count(), 1, |
| 217 page_layout_in_points, *header_footer_info_); |
| 218 } |
213 | 219 |
214 // Done printing. Close the device context to retrieve the compiled metafile. | 220 // Done printing. Close the device context to retrieve the compiled metafile. |
215 if (!metafile->FinishPage()) | 221 if (!metafile->FinishPage()) |
216 NOTREACHED() << "metafile failed"; | 222 NOTREACHED() << "metafile failed"; |
217 } | 223 } |
OLD | NEW |