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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 // The printPage method may take a reference to the canvas we pass down, so it | 184 // The printPage method may take a reference to the canvas we pass down, so it |
185 // can't be a stack object. | 185 // can't be a stack object. |
186 SkRefPtr<skia::VectorCanvas> canvas = new skia::VectorCanvas(device); | 186 SkRefPtr<skia::VectorCanvas> canvas = new skia::VectorCanvas(device); |
187 canvas->unref(); // SkRefPtr and new both took a reference. | 187 canvas->unref(); // SkRefPtr and new both took a reference. |
188 if (is_preview) { | 188 if (is_preview) { |
189 printing::MetafileSkiaWrapper::SetMetafileOnCanvas(canvas.get(), | 189 printing::MetafileSkiaWrapper::SetMetafileOnCanvas(canvas.get(), |
190 metafile->get()); | 190 metafile->get()); |
191 } | 191 } |
192 | 192 |
193 float webkit_scale_factor = frame->printPage(page_number, canvas.get()); | 193 float webkit_scale_factor = frame->printPage(page_number, canvas.get()); |
| 194 |
| 195 if (is_preview && params.display_header_footer) { |
| 196 // |page_number| is 0-based, so 1 is added. |
| 197 PrintHeaderAndFooter(device, canvas.get(), page_number + 1, |
| 198 print_preview_context_.total_page_count(), |
| 199 webkit_scale_factor, page_layout_in_points, |
| 200 *header_footer_info_); |
| 201 } |
| 202 |
194 if (*scale_factor <= 0 || webkit_scale_factor <= 0) { | 203 if (*scale_factor <= 0 || webkit_scale_factor <= 0) { |
195 NOTREACHED() << "Printing page " << page_number << " failed."; | 204 NOTREACHED() << "Printing page " << page_number << " failed."; |
196 } else { | 205 } else { |
197 // Update the dpi adjustment with the "page |scale_factor|" calculated in | 206 // Update the dpi adjustment with the "page |scale_factor|" calculated in |
198 // webkit. | 207 // webkit. |
199 *scale_factor /= webkit_scale_factor; | 208 *scale_factor /= webkit_scale_factor; |
200 } | 209 } |
201 | 210 |
202 bool result = (*metafile)->FinishPage(); | 211 bool result = (*metafile)->FinishPage(); |
203 DCHECK(result); | 212 DCHECK(result); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 shared_buf.Unmap(); | 290 shared_buf.Unmap(); |
282 return false; | 291 return false; |
283 } | 292 } |
284 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), shared_mem_handle); | 293 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), shared_mem_handle); |
285 shared_buf.Unmap(); | 294 shared_buf.Unmap(); |
286 | 295 |
287 Send(new PrintHostMsg_DuplicateSection(routing_id(), *shared_mem_handle, | 296 Send(new PrintHostMsg_DuplicateSection(routing_id(), *shared_mem_handle, |
288 shared_mem_handle)); | 297 shared_mem_handle)); |
289 return true; | 298 return true; |
290 } | 299 } |
OLD | NEW |