| 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 d97e93bd526bea01795afe316b1875f942fcf82c..e6386032b80755e80a31b050a2caeecd31962a25 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
|
| @@ -45,7 +45,7 @@ Polymer({
|
| },
|
|
|
| /** @type {!CupsPrinterInfo} */
|
| - selectedPrinter: {
|
| + newPrinter: {
|
| type: Object,
|
| notify: true,
|
| },
|
| @@ -73,12 +73,11 @@ Polymer({
|
| * @private
|
| */
|
| onPrinterDiscovered_: function(printers) {
|
| - this.discovering_ = true;
|
| - if (!this.discoveredPrinters) {
|
| - this.discoveredPrinters = printers;
|
| - } else {
|
| - for (var i = 0; i < printers.length; i++)
|
| - this.push('discoveredPrinters', printers[i]);
|
| + this.discoveredPrinters = printers;
|
| + if (!this.discovering_) {
|
| + // This update happened after we already finished the initial scan, so
|
| + // re-run the discovery done logic.
|
| + this.onPrinterDiscoveryDone_();
|
| }
|
| },
|
|
|
| @@ -99,6 +98,20 @@ Polymer({
|
| /** @private */
|
| switchToManualAddDialog_: function() {
|
| this.stopDiscoveringPrinters_();
|
| + // If the user has a printer selected in the discovery list, we *don't* want
|
| + // to use that if we go to add a printer manually, so reset newPrinter.
|
| + this.newPrinter = {
|
| + printerAddress: '',
|
| + printerDescription: '',
|
| + printerId: '',
|
| + printerManufacturer: '',
|
| + printerModel: '',
|
| + printerName: '',
|
| + printerPPDPath: '',
|
| + printerProtocol: 'ipp',
|
| + printerQueue: 'ipp/print',
|
| + printerStatus: '',
|
| + };
|
| this.$$('add-printer-dialog').close();
|
| this.fire('open-manually-add-printer-dialog');
|
| },
|
| @@ -110,10 +123,10 @@ Polymer({
|
| },
|
|
|
| /** @private */
|
| - switchToConfiguringDialog_: function() {
|
| + switchToManufacturerDialog_: function() {
|
| this.stopDiscoveringPrinters_();
|
| this.$$('add-printer-dialog').close();
|
| - this.fire('open-configuring-printer-dialog');
|
| + this.fire('open-manufacturer-model-dialog');
|
| },
|
| });
|
|
|
| @@ -317,11 +330,6 @@ Polymer({
|
|
|
| properties: {
|
| /** @type {!CupsPrinterInfo} */
|
| - selectedPrinter: {
|
| - type: Object,
|
| - },
|
| -
|
| - /** @type {!CupsPrinterInfo} */
|
| newPrinter: {
|
| type: Object,
|
| },
|
| @@ -369,8 +377,7 @@ Polymer({
|
| /** Opens the Add printer discovery dialog. */
|
| open: function() {
|
| this.resetData_();
|
| - this.switchDialog_(
|
| - '', AddPrinterDialogs.MANUALLY, 'showManuallyAddDialog_');
|
| + this.switchDialog_('', AddPrinterDialogs.DISCOVERY, 'showDiscoveryDialog_');
|
| },
|
|
|
| /**
|
| @@ -378,8 +385,6 @@ Polymer({
|
| * @private
|
| */
|
| resetData_: function() {
|
| - if (this.selectedPrinter)
|
| - this.selectedPrinter = this.getEmptyPrinter_();
|
| if (this.newPrinter)
|
| this.newPrinter = this.getEmptyPrinter_();
|
| this.setupFailed = false;
|
| @@ -424,14 +429,12 @@ Polymer({
|
| if (this.previousDialog_ == AddPrinterDialogs.DISCOVERY) {
|
| this.configuringDialogTitle =
|
| loadTimeData.getString('addPrintersNearbyTitle');
|
| - settings.CupsPrintersBrowserProxyImpl.getInstance().addCupsPrinter(
|
| - this.selectedPrinter);
|
| } else if (this.previousDialog_ == AddPrinterDialogs.MANUFACTURER) {
|
| this.configuringDialogTitle =
|
| loadTimeData.getString('addPrintersManuallyTitle');
|
| - settings.CupsPrintersBrowserProxyImpl.getInstance().addCupsPrinter(
|
| - this.newPrinter);
|
| }
|
| + settings.CupsPrintersBrowserProxyImpl.getInstance().addCupsPrinter(
|
| + this.newPrinter);
|
| },
|
|
|
| /** @private */
|
| @@ -477,9 +480,8 @@ Polymer({
|
| * @private
|
| */
|
| getConfiguringPrinterName_: function() {
|
| - if (this.previousDialog_ == AddPrinterDialogs.DISCOVERY)
|
| - return this.selectedPrinter.printerName;
|
| - if (this.previousDialog_ == AddPrinterDialogs.MANUALLY ||
|
| + if (this.previousDialog_ == AddPrinterDialogs.DISCOVERY ||
|
| + this.previousDialog_ == AddPrinterDialogs.MANUALLY ||
|
| this.previousDialog_ == AddPrinterDialogs.MANUFACTURER) {
|
| return this.newPrinter.printerName;
|
| }
|
|
|