Index: chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.js |
diff --git a/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.js b/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.js |
index 0fee051cf95d01558a8fc13a7ede461664bfefbe..aea91eb0e4261c88cd6c248284696f6f0856a883 100644 |
--- a/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.js |
+++ b/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.js |
@@ -84,8 +84,10 @@ Polymer({ |
'on-printer-discovered', this.onPrinterDiscovered_.bind(this)); |
this.addWebUIListener( |
'on-printer-discovery-done', this.onPrinterDiscoveryDone_.bind(this)); |
- this.addWebUIListener( |
- 'on-printer-discovery-failed', this.onPrinterDiscoveryDone_.bind(this)); |
+ }, |
+ |
+ close: function() { |
+ this.$$('add-printer-dialog').close(); |
}, |
/** |
@@ -106,7 +108,10 @@ Polymer({ |
onPrinterDiscoveryDone_: function() { |
this.discovering_ = false; |
this.$$('add-printer-list').style.maxHeight = kPrinterListFullHeight + 'px'; |
- this.$.noPrinterMessage.hidden = !!this.discoveredPrinters; |
+ this.$.noPrinterMessage.hidden = !!this.discoveredPrinters.length; |
+ |
+ if (!this.discoveredPrinters.length) |
+ this.fire('no-detected-printer'); |
}, |
/** @private */ |
@@ -378,6 +383,7 @@ Polymer({ |
'open-configuring-printer-dialog': 'openConfiguringPrinterDialog_', |
'open-discovery-printers-dialog': 'openDiscoveryPrintersDialog_', |
'open-manufacturer-model-dialog': 'openManufacturerModelDialog_', |
+ 'no-detected-printer': 'onNoDetectedPrinter_', |
}, |
/** @override */ |
@@ -510,6 +516,17 @@ Polymer({ |
} |
}, |
+ /** @private */ |
+ onNoDetectedPrinter_: function() { |
+ // If there is no detected printer, automatically open manually-add-printer |
+ // dialog only when the user opens the discovery-dialog through the |
+ // "ADD PRINTER" button. |
+ if (!this.previousDialog_) { |
+ this.$$('add-printer-discovery-dialog').close(); |
+ this.openManuallyAddPrinterDialog_(); |
+ } |
+ }, |
+ |
/** |
* Switch dialog from |fromDialog| to |toDialog|. |
* @param {string} fromDialog |