Chromium Code Reviews| Index: chrome/service/cloud_print/print_system_cups.cc |
| =================================================================== |
| --- chrome/service/cloud_print/print_system_cups.cc (revision 72357) |
| +++ chrome/service/cloud_print/print_system_cups.cc (working copy) |
| @@ -28,9 +28,11 @@ |
| #include "chrome/service/cloud_print/cloud_print_consts.h" |
| #include "chrome/service/cloud_print/cloud_print_helpers.h" |
| #include "googleurl/src/gurl.h" |
| +#include "grit/generated_resources.h" |
| #include "printing/backend/cups_helper.h" |
| #include "printing/backend/print_backend.h" |
| #include "printing/backend/print_backend_consts.h" |
| +#include "ui/base/l10n/l10n_util.h" |
| namespace { |
| static const char kCUPSPrinterInfoOpt[] = "printer-info"; |
| @@ -73,7 +75,8 @@ |
| // PrintSystem implementation. |
| virtual PrintSystemResult Init(); |
| - virtual void EnumeratePrinters(printing::PrinterList* printer_list); |
| + virtual PrintSystem::PrintSystemResult EnumeratePrinters( |
| + printing::PrinterList* printer_list); |
| virtual void GetPrinterCapsAndDefaults( |
| const std::string& printer_name, |
| @@ -151,6 +154,9 @@ |
| int update_timeout_; |
| bool initialized_; |
| + // A comma separated string of print server names for which enumeration of |
| + // printers failed. This is used to prepare a diagnostic error message. |
| + std::string enum_failed_server_list_; |
|
gene1
2011/01/24 19:46:47
Can we keep it as a bool flag?
I understand that i
Scott Byer
2011/01/24 20:02:07
Since it's not being used, how about making it a b
|
| }; |
| class PrintServerWatcherCUPS |
| @@ -412,8 +418,12 @@ |
| void PrintSystemCUPS::UpdatePrinters() { |
| PrintServerList::iterator it; |
| + enum_failed_server_list_.clear(); |
| for (it = print_servers_.begin(); it != print_servers_.end(); ++it) { |
| - it->backend->EnumeratePrinters(&it->printers); |
| + if (!it->backend->EnumeratePrinters(&it->printers)) { |
| + enum_failed_server_list_.append(it->url.spec()); |
| + enum_failed_server_list_.append(","); |
| + } |
| it->caps_cache.clear(); |
| printing::PrinterList::iterator printer_it; |
| for (printer_it = it->printers.begin(); |
| @@ -431,7 +441,8 @@ |
| GetUpdateTimeoutMs()); |
| } |
| -void PrintSystemCUPS::EnumeratePrinters(printing::PrinterList* printer_list) { |
| +PrintSystem::PrintSystemResult PrintSystemCUPS::EnumeratePrinters( |
| + printing::PrinterList* printer_list) { |
| DCHECK(initialized_); |
| printer_list->clear(); |
| PrintServerList::iterator it; |
| @@ -440,6 +451,13 @@ |
| it->printers.begin(), it->printers.end()); |
| } |
| VLOG(1) << "CUPS: Total " << printer_list->size() << " printers enumerated."; |
| + if (!enum_failed_server_list_.empty()) { |
| + // The enumeration failed on some servers. |
| + // TODO(sanjeevr): Maybe some day we want to report the actual server names. |
| + std::string message = l10n_util::GetStringUTF8(IDS_CLOUD_PRINT_ENUM_FAILED); |
| + return PrintSystemResult(false, message); |
| + } |
| + return PrintSystemResult(true, std::string()); |
| } |
| void PrintSystemCUPS::GetPrinterCapsAndDefaults( |