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