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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 this.fire('open-manually-add-printer-dialog'); | 103 this.fire('open-manually-add-printer-dialog'); |
| 104 }, | 104 }, |
| 105 | 105 |
| 106 /** @private */ | 106 /** @private */ |
| 107 onCancelTap_: function() { | 107 onCancelTap_: function() { |
| 108 this.stopDiscoveringPrinters_(); | 108 this.stopDiscoveringPrinters_(); |
| 109 this.$$('add-printer-dialog').close(); | 109 this.$$('add-printer-dialog').close(); |
| 110 }, | 110 }, |
| 111 | 111 |
| 112 /** @private */ | 112 /** @private */ |
| 113 switchToConfiguringDialog_: function() { | 113 switchToManufacturerDialog_: function() { |
| 114 this.stopDiscoveringPrinters_(); | 114 this.stopDiscoveringPrinters_(); |
| 115 this.$$('add-printer-dialog').close(); | 115 this.$$('add-printer-dialog').close(); |
| 116 this.fire('open-configuring-printer-dialog'); | 116 this.fire('open-manufacturer-model-dialog'); |
| 117 }, | 117 }, |
| 118 }); | 118 }); |
| 119 | 119 |
| 120 Polymer({ | 120 Polymer({ |
| 121 is: 'add-printer-manually-dialog', | 121 is: 'add-printer-manually-dialog', |
| 122 | 122 |
| 123 properties: { | 123 properties: { |
| 124 /** @type {!CupsPrinterInfo} */ | 124 /** @type {!CupsPrinterInfo} */ |
| 125 newPrinter: { | 125 newPrinter: { |
| 126 type: Object, | 126 type: Object, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 Polymer({ | 182 Polymer({ |
| 183 is: 'add-printer-manufacturer-model-dialog', | 183 is: 'add-printer-manufacturer-model-dialog', |
| 184 | 184 |
| 185 properties: { | 185 properties: { |
| 186 /** @type {!CupsPrinterInfo} */ | 186 /** @type {!CupsPrinterInfo} */ |
| 187 newPrinter: { | 187 newPrinter: { |
| 188 type: Object, | 188 type: Object, |
| 189 notify: true, | 189 notify: true, |
| 190 }, | 190 }, |
| 191 | 191 |
| 192 /** @type {!CupsPrinterInfo} */ | |
| 193 selectedPrinter: { | |
| 194 type: Object, | |
| 195 notify: true, | |
| 196 }, | |
| 197 | |
| 192 /** @type {?Array<string>} */ | 198 /** @type {?Array<string>} */ |
| 193 manufacturerList: { | 199 manufacturerList: { |
| 194 type: Array, | 200 type: Array, |
| 195 }, | 201 }, |
| 196 | 202 |
| 197 /** @type {?Array<string>} */ | 203 /** @type {?Array<string>} */ |
| 198 modelList: { | 204 modelList: { |
| 199 type: Array, | 205 type: Array, |
| 200 }, | 206 }, |
| 201 | 207 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 newPrinter: { | 335 newPrinter: { |
| 330 type: Object, | 336 type: Object, |
| 331 }, | 337 }, |
| 332 | 338 |
| 333 /** @type {boolean} whether the new printer setup is failed. */ | 339 /** @type {boolean} whether the new printer setup is failed. */ |
| 334 setupFailed: { | 340 setupFailed: { |
| 335 type: Boolean, | 341 type: Boolean, |
| 336 value: false, | 342 value: false, |
| 337 }, | 343 }, |
| 338 | 344 |
| 345 /** | |
| 346 * @type {boolean} whether we're doing manufacturer/model in | |
| 347 * a manual flow (as opposed to a discovery flow). | |
| 348 * @private | |
| 349 */ | |
| 350 inManualFlow: { | |
| 351 type: Boolean, | |
| 352 value: false, | |
| 353 }, | |
| 354 | |
| 339 configuringDialogTitle: String, | 355 configuringDialogTitle: String, |
| 340 | 356 |
| 341 /** @private {string} */ | 357 /** @private {string} */ |
| 342 previousDialog_: String, | 358 previousDialog_: String, |
| 343 | 359 |
| 344 /** @private {string} */ | 360 /** @private {string} */ |
| 345 currentDialog_: String, | 361 currentDialog_: String, |
| 346 | 362 |
| 347 /** @private {boolean} */ | 363 /** @private {boolean} */ |
| 348 showDiscoveryDialog_: Boolean, | 364 showDiscoveryDialog_: Boolean, |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 366 }, | 382 }, |
| 367 | 383 |
| 368 /** @override */ | 384 /** @override */ |
| 369 ready: function() { | 385 ready: function() { |
| 370 this.addWebUIListener('on-add-cups-printer', this.onAddPrinter_.bind(this)); | 386 this.addWebUIListener('on-add-cups-printer', this.onAddPrinter_.bind(this)); |
| 371 }, | 387 }, |
| 372 | 388 |
| 373 /** Opens the Add printer discovery dialog. */ | 389 /** Opens the Add printer discovery dialog. */ |
| 374 open: function() { | 390 open: function() { |
| 375 this.resetData_(); | 391 this.resetData_(); |
| 376 this.switchDialog_( | 392 this.switchDialog_('', AddPrinterDialogs.DISCOVERY, 'showDiscoveryDialog_'); |
| 377 '', AddPrinterDialogs.MANUALLY, 'showManuallyAddDialog_'); | |
| 378 }, | 393 }, |
| 379 | 394 |
| 380 /** | 395 /** |
| 381 * Reset all the printer data in the Add printer flow. | 396 * Reset all the printer data in the Add printer flow. |
| 382 * @private | 397 * @private |
| 383 */ | 398 */ |
| 384 resetData_: function() { | 399 resetData_: function() { |
| 385 if (this.selectedPrinter) | 400 if (this.selectedPrinter) |
| 386 this.selectedPrinter = this.getEmptyPrinter_(); | 401 this.selectedPrinter = this.getEmptyPrinter_(); |
| 387 if (this.newPrinter) | 402 if (this.newPrinter) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 435 loadTimeData.getString('addPrintersManuallyTitle'); | 450 loadTimeData.getString('addPrintersManuallyTitle'); |
| 436 settings.CupsPrintersBrowserProxyImpl.getInstance().addCupsPrinter( | 451 settings.CupsPrintersBrowserProxyImpl.getInstance().addCupsPrinter( |
| 437 this.newPrinter); | 452 this.newPrinter); |
| 438 } | 453 } |
| 439 }, | 454 }, |
| 440 | 455 |
| 441 /** @private */ | 456 /** @private */ |
| 442 openManufacturerModelDialog_: function() { | 457 openManufacturerModelDialog_: function() { |
| 443 this.switchDialog_(this.currentDialog_, AddPrinterDialogs.MANUFACTURER, | 458 this.switchDialog_(this.currentDialog_, AddPrinterDialogs.MANUFACTURER, |
| 444 'showManufacturerDialog_'); | 459 'showManufacturerDialog_'); |
| 460 this.inManualFlow = false; | |
| 461 if (this.previousDialog_ == AddPrinterDialogs.MANUALLY) { | |
| 462 this.inManualFlow = true; | |
| 463 } else if (this.previousDialog_ == AddPrinterDialogs.DISCOVERY) { | |
| 464 // If we come to the manufacturer-model dialog via discovery, then the new | |
| 465 // printer we're working with is the selected one, so copy it over. If we | |
| 466 // have a manufacturer entry from detection we'll leave it intact, but | |
| 467 // clear any manufacturer/model entries since the fact that we need to | |
| 468 // have the user select means we don't think we have the right one. | |
| 469 this.newPrinter = Object.assign({}, this.selectedPrinter); | |
|
xdai1
2017/05/10 20:12:53
The reason I prefer not "copying fields over" eith
Carlson
2017/05/10 21:28:18
I think I understand this now. Replied at top lev
| |
| 470 this.newPrinter.printerManufacturer = ''; | |
| 471 this.newPrinter.printerModel = ''; | |
| 472 this.newPrinter.printerPPDPath = ''; | |
| 473 } | |
| 445 }, | 474 }, |
| 446 | 475 |
| 447 /** @private */ | 476 /** @private */ |
| 448 configuringDialogClosed_: function() { | 477 configuringDialogClosed_: function() { |
| 449 if (this.previousDialog_ == AddPrinterDialogs.MANUALLY) { | 478 if (this.previousDialog_ == AddPrinterDialogs.MANUALLY) { |
| 450 this.switchDialog_( | 479 this.switchDialog_( |
| 451 this.currentDialog_, this.previousDialog_, 'showManuallyAddDialog_'); | 480 this.currentDialog_, this.previousDialog_, 'showManuallyAddDialog_'); |
| 452 } else if (this.previousDialog_ == AddPrinterDialogs.MANUFACTURER) { | 481 } else if (this.previousDialog_ == AddPrinterDialogs.MANUFACTURER) { |
| 453 this.switchDialog_( | 482 this.switchDialog_( |
| 454 this.currentDialog_, this.previousDialog_, 'showManufacturerDialog_'); | 483 this.currentDialog_, this.previousDialog_, 'showManufacturerDialog_'); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 498 onAddPrinter_: function(success, printerName) { | 527 onAddPrinter_: function(success, printerName) { |
| 499 this.$$('add-printer-configuring-dialog').close(); | 528 this.$$('add-printer-configuring-dialog').close(); |
| 500 if (success) | 529 if (success) |
| 501 return; | 530 return; |
| 502 | 531 |
| 503 if (this.previousDialog_ == AddPrinterDialogs.MANUFACTURER) { | 532 if (this.previousDialog_ == AddPrinterDialogs.MANUFACTURER) { |
| 504 this.setupFailed = true; | 533 this.setupFailed = true; |
| 505 } | 534 } |
| 506 }, | 535 }, |
| 507 }); | 536 }); |
| OLD | NEW |