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/file_descriptor_posix.h" | 7 #include "base/file_descriptor_posix.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "chrome/common/print_messages.h" | 10 #include "chrome/common/print_messages.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 frame->view()); | 165 frame->view()); |
166 *page_count = prep_frame_view.GetExpectedPageCount(); | 166 *page_count = prep_frame_view.GetExpectedPageCount(); |
167 if (send_expected_page_count) { | 167 if (send_expected_page_count) { |
168 Send(new PrintHostMsg_DidGetPrintedPagesCount(routing_id(), | 168 Send(new PrintHostMsg_DidGetPrintedPagesCount(routing_id(), |
169 printParams.document_cookie, | 169 printParams.document_cookie, |
170 *page_count)); | 170 *page_count)); |
171 } | 171 } |
172 if (!*page_count) | 172 if (!*page_count) |
173 return false; | 173 return false; |
174 | 174 |
175 metafile->Init(); | |
176 | |
177 PrintMsg_PrintPage_Params page_params; | 175 PrintMsg_PrintPage_Params page_params; |
178 page_params.params = printParams; | 176 page_params.params = printParams; |
179 const gfx::Size& canvas_size = prep_frame_view.GetPrintCanvasSize(); | 177 const gfx::Size& canvas_size = prep_frame_view.GetPrintCanvasSize(); |
180 if (params.pages.empty()) { | 178 if (params.pages.empty()) { |
181 for (int i = 0; i < *page_count; ++i) { | 179 for (int i = 0; i < *page_count; ++i) { |
182 page_params.page_number = i; | 180 page_params.page_number = i; |
183 PrintPage(page_params, canvas_size, frame, metafile, &canvas); | 181 PrintPage(page_params, canvas_size, frame, metafile, &canvas); |
184 } | 182 } |
185 } else { | 183 } else { |
186 for (size_t i = 0; i < params.pages.size(); ++i) { | 184 for (size_t i = 0; i < params.pages.size(); ++i) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 metafile); | 231 metafile); |
234 frame->printPage(params.page_number, canvas->get()); | 232 frame->printPage(params.page_number, canvas->get()); |
235 | 233 |
236 // TODO(myhuang): We should handle transformation for paper margins. | 234 // TODO(myhuang): We should handle transformation for paper margins. |
237 // TODO(myhuang): We should render the header and the footer. | 235 // TODO(myhuang): We should render the header and the footer. |
238 | 236 |
239 // Done printing. Close the device context to retrieve the compiled metafile. | 237 // Done printing. Close the device context to retrieve the compiled metafile. |
240 if (!metafile->FinishPage()) | 238 if (!metafile->FinishPage()) |
241 NOTREACHED() << "metafile failed"; | 239 NOTREACHED() << "metafile failed"; |
242 } | 240 } |
OLD | NEW |