Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Side by Side Diff: chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.js

Issue 2979903003: [CUPS] If no printers is auto-discovered, show the manual printer setup dialog (Closed)
Patch Set: . Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 }, 77 },
78 78
79 /** @override */ 79 /** @override */
80 ready: function() { 80 ready: function() {
81 settings.CupsPrintersBrowserProxyImpl.getInstance() 81 settings.CupsPrintersBrowserProxyImpl.getInstance()
82 .startDiscoveringPrinters(); 82 .startDiscoveringPrinters();
83 this.addWebUIListener( 83 this.addWebUIListener(
84 'on-printer-discovered', this.onPrinterDiscovered_.bind(this)); 84 'on-printer-discovered', this.onPrinterDiscovered_.bind(this));
85 this.addWebUIListener( 85 this.addWebUIListener(
86 'on-printer-discovery-done', this.onPrinterDiscoveryDone_.bind(this)); 86 'on-printer-discovery-done', this.onPrinterDiscoveryDone_.bind(this));
87 this.addWebUIListener( 87 },
88 'on-printer-discovery-failed', this.onPrinterDiscoveryDone_.bind(this)); 88
89 close: function() {
90 this.$$('add-printer-dialog').close();
89 }, 91 },
90 92
91 /** 93 /**
92 * @param {!Array<!CupsPrinterInfo>} printers 94 * @param {!Array<!CupsPrinterInfo>} printers
93 * @private 95 * @private
94 */ 96 */
95 onPrinterDiscovered_: function(printers) { 97 onPrinterDiscovered_: function(printers) {
96 this.discovering_ = true; 98 this.discovering_ = true;
97 if (!this.discoveredPrinters) { 99 if (!this.discoveredPrinters) {
98 this.discoveredPrinters = printers; 100 this.discoveredPrinters = printers;
99 } else { 101 } else {
100 for (var i = 0; i < printers.length; i++) 102 for (var i = 0; i < printers.length; i++)
101 this.push('discoveredPrinters', printers[i]); 103 this.push('discoveredPrinters', printers[i]);
102 } 104 }
103 }, 105 },
104 106
105 /** @private */ 107 /** @private */
106 onPrinterDiscoveryDone_: function() { 108 onPrinterDiscoveryDone_: function() {
107 this.discovering_ = false; 109 this.discovering_ = false;
108 this.$$('add-printer-list').style.maxHeight = kPrinterListFullHeight + 'px'; 110 this.$$('add-printer-list').style.maxHeight = kPrinterListFullHeight + 'px';
109 this.$.noPrinterMessage.hidden = !!this.discoveredPrinters; 111 this.$.noPrinterMessage.hidden = !!this.discoveredPrinters.length;
112
113 if (!this.discoveredPrinters.length)
114 this.fire('no-detected-printer');
110 }, 115 },
111 116
112 /** @private */ 117 /** @private */
113 stopDiscoveringPrinters_: function() { 118 stopDiscoveringPrinters_: function() {
114 settings.CupsPrintersBrowserProxyImpl.getInstance() 119 settings.CupsPrintersBrowserProxyImpl.getInstance()
115 .stopDiscoveringPrinters(); 120 .stopDiscoveringPrinters();
116 this.discovering_ = false; 121 this.discovering_ = false;
117 }, 122 },
118 123
119 /** @private */ 124 /** @private */
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 /** @private {boolean} */ 376 /** @private {boolean} */
372 showManufacturerDialog_: Boolean, 377 showManufacturerDialog_: Boolean,
373 }, 378 },
374 379
375 listeners: { 380 listeners: {
376 'configuring-dialog-closed': 'configuringDialogClosed_', 381 'configuring-dialog-closed': 'configuringDialogClosed_',
377 'open-manually-add-printer-dialog': 'openManuallyAddPrinterDialog_', 382 'open-manually-add-printer-dialog': 'openManuallyAddPrinterDialog_',
378 'open-configuring-printer-dialog': 'openConfiguringPrinterDialog_', 383 'open-configuring-printer-dialog': 'openConfiguringPrinterDialog_',
379 'open-discovery-printers-dialog': 'openDiscoveryPrintersDialog_', 384 'open-discovery-printers-dialog': 'openDiscoveryPrintersDialog_',
380 'open-manufacturer-model-dialog': 'openManufacturerModelDialog_', 385 'open-manufacturer-model-dialog': 'openManufacturerModelDialog_',
386 'no-detected-printer': 'onNoDetectedPrinter_',
381 }, 387 },
382 388
383 /** @override */ 389 /** @override */
384 ready: function() { 390 ready: function() {
385 this.addWebUIListener('on-add-cups-printer', this.onAddPrinter_.bind(this)); 391 this.addWebUIListener('on-add-cups-printer', this.onAddPrinter_.bind(this));
386 }, 392 },
387 393
388 /** Opens the Add printer discovery dialog. */ 394 /** Opens the Add printer discovery dialog. */
389 open: function() { 395 open: function() {
390 this.resetData_(); 396 this.resetData_();
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 this.currentDialog_, this.previousDialog_, 'showDiscoveryDialog_'); 509 this.currentDialog_, this.previousDialog_, 'showDiscoveryDialog_');
504 } else if (this.previousDialog_ == AddPrinterDialogs.MANUALLY) { 510 } else if (this.previousDialog_ == AddPrinterDialogs.MANUALLY) {
505 this.switchDialog_( 511 this.switchDialog_(
506 this.currentDialog_, this.previousDialog_, 'showManuallyAddDialog_'); 512 this.currentDialog_, this.previousDialog_, 'showManuallyAddDialog_');
507 } else if (this.previousDialog_ == AddPrinterDialogs.MANUFACTURER) { 513 } else if (this.previousDialog_ == AddPrinterDialogs.MANUFACTURER) {
508 this.switchDialog_( 514 this.switchDialog_(
509 this.currentDialog_, this.previousDialog_, 'showManufacturerDialog_'); 515 this.currentDialog_, this.previousDialog_, 'showManufacturerDialog_');
510 } 516 }
511 }, 517 },
512 518
519 /** @private */
520 onNoDetectedPrinter_: function() {
521 // If there is no detected printer, automatically open manually-add-printer
522 // dialog only when the user opens the discovery-dialog through the
523 // "ADD PRINTER" button.
524 if (!this.previousDialog_) {
525 this.$$('add-printer-discovery-dialog').close();
526 this.openManuallyAddPrinterDialog_();
527 }
528 },
529
513 /** 530 /**
514 * Switch dialog from |fromDialog| to |toDialog|. 531 * Switch dialog from |fromDialog| to |toDialog|.
515 * @param {string} fromDialog 532 * @param {string} fromDialog
516 * @param {string} toDialog 533 * @param {string} toDialog
517 * @param {string} domIfBooleanName The name of the boolean variable 534 * @param {string} domIfBooleanName The name of the boolean variable
518 * corresponding to the |toDialog|. 535 * corresponding to the |toDialog|.
519 * @private 536 * @private
520 */ 537 */
521 switchDialog_: function(fromDialog, toDialog, domIfBooleanName) { 538 switchDialog_: function(fromDialog, toDialog, domIfBooleanName) {
522 this.previousDialog_ = fromDialog; 539 this.previousDialog_ = fromDialog;
(...skipping 16 matching lines...) Expand all
539 onAddPrinter_: function(success, printerName) { 556 onAddPrinter_: function(success, printerName) {
540 this.$$('add-printer-configuring-dialog').close(); 557 this.$$('add-printer-configuring-dialog').close();
541 if (success) 558 if (success)
542 return; 559 return;
543 560
544 if (this.previousDialog_ == AddPrinterDialogs.MANUFACTURER) { 561 if (this.previousDialog_ == AddPrinterDialogs.MANUFACTURER) {
545 this.setupFailed = true; 562 this.setupFailed = true;
546 } 563 }
547 }, 564 },
548 }); 565 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698