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

Unified Diff: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc

Issue 15961007: Highlight fields we know to be invalid but have no way of locally checking. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
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..58ff945094bf6ae54de7bcfcd0dfd4319e34ae10 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,32 @@ 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)) {
+ bool invalid_exp = false;
groby-ooo-7-16 2013/05/31 04:12:51 nit: invalid_expiration. invalid_date. Something t
Dan Beam 2013/05/31 05:08:50 Done.
+
+ // If the expiration is in the past as per the local clock, it's invalid.
if (!autofill::IsValidCreditCardExpirationDate(
field_values[CREDIT_CARD_EXP_4_DIGIT_YEAR],
field_values[CREDIT_CARD_EXP_MONTH],
base::Time::Now())) {
+ invalid_exp = true;
+ } else if (validation_type == VALIDATE_SELECT && IsPayingWithWallet()) {
+ std::map<DialogSection, bool>::const_iterator it =
groby-ooo-7-16 2013/05/31 04:12:51 You can skip the "find" hoops - just section_editi
Dan Beam 2013/05/31 05:08:50 const, the hoops must stay std::set, a better way
+ 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_exp = true;
+ }
+ }
+ }
+
+ if (invalid_exp) {
invalid_messages[CREDIT_CARD_EXP_MONTH] =
ASCIIToUTF16("more complicated message");
invalid_messages[CREDIT_CARD_EXP_4_DIGIT_YEAR] =
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_controller.h ('k') | chrome/browser/ui/views/autofill/autofill_dialog_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698