| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/printing/print_web_view_helper.h" | 5 #include "chrome/renderer/printing/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/process_handle.h" | 10 #include "base/process/process_handle.h" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 skia::AdoptRef(new skia::VectorCanvas(device)); | 180 skia::AdoptRef(new skia::VectorCanvas(device)); |
| 181 | 181 |
| 182 if (is_preview) { | 182 if (is_preview) { |
| 183 MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile); | 183 MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile); |
| 184 skia::SetIsDraftMode(*canvas, is_print_ready_metafile_sent_); | 184 skia::SetIsDraftMode(*canvas, is_print_ready_metafile_sent_); |
| 185 skia::SetIsPreviewMetafile(*canvas, is_preview); | 185 skia::SetIsPreviewMetafile(*canvas, is_preview); |
| 186 } | 186 } |
| 187 | 187 |
| 188 if (params.display_header_footer) { | 188 if (params.display_header_footer) { |
| 189 // |page_number| is 0-based, so 1 is added. | 189 // |page_number| is 0-based, so 1 is added. |
| 190 PrintHeaderAndFooter(canvas.get(), page_number + 1, | 190 PrintHeaderAndFooter(canvas.get(), |
| 191 print_preview_context_.total_page_count(), scale_factor, | 191 page_number + 1, |
| 192 page_layout_in_points, *header_footer_info_, params); | 192 print_preview_context_.total_page_count(), |
| 193 *frame, |
| 194 scale_factor, |
| 195 page_layout_in_points, |
| 196 params); |
| 193 } | 197 } |
| 194 | 198 |
| 195 float webkit_scale_factor = RenderPageContent(frame, page_number, canvas_area, | 199 float webkit_scale_factor = RenderPageContent(frame, page_number, canvas_area, |
| 196 content_area, scale_factor, | 200 content_area, scale_factor, |
| 197 canvas.get()); | 201 canvas.get()); |
| 198 | 202 |
| 199 if (*actual_shrink <= 0 || webkit_scale_factor <= 0) { | 203 if (*actual_shrink <= 0 || webkit_scale_factor <= 0) { |
| 200 NOTREACHED() << "Printing page " << page_number << " failed."; | 204 NOTREACHED() << "Printing page " << page_number << " failed."; |
| 201 } else { | 205 } else { |
| 202 // While rendering certain plugins (PDF) to metafile, we might need to | 206 // While rendering certain plugins (PDF) to metafile, we might need to |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 } | 244 } |
| 241 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), shared_mem_handle); | 245 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), shared_mem_handle); |
| 242 shared_buf.Unmap(); | 246 shared_buf.Unmap(); |
| 243 | 247 |
| 244 Send(new PrintHostMsg_DuplicateSection(routing_id(), *shared_mem_handle, | 248 Send(new PrintHostMsg_DuplicateSection(routing_id(), *shared_mem_handle, |
| 245 shared_mem_handle)); | 249 shared_mem_handle)); |
| 246 return true; | 250 return true; |
| 247 } | 251 } |
| 248 | 252 |
| 249 } // namespace printing | 253 } // namespace printing |
| OLD | NEW |