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 #ifndef PRINTING_BACKEND_WIN_HELPER_H_ | 5 #ifndef PRINTING_BACKEND_WIN_HELPER_H_ |
6 #define PRINTING_BACKEND_WIN_HELPER_H_ | 6 #define PRINTING_BACKEND_WIN_HELPER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <objidl.h> | 9 #include <objidl.h> |
10 #include <winspool.h> | 10 #include <winspool.h> |
11 #include <prntvpt.h> | 11 #include <prntvpt.h> |
12 #include <xpsprint.h> | 12 #include <xpsprint.h> |
13 | 13 |
14 #include <string> | 14 #include <string> |
15 | 15 |
16 #include "base/memory/scoped_ptr.h" | |
17 #include "base/string16.h" | 16 #include "base/string16.h" |
18 #include "base/win/scoped_handle.h" | 17 #include "base/win/scoped_handle.h" |
19 #include "printing/printing_export.h" | 18 #include "printing/printing_export.h" |
20 | 19 |
21 // These are helper functions for dealing with Windows Printing. | 20 // These are helper functions for dealing with Windows Printing. |
22 namespace printing { | 21 namespace printing { |
23 | 22 |
24 struct PRINTING_EXPORT PrinterBasicInfo; | 23 struct PRINTING_EXPORT PrinterBasicInfo; |
25 | 24 |
26 class PrinterHandleTraits { | 25 class PrinterHandleTraits { |
(...skipping 24 matching lines...) Expand all Loading... |
51 // this would mean having to add that to every binary that links with | 50 // this would mean having to add that to every binary that links with |
52 // printing.lib (which is a LOT of binaries). So choosing the GetProcAddress | 51 // printing.lib (which is a LOT of binaries). So choosing the GetProcAddress |
53 // route instead). | 52 // route instead). |
54 class PRINTING_EXPORT XPSModule { | 53 class PRINTING_EXPORT XPSModule { |
55 public: | 54 public: |
56 // All the other methods can ONLY be called after a successful call to Init. | 55 // All the other methods can ONLY be called after a successful call to Init. |
57 // Init can be called many times and by multiple threads. | 56 // Init can be called many times and by multiple threads. |
58 static bool Init(); | 57 static bool Init(); |
59 static HRESULT OpenProvider(const string16& printer_name, | 58 static HRESULT OpenProvider(const string16& printer_name, |
60 DWORD version, | 59 DWORD version, |
61 HPTPROVIDER *provider); | 60 HPTPROVIDER* provider); |
62 static HRESULT GetPrintCapabilities(HPTPROVIDER provider, | 61 static HRESULT GetPrintCapabilities(HPTPROVIDER provider, |
63 IStream *print_ticket, | 62 IStream* print_ticket, |
64 IStream *capabilities, | 63 IStream* capabilities, |
65 BSTR* error_message); | 64 BSTR* error_message); |
66 static HRESULT ConvertDevModeToPrintTicket(HPTPROVIDER provider, | 65 static HRESULT ConvertDevModeToPrintTicket(HPTPROVIDER provider, |
67 ULONG devmode_size_in_bytes, | 66 ULONG devmode_size_in_bytes, |
68 PDEVMODE devmode, | 67 PDEVMODE devmode, |
69 EPrintTicketScope scope, | 68 EPrintTicketScope scope, |
70 IStream* print_ticket); | 69 IStream* print_ticket); |
71 static HRESULT ConvertPrintTicketToDevMode( | 70 static HRESULT ConvertPrintTicketToDevMode( |
72 HPTPROVIDER provider, | 71 HPTPROVIDER provider, |
73 IStream* print_ticket, | 72 IStream* print_ticket, |
74 EDefaultDevmodeType base_devmode_type, | 73 EDefaultDevmodeType base_devmode_type, |
75 EPrintTicketScope scope, | 74 EPrintTicketScope scope, |
76 ULONG* devmode_byte_count, | 75 ULONG* devmode_byte_count, |
77 PDEVMODE *devmode, | 76 PDEVMODE* devmode, |
78 BSTR* error_message); | 77 BSTR* error_message); |
79 static HRESULT MergeAndValidatePrintTicket(HPTPROVIDER provider, | 78 static HRESULT MergeAndValidatePrintTicket(HPTPROVIDER provider, |
80 IStream* base_ticket, | 79 IStream* base_ticket, |
81 IStream* delta_ticket, | 80 IStream* delta_ticket, |
82 EPrintTicketScope scope, | 81 EPrintTicketScope scope, |
83 IStream* result_ticket, | 82 IStream* result_ticket, |
84 BSTR* error_message); | 83 BSTR* error_message); |
85 static HRESULT ReleaseMemory(PVOID buffer); | 84 static HRESULT ReleaseMemory(PVOID buffer); |
86 static HRESULT CloseProvider(HPTPROVIDER provider); | 85 static HRESULT CloseProvider(HPTPROVIDER provider); |
| 86 |
87 private: | 87 private: |
88 XPSModule() { } | 88 XPSModule() { } |
89 static bool InitImpl(); | 89 static bool InitImpl(); |
90 }; | 90 }; |
91 | 91 |
92 // See comments in cc file explaining why we need this. | 92 // See comments in cc file explaining why we need this. |
93 class PRINTING_EXPORT ScopedXPSInitializer { | 93 class PRINTING_EXPORT ScopedXPSInitializer { |
94 public: | 94 public: |
95 ScopedXPSInitializer(); | 95 ScopedXPSInitializer(); |
96 ~ScopedXPSInitializer(); | 96 ~ScopedXPSInitializer(); |
(...skipping 11 matching lines...) Expand all Loading... |
108 public: | 108 public: |
109 // All the other methods can ONLY be called after a successful call to Init. | 109 // All the other methods can ONLY be called after a successful call to Init. |
110 // Init can be called many times and by multiple threads. | 110 // Init can be called many times and by multiple threads. |
111 static bool Init(); | 111 static bool Init(); |
112 static HRESULT StartXpsPrintJob( | 112 static HRESULT StartXpsPrintJob( |
113 const LPCWSTR printer_name, | 113 const LPCWSTR printer_name, |
114 const LPCWSTR job_name, | 114 const LPCWSTR job_name, |
115 const LPCWSTR output_file_name, | 115 const LPCWSTR output_file_name, |
116 HANDLE progress_event, | 116 HANDLE progress_event, |
117 HANDLE completion_event, | 117 HANDLE completion_event, |
118 UINT8 *printable_pages_on, | 118 UINT8* printable_pages_on, |
119 UINT32 printable_pages_on_count, | 119 UINT32 printable_pages_on_count, |
120 IXpsPrintJob **xps_print_job, | 120 IXpsPrintJob **xps_print_job, |
121 IXpsPrintJobStream **document_stream, | 121 IXpsPrintJobStream **document_stream, |
122 IXpsPrintJobStream **print_ticket_stream); | 122 IXpsPrintJobStream **print_ticket_stream); |
123 private: | 123 private: |
124 XPSPrintModule() { } | 124 XPSPrintModule() { } |
125 static bool InitImpl(); | 125 static bool InitImpl(); |
126 }; | 126 }; |
127 | 127 |
128 PRINTING_EXPORT bool InitBasicPrinterInfo(HANDLE printer, | 128 PRINTING_EXPORT bool InitBasicPrinterInfo(HANDLE printer, |
129 PrinterBasicInfo* printer_info); | 129 PrinterBasicInfo* printer_info); |
130 | 130 |
131 PRINTING_EXPORT std::string GetDriverInfo(HANDLE printer); | 131 PRINTING_EXPORT std::string GetDriverInfo(HANDLE printer); |
132 | 132 |
133 } // namespace printing | 133 } // namespace printing |
134 | 134 |
135 #endif // PRINTING_BACKEND_WIN_HELPER_H_ | 135 #endif // PRINTING_BACKEND_WIN_HELPER_H_ |
OLD | NEW |