| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/renderer/printing/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 "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 if (printed_pages.empty()) | 85 if (printed_pages.empty()) |
| 86 return false; | 86 return false; |
| 87 | 87 |
| 88 PrintMsg_PrintPage_Params page_params; | 88 PrintMsg_PrintPage_Params page_params; |
| 89 page_params.params = params.params; | 89 page_params.params = params.params; |
| 90 for (size_t i = 0; i < printed_pages.size(); ++i) { | 90 for (size_t i = 0; i < printed_pages.size(); ++i) { |
| 91 page_params.page_number = printed_pages[i]; | 91 page_params.page_number = printed_pages[i]; |
| 92 PrintPageInternal(page_params, canvas_size, frame, &metafile); | 92 PrintPageInternal(page_params, canvas_size, frame, &metafile); |
| 93 } | 93 } |
| 94 | 94 |
| 95 // WebKit::printEnd() for PDF should be called before metafile is closed. |
| 96 FinishFramePrinting(); |
| 97 |
| 95 metafile.FinishDocument(); | 98 metafile.FinishDocument(); |
| 96 | 99 |
| 97 // Get the size of the resulting metafile. | 100 // Get the size of the resulting metafile. |
| 98 uint32 buf_size = metafile.GetDataSize(); | 101 uint32 buf_size = metafile.GetDataSize(); |
| 99 DCHECK_GT(buf_size, 0u); | 102 DCHECK_GT(buf_size, 0u); |
| 100 | 103 |
| 101 #if defined(OS_CHROMEOS) | 104 #if defined(OS_CHROMEOS) |
| 102 int sequence_number = -1; | 105 int sequence_number = -1; |
| 103 base::FileDescriptor fd; | 106 base::FileDescriptor fd; |
| 104 | 107 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 } | 188 } |
| 186 RenderPageContent(frame, params.page_number, canvas_area, content_area, | 189 RenderPageContent(frame, params.page_number, canvas_area, content_area, |
| 187 scale_factor, canvas.get()); | 190 scale_factor, canvas.get()); |
| 188 | 191 |
| 189 // Done printing. Close the device context to retrieve the compiled metafile. | 192 // Done printing. Close the device context to retrieve the compiled metafile. |
| 190 if (!metafile->FinishPage()) | 193 if (!metafile->FinishPage()) |
| 191 NOTREACHED() << "metafile failed"; | 194 NOTREACHED() << "metafile failed"; |
| 192 } | 195 } |
| 193 | 196 |
| 194 } // namespace printing | 197 } // namespace printing |
| OLD | NEW |