| 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 "chrome/common/print_messages.h" | 9 #include "chrome/common/print_messages.h" |
| 10 #include "content/public/renderer/render_thread.h" | 10 #include "content/public/renderer/render_thread.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 if (!device) | 167 if (!device) |
| 168 return; | 168 return; |
| 169 | 169 |
| 170 // The printPage method take a reference to the canvas we pass down, so it | 170 // The printPage method take a reference to the canvas we pass down, so it |
| 171 // can't be a stack object. | 171 // can't be a stack object. |
| 172 skia::RefPtr<skia::VectorCanvas> canvas = | 172 skia::RefPtr<skia::VectorCanvas> canvas = |
| 173 skia::AdoptRef(new skia::VectorCanvas(device)); | 173 skia::AdoptRef(new skia::VectorCanvas(device)); |
| 174 MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile); | 174 MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile); |
| 175 skia::SetIsDraftMode(*canvas, is_print_ready_metafile_sent_); | 175 skia::SetIsDraftMode(*canvas, is_print_ready_metafile_sent_); |
| 176 | 176 |
| 177 #if defined(ENABLE_PRINT_PREVIEW) |
| 177 if (params.params.display_header_footer) { | 178 if (params.params.display_header_footer) { |
| 178 // |page_number| is 0-based, so 1 is added. | 179 // |page_number| is 0-based, so 1 is added. |
| 179 // TODO(vitalybuka) : why does it work only with 1.25? | 180 // TODO(vitalybuka) : why does it work only with 1.25? |
| 180 PrintHeaderAndFooter(canvas.get(), | 181 PrintHeaderAndFooter(canvas.get(), |
| 181 params.page_number + 1, | 182 params.page_number + 1, |
| 182 print_preview_context_.total_page_count(), | 183 print_preview_context_.total_page_count(), |
| 183 *frame, | 184 *frame, |
| 184 scale_factor / 1.25, | 185 scale_factor / 1.25, |
| 185 page_layout_in_points, | 186 page_layout_in_points, |
| 186 params.params); | 187 params.params); |
| 187 } | 188 } |
| 189 #endif // defined(ENABLE_PRINT_PREVIEW) |
| 190 |
| 188 RenderPageContent(frame, params.page_number, canvas_area, content_area, | 191 RenderPageContent(frame, params.page_number, canvas_area, content_area, |
| 189 scale_factor, canvas.get()); | 192 scale_factor, canvas.get()); |
| 190 | 193 |
| 191 // Done printing. Close the device context to retrieve the compiled metafile. | 194 // Done printing. Close the device context to retrieve the compiled metafile. |
| 192 if (!metafile->FinishPage()) | 195 if (!metafile->FinishPage()) |
| 193 NOTREACHED() << "metafile failed"; | 196 NOTREACHED() << "metafile failed"; |
| 194 } | 197 } |
| 195 | 198 |
| 196 } // namespace printing | 199 } // namespace printing |
| OLD | NEW |