Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5642)

Unified Diff: chrome/browser/printing/print_system_task_proxy.cc

Issue 10867004: Notify print preview UI if getting capabilityes failed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/printing/print_system_task_proxy.cc
diff --git a/chrome/browser/printing/print_system_task_proxy.cc b/chrome/browser/printing/print_system_task_proxy.cc
index b0e24340e5ef78460a5e9f0c712de89b20e21bc6..f7390431517a0c349a3ff272cce0800aa92fbb64 100644
--- a/chrome/browser/printing/print_system_task_proxy.cc
+++ b/chrome/browser/printing/print_system_task_proxy.cc
@@ -319,25 +319,21 @@ PrintSystemTaskProxy::~PrintSystemTaskProxy() {
void PrintSystemTaskProxy::GetDefaultPrinter() {
VLOG(1) << "Get default printer start";
- std::string* default_printer = NULL;
- default_printer = new std::string(print_backend_->GetDefaultPrinterName());
-
VLOG(1) << "Get default printer finished, found: "
- << *default_printer;
-
- std::string* cloud_print_data = new std::string;
+ << print_backend_->GetDefaultPrinterName();
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&PrintSystemTaskProxy::SendDefaultPrinter, this,
- default_printer, cloud_print_data));
+ print_backend_->GetDefaultPrinterName(),
+ std::string()));
}
void PrintSystemTaskProxy::SendDefaultPrinter(
- const std::string* default_printer, const std::string* cloud_print_data) {
+ const std::string& default_printer,
+ const std::string& cloud_print_data) {
if (handler_)
- handler_->SendInitialSettings(*default_printer, *cloud_print_data);
- delete default_printer;
+ handler_->SendInitialSettings(default_printer, cloud_print_data);
}
void PrintSystemTaskProxy::EnumeratePrinters() {
@@ -383,8 +379,7 @@ void PrintSystemTaskProxy::SetupPrinterList(ListValue* printers) {
}
#if defined(USE_CUPS)
-// static
-bool PrintSystemTaskProxy::GetPrinterCapabilitiesCUPS(
+bool PrintSystemTaskProxy::ParsePrinterCapabilities(
Albert Bodenhamer 2012/08/22 01:02:23 Prototype is the same on all platforms. Move the
Vitaly Buka (NO REVIEWS) 2012/08/22 02:58:02 Done.
const printing::PrinterCapsAndDefaults& printer_info,
const std::string& printer_name,
bool* set_color_as_default,
@@ -454,11 +449,12 @@ bool PrintSystemTaskProxy::GetPrinterCapabilitiesCUPS(
file_util::Delete(ppd_file_path, false);
return true;
}
-#endif // defined(USE_CUPS)
-#if defined(OS_WIN)
-void PrintSystemTaskProxy::GetPrinterCapabilitiesWin(
+#elif defined(OS_WIN)
+
+bool PrintSystemTaskProxy::ParsePrinterCapabilities(
const printing::PrinterCapsAndDefaults& printer_info,
+ const std::string& printer_name,
bool* set_color_as_default,
int* printer_color_space_for_color,
int* printer_color_space_for_black,
@@ -495,6 +491,21 @@ void PrintSystemTaskProxy::GetPrinterCapabilitiesWin(
*default_duplex_setting_value = printing::SIMPLEX;
}
}
+ return true;
+}
+
+#else
+
+bool PrintSystemTaskProxy::ParsePrinterCapabilities(
+ const printing::PrinterCapsAndDefaults& printer_info,
+ const std::string& printer_name,
+ bool* set_color_as_default,
+ int* printer_color_space_for_color,
+ int* printer_color_space_for_black,
+ bool* set_duplex_as_default,
+ int* default_duplex_setting_value) {
+ NOTIMPLEMENTED();
+ return false;
}
#endif // defined(OS_WIN)
@@ -511,28 +522,20 @@ void PrintSystemTaskProxy::GetPrinterCapabilities(
int default_duplex_setting_value = printing::UNKNOWN_DUPLEX_MODE;
printing::PrinterCapsAndDefaults printer_info;
- if (print_backend_->GetPrinterCapsAndDefaults(printer_name,
- &printer_info)) {
-#if defined(USE_CUPS)
- if (!GetPrinterCapabilitiesCUPS(printer_info,
- printer_name,
- &set_color_as_default,
- &printer_color_space_for_color,
- &printer_color_space_for_black,
- &set_duplex_as_default,
- &default_duplex_setting_value)) {
- return;
- }
-#elif defined(OS_WIN)
- GetPrinterCapabilitiesWin(printer_info,
- &set_color_as_default,
- &printer_color_space_for_color,
- &printer_color_space_for_black,
- &set_duplex_as_default,
- &default_duplex_setting_value);
-#else
- NOTIMPLEMENTED();
-#endif
+ if (!print_backend_->GetPrinterCapsAndDefaults(printer_name,
+ &printer_info) ||
+ !ParsePrinterCapabilities(printer_info,
+ printer_name,
+ &set_color_as_default,
+ &printer_color_space_for_color,
+ &printer_color_space_for_black,
+ &set_duplex_as_default,
+ &default_duplex_setting_value)) {
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&PrintSystemTaskProxy::SendFailedToGetPrinterCapabilities,
+ this, printer_name));
+ return;
}
bool disable_color_options = (!printer_color_space_for_color ||
!printer_color_space_for_black ||
@@ -569,3 +572,9 @@ void PrintSystemTaskProxy::SendPrinterCapabilities(
handler_->SendPrinterCapabilities(*settings_info);
delete settings_info;
}
+
+void PrintSystemTaskProxy::SendFailedToGetPrinterCapabilities(
+ const std::string& printer_name) {
+ if (handler_)
+ handler_->SendFailedToGetPrinterCapabilities(printer_name);
Robert Toscano 2012/08/22 01:05:31 Is it Google C++ to leave off curlies on one-liner
Albert Bodenhamer 2012/08/22 01:09:41 It's the preferred Chrome style. I personally dis
Vitaly Buka (NO REVIEWS) 2012/08/22 02:58:02 Both styles are allowed.
+}

Powered by Google App Engine
This is Rietveld 408576698