| 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 |
| 116 // Copy relevant fields over from selected printer, |
| 117 // clear the rest. |
| 118 this.newPrinter = { |
| 119 printerAddress: this.selectedPrinter.printerAddress, |
| 120 printerDescription: this.selectedPrinter.printerDescription, |
| 121 printerId: this.selectedPrinter.printerId, |
| 122 printerName: this.selectedPrinter.printerName, |
| 123 printerProtocol: this.selectedPrinter.printerProtocol, |
| 124 printerQueue: this.selectedPrinter.printerQueue, |
| 125 printerStatus: this.selectedPrinter.printerStatus, |
| 126 printerManufacturer: '', |
| 127 printerModel: '', |
| 128 printerPPDPath: '', |
| 129 }; |
| 115 this.$$('add-printer-dialog').close(); | 130 this.$$('add-printer-dialog').close(); |
| 116 this.fire('open-configuring-printer-dialog'); | 131 this.fire('open-manufacturer-model-dialog'); |
| 117 }, | 132 }, |
| 118 }); | 133 }); |
| 119 | 134 |
| 120 Polymer({ | 135 Polymer({ |
| 121 is: 'add-printer-manually-dialog', | 136 is: 'add-printer-manually-dialog', |
| 122 | 137 |
| 123 properties: { | 138 properties: { |
| 124 /** @type {!CupsPrinterInfo} */ | 139 /** @type {!CupsPrinterInfo} */ |
| 125 newPrinter: { | 140 newPrinter: { |
| 126 type: Object, | 141 type: Object, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 Polymer({ | 197 Polymer({ |
| 183 is: 'add-printer-manufacturer-model-dialog', | 198 is: 'add-printer-manufacturer-model-dialog', |
| 184 | 199 |
| 185 properties: { | 200 properties: { |
| 186 /** @type {!CupsPrinterInfo} */ | 201 /** @type {!CupsPrinterInfo} */ |
| 187 newPrinter: { | 202 newPrinter: { |
| 188 type: Object, | 203 type: Object, |
| 189 notify: true, | 204 notify: true, |
| 190 }, | 205 }, |
| 191 | 206 |
| 207 /** @type {!CupsPrinterInfo} */ |
| 208 selectedPrinter: { |
| 209 type: Object, |
| 210 notify: true, |
| 211 }, |
| 212 |
| 192 /** @type {?Array<string>} */ | 213 /** @type {?Array<string>} */ |
| 193 manufacturerList: { | 214 manufacturerList: { |
| 194 type: Array, | 215 type: Array, |
| 195 }, | 216 }, |
| 196 | 217 |
| 197 /** @type {?Array<string>} */ | 218 /** @type {?Array<string>} */ |
| 198 modelList: { | 219 modelList: { |
| 199 type: Array, | 220 type: Array, |
| 200 }, | 221 }, |
| 201 | 222 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 newPrinter: { | 350 newPrinter: { |
| 330 type: Object, | 351 type: Object, |
| 331 }, | 352 }, |
| 332 | 353 |
| 333 /** @type {boolean} whether the new printer setup is failed. */ | 354 /** @type {boolean} whether the new printer setup is failed. */ |
| 334 setupFailed: { | 355 setupFailed: { |
| 335 type: Boolean, | 356 type: Boolean, |
| 336 value: false, | 357 value: false, |
| 337 }, | 358 }, |
| 338 | 359 |
| 360 /** |
| 361 * @type {boolean} whether we're doing manufacturer/model in |
| 362 * a manual flow (as opposed to a discovery flow). |
| 363 * @private |
| 364 */ |
| 365 inManualFlow: { |
| 366 type: Boolean, |
| 367 value: false, |
| 368 }, |
| 369 |
| 339 configuringDialogTitle: String, | 370 configuringDialogTitle: String, |
| 340 | 371 |
| 341 /** @private {string} */ | 372 /** @private {string} */ |
| 342 previousDialog_: String, | 373 previousDialog_: String, |
| 343 | 374 |
| 344 /** @private {string} */ | 375 /** @private {string} */ |
| 345 currentDialog_: String, | 376 currentDialog_: String, |
| 346 | 377 |
| 347 /** @private {boolean} */ | 378 /** @private {boolean} */ |
| 348 showDiscoveryDialog_: Boolean, | 379 showDiscoveryDialog_: Boolean, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 366 }, | 397 }, |
| 367 | 398 |
| 368 /** @override */ | 399 /** @override */ |
| 369 ready: function() { | 400 ready: function() { |
| 370 this.addWebUIListener('on-add-cups-printer', this.onAddPrinter_.bind(this)); | 401 this.addWebUIListener('on-add-cups-printer', this.onAddPrinter_.bind(this)); |
| 371 }, | 402 }, |
| 372 | 403 |
| 373 /** Opens the Add printer discovery dialog. */ | 404 /** Opens the Add printer discovery dialog. */ |
| 374 open: function() { | 405 open: function() { |
| 375 this.resetData_(); | 406 this.resetData_(); |
| 376 this.switchDialog_( | 407 this.switchDialog_('', AddPrinterDialogs.DISCOVERY, 'showDiscoveryDialog_'); |
| 377 '', AddPrinterDialogs.MANUALLY, 'showManuallyAddDialog_'); | |
| 378 }, | 408 }, |
| 379 | 409 |
| 380 /** | 410 /** |
| 381 * Reset all the printer data in the Add printer flow. | 411 * Reset all the printer data in the Add printer flow. |
| 382 * @private | 412 * @private |
| 383 */ | 413 */ |
| 384 resetData_: function() { | 414 resetData_: function() { |
| 385 if (this.selectedPrinter) | 415 if (this.selectedPrinter) |
| 386 this.selectedPrinter = this.getEmptyPrinter_(); | 416 this.selectedPrinter = this.getEmptyPrinter_(); |
| 387 if (this.newPrinter) | 417 if (this.newPrinter) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 loadTimeData.getString('addPrintersManuallyTitle'); | 465 loadTimeData.getString('addPrintersManuallyTitle'); |
| 436 settings.CupsPrintersBrowserProxyImpl.getInstance().addCupsPrinter( | 466 settings.CupsPrintersBrowserProxyImpl.getInstance().addCupsPrinter( |
| 437 this.newPrinter); | 467 this.newPrinter); |
| 438 } | 468 } |
| 439 }, | 469 }, |
| 440 | 470 |
| 441 /** @private */ | 471 /** @private */ |
| 442 openManufacturerModelDialog_: function() { | 472 openManufacturerModelDialog_: function() { |
| 443 this.switchDialog_(this.currentDialog_, AddPrinterDialogs.MANUFACTURER, | 473 this.switchDialog_(this.currentDialog_, AddPrinterDialogs.MANUFACTURER, |
| 444 'showManufacturerDialog_'); | 474 'showManufacturerDialog_'); |
| 475 this.inManualFlow = false; |
| 476 if (this.previousDialog_ == AddPrinterDialogs.MANUALLY) { |
| 477 this.inManualFlow = true; |
| 478 } else if (this.previousDialog_ == AddPrinterDialogs.DISCOVERY) { |
| 479 // If we come to the manufacturer-model dialog via discovery, then the new |
| 480 // printer we're working with is the selected one, so copy it over. If we |
| 481 // have a manufacturer entry from detection we'll leave it intact, but |
| 482 // clear any manufacturer/model entries since the fact that we need to |
| 483 // have the user select means we don't think we have the right one. |
| 484 this.newPrinter = Object.assign({}, this.selectedPrinter); |
| 485 this.newPrinter.printerManufacturer = ''; |
| 486 this.newPrinter.printerModel = ''; |
| 487 } |
| 445 }, | 488 }, |
| 446 | 489 |
| 447 /** @private */ | 490 /** @private */ |
| 448 configuringDialogClosed_: function() { | 491 configuringDialogClosed_: function() { |
| 449 if (this.previousDialog_ == AddPrinterDialogs.MANUALLY) { | 492 if (this.previousDialog_ == AddPrinterDialogs.MANUALLY) { |
| 450 this.switchDialog_( | 493 this.switchDialog_( |
| 451 this.currentDialog_, this.previousDialog_, 'showManuallyAddDialog_'); | 494 this.currentDialog_, this.previousDialog_, 'showManuallyAddDialog_'); |
| 452 } else if (this.previousDialog_ == AddPrinterDialogs.MANUFACTURER) { | 495 } else if (this.previousDialog_ == AddPrinterDialogs.MANUFACTURER) { |
| 453 this.switchDialog_( | 496 this.switchDialog_( |
| 454 this.currentDialog_, this.previousDialog_, 'showManufacturerDialog_'); | 497 this.currentDialog_, this.previousDialog_, 'showManufacturerDialog_'); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 onAddPrinter_: function(success, printerName) { | 541 onAddPrinter_: function(success, printerName) { |
| 499 this.$$('add-printer-configuring-dialog').close(); | 542 this.$$('add-printer-configuring-dialog').close(); |
| 500 if (success) | 543 if (success) |
| 501 return; | 544 return; |
| 502 | 545 |
| 503 if (this.previousDialog_ == AddPrinterDialogs.MANUFACTURER) { | 546 if (this.previousDialog_ == AddPrinterDialogs.MANUFACTURER) { |
| 504 this.setupFailed = true; | 547 this.setupFailed = true; |
| 505 } | 548 } |
| 506 }, | 549 }, |
| 507 }); | 550 }); |
| OLD | NEW |