Index: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
index b122d2f547b07c4537d4f6d355cede5703b746ab..e314fb72f3de0b877fcb14bf98bc7a2a78198718 100644 |
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
@@ -1225,9 +1225,11 @@ ValidityData AutofillDialogControllerImpl::InputsAreValid( |
std::map<AutofillFieldType, string16> field_values; |
for (DetailOutputMap::const_iterator iter = inputs.begin(); |
iter != inputs.end(); ++iter) { |
- // Skip empty fields in edit mode. |
- if (validation_type == VALIDATE_EDIT && iter->second.empty()) |
+ // Skip empty fields in edit mode or when selecting a suggestion. |
+ if ((validation_type == VALIDATE_EDIT || |
+ validation_type == VALIDATE_SELECT) && iter->second.empty()) { |
continue; |
+ } |
const AutofillFieldType type = iter->first->type; |
string16 message = InputValidityMessage(type, iter->second); |
@@ -1241,10 +1243,31 @@ ValidityData AutofillDialogControllerImpl::InputsAreValid( |
// never supposed to have 2-digit years, so not checked). |
if (field_values.count(CREDIT_CARD_EXP_MONTH) && |
field_values.count(CREDIT_CARD_EXP_4_DIGIT_YEAR)) { |
+ // If the expiration is in the past as per the local clock, it's invalid. |
+ bool invalid_expiration = false; |
if (!autofill::IsValidCreditCardExpirationDate( |
field_values[CREDIT_CARD_EXP_4_DIGIT_YEAR], |
field_values[CREDIT_CARD_EXP_MONTH], |
base::Time::Now())) { |
+ invalid_expiration = true; |
+ } else if (validation_type == VALIDATE_SELECT && IsPayingWithWallet()) { |
Evan Stade
2013/05/31 23:06:45
instead of VALIDATE_SELECT, can you check if input
Evan Stade
2013/05/31 23:06:45
It also might be easier to read if you moved the i
Dan Beam
2013/06/01 00:23:06
Done.
Dan Beam
2013/06/01 00:23:06
Done.
|
+ std::map<DialogSection, bool>::const_iterator it = |
+ section_editing_state_.find(SECTION_CC_BILLING); |
+ if (it != section_editing_state_.end() && it->second) { |
+ const SuggestionsMenuModel* model = |
+ SuggestionsMenuModelForSection(SECTION_CC_BILLING); |
+ int instrument_index = -1; |
+ base::StringToInt(model->GetItemKeyForCheckedItem(), &instrument_index); |
+ if (wallet_items_->instruments()[instrument_index]->status() == |
+ wallet::WalletItems::MaskedInstrument::EXPIRED) { |
+ // Otherwise, if the user is editing an instrument that's deemed |
+ // expired by the Online Wallet server, mark it invalid on selection. |
+ invalid_expiration = true; |
+ } |
+ } |
+ } |
+ |
+ if (invalid_expiration) { |
invalid_messages[CREDIT_CARD_EXP_MONTH] = |
ASCIIToUTF16("more complicated message"); |
invalid_messages[CREDIT_CARD_EXP_4_DIGIT_YEAR] = |