Chromium Code Reviews| 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 c46f3a1f795bfc1a3c47d90172a085733bea89bc..27441304a2bc99790b039b0e35854b4c08383ace 100644 |
| --- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
| +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
| @@ -641,12 +641,27 @@ void AutofillDialogControllerImpl::EnsureLegalDocumentsText() { |
| legal_documents_text_ = text; |
| } |
| -void AutofillDialogControllerImpl::ResetManualInputForSection( |
| +void AutofillDialogControllerImpl::PrepareDetailInputsForSection( |
| DialogSection section) { |
| + // Reset all previously entered data and stop editing |section|. |
| DetailInputs* inputs = MutableRequestedFieldsForSection(section); |
| - for (size_t i = 0; i < inputs->size(); ++i) |
| + for (size_t i = 0; i < inputs->size(); ++i) { |
| (*inputs)[i].initial_value.clear(); |
| + } |
| section_editing_state_[section] = false; |
| + |
| + // If the chosen item in |model| yields an empty suggestion text, it is |
| + // invalid. In this case, show the editing UI with invalid fields highlighted. |
| + SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section); |
| + if (IsASuggestionItemKey(model->GetItemKeyForCheckedItem()) && |
| + SuggestionTextForSection(section).empty()) { |
| + scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section); |
| + wrapper->FillInputs(MutableRequestedFieldsForSection(section)); |
| + section_editing_state_[section] = true; |
| + } |
| + |
| + if (view_) |
| + view_->UpdateSection(section); |
| } |
| const DetailInputs& AutofillDialogControllerImpl::RequestedFieldsForSection( |
| @@ -751,8 +766,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(); |
| @@ -902,9 +918,8 @@ bool AutofillDialogControllerImpl::EditEnabledForSection( |
| void AutofillDialogControllerImpl::EditClickedForSection( |
| DialogSection section) { |
| - DetailInputs* inputs = MutableRequestedFieldsForSection(section); |
| scoped_ptr<DataModelWrapper> model = CreateWrapper(section); |
| - model->FillInputs(inputs); |
| + model->FillInputs(MutableRequestedFieldsForSection(section)); |
| section_editing_state_[section] = true; |
| view_->UpdateSection(section); |
| @@ -914,8 +929,7 @@ void AutofillDialogControllerImpl::EditClickedForSection( |
| void AutofillDialogControllerImpl::EditCancelledForSection( |
| DialogSection section) { |
| - ResetManualInputForSection(section); |
| - view_->UpdateSection(section); |
| + PrepareDetailInputsForSection(section); |
| } |
| gfx::Image AutofillDialogControllerImpl::IconForField( |
| @@ -1395,7 +1409,7 @@ void AutofillDialogControllerImpl::SuggestionItemSelected( |
| } |
| model->SetCheckedIndex(index); |
| - EditCancelledForSection(SectionForSuggestionsMenuModel(*model)); |
| + PrepareDetailInputsForSection(SectionForSuggestionsMenuModel(*model)); |
| LogSuggestionItemSelectedMetric(*model); |
| } |
| @@ -1572,13 +1586,6 @@ void AutofillDialogControllerImpl::OnPersonalDataChanged() { |
| // AccountChooserModelDelegate implementation. |
| 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); |
| - |
| if (is_submitting_) |
| GetWalletClient()->CancelRequests(); |
| @@ -1734,7 +1741,6 @@ void AutofillDialogControllerImpl::SuggestionsUpdated() { |
| base::IntToString(i), |
| addresses[i]->DisplayName(), |
| addresses[i]->DisplayNameDetail()); |
| - |
| } |
| if (!IsSubmitPausedOn(wallet::VERIFY_CVV)) { |
| @@ -1827,12 +1833,17 @@ void AutofillDialogControllerImpl::SuggestionsUpdated() { |
| const std::string& first_real_suggestion_item_key = |
| suggested_shipping_.GetItemKeyAt(1); |
| if (IsASuggestionItemKey(first_real_suggestion_item_key)) |
| - suggested_shipping_.SetCheckedItem(first_real_suggestion_item_key); |
| + suggested_shipping_.SetCheckedItem(first_real_suggestion_item_key); |
| if (view_) |
| view_->ModelChanged(); |
| + |
| + for (size_t section = SECTION_MIN; section <= SECTION_MAX; ++section) { |
| + PrepareDetailInputsForSection(static_cast<DialogSection>(section)); |
| + } |
| } |
| + |
|
Evan Stade
2013/05/01 21:54:31
^H
Dan Beam
2013/05/02 00:03:31
Done.
|
| bool AutofillDialogControllerImpl::IsCompleteProfile( |
| const AutofillProfile& profile) { |
| const std::string app_locale = g_browser_process->GetApplicationLocale(); |
| @@ -2315,7 +2326,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 |