Chromium Code Reviews| Index: printing/backend/print_backend_cups.cc |
| diff --git a/printing/backend/print_backend_cups.cc b/printing/backend/print_backend_cups.cc |
| index 9a17ddf4c39d57ea9431a857c5259c976a5cffef..16336f8a152f3af874711836675dd815400358e2 100644 |
| --- a/printing/backend/print_backend_cups.cc |
| +++ b/printing/backend/print_backend_cups.cc |
| @@ -98,6 +98,7 @@ namespace printing { |
| static const char kCUPSPrinterInfoOpt[] = "printer-info"; |
| static const char kCUPSPrinterStateOpt[] = "printer-state"; |
| static const char kCUPSPrinterTypeOpt[] = "printer-type"; |
| +static const char kCUPSPrinterMakeModelOpt[] = "printer-make-and-model"; |
| class PrintBackendCUPS : public PrintBackend { |
| public: |
| @@ -113,8 +114,8 @@ class PrintBackendCUPS : public PrintBackend { |
| const std::string& printer_name, |
| PrinterCapsAndDefaults* printer_info) OVERRIDE; |
| - virtual bool GetPrinterDriverInfo(const std::string& printer_name, |
| - std::string* driver_info) OVERRIDE; |
| + virtual std::string GetPrinterDriverInfo( |
| + const std::string& printer_name) OVERRIDE; |
| virtual bool IsValidPrinter(const std::string& printer_name) OVERRIDE; |
| @@ -228,10 +229,32 @@ bool PrintBackendCUPS::GetPrinterCapsAndDefaults( |
| return res; |
| } |
| -bool PrintBackendCUPS::GetPrinterDriverInfo(const std::string& printer_name, |
| - std::string* driver_info) { |
| - // TODO(vitalybuka): MAC implementation. http://crbug.com/108194 |
| - return false; |
| +std::string PrintBackendCUPS::GetPrinterDriverInfo( |
| + const std::string& printer_name) { |
| + cups_dest_t* destinations = NULL; |
| + int num_dests = GetDests(&destinations); |
| + if ((num_dests == 0) && (cupsLastError() > IPP_OK_EVENTS_COMPLETE)) { |
| + VLOG(1) << "CP_CUPS: Error getting printers from CUPS server. Server: " |
| + << print_server_url_ |
| + << " Error: " |
| + << static_cast<int>(cupsLastError()); |
| + return false; |
| + } |
| + |
| + std::string result; |
| + for (int printer_index = 0; printer_index < num_dests; printer_index++) { |
| + const cups_dest_t& printer = destinations[printer_index]; |
| + |
| + if (printer_name = printer.name) { |
| + const char* info = cupsGetOption(kCUPSPrinterMakeModelOpt, printer.num_options, |
|
Albert Bodenhamer
2012/03/13 23:57:39
80 chars
Vitaly Buka (NO REVIEWS)
2012/03/14 00:11:20
Done.
|
| + printer.options); |
| + if (info) |
| + result = *info; |
| + } |
| + } |
| + |
| + cupsFreeDests(num_dests, destinations); |
| + return result; |
| } |
| bool PrintBackendCUPS::IsValidPrinter(const std::string& printer_name) { |