Chromium Code Reviews| 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 "base/string16.h" | 14 #include "base/string16.h" |
| 15 #include "base/win/scoped_handle.h" | 15 #include "base/win/scoped_handle.h" |
| 16 #include "printing/printing_export.h" | 16 #include "printing/printing_export.h" |
| 17 | 17 |
| 18 // These are helper functions for dealing with Windows Printing. | 18 // These are helper functions for dealing with Windows Printing. |
| 19 namespace printing { | 19 namespace printing { |
| 20 | 20 |
| 21 class PrinterHandleTraits { | 21 class PrinterHandleTraits { |
|
Vitaly Buka (NO REVIEWS)
2012/03/05 18:52:14
PrinterHandleTraits : public HandleTraits {
Clos
alexeypa (please no reviews)
2012/03/05 18:56:58
The same thing, trait classes are unrelated in thi
| |
| 22 public: | 22 public: |
| 23 typedef HANDLE Handle; | |
| 24 | |
| 23 static bool CloseHandle(HANDLE handle) { | 25 static bool CloseHandle(HANDLE handle) { |
| 24 return ::ClosePrinter(handle) != FALSE; | 26 return ::ClosePrinter(handle) != FALSE; |
| 25 } | 27 } |
| 28 | |
| 29 static bool IsHandleValid(HANDLE handle) { | |
| 30 return handle != NULL; | |
| 31 } | |
| 32 | |
| 33 static HANDLE NullHandle() { | |
| 34 return NULL; | |
| 35 } | |
| 36 | |
| 37 private: | |
| 38 DISALLOW_IMPLICIT_CONSTRUCTORS(PrinterHandleTraits); | |
| 26 }; | 39 }; |
| 27 | 40 |
| 28 typedef base::win::GenericScopedHandle<PrinterHandleTraits> ScopedPrinterHandle; | 41 typedef base::win::GenericScopedHandle<PrinterHandleTraits> ScopedPrinterHandle; |
| 29 | 42 |
| 30 | 43 |
| 31 // Wrapper class to wrap the XPS APIs (PTxxx APIs). This is needed because these | 44 // Wrapper class to wrap the XPS APIs (PTxxx APIs). This is needed because these |
| 32 // APIs are not available by default on XP. We could delayload prntvpt.dll but | 45 // APIs are not available by default on XP. We could delayload prntvpt.dll but |
| 33 // this would mean having to add that to every binary that links with | 46 // this would mean having to add that to every binary that links with |
| 34 // printing.lib (which is a LOT of binaries). So choosing the GetProcAddress | 47 // printing.lib (which is a LOT of binaries). So choosing the GetProcAddress |
| 35 // route instead). | 48 // route instead). |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 IXpsPrintJobStream **document_stream, | 116 IXpsPrintJobStream **document_stream, |
| 104 IXpsPrintJobStream **print_ticket_stream); | 117 IXpsPrintJobStream **print_ticket_stream); |
| 105 private: | 118 private: |
| 106 XPSPrintModule() { } | 119 XPSPrintModule() { } |
| 107 static bool InitImpl(); | 120 static bool InitImpl(); |
| 108 }; | 121 }; |
| 109 | 122 |
| 110 } // namespace printing | 123 } // namespace printing |
| 111 | 124 |
| 112 #endif // PRINTING_BACKEND_WIN_HELPER_H_ | 125 #endif // PRINTING_BACKEND_WIN_HELPER_H_ |
| OLD | NEW |