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 "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #include <dlfcn.h> | 9 #include <dlfcn.h> |
10 #include <errno.h> | 10 #include <errno.h> |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 static const char kCUPSPrinterMakeModelOpt[] = "printer-make-and-model"; | 101 static const char kCUPSPrinterMakeModelOpt[] = "printer-make-and-model"; |
102 | 102 |
103 class PrintBackendCUPS : public PrintBackend { | 103 class PrintBackendCUPS : public PrintBackend { |
104 public: | 104 public: |
105 PrintBackendCUPS(const GURL& print_server_url, | 105 PrintBackendCUPS(const GURL& print_server_url, |
106 http_encryption_t encryption, bool blocking); | 106 http_encryption_t encryption, bool blocking); |
107 | 107 |
108 // PrintBackend implementation. | 108 // PrintBackend implementation. |
109 virtual bool EnumeratePrinters(PrinterList* printer_list) OVERRIDE; | 109 virtual bool EnumeratePrinters(PrinterList* printer_list) OVERRIDE; |
110 virtual std::string GetDefaultPrinterName() OVERRIDE; | 110 virtual std::string GetDefaultPrinterName() OVERRIDE; |
| 111 virtual bool GetPrinterSemanticCapsAndDefaults( |
| 112 const std::string& printer_name, |
| 113 PrinterSemanticCapsAndDefaults* printer_info) OVERRIDE; |
111 virtual bool GetPrinterCapsAndDefaults( | 114 virtual bool GetPrinterCapsAndDefaults( |
112 const std::string& printer_name, | 115 const std::string& printer_name, |
113 PrinterCapsAndDefaults* printer_info) OVERRIDE; | 116 PrinterCapsAndDefaults* printer_info) OVERRIDE; |
114 virtual std::string GetPrinterDriverInfo( | 117 virtual std::string GetPrinterDriverInfo( |
115 const std::string& printer_name) OVERRIDE; | 118 const std::string& printer_name) OVERRIDE; |
116 virtual bool IsValidPrinter(const std::string& printer_name) OVERRIDE; | 119 virtual bool IsValidPrinter(const std::string& printer_name) OVERRIDE; |
117 | 120 |
118 protected: | 121 protected: |
119 virtual ~PrintBackendCUPS() {} | 122 virtual ~PrintBackendCUPS() {} |
120 | 123 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 } | 206 } |
204 | 207 |
205 std::string PrintBackendCUPS::GetDefaultPrinterName() { | 208 std::string PrintBackendCUPS::GetDefaultPrinterName() { |
206 // Not using cupsGetDefault() because it lies about the default printer. | 209 // Not using cupsGetDefault() because it lies about the default printer. |
207 cups_dest_t* dests; | 210 cups_dest_t* dests; |
208 int num_dests = GetDests(&dests); | 211 int num_dests = GetDests(&dests); |
209 cups_dest_t* dest = cupsGetDest(NULL, NULL, num_dests, dests); | 212 cups_dest_t* dest = cupsGetDest(NULL, NULL, num_dests, dests); |
210 return dest ? std::string(dest->name) : std::string(); | 213 return dest ? std::string(dest->name) : std::string(); |
211 } | 214 } |
212 | 215 |
| 216 bool PrintBackendCUPS::GetPrinterSemanticCapsAndDefaults( |
| 217 const std::string& printer_name, |
| 218 PrinterSemanticCapsAndDefaults* printer_info) { |
| 219 PrinterCapsAndDefaults info; |
| 220 if (!GetPrinterCapsAndDefaults(printer_name, &info) ) |
| 221 return false; |
| 222 |
| 223 return parsePpdCapabilities( |
| 224 printer_name, info.printer_capabilities, printer_info); |
| 225 } |
| 226 |
213 bool PrintBackendCUPS::GetPrinterCapsAndDefaults( | 227 bool PrintBackendCUPS::GetPrinterCapsAndDefaults( |
214 const std::string& printer_name, | 228 const std::string& printer_name, |
215 PrinterCapsAndDefaults* printer_info) { | 229 PrinterCapsAndDefaults* printer_info) { |
216 DCHECK(printer_info); | 230 DCHECK(printer_info); |
217 | 231 |
218 VLOG(1) << "CUPS: Getting caps and defaults" | 232 VLOG(1) << "CUPS: Getting caps and defaults" |
219 << ", printer name: " << printer_name; | 233 << ", printer name: " << printer_name; |
220 | 234 |
221 FilePath ppd_path(GetPPD(printer_name.c_str())); | 235 FilePath ppd_path(GetPPD(printer_name.c_str())); |
222 // In some cases CUPS failed to get ppd file. | 236 // In some cases CUPS failed to get ppd file. |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 << ", HTTP error: " << http_error; | 367 << ", HTTP error: " << http_error; |
354 file_util::Delete(ppd_path, false); | 368 file_util::Delete(ppd_path, false); |
355 ppd_path.clear(); | 369 ppd_path.clear(); |
356 } | 370 } |
357 } | 371 } |
358 } | 372 } |
359 return ppd_path; | 373 return ppd_path; |
360 } | 374 } |
361 | 375 |
362 } // namespace printing | 376 } // namespace printing |
OLD | NEW |