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..9c7f7cb2c28f87bc3e826145fb1f4a578a014704 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 |
@@ -33,6 +33,25 @@ var AddPrinterDialogs = { |
*/ |
var kPrinterListFullHeight = 350; |
+/** |
+ * Return a reset CupsPrinterInfo object. |
+ * @return {!CupsPrinterInfo} |
+ */ |
+function getEmptyPrinter_() { |
+ return { |
+ printerAddress: '', |
+ printerDescription: '', |
+ printerId: '', |
+ printerManufacturer: '', |
+ printerModel: '', |
+ printerName: '', |
+ printerPPDPath: '', |
+ printerProtocol: 'ipp', |
+ printerQueue: '', |
+ printerStatus: '', |
+ }; |
+} |
+ |
Polymer({ |
is: 'add-printer-discovery-dialog', |
@@ -99,6 +118,9 @@ Polymer({ |
/** @private */ |
switchToManualAddDialog_: function() { |
this.stopDiscoveringPrinters_(); |
+ // We're abandoning discovery in favor of manual specification, so |
+ // drop the selection if one exists. |
+ this.selectedPrinter = getEmptyPrinter_(); |
this.$$('add-printer-dialog').close(); |
this.fire('open-manually-add-printer-dialog'); |
}, |
@@ -110,10 +132,16 @@ Polymer({ |
}, |
/** @private */ |
- switchToConfiguringDialog_: function() { |
+ switchToManufacturerDialog_: function() { |
this.stopDiscoveringPrinters_(); |
+ // If we're switching to the manufacturer/model dialog, clear the existing |
+ // data we have about the PPD (if any), as we're dropping that in favor of |
+ // user selections. |
+ this.selectedPrinter.printerManufacturer = ''; |
+ this.selectedPrinter.printerModel = ''; |
+ this.selectedPrinter.printerPPDPath = ''; |
xdai1
2017/05/11 22:50:28
You probably don't need these three lines. After t
Carlson
2017/05/11 23:57:10
That's true, but when we actually do select a prin
xdai1
2017/05/12 00:30:43
Acknowledged.
|
this.$$('add-printer-dialog').close(); |
- this.fire('open-configuring-printer-dialog'); |
+ this.fire('open-manufacturer-model-dialog'); |
}, |
}); |
@@ -125,20 +153,7 @@ Polymer({ |
newPrinter: { |
type: Object, |
notify: true, |
- value: function() { |
- return { |
- printerAddress: '', |
- printerDescription: '', |
- printerId: '', |
- printerManufacturer: '', |
- printerModel: '', |
- printerName: '', |
- printerPPDPath: '', |
- printerProtocol: 'ipp', |
- printerQueue: '', |
- printerStatus: '', |
- }; |
- }, |
+ value: getEmptyPrinter_ |
xdai1
2017/05/11 22:50:28
getEmptyPrinter_()?
Carlson
2017/05/11 23:57:11
I don't think so?
https://www.polymer-project.or
xdai1
2017/05/12 00:30:43
Acknowledged.
|
}, |
}, |
@@ -199,6 +214,9 @@ Polymer({ |
type: Array, |
}, |
+ /** @type {string} */ |
+ previousDialog: String, |
+ |
setupFailed: { |
type: Boolean, |
value: false, |
@@ -263,9 +281,13 @@ Polymer({ |
}, |
/** @private */ |
- switchToManualAddDialog_: function() { |
+ switchToPreviousDialog_: function() { |
this.$$('add-printer-dialog').close(); |
- this.fire('open-manually-add-printer-dialog'); |
+ if (this.previousDialog == AddPrinterDialogs.DISCOVERY) { |
+ this.fire('open-discovery-printers-dialog'); |
+ } else if (this.previousDialog == AddPrinterDialogs.MANUALLY) { |
+ this.fire('open-manually-add-printer-dialog'); |
+ } |
}, |
/** @private */ |
@@ -320,11 +342,6 @@ Polymer({ |
behaviors: [WebUIListenerBehavior], |
properties: { |
- /** @type {!CupsPrinterInfo} */ |
- selectedPrinter: { |
- type: Object, |
- }, |
- |
/** @type {!CupsPrinterInfo} */ |
newPrinter: { |
type: Object, |
@@ -338,8 +355,8 @@ Polymer({ |
configuringDialogTitle: String, |
- /** @private {string} */ |
- previousDialog_: String, |
+ /** @type {string} */ |
+ previousDialog: String, |
/** @private {string} */ |
currentDialog_: String, |
@@ -373,8 +390,7 @@ Polymer({ |
/** Opens the Add printer discovery dialog. */ |
open: function() { |
this.resetData_(); |
- this.switchDialog_( |
- '', AddPrinterDialogs.MANUALLY, 'showManuallyAddDialog_'); |
+ this.switchDialog_('', AddPrinterDialogs.DISCOVERY, 'showDiscoveryDialog_'); |
}, |
/** |
@@ -382,32 +398,11 @@ Polymer({ |
* @private |
*/ |
resetData_: function() { |
- if (this.selectedPrinter) |
- this.selectedPrinter = this.getEmptyPrinter_(); |
if (this.newPrinter) |
- this.newPrinter = this.getEmptyPrinter_(); |
+ this.newPrinter = getEmptyPrinter_(); |
this.setupFailed = false; |
}, |
- /** |
- * @return {!CupsPrinterInfo} |
- * @private |
- */ |
- getEmptyPrinter_: function() { |
- return { |
- printerAddress: '', |
- printerDescription: '', |
- printerId: '', |
- printerManufacturer: '', |
- printerModel: '', |
- printerName: '', |
- printerPPDPath: '', |
- printerProtocol: 'ipp', |
- printerQueue: '', |
- printerStatus: '', |
- }; |
- }, |
- |
/** @private */ |
openManuallyAddPrinterDialog_: function() { |
this.switchDialog_(this.currentDialog_, AddPrinterDialogs.MANUALLY, |
@@ -425,12 +420,12 @@ Polymer({ |
this.switchDialog_( |
xdai1
2017/05/11 22:50:28
After your change, the previous dialog for configu
Carlson
2017/05/11 23:57:11
That's true right now, but isn't the right thing i
xdai1
2017/05/12 00:30:43
Because the previous dialog will always be this.pr
Carlson
2017/05/12 17:12:46
Took me a while, but I understand now.
I'm not su
xdai1
2017/05/12 17:56:55
Yes. I'm fine to file a bug for this.
Carlson
2017/05/12 18:14:09
Filed crbug/721841
|
this.currentDialog_, AddPrinterDialogs.CONFIGURING, |
'showConfiguringDialog_'); |
- if (this.previousDialog_ == AddPrinterDialogs.DISCOVERY) { |
+ if (this.previousDialog == AddPrinterDialogs.DISCOVERY) { |
this.configuringDialogTitle = |
loadTimeData.getString('addPrintersNearbyTitle'); |
settings.CupsPrintersBrowserProxyImpl.getInstance().addCupsPrinter( |
this.selectedPrinter); |
- } else if (this.previousDialog_ == AddPrinterDialogs.MANUFACTURER) { |
+ } else if (this.previousDialog == AddPrinterDialogs.MANUFACTURER) { |
this.configuringDialogTitle = |
loadTimeData.getString('addPrintersManuallyTitle'); |
settings.CupsPrintersBrowserProxyImpl.getInstance().addCupsPrinter( |
@@ -446,12 +441,12 @@ Polymer({ |
/** @private */ |
configuringDialogClosed_: function() { |
- if (this.previousDialog_ == AddPrinterDialogs.MANUALLY) { |
+ if (this.previousDialog == AddPrinterDialogs.MANUALLY) { |
xdai1
2017/05/11 22:50:28
Same as above.
Carlson
2017/05/11 23:57:10
Same reply here. Eventually this will be needed a
xdai1
2017/05/12 00:30:43
Acknowledged.
Carlson
2017/05/12 17:12:46
Actually, this one is a real problem looking more
|
this.switchDialog_( |
- this.currentDialog_, this.previousDialog_, 'showManuallyAddDialog_'); |
- } else if (this.previousDialog_ == AddPrinterDialogs.MANUFACTURER) { |
+ this.currentDialog_, this.previousDialog, 'showManuallyAddDialog_'); |
+ } else if (this.previousDialog == AddPrinterDialogs.MANUFACTURER) { |
this.switchDialog_( |
- this.currentDialog_, this.previousDialog_, 'showManufacturerDialog_'); |
+ this.currentDialog_, this.previousDialog, 'showManufacturerDialog_'); |
} |
}, |
@@ -464,7 +459,7 @@ Polymer({ |
* @private |
*/ |
switchDialog_: function(fromDialog, toDialog, domIfBooleanName) { |
- this.previousDialog_ = fromDialog; |
+ this.previousDialog = fromDialog; |
this.currentDialog_ = toDialog; |
this.set(domIfBooleanName, true); |
@@ -481,10 +476,9 @@ Polymer({ |
* @private |
*/ |
getConfiguringPrinterName_: function() { |
xdai1
2017/05/11 22:50:28
This function can be removed now. And in configuri
Carlson
2017/05/11 23:57:10
Good point, done.
|
- if (this.previousDialog_ == AddPrinterDialogs.DISCOVERY) |
- return this.selectedPrinter.printerName; |
- if (this.previousDialog_ == AddPrinterDialogs.MANUALLY || |
- this.previousDialog_ == AddPrinterDialogs.MANUFACTURER) { |
+ if (this.previousDialog == AddPrinterDialogs.DISCOVERY || |
+ this.previousDialog == AddPrinterDialogs.MANUALLY || |
+ this.previousDialog == AddPrinterDialogs.MANUFACTURER) { |
return this.newPrinter.printerName; |
} |
return ''; |
@@ -500,7 +494,7 @@ Polymer({ |
if (success) |
return; |
- if (this.previousDialog_ == AddPrinterDialogs.MANUFACTURER) { |
+ if (this.previousDialog == AddPrinterDialogs.MANUFACTURER) { |
this.setupFailed = true; |
} |
}, |