Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview 'settings-cups-add-printer-dialog' includes multiple dialogs to | 6 * @fileoverview 'settings-cups-add-printer-dialog' includes multiple dialogs to |
| 7 * set up a new CUPS printer. | 7 * set up a new CUPS printer. |
| 8 * Subdialogs include: | 8 * Subdialogs include: |
| 9 * - 'add-printer-discovery-dialog' is a dialog showing discovered printers on | 9 * - 'add-printer-discovery-dialog' is a dialog showing discovered printers on |
| 10 * the network that are available for setup. | 10 * the network that are available for setup. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 printerAddress: '', | 42 printerAddress: '', |
| 43 printerDescription: '', | 43 printerDescription: '', |
| 44 printerId: '', | 44 printerId: '', |
| 45 printerManufacturer: '', | 45 printerManufacturer: '', |
| 46 printerModel: '', | 46 printerModel: '', |
| 47 printerName: '', | 47 printerName: '', |
| 48 printerPPDPath: '', | 48 printerPPDPath: '', |
| 49 printerProtocol: 'ipp', | 49 printerProtocol: 'ipp', |
| 50 printerQueue: '', | 50 printerQueue: '', |
| 51 printerStatus: '', | 51 printerStatus: '', |
| 52 autoconf: false, | |
|
Carlson
2017/05/31 16:58:52
Dunno why the printerXXX naming convention is used
skau
2017/06/01 21:50:28
No reason either way AFAICT. I've changed it.
| |
| 52 }; | 53 }; |
| 53 } | 54 } |
| 54 | 55 |
| 55 Polymer({ | 56 Polymer({ |
| 56 is: 'add-printer-discovery-dialog', | 57 is: 'add-printer-discovery-dialog', |
| 57 | 58 |
| 58 behaviors: [WebUIListenerBehavior], | 59 behaviors: [WebUIListenerBehavior], |
| 59 | 60 |
| 60 properties: { | 61 properties: { |
| 61 /** @type {!Array<!CupsPrinterInfo>|undefined} */ | 62 /** @type {!Array<!CupsPrinterInfo>|undefined} */ |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 switchToDiscoveryDialog_: function() { | 162 switchToDiscoveryDialog_: function() { |
| 162 this.$$('add-printer-dialog').close(); | 163 this.$$('add-printer-dialog').close(); |
| 163 this.fire('open-discovery-printers-dialog'); | 164 this.fire('open-discovery-printers-dialog'); |
| 164 }, | 165 }, |
| 165 | 166 |
| 166 /** @private */ | 167 /** @private */ |
| 167 onCancelTap_: function() { | 168 onCancelTap_: function() { |
| 168 this.$$('add-printer-dialog').close(); | 169 this.$$('add-printer-dialog').close(); |
| 169 }, | 170 }, |
| 170 | 171 |
| 172 /** | |
| 173 * @param {!PrinterMakeModel} info | |
| 174 * @private | |
| 175 * */ | |
| 176 onPrinterFound_: function(info) { | |
| 177 this.newPrinter.printerManufacturer = info[0]; | |
| 178 this.newPrinter.printerModel = info[1]; | |
| 179 this.newPrinter.autoconf = info[2]; | |
| 180 | |
| 181 if (!this.newPrinter.autoconf) { | |
| 182 this.switchToManufacturerDialog_(); | |
| 183 return; | |
|
Carlson
2017/05/31 16:58:52
nit:
if () {
x
} else {
y
}
seems slightly
skau
2017/06/01 21:50:28
Done.
| |
| 184 } | |
| 185 | |
| 186 // Open configuring dialog. | |
|
Carlson
2017/05/31 16:58:52
Generally, better to comment why you're doing stuf
skau
2017/06/01 21:50:28
Done.
| |
| 187 this.$$('add-printer-dialog').close(); | |
| 188 this.fire('open-configuring-printer-dialog'); | |
| 189 }, | |
| 190 | |
| 191 /** | |
| 192 * @param {!QueryFailure} rejected | |
| 193 * @private | |
| 194 */ | |
| 195 infoFailed_: function(rejected) { | |
|
Carlson
2017/05/31 16:58:52
Why is rejected not used?
skau
2017/06/01 21:50:29
There's nothing useful in it at the moment. But t
| |
| 196 this.switchToManufacturerDialog_(); | |
| 197 }, | |
| 198 | |
| 199 /** @private */ | |
| 200 addPressed_: function() { | |
| 201 if (this.newPrinter.printerProtocol == 'ipp' || | |
| 202 this.newPrinter.printerProtocol == 'ipps') { | |
| 203 settings.CupsPrintersBrowserProxyImpl.getInstance(). | |
| 204 getPrinterInfo(this.newPrinter). | |
| 205 then(this.onPrinterFound_.bind(this), this.infoFailed_.bind(this)); | |
| 206 return; | |
| 207 } | |
| 208 | |
| 209 this.switchToManufacturerDialog_(); | |
| 210 }, | |
| 211 | |
| 171 /** @private */ | 212 /** @private */ |
| 172 switchToManufacturerDialog_: function() { | 213 switchToManufacturerDialog_: function() { |
| 173 // Set the default printer queue to be "ipp/print". | 214 // Set the default printer queue to be "ipp/print". |
| 174 if (!this.newPrinter.printerQueue) | 215 if (!this.newPrinter.printerQueue) |
| 175 this.set('newPrinter.printerQueue', 'ipp/print'); | 216 this.set('newPrinter.printerQueue', 'ipp/print'); |
| 176 | 217 |
| 177 this.$$('add-printer-dialog').close(); | 218 this.$$('add-printer-dialog').close(); |
| 178 this.fire('open-manufacturer-model-dialog'); | 219 this.fire('open-manufacturer-model-dialog'); |
| 179 }, | 220 }, |
| 180 | 221 |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 418 /** @private */ | 459 /** @private */ |
| 419 openConfiguringPrinterDialog_: function() { | 460 openConfiguringPrinterDialog_: function() { |
| 420 this.switchDialog_( | 461 this.switchDialog_( |
| 421 this.currentDialog_, AddPrinterDialogs.CONFIGURING, | 462 this.currentDialog_, AddPrinterDialogs.CONFIGURING, |
| 422 'showConfiguringDialog_'); | 463 'showConfiguringDialog_'); |
| 423 if (this.previousDialog_ == AddPrinterDialogs.DISCOVERY) { | 464 if (this.previousDialog_ == AddPrinterDialogs.DISCOVERY) { |
| 424 this.configuringDialogTitle = | 465 this.configuringDialogTitle = |
| 425 loadTimeData.getString('addPrintersNearbyTitle'); | 466 loadTimeData.getString('addPrintersNearbyTitle'); |
| 426 settings.CupsPrintersBrowserProxyImpl.getInstance().addCupsPrinter( | 467 settings.CupsPrintersBrowserProxyImpl.getInstance().addCupsPrinter( |
| 427 this.newPrinter); | 468 this.newPrinter); |
| 428 } else if (this.previousDialog_ == AddPrinterDialogs.MANUFACTURER) { | 469 } else if ( |
| 470 this.previousDialog_ == AddPrinterDialogs.MANUFACTURER || | |
| 471 this.previousDialog_ == AddPrinterDialogs.MANUALLY) { | |
| 429 this.configuringDialogTitle = | 472 this.configuringDialogTitle = |
| 430 loadTimeData.getString('addPrintersManuallyTitle'); | 473 loadTimeData.getString('addPrintersManuallyTitle'); |
| 431 settings.CupsPrintersBrowserProxyImpl.getInstance().addCupsPrinter( | 474 settings.CupsPrintersBrowserProxyImpl.getInstance().addCupsPrinter( |
| 432 this.newPrinter); | 475 this.newPrinter); |
| 433 } | 476 } |
| 434 }, | 477 }, |
| 435 | 478 |
| 436 /** @private */ | 479 /** @private */ |
| 437 openManufacturerModelDialog_: function() { | 480 openManufacturerModelDialog_: function() { |
| 438 this.switchDialog_(this.currentDialog_, AddPrinterDialogs.MANUFACTURER, | 481 this.switchDialog_(this.currentDialog_, AddPrinterDialogs.MANUFACTURER, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 488 onAddPrinter_: function(success, printerName) { | 531 onAddPrinter_: function(success, printerName) { |
| 489 this.$$('add-printer-configuring-dialog').close(); | 532 this.$$('add-printer-configuring-dialog').close(); |
| 490 if (success) | 533 if (success) |
| 491 return; | 534 return; |
| 492 | 535 |
| 493 if (this.previousDialog_ == AddPrinterDialogs.MANUFACTURER) { | 536 if (this.previousDialog_ == AddPrinterDialogs.MANUFACTURER) { |
| 494 this.setupFailed = true; | 537 this.setupFailed = true; |
| 495 } | 538 } |
| 496 }, | 539 }, |
| 497 }); | 540 }); |
| OLD | NEW |