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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 print_params.document_cookie, | 150 print_params.document_cookie, |
151 *page_count)); | 151 *page_count)); |
152 #endif | 152 #endif |
153 | 153 |
154 base::TimeTicks begin_time = base::TimeTicks::Now(); | 154 base::TimeTicks begin_time = base::TimeTicks::Now(); |
155 base::TimeTicks page_begin_time = begin_time; | 155 base::TimeTicks page_begin_time = begin_time; |
156 | 156 |
157 PrintMsg_PrintPage_Params page_params; | 157 PrintMsg_PrintPage_Params page_params; |
158 page_params.params = print_params; | 158 page_params.params = print_params; |
159 const gfx::Size& canvas_size = prepare->GetPrintCanvasSize(); | 159 const gfx::Size& canvas_size = prepare->GetPrintCanvasSize(); |
| 160 page_params.params.display_header_footer = false; |
160 if (params.pages.empty()) { | 161 if (params.pages.empty()) { |
161 for (int i = 0; i < *page_count; ++i) { | 162 for (int i = 0; i < *page_count; ++i) { |
162 page_params.page_number = i; | 163 page_params.page_number = i; |
163 PrintPageInternal(page_params, canvas_size, frame, metafile); | 164 PrintPageInternal(page_params, canvas_size, frame, metafile); |
164 } | 165 } |
165 } else { | 166 } else { |
166 for (size_t i = 0; i < params.pages.size(); ++i) { | 167 for (size_t i = 0; i < params.pages.size(); ++i) { |
167 page_params.page_number = params.pages[i]; | 168 page_params.page_number = params.pages[i]; |
168 PrintPageInternal(page_params, canvas_size, frame, metafile); | 169 PrintPageInternal(page_params, canvas_size, frame, metafile); |
169 } | 170 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 if (!device) | 203 if (!device) |
203 return; | 204 return; |
204 | 205 |
205 // The printPage method take a reference to the canvas we pass down, so it | 206 // The printPage method take a reference to the canvas we pass down, so it |
206 // can't be a stack object. | 207 // can't be a stack object. |
207 SkRefPtr<skia::VectorCanvas> canvas = new skia::VectorCanvas(device); | 208 SkRefPtr<skia::VectorCanvas> canvas = new skia::VectorCanvas(device); |
208 canvas->unref(); // SkRefPtr and new both took a reference. | 209 canvas->unref(); // SkRefPtr and new both took a reference. |
209 printing::MetafileSkiaWrapper::SetMetafileOnCanvas(canvas.get(), metafile); | 210 printing::MetafileSkiaWrapper::SetMetafileOnCanvas(canvas.get(), metafile); |
210 frame->printPage(params.page_number, canvas.get()); | 211 frame->printPage(params.page_number, canvas.get()); |
211 | 212 |
212 // TODO(myhuang): We should render the header and the footer. | 213 if (params.params.display_header_footer) { |
| 214 // |page_number| is 0-based, so 1 is added. |
| 215 // The scale factor on Linux is 1. |
| 216 PrintHeaderAndFooter(device, canvas.get(), params.page_number + 1, |
| 217 print_preview_context_.total_page_count(), 1, |
| 218 page_layout_in_points, *header_footer_info_); |
| 219 } |
213 | 220 |
214 // Done printing. Close the device context to retrieve the compiled metafile. | 221 // Done printing. Close the device context to retrieve the compiled metafile. |
215 if (!metafile->FinishPage()) | 222 if (!metafile->FinishPage()) |
216 NOTREACHED() << "metafile failed"; | 223 NOTREACHED() << "metafile failed"; |
217 } | 224 } |
OLD | NEW |