| 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_web_view_helper.h" | 5 #include "components/printing/renderer/print_web_view_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" |
| 11 #include "components/printing/common/print_messages.h" | 11 #include "components/printing/common/print_messages.h" |
| 12 #include "printing/features/features.h" |
| 12 #include "printing/metafile_skia_wrapper.h" | 13 #include "printing/metafile_skia_wrapper.h" |
| 13 | 14 |
| 14 #if defined(OS_ANDROID) | 15 #if defined(OS_ANDROID) |
| 15 #include "base/file_descriptor_posix.h" | 16 #include "base/file_descriptor_posix.h" |
| 16 #else | 17 #else |
| 17 #include "base/process/process_handle.h" | 18 #include "base/process/process_handle.h" |
| 18 #endif // defined(OS_ANDROID) | 19 #endif // defined(OS_ANDROID) |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 35 if (!fd.auto_close) | 36 if (!fd.auto_close) |
| 36 file.TakePlatformFile(); | 37 file.TakePlatformFile(); |
| 37 return result; | 38 return result; |
| 38 } | 39 } |
| 39 #endif // defined(OS_ANDROID) | 40 #endif // defined(OS_ANDROID) |
| 40 | 41 |
| 41 } // namespace | 42 } // namespace |
| 42 | 43 |
| 43 namespace printing { | 44 namespace printing { |
| 44 | 45 |
| 45 #if defined(ENABLE_BASIC_PRINTING) | 46 #if BUILDFLAG(ENABLE_BASIC_PRINTING) |
| 46 bool PrintWebViewHelper::PrintPagesNative(blink::WebLocalFrame* frame, | 47 bool PrintWebViewHelper::PrintPagesNative(blink::WebLocalFrame* frame, |
| 47 int page_count) { | 48 int page_count) { |
| 48 PdfMetafileSkia metafile(PDF_SKIA_DOCUMENT_TYPE); | 49 PdfMetafileSkia metafile(PDF_SKIA_DOCUMENT_TYPE); |
| 49 CHECK(metafile.Init()); | 50 CHECK(metafile.Init()); |
| 50 | 51 |
| 51 const PrintMsg_PrintPages_Params& params = *print_pages_params_; | 52 const PrintMsg_PrintPages_Params& params = *print_pages_params_; |
| 52 std::vector<int> printed_pages = GetPrintedPages(params, page_count); | 53 std::vector<int> printed_pages = GetPrintedPages(params, page_count); |
| 53 if (printed_pages.empty()) | 54 if (printed_pages.empty()) |
| 54 return false; | 55 return false; |
| 55 | 56 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 94 |
| 94 for (size_t i = 0; i < printed_pages.size(); ++i) { | 95 for (size_t i = 0; i < printed_pages.size(); ++i) { |
| 95 printed_page_params.page_number = printed_pages[i]; | 96 printed_page_params.page_number = printed_pages[i]; |
| 96 Send(new PrintHostMsg_DidPrintPage(routing_id(), printed_page_params)); | 97 Send(new PrintHostMsg_DidPrintPage(routing_id(), printed_page_params)); |
| 97 // Send the rest of the pages with an invalid metafile handle. | 98 // Send the rest of the pages with an invalid metafile handle. |
| 98 printed_page_params.metafile_data_handle.fd = -1; | 99 printed_page_params.metafile_data_handle.fd = -1; |
| 99 } | 100 } |
| 100 return true; | 101 return true; |
| 101 #endif // defined(OS_ANDROID) | 102 #endif // defined(OS_ANDROID) |
| 102 } | 103 } |
| 103 #endif // defined(ENABLE_BASIC_PRINTING) | 104 #endif // BUILDFLAG(ENABLE_BASIC_PRINTING) |
| 104 | 105 |
| 105 } // namespace printing | 106 } // namespace printing |
| OLD | NEW |