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 21 matching lines...) Expand all Loading... | |
| 32 * @const {number} | 32 * @const {number} |
| 33 */ | 33 */ |
| 34 var kPrinterListFullHeight = 350; | 34 var kPrinterListFullHeight = 350; |
| 35 | 35 |
| 36 /** | 36 /** |
| 37 * Return a reset CupsPrinterInfo object. | 37 * Return a reset CupsPrinterInfo object. |
| 38 * @return {!CupsPrinterInfo} | 38 * @return {!CupsPrinterInfo} |
| 39 */ | 39 */ |
| 40 function getEmptyPrinter_() { | 40 function getEmptyPrinter_() { |
| 41 return { | 41 return { |
| 42 printerAutoconf: false, | |
| 42 printerAddress: '', | 43 printerAddress: '', |
| 43 printerDescription: '', | 44 printerDescription: '', |
| 44 printerId: '', | 45 printerId: '', |
| 45 printerManufacturer: '', | 46 printerManufacturer: '', |
| 46 printerModel: '', | 47 printerModel: '', |
| 47 printerName: '', | 48 printerName: '', |
| 48 printerPPDPath: '', | 49 printerPPDPath: '', |
| 49 printerProtocol: 'ipp', | 50 printerProtocol: 'ipp', |
| 50 printerQueue: '', | 51 printerQueue: '', |
| 51 printerStatus: '', | 52 printerStatus: '', |
| (...skipping 109 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 * Handler for getPrinterInfo success. | |
| 174 * @param {!PrinterMakeModel} info | |
| 175 * @private | |
| 176 * */ | |
| 177 onPrinterFound_: function(info) { | |
| 178 this.newPrinter.printerManufacturer = info.manufacturer; | |
| 179 this.newPrinter.printerModel = info.model; | |
| 180 this.newPrinter.autoconf = info.autoconf; | |
| 181 | |
| 182 // Show the manufacturer dialog if we can't autoconfigure. Otherwise, show | |
| 183 // configuring while we wait. | |
| 184 if (!this.newPrinter.autoconf) { | |
| 185 this.switchToManufacturerDialog_(); | |
| 186 } else { | |
| 187 this.$$('add-printer-dialog').close(); | |
| 188 this.fire('open-configuring-printer-dialog'); | |
| 189 } | |
| 190 }, | |
| 191 | |
| 192 /** | |
| 193 * Handler for getPrinterInfo failure. | |
| 194 * @param {!QueryFailure} rejected | |
| 195 * @private | |
| 196 */ | |
| 197 infoFailed_: function(rejected) { | |
| 198 this.switchToManufacturerDialog_(); | |
| 199 }, | |
| 200 | |
| 201 /** @private */ | |
| 202 addPressed_: function() { | |
| 203 if (this.newPrinter.printerProtocol == 'ipp' || | |
|
xdai1
2017/06/05 17:55:55
Do you need to move line 216 - 218 to here?
skau
2017/06/07 23:55:39
I've moved this query to the configuring screen in
| |
| 204 this.newPrinter.printerProtocol == 'ipps') { | |
| 205 settings.CupsPrintersBrowserProxyImpl.getInstance(). | |
| 206 getPrinterInfo(this.newPrinter). | |
| 207 then(this.onPrinterFound_.bind(this), this.infoFailed_.bind(this)); | |
| 208 return; | |
| 209 } | |
| 210 | |
| 211 this.switchToManufacturerDialog_(); | |
| 212 }, | |
| 213 | |
| 171 /** @private */ | 214 /** @private */ |
| 172 switchToManufacturerDialog_: function() { | 215 switchToManufacturerDialog_: function() { |
| 173 // Set the default printer queue to be "ipp/print". | 216 // Set the default printer queue to be "ipp/print". |
| 174 if (!this.newPrinter.printerQueue) | 217 if (!this.newPrinter.printerQueue) |
| 175 this.set('newPrinter.printerQueue', 'ipp/print'); | 218 this.set('newPrinter.printerQueue', 'ipp/print'); |
| 176 | 219 |
| 177 this.$$('add-printer-dialog').close(); | 220 this.$$('add-printer-dialog').close(); |
| 178 this.fire('open-manufacturer-model-dialog'); | 221 this.fire('open-manufacturer-model-dialog'); |
| 179 }, | 222 }, |
| 180 | 223 |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 418 /** @private */ | 461 /** @private */ |
| 419 openConfiguringPrinterDialog_: function() { | 462 openConfiguringPrinterDialog_: function() { |
| 420 this.switchDialog_( | 463 this.switchDialog_( |
| 421 this.currentDialog_, AddPrinterDialogs.CONFIGURING, | 464 this.currentDialog_, AddPrinterDialogs.CONFIGURING, |
| 422 'showConfiguringDialog_'); | 465 'showConfiguringDialog_'); |
| 423 if (this.previousDialog_ == AddPrinterDialogs.DISCOVERY) { | 466 if (this.previousDialog_ == AddPrinterDialogs.DISCOVERY) { |
| 424 this.configuringDialogTitle = | 467 this.configuringDialogTitle = |
| 425 loadTimeData.getString('addPrintersNearbyTitle'); | 468 loadTimeData.getString('addPrintersNearbyTitle'); |
| 426 settings.CupsPrintersBrowserProxyImpl.getInstance().addCupsPrinter( | 469 settings.CupsPrintersBrowserProxyImpl.getInstance().addCupsPrinter( |
| 427 this.newPrinter); | 470 this.newPrinter); |
| 428 } else if (this.previousDialog_ == AddPrinterDialogs.MANUFACTURER) { | 471 } else if ( |
| 472 this.previousDialog_ == AddPrinterDialogs.MANUFACTURER || | |
| 473 this.previousDialog_ == AddPrinterDialogs.MANUALLY) { | |
| 429 this.configuringDialogTitle = | 474 this.configuringDialogTitle = |
| 430 loadTimeData.getString('addPrintersManuallyTitle'); | 475 loadTimeData.getString('addPrintersManuallyTitle'); |
| 431 settings.CupsPrintersBrowserProxyImpl.getInstance().addCupsPrinter( | 476 settings.CupsPrintersBrowserProxyImpl.getInstance().addCupsPrinter( |
| 432 this.newPrinter); | 477 this.newPrinter); |
| 433 } | 478 } |
| 434 }, | 479 }, |
| 435 | 480 |
| 436 /** @private */ | 481 /** @private */ |
| 437 openManufacturerModelDialog_: function() { | 482 openManufacturerModelDialog_: function() { |
| 438 this.switchDialog_(this.currentDialog_, AddPrinterDialogs.MANUFACTURER, | 483 this.switchDialog_(this.currentDialog_, AddPrinterDialogs.MANUFACTURER, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 488 onAddPrinter_: function(success, printerName) { | 533 onAddPrinter_: function(success, printerName) { |
| 489 this.$$('add-printer-configuring-dialog').close(); | 534 this.$$('add-printer-configuring-dialog').close(); |
| 490 if (success) | 535 if (success) |
| 491 return; | 536 return; |
| 492 | 537 |
| 493 if (this.previousDialog_ == AddPrinterDialogs.MANUFACTURER) { | 538 if (this.previousDialog_ == AddPrinterDialogs.MANUFACTURER) { |
| 494 this.setupFailed = true; | 539 this.setupFailed = true; |
| 495 } | 540 } |
| 496 }, | 541 }, |
| 497 }); | 542 }); |
| OLD | NEW |