| 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 #include "printing/backend/print_backend.h" | 5 #include "printing/backend/print_backend.h" |
| 6 | 6 |
| 7 #include <objidl.h> | 7 #include <objidl.h> |
| 8 #include <winspool.h> | 8 #include <winspool.h> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 return hr; | 31 return hr; |
| 32 } | 32 } |
| 33 | 33 |
| 34 } // namespace | 34 } // namespace |
| 35 | 35 |
| 36 namespace printing { | 36 namespace printing { |
| 37 | 37 |
| 38 class PrintBackendWin : public PrintBackend { | 38 class PrintBackendWin : public PrintBackend { |
| 39 public: | 39 public: |
| 40 PrintBackendWin() {} | 40 PrintBackendWin() {} |
| 41 |
| 42 // PrintBackend implementation. |
| 43 virtual bool EnumeratePrinters(PrinterList* printer_list) OVERRIDE; |
| 44 virtual std::string GetDefaultPrinterName() OVERRIDE; |
| 45 virtual bool GetPrinterCapsAndDefaults( |
| 46 const std::string& printer_name, |
| 47 PrinterCapsAndDefaults* printer_info) OVERRIDE; |
| 48 virtual std::string GetPrinterDriverInfo( |
| 49 const std::string& printer_name) OVERRIDE; |
| 50 virtual bool IsValidPrinter(const std::string& printer_name) OVERRIDE; |
| 51 |
| 52 protected: |
| 41 virtual ~PrintBackendWin() {} | 53 virtual ~PrintBackendWin() {} |
| 42 | |
| 43 virtual bool EnumeratePrinters(PrinterList* printer_list); | |
| 44 | |
| 45 virtual std::string GetDefaultPrinterName(); | |
| 46 | |
| 47 virtual bool GetPrinterCapsAndDefaults(const std::string& printer_name, | |
| 48 PrinterCapsAndDefaults* printer_info); | |
| 49 | |
| 50 virtual std::string GetPrinterDriverInfo(const std::string& printer_name); | |
| 51 | |
| 52 virtual bool IsValidPrinter(const std::string& printer_name); | |
| 53 }; | 54 }; |
| 54 | 55 |
| 55 bool PrintBackendWin::EnumeratePrinters(PrinterList* printer_list) { | 56 bool PrintBackendWin::EnumeratePrinters(PrinterList* printer_list) { |
| 56 DCHECK(printer_list); | 57 DCHECK(printer_list); |
| 57 DWORD bytes_needed = 0; | 58 DWORD bytes_needed = 0; |
| 58 DWORD count_returned = 0; | 59 DWORD count_returned = 0; |
| 59 const DWORD kLevel = 4; | 60 const DWORD kLevel = 4; |
| 60 BOOL ret = EnumPrinters(PRINTER_ENUM_LOCAL|PRINTER_ENUM_CONNECTIONS, NULL, | 61 BOOL ret = EnumPrinters(PRINTER_ENUM_LOCAL|PRINTER_ENUM_CONNECTIONS, NULL, |
| 61 kLevel, NULL, 0, &bytes_needed, &count_returned); | 62 kLevel, NULL, 0, &bytes_needed, &count_returned); |
| 62 if (!bytes_needed) | 63 if (!bytes_needed) |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 printer_handle.Receive(), NULL); | 186 printer_handle.Receive(), NULL); |
| 186 return printer_handle.IsValid(); | 187 return printer_handle.IsValid(); |
| 187 } | 188 } |
| 188 | 189 |
| 189 scoped_refptr<PrintBackend> PrintBackend::CreateInstance( | 190 scoped_refptr<PrintBackend> PrintBackend::CreateInstance( |
| 190 const base::DictionaryValue* print_backend_settings) { | 191 const base::DictionaryValue* print_backend_settings) { |
| 191 return new PrintBackendWin; | 192 return new PrintBackendWin; |
| 192 } | 193 } |
| 193 | 194 |
| 194 } // namespace printing | 195 } // namespace printing |
| OLD | NEW |