| Index: chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.js
|
| diff --git a/chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.js b/chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.js
|
| index b3ff3fb37ce31ce64f546ee2322215e7d9c107d5..32a7dd3fe91c241ac72294a689a149ff1f1fcf10 100644
|
| --- a/chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.js
|
| +++ b/chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.js
|
| @@ -55,6 +55,17 @@ Polymer({
|
| I18nBehavior,
|
| ],
|
|
|
| + /**
|
| + * @return {boolean} True iff the provided expiration date is passed.
|
| + * @private
|
| + */
|
| + checkIfCardExpired_: function(expirationMonth_, expirationYear_) {
|
| + var now = new Date();
|
| + return (expirationYear_ < now.getFullYear() ||
|
| + (expirationYear_ == now.getFullYear() &&
|
| + expirationMonth_ <= now.getMonth()));
|
| + },
|
| +
|
| /** @override */
|
| attached: function() {
|
| this.title_ = this.i18n(
|
| @@ -108,10 +119,15 @@ Polymer({
|
| * @private
|
| */
|
| onSaveButtonTap_: function() {
|
| - this.creditCard.expirationYear = this.expirationYear_;
|
| - this.creditCard.expirationMonth = this.expirationMonth_;
|
| - this.fire('save-credit-card', this.creditCard);
|
| - this.close();
|
| + // If the card is expired, reflect the error to the user.
|
| + // Otherwise, update the card, save and close the dialog.
|
| + if (!this.checkIfCardExpired_(this.expirationMonth_,
|
| + this.expirationYear_)) {
|
| + this.creditCard.expirationYear = this.expirationYear_;
|
| + this.creditCard.expirationMonth = this.expirationMonth_;
|
| + this.fire('save-credit-card', this.creditCard);
|
| + this.close();
|
| + }
|
| },
|
|
|
| /** @private */
|
|
|