| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CHROME_UTILITY_PRINTING_HANDLER_H_ | 5 #ifndef CHROME_UTILITY_PRINTING_HANDLER_H_ |
| 6 #define CHROME_UTILITY_PRINTING_HANDLER_H_ | 6 #define CHROME_UTILITY_PRINTING_HANDLER_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "chrome/utility/utility_message_handler.h" | 11 #include "chrome/utility/utility_message_handler.h" |
| 12 #include "ipc/ipc_platform_file.h" | 12 #include "ipc/ipc_platform_file.h" |
| 13 #include "printing/features/features.h" |
| 13 #include "printing/pdf_render_settings.h" | 14 #include "printing/pdf_render_settings.h" |
| 14 | 15 |
| 15 #if !defined(ENABLE_PRINT_PREVIEW) && \ | 16 #if !BUILDFLAG(ENABLE_PRINT_PREVIEW) && \ |
| 16 !(defined(ENABLE_BASIC_PRINTING) && defined(OS_WIN)) | 17 !(BUILDFLAG(ENABLE_BASIC_PRINTING) && defined(OS_WIN)) |
| 17 #error "Windows basic printing or print preview must be enabled" | 18 #error "Windows basic printing or print preview must be enabled" |
| 18 #endif | 19 #endif |
| 19 | 20 |
| 20 namespace printing { | 21 namespace printing { |
| 21 | 22 |
| 22 class PdfRenderSettings; | 23 class PdfRenderSettings; |
| 23 struct PwgRasterSettings; | 24 struct PwgRasterSettings; |
| 24 struct PageRange; | 25 struct PageRange; |
| 25 | 26 |
| 26 // Dispatches IPCs for printing. | 27 // Dispatches IPCs for printing. |
| 27 class PrintingHandler : public UtilityMessageHandler { | 28 class PrintingHandler : public UtilityMessageHandler { |
| 28 public: | 29 public: |
| 29 PrintingHandler(); | 30 PrintingHandler(); |
| 30 ~PrintingHandler() override; | 31 ~PrintingHandler() override; |
| 31 | 32 |
| 32 // IPC::Listener: | 33 // IPC::Listener: |
| 33 bool OnMessageReceived(const IPC::Message& message) override; | 34 bool OnMessageReceived(const IPC::Message& message) override; |
| 34 | 35 |
| 35 private: | 36 private: |
| 36 // IPC message handlers. | 37 // IPC message handlers. |
| 37 #if defined(OS_WIN) | 38 #if defined(OS_WIN) |
| 38 void OnRenderPDFPagesToMetafile(IPC::PlatformFileForTransit pdf_transit, | 39 void OnRenderPDFPagesToMetafile(IPC::PlatformFileForTransit pdf_transit, |
| 39 const PdfRenderSettings& settings, | 40 const PdfRenderSettings& settings, |
| 40 bool print_text_with_gdi); | 41 bool print_text_with_gdi); |
| 41 void OnRenderPDFPagesToMetafileGetPage( | 42 void OnRenderPDFPagesToMetafileGetPage( |
| 42 int page_number, | 43 int page_number, |
| 43 IPC::PlatformFileForTransit output_file); | 44 IPC::PlatformFileForTransit output_file); |
| 44 void OnRenderPDFPagesToMetafileStop(); | 45 void OnRenderPDFPagesToMetafileStop(); |
| 45 #endif // OS_WIN | 46 #endif // OS_WIN |
| 46 #if defined(ENABLE_PRINT_PREVIEW) | 47 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) |
| 47 void OnRenderPDFPagesToPWGRaster(IPC::PlatformFileForTransit pdf_transit, | 48 void OnRenderPDFPagesToPWGRaster(IPC::PlatformFileForTransit pdf_transit, |
| 48 const PdfRenderSettings& settings, | 49 const PdfRenderSettings& settings, |
| 49 const PwgRasterSettings& bitmap_settings, | 50 const PwgRasterSettings& bitmap_settings, |
| 50 IPC::PlatformFileForTransit bitmap_transit); | 51 IPC::PlatformFileForTransit bitmap_transit); |
| 51 #endif // ENABLE_PRINT_PREVIEW | 52 #endif // ENABLE_PRINT_PREVIEW |
| 52 | 53 |
| 53 #if defined(OS_WIN) | 54 #if defined(OS_WIN) |
| 54 int LoadPDF(base::File pdf_file); | 55 int LoadPDF(base::File pdf_file); |
| 55 bool RenderPdfPageToMetafile(int page_number, | 56 bool RenderPdfPageToMetafile(int page_number, |
| 56 base::File output_file, | 57 base::File output_file, |
| 57 float* scale_factor); | 58 float* scale_factor); |
| 58 #endif // OS_WIN | 59 #endif // OS_WIN |
| 59 #if defined(ENABLE_PRINT_PREVIEW) | 60 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) |
| 60 bool RenderPDFPagesToPWGRaster(base::File pdf_file, | 61 bool RenderPDFPagesToPWGRaster(base::File pdf_file, |
| 61 const PdfRenderSettings& settings, | 62 const PdfRenderSettings& settings, |
| 62 const PwgRasterSettings& bitmap_settings, | 63 const PwgRasterSettings& bitmap_settings, |
| 63 base::File bitmap_file); | 64 base::File bitmap_file); |
| 64 | 65 |
| 65 void OnGetPrinterCapsAndDefaults(const std::string& printer_name); | 66 void OnGetPrinterCapsAndDefaults(const std::string& printer_name); |
| 66 void OnGetPrinterSemanticCapsAndDefaults(const std::string& printer_name); | 67 void OnGetPrinterSemanticCapsAndDefaults(const std::string& printer_name); |
| 67 #endif // ENABLE_PRINT_PREVIEW | 68 #endif // ENABLE_PRINT_PREVIEW |
| 68 | 69 |
| 69 #if defined(OS_WIN) | 70 #if defined(OS_WIN) |
| 70 std::vector<char> pdf_data_; | 71 std::vector<char> pdf_data_; |
| 71 PdfRenderSettings pdf_rendering_settings_; | 72 PdfRenderSettings pdf_rendering_settings_; |
| 72 #endif | 73 #endif |
| 73 | 74 |
| 74 DISALLOW_COPY_AND_ASSIGN(PrintingHandler); | 75 DISALLOW_COPY_AND_ASSIGN(PrintingHandler); |
| 75 }; | 76 }; |
| 76 | 77 |
| 77 } // namespace printing | 78 } // namespace printing |
| 78 | 79 |
| 79 #endif // CHROME_UTILITY_PRINTING_HANDLER_H_ | 80 #endif // CHROME_UTILITY_PRINTING_HANDLER_H_ |
| OLD | NEW |