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 #include "printing/backend/print_backend.h" | 5 #include "printing/backend/print_backend.h" |
6 | 6 |
7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #if !defined(OS_MACOSX) | 9 #if !defined(OS_MACOSX) |
10 #include <gcrypt.h> | 10 #include <gcrypt.h> |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 static const char kCUPSPrinterStateOpt[] = "printer-state"; | 79 static const char kCUPSPrinterStateOpt[] = "printer-state"; |
80 | 80 |
81 class PrintBackendCUPS : public PrintBackend { | 81 class PrintBackendCUPS : public PrintBackend { |
82 public: | 82 public: |
83 PrintBackendCUPS(const GURL& print_server_url, bool blocking); | 83 PrintBackendCUPS(const GURL& print_server_url, bool blocking); |
84 virtual ~PrintBackendCUPS() {} | 84 virtual ~PrintBackendCUPS() {} |
85 | 85 |
86 // PrintBackend implementation. | 86 // PrintBackend implementation. |
87 virtual bool EnumeratePrinters(PrinterList* printer_list); | 87 virtual bool EnumeratePrinters(PrinterList* printer_list); |
88 | 88 |
| 89 virtual std::string GetDefaultPrinterName(); |
| 90 |
89 virtual bool GetPrinterCapsAndDefaults(const std::string& printer_name, | 91 virtual bool GetPrinterCapsAndDefaults(const std::string& printer_name, |
90 PrinterCapsAndDefaults* printer_info); | 92 PrinterCapsAndDefaults* printer_info); |
91 | 93 |
92 virtual bool IsValidPrinter(const std::string& printer_name); | 94 virtual bool IsValidPrinter(const std::string& printer_name); |
93 | 95 |
94 private: | 96 private: |
95 // Following functions are wrappers around corresponding CUPS functions. | 97 // Following functions are wrappers around corresponding CUPS functions. |
96 // <functions>2() are called when print server is specified, and plain | 98 // <functions>2() are called when print server is specified, and plain |
97 // version in another case. There is an issue specifing CUPS_HTTP_DEFAULT | 99 // version in another case. There is an issue specifing CUPS_HTTP_DEFAULT |
98 // in the <functions>2(), it does not work in CUPS prior to 1.4. | 100 // in the <functions>2(), it does not work in CUPS prior to 1.4. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 148 |
147 printer_list->push_back(printer_info); | 149 printer_list->push_back(printer_info); |
148 } | 150 } |
149 | 151 |
150 cupsFreeDests(num_dests, destinations); | 152 cupsFreeDests(num_dests, destinations); |
151 | 153 |
152 VLOG(1) << "CUPS: Enumerated " << printer_list->size() << " printers."; | 154 VLOG(1) << "CUPS: Enumerated " << printer_list->size() << " printers."; |
153 return true; | 155 return true; |
154 } | 156 } |
155 | 157 |
| 158 std::string PrintBackendCUPS::GetDefaultPrinterName() { |
| 159 // TODO(thestig) Figure out why cupsGetDefault() lies about the default |
| 160 // printer. :-( |
| 161 // Return an empty string for now. |
| 162 return std::string(); |
| 163 } |
| 164 |
156 bool PrintBackendCUPS::GetPrinterCapsAndDefaults( | 165 bool PrintBackendCUPS::GetPrinterCapsAndDefaults( |
157 const std::string& printer_name, | 166 const std::string& printer_name, |
158 PrinterCapsAndDefaults* printer_info) { | 167 PrinterCapsAndDefaults* printer_info) { |
159 DCHECK(printer_info); | 168 DCHECK(printer_info); |
160 | 169 |
161 VLOG(1) << "CUPS: Getting Caps and Defaults for: " << printer_name; | 170 VLOG(1) << "CUPS: Getting Caps and Defaults for: " << printer_name; |
162 | 171 |
163 FilePath ppd_path(GetPPD(printer_name.c_str())); | 172 FilePath ppd_path(GetPPD(printer_name.c_str())); |
164 // In some cases CUPS failed to get ppd file. | 173 // In some cases CUPS failed to get ppd file. |
165 if (ppd_path.empty()) { | 174 if (ppd_path.empty()) { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 << ", HTTP error: " << http_error; | 277 << ", HTTP error: " << http_error; |
269 file_util::Delete(ppd_path, false); | 278 file_util::Delete(ppd_path, false); |
270 ppd_path.clear(); | 279 ppd_path.clear(); |
271 } | 280 } |
272 } | 281 } |
273 } | 282 } |
274 return ppd_path; | 283 return ppd_path; |
275 } | 284 } |
276 | 285 |
277 } // namespace printing | 286 } // namespace printing |
OLD | NEW |