| 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 146 |
| 147 bool PrintWebViewHelper::RenderPages(const PrintMsg_PrintPages_Params& params, | 147 bool PrintWebViewHelper::RenderPages(const PrintMsg_PrintPages_Params& params, |
| 148 WebKit::WebFrame* frame, | 148 WebKit::WebFrame* frame, |
| 149 WebKit::WebNode* node, | 149 WebKit::WebNode* node, |
| 150 bool send_expected_page_count, | 150 bool send_expected_page_count, |
| 151 int* page_count, | 151 int* page_count, |
| 152 printing::NativeMetafile* metafile) { | 152 printing::NativeMetafile* metafile) { |
| 153 PrintMsg_Print_Params printParams = params.params; | 153 PrintMsg_Print_Params printParams = params.params; |
| 154 scoped_ptr<skia::VectorCanvas> canvas; | 154 scoped_ptr<skia::VectorCanvas> canvas; |
| 155 | 155 |
| 156 UpdatePrintableSizeInPrintParameters(frame, node, &printParams); |
| 157 |
| 156 { | 158 { |
| 157 // Hack - when |prep_frame_view| goes out of scope, PrintEnd() gets called. | 159 // Hack - when |prep_frame_view| goes out of scope, PrintEnd() gets called. |
| 158 // Doing this before closing |metafile| below ensures | 160 // Doing this before closing |metafile| below ensures |
| 159 // webkit::ppapi::PluginInstance::PrintEnd() has a valid canvas/metafile to | 161 // webkit::ppapi::PluginInstance::PrintEnd() has a valid canvas/metafile to |
| 160 // save the final output to. See pepper_plugin_instance.cc for the whole | 162 // save the final output to. See pepper_plugin_instance.cc for the whole |
| 161 // story. | 163 // story. |
| 162 PrepareFrameAndViewForPrint prep_frame_view(printParams, | 164 PrepareFrameAndViewForPrint prep_frame_view(printParams, |
| 163 frame, | 165 frame, |
| 164 node, | 166 node, |
| 165 frame->view()); | 167 frame->view()); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 metafile); | 234 metafile); |
| 233 frame->printPage(params.page_number, canvas->get()); | 235 frame->printPage(params.page_number, canvas->get()); |
| 234 | 236 |
| 235 // TODO(myhuang): We should handle transformation for paper margins. | 237 // TODO(myhuang): We should handle transformation for paper margins. |
| 236 // TODO(myhuang): We should render the header and the footer. | 238 // TODO(myhuang): We should render the header and the footer. |
| 237 | 239 |
| 238 // Done printing. Close the device context to retrieve the compiled metafile. | 240 // Done printing. Close the device context to retrieve the compiled metafile. |
| 239 if (!metafile->FinishPage()) | 241 if (!metafile->FinishPage()) |
| 240 NOTREACHED() << "metafile failed"; | 242 NOTREACHED() << "metafile failed"; |
| 241 } | 243 } |
| OLD | NEW |