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 "chrome/utility/utility_message_handler.h" | 10 #include "chrome/utility/utility_message_handler.h" |
11 #include "ipc/ipc_platform_file.h" | 11 #include "ipc/ipc_platform_file.h" |
| 12 #include "printing/pdf_render_settings.h" |
12 | 13 |
13 #if !defined(ENABLE_FULL_PRINTING) && !defined(OS_WIN) | 14 #if !defined(ENABLE_FULL_PRINTING) && !defined(OS_WIN) |
14 #error "Windows or full printing must be enabled" | 15 #error "Windows or full printing must be enabled" |
15 #endif | 16 #endif |
16 | 17 |
17 namespace printing { | 18 namespace printing { |
18 class PdfRenderSettings; | 19 class PdfRenderSettings; |
19 struct PwgRasterSettings; | 20 struct PwgRasterSettings; |
20 struct PageRange; | 21 struct PageRange; |
21 } | 22 } |
22 | 23 |
23 // Dispatches IPCs for printing. | 24 // Dispatches IPCs for printing. |
24 class PrintingHandler : public UtilityMessageHandler { | 25 class PrintingHandler : public UtilityMessageHandler { |
25 public: | 26 public: |
26 PrintingHandler(); | 27 PrintingHandler(); |
27 virtual ~PrintingHandler(); | 28 virtual ~PrintingHandler(); |
28 | 29 |
29 static void PreSandboxStartup(); | 30 static void PreSandboxStartup(); |
30 | 31 |
31 // IPC::Listener: | 32 // IPC::Listener: |
32 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 33 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
33 | 34 |
34 private: | 35 private: |
35 // IPC message handlers. | 36 // IPC message handlers. |
36 #if defined(OS_WIN) | 37 #if defined(OS_WIN) |
37 void OnRenderPDFPagesToMetafile( | 38 void OnRenderPDFPagesToMetafile(IPC::PlatformFileForTransit pdf_transit, |
38 IPC::PlatformFileForTransit pdf_transit, | 39 const printing::PdfRenderSettings& settings); |
39 const base::FilePath& metafile_path, | 40 void OnRenderPDFPagesToMetafileGetPage( |
40 const printing::PdfRenderSettings& settings, | 41 int page_number, |
41 const std::vector<printing::PageRange>& page_ranges); | 42 IPC::PlatformFileForTransit output_file); |
| 43 void OnRenderPDFPagesToMetafileStop(); |
42 #endif // OS_WIN | 44 #endif // OS_WIN |
43 #if defined(ENABLE_FULL_PRINTING) | 45 #if defined(ENABLE_FULL_PRINTING) |
44 void OnRenderPDFPagesToPWGRaster( | 46 void OnRenderPDFPagesToPWGRaster( |
45 IPC::PlatformFileForTransit pdf_transit, | 47 IPC::PlatformFileForTransit pdf_transit, |
46 const printing::PdfRenderSettings& settings, | 48 const printing::PdfRenderSettings& settings, |
47 const printing::PwgRasterSettings& bitmap_settings, | 49 const printing::PwgRasterSettings& bitmap_settings, |
48 IPC::PlatformFileForTransit bitmap_transit); | 50 IPC::PlatformFileForTransit bitmap_transit); |
49 #endif // ENABLE_FULL_PRINTING | 51 #endif // ENABLE_FULL_PRINTING |
50 | 52 |
51 #if defined(OS_WIN) | 53 #if defined(OS_WIN) |
52 // Helper method for Windows. | 54 int LoadPDF(base::File pdf_file); |
53 // |highest_rendered_page_number| is set to -1 on failure to render any page. | 55 bool RenderPdfPageToMetafile(int page_number, |
54 // |page_ranges| is both input and output. If supplied as input, only the | 56 base::File output_file, |
55 // specified pages will be rendered. If an empty vector is supplied it will | 57 double* scale_factor); |
56 // be filled with a range of all pages that were rendered. | |
57 bool RenderPDFToWinMetafile( | |
58 base::File pdf_file, | |
59 const base::FilePath& metafile_path, | |
60 const printing::PdfRenderSettings& settings, | |
61 std::vector<printing::PageRange>* page_ranges, | |
62 int* highest_rendered_page_number, | |
63 double* scale_factor); | |
64 #endif // OS_WIN | 58 #endif // OS_WIN |
65 #if defined(ENABLE_FULL_PRINTING) | 59 #if defined(ENABLE_FULL_PRINTING) |
66 bool RenderPDFPagesToPWGRaster( | 60 bool RenderPDFPagesToPWGRaster( |
67 base::File pdf_file, | 61 base::File pdf_file, |
68 const printing::PdfRenderSettings& settings, | 62 const printing::PdfRenderSettings& settings, |
69 const printing::PwgRasterSettings& bitmap_settings, | 63 const printing::PwgRasterSettings& bitmap_settings, |
70 base::File bitmap_file); | 64 base::File bitmap_file); |
71 | 65 |
72 void OnGetPrinterCapsAndDefaults(const std::string& printer_name); | 66 void OnGetPrinterCapsAndDefaults(const std::string& printer_name); |
73 void OnGetPrinterSemanticCapsAndDefaults(const std::string& printer_name); | 67 void OnGetPrinterSemanticCapsAndDefaults(const std::string& printer_name); |
74 #endif // ENABLE_FULL_PRINTING | 68 #endif // ENABLE_FULL_PRINTING |
75 | 69 |
| 70 #if defined(OS_WIN) |
| 71 std::vector<char> pdf_data_; |
| 72 printing::PdfRenderSettings pdf_rendering_settings_; |
| 73 #endif |
| 74 |
76 DISALLOW_COPY_AND_ASSIGN(PrintingHandler); | 75 DISALLOW_COPY_AND_ASSIGN(PrintingHandler); |
77 }; | 76 }; |
78 | 77 |
79 #endif // CHROME_UTILITY_PRINTING_HANDLER_H_ | 78 #endif // CHROME_UTILITY_PRINTING_HANDLER_H_ |
OLD | NEW |