OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/string16.h" | 14 #include "base/string16.h" |
| 15 #include "printing/printing_export.h" |
15 | 16 |
16 // These are helper functions for dealing with Windows Printing. | 17 // These are helper functions for dealing with Windows Printing. |
17 namespace printing { | 18 namespace printing { |
18 | 19 |
19 // Wrapper class to wrap the XPS APIs (PTxxx APIs). This is needed because these | 20 // Wrapper class to wrap the XPS APIs (PTxxx APIs). This is needed because these |
20 // APIs are not available by default on XP. We could delayload prntvpt.dll but | 21 // APIs are not available by default on XP. We could delayload prntvpt.dll but |
21 // this would mean having to add that to every binary that links with | 22 // this would mean having to add that to every binary that links with |
22 // printing.lib (which is a LOT of binaries). So choosing the GetProcAddress | 23 // printing.lib (which is a LOT of binaries). So choosing the GetProcAddress |
23 // route instead). | 24 // route instead). |
24 class XPSModule { | 25 class PRINTING_EXPORT XPSModule { |
25 public: | 26 public: |
26 // All the other methods can ONLY be called after a successful call to Init. | 27 // All the other methods can ONLY be called after a successful call to Init. |
27 // Init can be called many times and by multiple threads. | 28 // Init can be called many times and by multiple threads. |
28 static bool Init(); | 29 static bool Init(); |
29 static HRESULT OpenProvider(const string16& printer_name, | 30 static HRESULT OpenProvider(const string16& printer_name, |
30 DWORD version, | 31 DWORD version, |
31 HPTPROVIDER *provider); | 32 HPTPROVIDER *provider); |
32 static HRESULT GetPrintCapabilities(HPTPROVIDER provider, | 33 static HRESULT GetPrintCapabilities(HPTPROVIDER provider, |
33 IStream *print_ticket, | 34 IStream *print_ticket, |
34 IStream *capabilities, | 35 IStream *capabilities, |
(...skipping 18 matching lines...) Expand all Loading... |
53 IStream* result_ticket, | 54 IStream* result_ticket, |
54 BSTR* error_message); | 55 BSTR* error_message); |
55 static HRESULT ReleaseMemory(PVOID buffer); | 56 static HRESULT ReleaseMemory(PVOID buffer); |
56 static HRESULT CloseProvider(HPTPROVIDER provider); | 57 static HRESULT CloseProvider(HPTPROVIDER provider); |
57 private: | 58 private: |
58 XPSModule() { } | 59 XPSModule() { } |
59 static bool InitImpl(); | 60 static bool InitImpl(); |
60 }; | 61 }; |
61 | 62 |
62 // See comments in cc file explaining why we need this. | 63 // See comments in cc file explaining why we need this. |
63 class ScopedXPSInitializer { | 64 class PRINTING_EXPORT ScopedXPSInitializer { |
64 public: | 65 public: |
65 ScopedXPSInitializer(); | 66 ScopedXPSInitializer(); |
66 ~ScopedXPSInitializer(); | 67 ~ScopedXPSInitializer(); |
67 | 68 |
68 bool initialized() const { return initialized_; } | 69 bool initialized() const { return initialized_; } |
69 | 70 |
70 private: | 71 private: |
71 bool initialized_; | 72 bool initialized_; |
72 }; | 73 }; |
73 | 74 |
74 // Wrapper class to wrap the XPS Print APIs (these are different from the PTxxx | 75 // Wrapper class to wrap the XPS Print APIs (these are different from the PTxxx |
75 // which deal with the XML Print Schema). This is needed because these | 76 // which deal with the XML Print Schema). This is needed because these |
76 // APIs are only available on Windows 7 and higher. | 77 // APIs are only available on Windows 7 and higher. |
77 class XPSPrintModule { | 78 class PRINTING_EXPORT XPSPrintModule { |
78 public: | 79 public: |
79 // All the other methods can ONLY be called after a successful call to Init. | 80 // All the other methods can ONLY be called after a successful call to Init. |
80 // Init can be called many times and by multiple threads. | 81 // Init can be called many times and by multiple threads. |
81 static bool Init(); | 82 static bool Init(); |
82 static HRESULT StartXpsPrintJob( | 83 static HRESULT StartXpsPrintJob( |
83 const LPCWSTR printer_name, | 84 const LPCWSTR printer_name, |
84 const LPCWSTR job_name, | 85 const LPCWSTR job_name, |
85 const LPCWSTR output_file_name, | 86 const LPCWSTR output_file_name, |
86 HANDLE progress_event, | 87 HANDLE progress_event, |
87 HANDLE completion_event, | 88 HANDLE completion_event, |
88 UINT8 *printable_pages_on, | 89 UINT8 *printable_pages_on, |
89 UINT32 printable_pages_on_count, | 90 UINT32 printable_pages_on_count, |
90 IXpsPrintJob **xps_print_job, | 91 IXpsPrintJob **xps_print_job, |
91 IXpsPrintJobStream **document_stream, | 92 IXpsPrintJobStream **document_stream, |
92 IXpsPrintJobStream **print_ticket_stream); | 93 IXpsPrintJobStream **print_ticket_stream); |
93 private: | 94 private: |
94 XPSPrintModule() { } | 95 XPSPrintModule() { } |
95 static bool InitImpl(); | 96 static bool InitImpl(); |
96 }; | 97 }; |
97 | 98 |
98 } // namespace printing | 99 } // namespace printing |
99 | 100 |
100 #endif // PRINTING_BACKEND_WIN_HELPER_H_ | 101 #endif // PRINTING_BACKEND_WIN_HELPER_H_ |
OLD | NEW |