| 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 "components/printing/renderer/print_web_view_helper.h" | 5 #include "components/printing/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 "components/printing/common/print_messages.h" | 9 #include "components/printing/common/print_messages.h" |
| 10 #include "content/public/renderer/render_thread.h" | 10 #include "content/public/renderer/render_thread.h" |
| 11 #include "printing/metafile_skia_wrapper.h" | 11 #include "printing/metafile_skia_wrapper.h" |
| 12 #include "printing/page_size_margins.h" | 12 #include "printing/page_size_margins.h" |
| 13 #include "printing/pdf_metafile_skia.h" | 13 #include "printing/pdf_metafile_skia.h" |
| 14 #include "skia/ext/platform_device.h" | |
| 15 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 14 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 16 | 15 |
| 17 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) | 16 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) |
| 18 #include "base/process/process_handle.h" | 17 #include "base/process/process_handle.h" |
| 19 #else | 18 #else |
| 20 #include "base/file_descriptor_posix.h" | 19 #include "base/file_descriptor_posix.h" |
| 21 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) | 20 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) |
| 22 | 21 |
| 23 namespace printing { | 22 namespace printing { |
| 24 | 23 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 &content_area); | 144 &content_area); |
| 146 gfx::Rect canvas_area = | 145 gfx::Rect canvas_area = |
| 147 params.params.display_header_footer ? gfx::Rect(page_size) : content_area; | 146 params.params.display_header_footer ? gfx::Rect(page_size) : content_area; |
| 148 | 147 |
| 149 skia::PlatformCanvas* canvas = | 148 skia::PlatformCanvas* canvas = |
| 150 metafile->GetVectorCanvasForNewPage(page_size, canvas_area, scale_factor); | 149 metafile->GetVectorCanvasForNewPage(page_size, canvas_area, scale_factor); |
| 151 if (!canvas) | 150 if (!canvas) |
| 152 return; | 151 return; |
| 153 | 152 |
| 154 MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile); | 153 MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile); |
| 155 skia::SetIsDraftMode(*canvas, is_print_ready_metafile_sent_); | |
| 156 | 154 |
| 157 #if defined(ENABLE_PRINT_PREVIEW) | 155 #if defined(ENABLE_PRINT_PREVIEW) |
| 158 if (params.params.display_header_footer) { | 156 if (params.params.display_header_footer) { |
| 159 // |page_number| is 0-based, so 1 is added. | 157 // |page_number| is 0-based, so 1 is added. |
| 160 // TODO(vitalybuka) : why does it work only with 1.25? | 158 // TODO(vitalybuka) : why does it work only with 1.25? |
| 161 PrintHeaderAndFooter(canvas, params.page_number + 1, | 159 PrintHeaderAndFooter(canvas, params.page_number + 1, |
| 162 print_preview_context_.total_page_count(), *frame, | 160 print_preview_context_.total_page_count(), *frame, |
| 163 scale_factor / 1.25, page_layout_in_points, | 161 scale_factor / 1.25, page_layout_in_points, |
| 164 params.params); | 162 params.params); |
| 165 } | 163 } |
| 166 #endif // defined(ENABLE_PRINT_PREVIEW) | 164 #endif // defined(ENABLE_PRINT_PREVIEW) |
| 167 | 165 |
| 168 RenderPageContent(frame, params.page_number, canvas_area, content_area, | 166 RenderPageContent(frame, params.page_number, canvas_area, content_area, |
| 169 scale_factor, canvas); | 167 scale_factor, canvas); |
| 170 | 168 |
| 171 // Done printing. Close the canvas to retrieve the compiled metafile. | 169 // Done printing. Close the canvas to retrieve the compiled metafile. |
| 172 if (!metafile->FinishPage()) | 170 if (!metafile->FinishPage()) |
| 173 NOTREACHED() << "metafile failed"; | 171 NOTREACHED() << "metafile failed"; |
| 174 } | 172 } |
| 175 | 173 |
| 176 } // namespace printing | 174 } // namespace printing |
| OLD | NEW |