Skip to content

Commit

Permalink
Add boolean property to track when adding a printer is in progress
Browse files Browse the repository at this point in the history
This fixes a bug where hitting ENTER multiple times while clicking the
Add button of the add-printer-manufacturer-model-dialog would add a
printer multiple times. Now the Add button is disabled when adding a
printer is still in progress.

verify Add button gets disabled after clicking it on the Advanced
printer configuration dialog

Bug: 990755
Test: Navigate to chrome://settings/cupsPrinters, click Add Printer, and
Change-Id: Iae43376aacd8427cf5c5f3ee85f6f36efa39a75e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1747154
Reviewed-by: Bailey Berro <baileyberro@chromium.org>
Reviewed-by: Dan Beam <dbeam@chromium.org>
Reviewed-by: Sean Kau <skau@chromium.org>
Commit-Queue: Jesse Schettler <jschettler@chromium.org>
Cr-Commit-Position: refs/heads/master@{#685815}
  • Loading branch information
Jesse Schettler authored and Commit Bot committed Aug 10, 2019
1 parent b2d5056 commit 40a4172
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@
</cr-button>
<cr-button id="addPrinterButton" class="action-button"
on-click="addPressed_"
disabled="[[!canAddPrinter_(newPrinter.*, inProgress_)]]">
disabled="[[!canAddPrinter_(newPrinter.*,
addPrinterInProgress_)]]">
$i18n{addPrinterButtonText}
</cr-button>
</div>
Expand Down Expand Up @@ -216,7 +217,8 @@
<cr-button class="action-button" id="addPrinterButton"
disabled="[[!canAddPrinter_(activePrinter.ppdManufacturer,
activePrinter.ppdModel,
activePrinter.printerPPDPath)]]"
activePrinter.printerPPDPath,
addPrinterInProgress_)]]"
on-click="addPrinter_">
$i18n{addPrinterButtonText}
</cr-button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,12 @@ Polymer({
value: '',
},

/** @private */
addPrinterInProgress_: {
type: Boolean,
value: false,
},

/**
* The error text to be displayed on the dialog.
* @private
Expand Down Expand Up @@ -431,6 +437,7 @@ Polymer({
* @private
* */
onPrinterAddedFailed_: function(result) {
this.addPrinterInProgress_ = false;
this.errorText_ = settings.printing.getErrorText(
/** @type {PrinterSetupResult} */ (result));
},
Expand Down Expand Up @@ -548,6 +555,7 @@ Polymer({

/** @private */
addPrinter_: function() {
this.addPrinterInProgress_ = true;
settings.CupsPrintersBrowserProxyImpl.getInstance()
.addCupsPrinter(this.activePrinter)
.then(
Expand All @@ -563,8 +571,9 @@ Polymer({
* @private
*/
canAddPrinter_: function(ppdManufacturer, ppdModel, printerPPDPath) {
return settings.printing.isPPDInfoValid(
ppdManufacturer, ppdModel, printerPPDPath);
return !this.addPrinterInProgress_ &&
settings.printing.isPPDInfoValid(
ppdManufacturer, ppdModel, printerPPDPath);
},
});

Expand Down

0 comments on commit 40a4172

Please sign in to comment.