| 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 "components/printing/renderer/print_render_frame_helper.h" | 5 #include "components/printing/renderer/print_render_frame_helper.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 } | 39 } |
| 40 #endif // defined(OS_ANDROID) | 40 #endif // defined(OS_ANDROID) |
| 41 | 41 |
| 42 } // namespace | 42 } // namespace |
| 43 | 43 |
| 44 namespace printing { | 44 namespace printing { |
| 45 | 45 |
| 46 #if BUILDFLAG(ENABLE_BASIC_PRINTING) | 46 #if BUILDFLAG(ENABLE_BASIC_PRINTING) |
| 47 bool PrintRenderFrameHelper::PrintPagesNative(blink::WebLocalFrame* frame, | 47 bool PrintRenderFrameHelper::PrintPagesNative(blink::WebLocalFrame* frame, |
| 48 int page_count) { | 48 int page_count) { |
| 49 PdfMetafileSkia metafile(PDF_SKIA_DOCUMENT_TYPE); | 49 const PrintMsg_PrintPages_Params& params = *print_pages_params_; |
| 50 const PrintMsg_Print_Params& print_params = params.params; |
| 51 PdfMetafileSkia metafile(print_params.printed_doc_type); |
| 50 CHECK(metafile.Init()); | 52 CHECK(metafile.Init()); |
| 51 | 53 |
| 52 const PrintMsg_PrintPages_Params& params = *print_pages_params_; | |
| 53 std::vector<int> printed_pages = GetPrintedPages(params, page_count); | 54 std::vector<int> printed_pages = GetPrintedPages(params, page_count); |
| 54 if (printed_pages.empty()) | 55 if (printed_pages.empty()) |
| 55 return false; | 56 return false; |
| 56 | 57 |
| 57 for (int page_number : printed_pages) { | 58 for (int page_number : printed_pages) { |
| 58 PrintPageInternal(params.params, page_number, page_count, frame, &metafile, | 59 PrintPageInternal(params.params, page_number, page_count, frame, &metafile, |
| 59 nullptr, nullptr, nullptr); | 60 nullptr, nullptr, nullptr); |
| 60 } | 61 } |
| 61 | 62 |
| 62 // blink::printEnd() for PDF should be called before metafile is closed. | 63 // blink::printEnd() for PDF should be called before metafile is closed. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 Send(new PrintHostMsg_DidPrintPage(routing_id(), printed_page_params)); | 95 Send(new PrintHostMsg_DidPrintPage(routing_id(), printed_page_params)); |
| 95 // Send the rest of the pages with an invalid metafile handle. | 96 // Send the rest of the pages with an invalid metafile handle. |
| 96 printed_page_params.metafile_data_handle.Release(); | 97 printed_page_params.metafile_data_handle.Release(); |
| 97 } | 98 } |
| 98 return true; | 99 return true; |
| 99 #endif // defined(OS_ANDROID) | 100 #endif // defined(OS_ANDROID) |
| 100 } | 101 } |
| 101 #endif // BUILDFLAG(ENABLE_BASIC_PRINTING) | 102 #endif // BUILDFLAG(ENABLE_BASIC_PRINTING) |
| 102 | 103 |
| 103 } // namespace printing | 104 } // namespace printing |
| OLD | NEW |