| 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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "chrome/common/print_messages.h" | 10 #include "chrome/common/print_messages.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 // Doing this before closing |metafile| below ensures | 158 // Doing this before closing |metafile| below ensures |
| 159 // webkit::ppapi::PluginInstance::PrintEnd() has a valid canvas/metafile to | 159 // webkit::ppapi::PluginInstance::PrintEnd() has a valid canvas/metafile to |
| 160 // save the final output to. See pepper_plugin_instance.cc for the whole | 160 // save the final output to. See pepper_plugin_instance.cc for the whole |
| 161 // story. | 161 // story. |
| 162 PrepareFrameAndViewForPrint prep_frame_view(printParams, | 162 PrepareFrameAndViewForPrint prep_frame_view(printParams, |
| 163 frame, | 163 frame, |
| 164 node, | 164 node, |
| 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_DidGetBasicPrintJobInfo(routing_id(), |
| 169 printParams.document_cookie, | 169 printParams.document_cookie, |
| 170 *page_count)); | 170 *page_count, |
| 171 job_title_)); |
| 171 } | 172 } |
| 172 if (!*page_count) | 173 if (!*page_count) |
| 173 return false; | 174 return false; |
| 174 | 175 |
| 175 PrintMsg_PrintPage_Params page_params; | 176 PrintMsg_PrintPage_Params page_params; |
| 176 page_params.params = printParams; | 177 page_params.params = printParams; |
| 177 const gfx::Size& canvas_size = prep_frame_view.GetPrintCanvasSize(); | 178 const gfx::Size& canvas_size = prep_frame_view.GetPrintCanvasSize(); |
| 178 if (params.pages.empty()) { | 179 if (params.pages.empty()) { |
| 179 for (int i = 0; i < *page_count; ++i) { | 180 for (int i = 0; i < *page_count; ++i) { |
| 180 page_params.page_number = i; | 181 page_params.page_number = i; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 metafile); | 232 metafile); |
| 232 frame->printPage(params.page_number, canvas->get()); | 233 frame->printPage(params.page_number, canvas->get()); |
| 233 | 234 |
| 234 // TODO(myhuang): We should handle transformation for paper margins. | 235 // TODO(myhuang): We should handle transformation for paper margins. |
| 235 // TODO(myhuang): We should render the header and the footer. | 236 // TODO(myhuang): We should render the header and the footer. |
| 236 | 237 |
| 237 // Done printing. Close the device context to retrieve the compiled metafile. | 238 // Done printing. Close the device context to retrieve the compiled metafile. |
| 238 if (!metafile->FinishPage()) | 239 if (!metafile->FinishPage()) |
| 239 NOTREACHED() << "metafile failed"; | 240 NOTREACHED() << "metafile failed"; |
| 240 } | 241 } |
| OLD | NEW |