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 d2270f7c1a2fe01b487d5cc35d01b936cc3ae8d7..b6c2cf0ed54f04214461b4e67d53a3e9a86f8359 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 |
@@ -110,10 +110,25 @@ Polymer({ |
}, |
/** @private */ |
- switchToConfiguringDialog_: function() { |
+ switchToManufacturerDialog_: function() { |
this.stopDiscoveringPrinters_(); |
+ |
+ // Copy relevant fields over from selected printer, |
+ // clear the rest. |
+ this.newPrinter = { |
+ printerAddress: this.selectedPrinter.printerAddress, |
+ printerDescription: this.selectedPrinter.printerDescription, |
+ printerId: this.selectedPrinter.printerId, |
+ printerName: this.selectedPrinter.printerName, |
+ printerProtocol: this.selectedPrinter.printerProtocol, |
+ printerQueue: this.selectedPrinter.printerQueue, |
+ printerStatus: this.selectedPrinter.printerStatus, |
+ printerManufacturer: '', |
+ printerModel: '', |
+ printerPPDPath: '', |
+ }; |
this.$$('add-printer-dialog').close(); |
- this.fire('open-configuring-printer-dialog'); |
+ this.fire('open-manufacturer-model-dialog'); |
}, |
}); |
@@ -189,6 +204,12 @@ Polymer({ |
notify: true, |
}, |
+ /** @type {!CupsPrinterInfo} */ |
+ selectedPrinter: { |
+ type: Object, |
+ notify: true, |
+ }, |
+ |
/** @type {?Array<string>} */ |
manufacturerList: { |
type: Array, |
@@ -336,6 +357,16 @@ Polymer({ |
value: false, |
}, |
+ /** |
+ * @type {boolean} whether we're doing manufacturer/model in |
+ * a manual flow (as opposed to a discovery flow). |
+ * @private |
+ */ |
+ inManualFlow: { |
+ type: Boolean, |
+ value: false, |
+ }, |
+ |
configuringDialogTitle: String, |
/** @private {string} */ |
@@ -373,8 +404,7 @@ Polymer({ |
/** Opens the Add printer discovery dialog. */ |
open: function() { |
this.resetData_(); |
- this.switchDialog_( |
- '', AddPrinterDialogs.MANUALLY, 'showManuallyAddDialog_'); |
+ this.switchDialog_('', AddPrinterDialogs.DISCOVERY, 'showDiscoveryDialog_'); |
}, |
/** |
@@ -442,6 +472,19 @@ Polymer({ |
openManufacturerModelDialog_: function() { |
this.switchDialog_(this.currentDialog_, AddPrinterDialogs.MANUFACTURER, |
'showManufacturerDialog_'); |
+ this.inManualFlow = false; |
+ if (this.previousDialog_ == AddPrinterDialogs.MANUALLY) { |
+ this.inManualFlow = true; |
+ } else if (this.previousDialog_ == AddPrinterDialogs.DISCOVERY) { |
+ // If we come to the manufacturer-model dialog via discovery, then the new |
+ // printer we're working with is the selected one, so copy it over. If we |
+ // have a manufacturer entry from detection we'll leave it intact, but |
+ // clear any manufacturer/model entries since the fact that we need to |
+ // have the user select means we don't think we have the right one. |
+ this.newPrinter = Object.assign({}, this.selectedPrinter); |
+ this.newPrinter.printerManufacturer = ''; |
+ this.newPrinter.printerModel = ''; |
+ } |
}, |
/** @private */ |