OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 // TODO(sgurun) copied from chrome/renderer. Remove after crbug.com/322276 |
6 | 6 |
| 7 #include "android_webview/renderer/print_web_view_helper.h" |
| 8 |
| 9 #include "android_webview/common/print_messages.h" |
7 #include "base/logging.h" | 10 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
9 #include "chrome/common/print_messages.h" | |
10 #include "content/public/renderer/render_thread.h" | 12 #include "content/public/renderer/render_thread.h" |
11 #include "printing/metafile.h" | 13 #include "printing/metafile.h" |
12 #include "printing/metafile_impl.h" | 14 #include "printing/metafile_impl.h" |
13 #include "printing/metafile_skia_wrapper.h" | 15 #include "printing/metafile_skia_wrapper.h" |
14 #include "printing/page_size_margins.h" | 16 #include "printing/page_size_margins.h" |
15 #include "skia/ext/platform_device.h" | 17 #include "skia/ext/platform_device.h" |
16 #include "skia/ext/vector_canvas.h" | 18 #include "skia/ext/vector_canvas.h" |
17 #include "third_party/WebKit/public/web/WebFrame.h" | 19 #include "third_party/WebKit/public/web/WebFrame.h" |
18 | 20 |
19 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) | 21 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 &(printed_page_params.metafile_data_handle)); | 140 &(printed_page_params.metafile_data_handle)); |
139 } | 141 } |
140 | 142 |
141 for (size_t i = 0; i < printed_pages.size(); ++i) { | 143 for (size_t i = 0; i < printed_pages.size(); ++i) { |
142 printed_page_params.page_number = printed_pages[i]; | 144 printed_page_params.page_number = printed_pages[i]; |
143 Send(new PrintHostMsg_DidPrintPage(routing_id(), printed_page_params)); | 145 Send(new PrintHostMsg_DidPrintPage(routing_id(), printed_page_params)); |
144 // Send the rest of the pages with an invalid metafile handle. | 146 // Send the rest of the pages with an invalid metafile handle. |
145 printed_page_params.metafile_data_handle.fd = -1; | 147 printed_page_params.metafile_data_handle.fd = -1; |
146 } | 148 } |
147 return true; | 149 return true; |
148 #endif // defined(OS_CHROMEOS) | 150 #endif // defined(OS_CHROMEOS) || defined(OS_ANDROID) |
149 } | 151 } |
150 | 152 |
151 void PrintWebViewHelper::PrintPageInternal( | 153 void PrintWebViewHelper::PrintPageInternal( |
152 const PrintMsg_PrintPage_Params& params, | 154 const PrintMsg_PrintPage_Params& params, |
153 const gfx::Size& canvas_size, | 155 const gfx::Size& canvas_size, |
154 WebFrame* frame, | 156 WebFrame* frame, |
155 Metafile* metafile) { | 157 Metafile* metafile) { |
156 PageSizeMargins page_layout_in_points; | 158 PageSizeMargins page_layout_in_points; |
157 double scale_factor = 1.0f; | 159 double scale_factor = 1.0f; |
158 ComputePageLayoutInPointsForCss(frame, params.page_number, params.params, | 160 ComputePageLayoutInPointsForCss(frame, params.page_number, params.params, |
(...skipping 30 matching lines...) Expand all Loading... |
189 } | 191 } |
190 RenderPageContent(frame, params.page_number, canvas_area, content_area, | 192 RenderPageContent(frame, params.page_number, canvas_area, content_area, |
191 scale_factor, canvas.get()); | 193 scale_factor, canvas.get()); |
192 | 194 |
193 // Done printing. Close the device context to retrieve the compiled metafile. | 195 // Done printing. Close the device context to retrieve the compiled metafile. |
194 if (!metafile->FinishPage()) | 196 if (!metafile->FinishPage()) |
195 NOTREACHED() << "metafile failed"; | 197 NOTREACHED() << "metafile failed"; |
196 } | 198 } |
197 | 199 |
198 } // namespace printing | 200 } // namespace printing |
OLD | NEW |