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

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

Issue 14425010: Handle expired Autofill credit cards in autofill dialog (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 8 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 09c2c7a006ce9a22616b2e256331001339fa9514..b100c6ddd4eda7a35ec12c0bdb4ed4f1441cea13 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
@@ -387,6 +387,15 @@ void AutofillDialogControllerImpl::Show() {
// TODO(aruslan): UMA metrics for sign-in.
if (account_chooser_model_.WalletIsSelected())
GetWalletItems();
+
+ // Some suggestions may be invalid to start. Run |SuggestionItemSelected()|
+ // for each section to make sure the edit UI is shown for these suggestions.
+ for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) {
+ DialogSection section = static_cast<DialogSection>(i);
+ SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section);
+ if (IsASuggestionItemKey(model->GetItemKeyForCheckedItem()))
+ SuggestionItemSelected(model, model->checked_item());
+ }
}
void AutofillDialogControllerImpl::Hide() {
@@ -632,6 +641,7 @@ void AutofillDialogControllerImpl::ResetManualInputForSection(
DetailInputs* inputs = MutableRequestedFieldsForSection(section);
for (size_t i = 0; i < inputs->size(); ++i)
(*inputs)[i].initial_value.clear();
+ // TODO(dbeam): why is this here rather than in EditCancelledForSection()?
section_editing_state_[section] = false;
}
@@ -737,8 +747,9 @@ string16 AutofillDialogControllerImpl::SuggestionTextForSection(
if (!action_text.empty())
return action_text;
- // When the user has clicked 'edit', don't show a suggestion (even though
- // there is a profile selected in the model).
+ // When the user has clicked 'edit' or a suggestion is somehow invalid (e.g. a
+ // user selects a credit card that has expired), don't show a suggestion (even
+ // though there is a profile selected in the model).
if (section_editing_state_[section])
return string16();
@@ -756,7 +767,7 @@ string16 AutofillDialogControllerImpl::SuggestionTextForSection(
return model->GetLabelAt(model->checked_item());
scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section);
- return wrapper->GetDisplayText();
+ return wrapper->IsValid() ? wrapper->GetDisplayText() : string16();
}
gfx::Font::FontStyle
@@ -889,16 +900,18 @@ bool AutofillDialogControllerImpl::EditEnabledForSection(
void AutofillDialogControllerImpl::EditClickedForSection(
DialogSection section) {
- DetailInputs* inputs = MutableRequestedFieldsForSection(section);
- scoped_ptr<DataModelWrapper> model = CreateWrapper(section);
- model->FillInputs(inputs);
- section_editing_state_[section] = true;
- view_->UpdateSection(section);
-
+ ShowEditingMode(section);
GetMetricLogger().LogDialogUiEvent(
dialog_type_, DialogSectionToUiEditEvent(section));
}
+void AutofillDialogControllerImpl::ShowEditingMode(DialogSection section) {
Evan Stade 2013/04/24 22:00:17 make functions match header order
Dan Beam 2013/04/26 02:11:32 Done.
+ scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section);
+ wrapper->FillInputs(MutableRequestedFieldsForSection(section));
+ section_editing_state_[section] = true;
+ view_->UpdateSection(section);
+}
+
void AutofillDialogControllerImpl::EditCancelledForSection(
DialogSection section) {
ResetManualInputForSection(section);
@@ -1384,7 +1397,15 @@ void AutofillDialogControllerImpl::SuggestionItemSelected(
}
model->SetCheckedIndex(index);
- EditCancelledForSection(SectionForSuggestionsMenuModel(*model));
+
+ const DialogSection section = SectionForSuggestionsMenuModel(*model);
+ if (IsASuggestionItemKey(model->GetItemKeyForCheckedItem()) &&
Evan Stade 2013/04/24 22:00:17 I can't for the life of me figure out what this is
Dan Beam 2013/04/26 02:11:32 Done.
+ SuggestionTextForSection(section).empty()) {
+ ResetManualInputForSection(section);
+ ShowEditingMode(section);
+ } else {
+ EditCancelledForSection(section);
+ }
LogSuggestionItemSelectedMetric(*model);
}
@@ -1562,11 +1583,9 @@ void AutofillDialogControllerImpl::OnPersonalDataChanged() {
void AutofillDialogControllerImpl::AccountChoiceChanged() {
// Whenever the user changes the account, all manual inputs should be reset.
- ResetManualInputForSection(SECTION_EMAIL);
- ResetManualInputForSection(SECTION_CC);
- ResetManualInputForSection(SECTION_BILLING);
- ResetManualInputForSection(SECTION_CC_BILLING);
- ResetManualInputForSection(SECTION_SHIPPING);
+ for (size_t section = SECTION_MIN; section <= SECTION_MAX; ++section) {
+ ResetManualInputForSection(static_cast<DialogSection>(section));
+ }
if (is_submitting_)
GetWalletClient()->CancelRequests();
@@ -1722,7 +1741,6 @@ void AutofillDialogControllerImpl::SuggestionsUpdated() {
base::IntToString(i),
addresses[i]->DisplayName(),
addresses[i]->DisplayNameDetail());
-
}
if (!IsSubmitPausedOn(wallet::VERIFY_CVV)) {
@@ -2272,7 +2290,6 @@ void AutofillDialogControllerImpl::LogSuggestionItemSelectedMetric(
dialog_ui_event = DialogSectionToUiItemAddedEvent(section);
} else if (IsASuggestionItemKey(model.GetItemKeyForCheckedItem())) {
// Selected an existing item.
- DCHECK(!section_editing_state_[section]);
dialog_ui_event = DialogSectionToUiSelectionChangedEvent(section);
} else {
// TODO(estade): add logging for "Manage items" or "Use billing for

Powered by Google App Engine
This is Rietveld 408576698