OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/win/scoped_handle.h" |
15 #include "printing/printing_export.h" | 16 #include "printing/printing_export.h" |
16 | 17 |
17 // These are helper functions for dealing with Windows Printing. | 18 // These are helper functions for dealing with Windows Printing. |
18 namespace printing { | 19 namespace printing { |
19 | 20 |
| 21 class PrinterHandleTraits { |
| 22 public: |
| 23 static bool CloseHandle(HANDLE handle) { |
| 24 return ::ClosePrinter(handle) != FALSE; |
| 25 } |
| 26 }; |
| 27 |
| 28 typedef base::win::GenericScopedHandle<PrinterHandleTraits> ScopedPrinterHandle; |
| 29 |
| 30 |
20 // Wrapper class to wrap the XPS APIs (PTxxx APIs). This is needed because these | 31 // Wrapper class to wrap the XPS APIs (PTxxx APIs). This is needed because these |
21 // APIs are not available by default on XP. We could delayload prntvpt.dll but | 32 // APIs are not available by default on XP. We could delayload prntvpt.dll but |
22 // this would mean having to add that to every binary that links with | 33 // this would mean having to add that to every binary that links with |
23 // printing.lib (which is a LOT of binaries). So choosing the GetProcAddress | 34 // printing.lib (which is a LOT of binaries). So choosing the GetProcAddress |
24 // route instead). | 35 // route instead). |
25 class PRINTING_EXPORT XPSModule { | 36 class PRINTING_EXPORT XPSModule { |
26 public: | 37 public: |
27 // All the other methods can ONLY be called after a successful call to Init. | 38 // All the other methods can ONLY be called after a successful call to Init. |
28 // Init can be called many times and by multiple threads. | 39 // Init can be called many times and by multiple threads. |
29 static bool Init(); | 40 static bool Init(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 IXpsPrintJobStream **document_stream, | 103 IXpsPrintJobStream **document_stream, |
93 IXpsPrintJobStream **print_ticket_stream); | 104 IXpsPrintJobStream **print_ticket_stream); |
94 private: | 105 private: |
95 XPSPrintModule() { } | 106 XPSPrintModule() { } |
96 static bool InitImpl(); | 107 static bool InitImpl(); |
97 }; | 108 }; |
98 | 109 |
99 } // namespace printing | 110 } // namespace printing |
100 | 111 |
101 #endif // PRINTING_BACKEND_WIN_HELPER_H_ | 112 #endif // PRINTING_BACKEND_WIN_HELPER_H_ |
OLD | NEW |