Chromium Code Reviews| 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 8e1d7de443205c16582434c5e374fa71b1a13b89..c6f2c1658e198d48a3721a75f5c6dc43e515ee8e 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 |
| @@ -39,6 +39,7 @@ var kPrinterListFullHeight = 350; |
| */ |
| function getEmptyPrinter_() { |
| return { |
| + printerAutoconf: false, |
| printerAddress: '', |
| printerDescription: '', |
| printerId: '', |
| @@ -168,6 +169,48 @@ Polymer({ |
| this.$$('add-printer-dialog').close(); |
| }, |
| + /** |
| + * Handler for getPrinterInfo success. |
| + * @param {!PrinterMakeModel} info |
| + * @private |
| + * */ |
| + onPrinterFound_: function(info) { |
| + this.newPrinter.printerManufacturer = info.manufacturer; |
| + this.newPrinter.printerModel = info.model; |
| + this.newPrinter.autoconf = info.autoconf; |
| + |
| + // Show the manufacturer dialog if we can't autoconfigure. Otherwise, show |
| + // configuring while we wait. |
| + if (!this.newPrinter.autoconf) { |
| + this.switchToManufacturerDialog_(); |
| + } else { |
| + this.$$('add-printer-dialog').close(); |
| + this.fire('open-configuring-printer-dialog'); |
| + } |
| + }, |
| + |
| + /** |
| + * Handler for getPrinterInfo failure. |
| + * @param {!QueryFailure} rejected |
| + * @private |
| + */ |
| + infoFailed_: function(rejected) { |
| + this.switchToManufacturerDialog_(); |
| + }, |
| + |
| + /** @private */ |
| + addPressed_: function() { |
| + if (this.newPrinter.printerProtocol == 'ipp' || |
|
xdai1
2017/06/05 17:55:55
Do you need to move line 216 - 218 to here?
skau
2017/06/07 23:55:39
I've moved this query to the configuring screen in
|
| + this.newPrinter.printerProtocol == 'ipps') { |
| + settings.CupsPrintersBrowserProxyImpl.getInstance(). |
| + getPrinterInfo(this.newPrinter). |
| + then(this.onPrinterFound_.bind(this), this.infoFailed_.bind(this)); |
| + return; |
| + } |
| + |
| + this.switchToManufacturerDialog_(); |
| + }, |
| + |
| /** @private */ |
| switchToManufacturerDialog_: function() { |
| // Set the default printer queue to be "ipp/print". |
| @@ -425,7 +468,9 @@ Polymer({ |
| loadTimeData.getString('addPrintersNearbyTitle'); |
| settings.CupsPrintersBrowserProxyImpl.getInstance().addCupsPrinter( |
| this.newPrinter); |
| - } else if (this.previousDialog_ == AddPrinterDialogs.MANUFACTURER) { |
| + } else if ( |
| + this.previousDialog_ == AddPrinterDialogs.MANUFACTURER || |
| + this.previousDialog_ == AddPrinterDialogs.MANUALLY) { |
| this.configuringDialogTitle = |
| loadTimeData.getString('addPrintersManuallyTitle'); |
| settings.CupsPrintersBrowserProxyImpl.getInstance().addCupsPrinter( |