| 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 45e023f6aa4e91bbf6ab2cffa113877a25079a0a..66e3a0aa66aff929161800992ac8e9032da98a1a 100644
|
| --- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
|
| +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
|
| @@ -2125,32 +2125,30 @@ void AutofillDialogControllerImpl::UserEditedOrActivatedInput(
|
| return;
|
| }
|
|
|
| - std::vector<base::string16> popup_values, popup_labels, popup_icons;
|
| + std::vector<autofill::Suggestion> popup_suggestions;
|
| + popup_suggestion_ids_.clear();
|
| if (common::IsCreditCardType(type)) {
|
| - GetManager()->GetCreditCardSuggestions(AutofillType(type),
|
| - field_contents,
|
| - &popup_values,
|
| - &popup_labels,
|
| - &popup_icons,
|
| - &popup_guids_);
|
| + popup_suggestions = GetManager()->GetCreditCardSuggestions(
|
| + AutofillType(type), field_contents);
|
| + for (const auto& suggestion : popup_suggestions)
|
| + popup_suggestion_ids_.push_back(suggestion.backend_id);
|
| } else {
|
| - GetManager()->GetProfileSuggestions(
|
| + popup_suggestions = GetManager()->GetProfileSuggestions(
|
| AutofillType(type),
|
| field_contents,
|
| false,
|
| RequestedTypesForSection(section),
|
| base::Bind(&AutofillDialogControllerImpl::ShouldSuggestProfile,
|
| - base::Unretained(this), section),
|
| - &popup_values,
|
| - &popup_labels,
|
| - &popup_icons,
|
| - &popup_guids_);
|
| + base::Unretained(this), section));
|
| + for (const auto& suggestion : popup_suggestions)
|
| + popup_suggestion_ids_.push_back(suggestion.backend_id);
|
|
|
| - GetI18nValidatorSuggestions(section, type, &popup_values, &popup_labels,
|
| - &popup_icons);
|
| + // This will append to the popup_suggestions but not the IDs since there
|
| + // are no backend IDs for the I18N validator suggestions.
|
| + GetI18nValidatorSuggestions(section, type, &popup_suggestions);
|
| }
|
|
|
| - if (popup_values.empty()) {
|
| + if (popup_suggestions.empty()) {
|
| HidePopup();
|
| return;
|
| }
|
| @@ -2159,11 +2157,11 @@ void AutofillDialogControllerImpl::UserEditedOrActivatedInput(
|
| popup_input_type_ = type;
|
| popup_section_ = section;
|
|
|
| + // Use our own 0-based IDs for the items.
|
| // TODO(estade): do we need separators and control rows like 'Clear
|
| // Form'?
|
| - std::vector<int> popup_ids;
|
| - for (size_t i = 0; i < popup_values.size(); ++i) {
|
| - popup_ids.push_back(i);
|
| + for (size_t i = 0; i < popup_suggestions.size(); ++i) {
|
| + popup_suggestions[i].frontend_id = i;
|
| }
|
|
|
| popup_controller_ = AutofillPopupControllerImpl::GetOrCreate(
|
| @@ -2174,10 +2172,7 @@ void AutofillDialogControllerImpl::UserEditedOrActivatedInput(
|
| content_bounds,
|
| base::i18n::IsRTL() ?
|
| base::i18n::RIGHT_TO_LEFT : base::i18n::LEFT_TO_RIGHT);
|
| - popup_controller_->Show(popup_values,
|
| - popup_labels,
|
| - popup_icons,
|
| - popup_ids);
|
| + popup_controller_->Show(popup_suggestions);
|
| }
|
|
|
| void AutofillDialogControllerImpl::FocusMoved() {
|
| @@ -2410,20 +2405,21 @@ void AutofillDialogControllerImpl::DidAcceptSuggestion(
|
| ScopedViewUpdates updates(view_.get());
|
| scoped_ptr<DataModelWrapper> wrapper;
|
|
|
| - if (static_cast<size_t>(identifier) < popup_guids_.size()) {
|
| - const PersonalDataManager::GUIDPair& pair = popup_guids_[identifier];
|
| + if (static_cast<size_t>(identifier) < popup_suggestion_ids_.size()) {
|
| + const SuggestionBackendID& sid = popup_suggestion_ids_[identifier];
|
| if (common::IsCreditCardType(popup_input_type)) {
|
| wrapper.reset(new AutofillCreditCardWrapper(
|
| - GetManager()->GetCreditCardByGUID(pair.first)));
|
| + GetManager()->GetCreditCardByGUID(sid.guid)));
|
| } else {
|
| wrapper.reset(new AutofillProfileWrapper(
|
| - GetManager()->GetProfileByGUID(pair.first),
|
| + GetManager()->GetProfileByGUID(sid.guid),
|
| AutofillType(popup_input_type),
|
| - pair.second));
|
| + sid.variant));
|
| }
|
| } else {
|
| wrapper.reset(new I18nAddressDataWrapper(
|
| - &i18n_validator_suggestions_[identifier - popup_guids_.size()]));
|
| + &i18n_validator_suggestions_[
|
| + identifier - popup_suggestion_ids_.size()]));
|
| }
|
|
|
| // If the user hasn't switched away from the default country and |wrapper|'s
|
| @@ -3385,9 +3381,7 @@ CountryComboboxModel* AutofillDialogControllerImpl::
|
| void AutofillDialogControllerImpl::GetI18nValidatorSuggestions(
|
| DialogSection section,
|
| ServerFieldType type,
|
| - std::vector<base::string16>* popup_values,
|
| - std::vector<base::string16>* popup_labels,
|
| - std::vector<base::string16>* popup_icons) {
|
| + std::vector<autofill::Suggestion>* popup_suggestions) {
|
| AddressField focused_field;
|
| if (!i18n::FieldForType(type, &focused_field))
|
| return;
|
| @@ -3412,24 +3406,23 @@ void AutofillDialogControllerImpl::GetI18nValidatorSuggestions(
|
| return;
|
|
|
| for (size_t i = 0; i < i18n_validator_suggestions_.size(); ++i) {
|
| - popup_values->push_back(base::UTF8ToUTF16(
|
| - i18n_validator_suggestions_[i].GetFieldValue(focused_field)));
|
| + popup_suggestions->push_back(autofill::Suggestion(
|
| + base::UTF8ToUTF16(
|
| + i18n_validator_suggestions_[i].GetFieldValue(focused_field))));
|
|
|
| // Disambiguate the suggestion by showing the smallest administrative
|
| // region of the suggested address:
|
| // ADMIN_AREA > LOCALITY > DEPENDENT_LOCALITY
|
| - popup_labels->push_back(base::string16());
|
| for (int field = DEPENDENT_LOCALITY; field >= ADMIN_AREA; --field) {
|
| const std::string& field_value =
|
| i18n_validator_suggestions_[i].GetFieldValue(
|
| static_cast<AddressField>(field));
|
| if (focused_field != field && !field_value.empty()) {
|
| - popup_labels->back().assign(base::UTF8ToUTF16(field_value));
|
| + popup_suggestions->back().label = base::UTF8ToUTF16(field_value);
|
| break;
|
| }
|
| }
|
| }
|
| - popup_icons->resize(popup_values->size());
|
| }
|
|
|
| DetailInputs* AutofillDialogControllerImpl::MutableRequestedFieldsForSection(
|
|
|