diff options
author | estade <estade@chromium.org> | 2015-06-01 18:04:42 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-02 01:05:38 +0000 |
commit | 01609f82dd975086b6ddb16a6085e291f44095a0 (patch) | |
tree | 642a9fe55a9b74ae01961c3b8d1a758606f18916 | |
parent | e9f16dac4e4720220557b1bce6cc8edf9af2745f (diff) | |
download | chromium_src-01609f82dd975086b6ddb16a6085e291f44095a0.zip chromium_src-01609f82dd975086b6ddb16a6085e291f44095a0.tar.gz chromium_src-01609f82dd975086b6ddb16a6085e291f44095a0.tar.bz2 |
[Autofill] Remove support for variants in suggestions dropdown
BUG=493856
Review URL: https://codereview.chromium.org/1167593002
Cr-Commit-Position: refs/heads/master@{#332290}
10 files changed, 266 insertions, 867 deletions
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc index 652953a..ff627e8 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc @@ -2116,7 +2116,7 @@ void AutofillDialogControllerImpl::UserEditedOrActivatedInput( // Filter out ones we don't want. for (int i = 0; i < static_cast<int>(popup_suggestions.size()); i++) { const autofill::AutofillProfile* profile = - GetManager()->GetProfileByGUID(popup_suggestions[i].backend_id.guid); + GetManager()->GetProfileByGUID(popup_suggestions[i].backend_id); if (!profile || !ShouldSuggestProfile(section, *profile)) { popup_suggestions.erase(popup_suggestions.begin() + i); i--; @@ -2390,13 +2390,13 @@ void AutofillDialogControllerImpl::DidAcceptSuggestion( scoped_ptr<DataModelWrapper> wrapper; if (static_cast<size_t>(identifier) < popup_suggestion_ids_.size()) { - const SuggestionBackendID& sid = popup_suggestion_ids_[identifier]; + const std::string& guid = popup_suggestion_ids_[identifier]; if (IsCreditCardType(popup_input_type)) { wrapper.reset(new AutofillCreditCardWrapper( - GetManager()->GetCreditCardByGUID(sid.guid))); + GetManager()->GetCreditCardByGUID(guid))); } else { wrapper.reset(new AutofillProfileWrapper( - GetManager()->GetProfileByGUID(sid.guid))); + GetManager()->GetProfileByGUID(guid))); } } else { wrapper.reset(new I18nAddressDataWrapper( diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h index 5d73d64..80757b7 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h @@ -748,7 +748,7 @@ class AutofillDialogControllerImpl // The IDs for the currently showing unverified profiles popup. This will // be the first section in the list. The rest of the items will be the // i18n_validator_suggestions_. - std::vector<autofill::SuggestionBackendID> popup_suggestion_ids_; + std::vector<std::string> popup_suggestion_ids_; // The autofill suggestions based on downloaded i18n validation rules. std::vector< ::i18n::addressinput::AddressData> i18n_validator_suggestions_; diff --git a/components/autofill/core/browser/autofill_manager.cc b/components/autofill/core/browser/autofill_manager.cc index a49fba4..756b1b1 100644 --- a/components/autofill/core/browser/autofill_manager.cc +++ b/components/autofill/core/browser/autofill_manager.cc @@ -581,8 +581,7 @@ void AutofillManager::FillOrPreviewCreditCardForm( int query_id, const FormData& form, const FormFieldData& field, - const CreditCard& credit_card, - size_t variant) { + const CreditCard& credit_card) { if (action == AutofillDriver::FORM_DATA_ACTION_FILL) { if (credit_card.record_type() == CreditCard::MASKED_SERVER_CARD && WillFillCreditCardNumber(form, field)) { @@ -600,7 +599,7 @@ void AutofillManager::FillOrPreviewCreditCardForm( } FillOrPreviewDataModelForm(action, query_id, form, field, credit_card, - variant, true /* is_credit_card */); + true /* is_credit_card */); } void AutofillManager::FillOrPreviewProfileForm( @@ -608,12 +607,11 @@ void AutofillManager::FillOrPreviewProfileForm( int query_id, const FormData& form, const FormFieldData& field, - const AutofillProfile& profile, - size_t variant) { + const AutofillProfile& profile) { if (action == AutofillDriver::FORM_DATA_ACTION_FILL) address_form_event_logger_->OnDidFillSuggestion(profile); - FillOrPreviewDataModelForm(action, query_id, form, field, profile, variant, + FillOrPreviewDataModelForm(action, query_id, form, field, profile, false /* is_credit_card */); } @@ -636,13 +634,12 @@ void AutofillManager::FillOrPreviewForm( if (!RefreshDataModels() || !driver_->RendererIsAvailable()) return; - size_t variant = 0; const CreditCard* credit_card = nullptr; const AutofillProfile* profile = nullptr; if (GetCreditCard(unique_id, &credit_card)) - FillOrPreviewCreditCardForm(action, query_id, form, field, *credit_card, 0); - else if (GetProfile(unique_id, &profile, &variant)) - FillOrPreviewProfileForm(action, query_id, form, field, *profile, variant); + FillOrPreviewCreditCardForm(action, query_id, form, field, *credit_card); + else if (GetProfile(unique_id, &profile)) + FillOrPreviewProfileForm(action, query_id, form, field, *profile); } void AutofillManager::FillCreditCardForm(int query_id, @@ -655,7 +652,7 @@ void AutofillManager::FillCreditCardForm(int query_id, } FillOrPreviewDataModelForm(AutofillDriver::FORM_DATA_ACTION_FILL, query_id, - form, field, credit_card, 0, true); + form, field, credit_card, true); } void AutofillManager::OnDidPreviewAutofillFormData() { @@ -729,7 +726,6 @@ bool AutofillManager::GetDeletionConfirmationText(const base::string16& value, if (identifier < 0) return false; - size_t variant = 0; const CreditCard* credit_card = nullptr; const AutofillProfile* profile = nullptr; if (GetCreditCard(identifier, &credit_card)) { @@ -744,7 +740,7 @@ bool AutofillManager::GetDeletionConfirmationText(const base::string16& value, } return true; - } else if (GetProfile(identifier, &profile, &variant)) { + } else if (GetProfile(identifier, &profile)) { if (profile->record_type() != AutofillProfile::LOCAL_PROFILE) return false; @@ -769,7 +765,6 @@ bool AutofillManager::GetDeletionConfirmationText(const base::string16& value, bool AutofillManager::RemoveAutofillProfileOrCreditCard(int unique_id) { std::string guid; - size_t variant = 0; const CreditCard* credit_card = nullptr; const AutofillProfile* profile = nullptr; if (GetCreditCard(unique_id, &credit_card)) { @@ -777,7 +772,7 @@ bool AutofillManager::RemoveAutofillProfileOrCreditCard(int unique_id) { return false; guid = credit_card->guid(); - } else if (GetProfile(unique_id, &profile, &variant)) { + } else if (GetProfile(unique_id, &profile)) { if (profile->record_type() != AutofillProfile::LOCAL_PROFILE) return false; @@ -787,12 +782,6 @@ bool AutofillManager::RemoveAutofillProfileOrCreditCard(int unique_id) { return false; } - // TODO(csharp): If we are dealing with a variant only the variant should - // be deleted, instead of doing nothing. - // http://crbug.com/124211 - if (variant != 0) - return false; - personal_data_->RemoveByGUID(guid); return true; } @@ -1090,38 +1079,34 @@ bool AutofillManager::RefreshDataModels() { bool AutofillManager::IsCreditCard(int unique_id) { // Unpack the |unique_id| into component parts. - SuggestionBackendID credit_card_id; - SuggestionBackendID profile_id; + std::string credit_card_id; + std::string profile_id; SplitFrontendID(unique_id, &credit_card_id, &profile_id); - DCHECK(!base::IsValidGUID(credit_card_id.guid) || - !base::IsValidGUID(profile_id.guid)); - return base::IsValidGUID(credit_card_id.guid); + DCHECK(!base::IsValidGUID(credit_card_id) || !base::IsValidGUID(profile_id)); + return base::IsValidGUID(credit_card_id); } bool AutofillManager::GetProfile(int unique_id, - const AutofillProfile** profile, - size_t* variant) { + const AutofillProfile** profile) { // Unpack the |unique_id| into component parts. - SuggestionBackendID credit_card_id; - SuggestionBackendID profile_id; + std::string credit_card_id; + std::string profile_id; SplitFrontendID(unique_id, &credit_card_id, &profile_id); *profile = NULL; - if (base::IsValidGUID(profile_id.guid)) { - *profile = personal_data_->GetProfileByGUID(profile_id.guid); - *variant = profile_id.variant; - } + if (base::IsValidGUID(profile_id)) + *profile = personal_data_->GetProfileByGUID(profile_id); return !!*profile; } bool AutofillManager::GetCreditCard(int unique_id, const CreditCard** credit_card) { // Unpack the |unique_id| into component parts. - SuggestionBackendID credit_card_id; - SuggestionBackendID profile_id; + std::string credit_card_id; + std::string profile_id; SplitFrontendID(unique_id, &credit_card_id, &profile_id); *credit_card = NULL; - if (base::IsValidGUID(credit_card_id.guid)) - *credit_card = personal_data_->GetCreditCardByGUID(credit_card_id.guid); + if (base::IsValidGUID(credit_card_id)) + *credit_card = personal_data_->GetCreditCardByGUID(credit_card_id); return !!*credit_card; } @@ -1131,7 +1116,6 @@ void AutofillManager::FillOrPreviewDataModelForm( const FormData& form, const FormFieldData& field, const AutofillDataModel& data_model, - size_t variant, bool is_credit_card) { FormStructure* form_structure = NULL; AutofillField* autofill_field = NULL; @@ -1158,8 +1142,8 @@ void AutofillManager::FillOrPreviewDataModelForm( for (std::vector<FormFieldData>::iterator iter = result.fields.begin(); iter != result.fields.end(); ++iter) { if (iter->SameFieldAs(field)) { - base::string16 value = data_model.GetInfoForVariant( - autofill_field->Type(), variant, app_locale_); + base::string16 value = + data_model.GetInfo(autofill_field->Type(), app_locale_); if (AutofillField::FillFormField(*autofill_field, value, profile_language_code, @@ -1190,8 +1174,6 @@ void AutofillManager::FillOrPreviewDataModelForm( return; } - // Cache the field type for the field from which the user initiated autofill. - FieldTypeGroup initiating_group_type = autofill_field->Type().group(); DCHECK_EQ(form_structure->field_count(), form.fields.size()); for (size_t i = 0; i < form_structure->field_count(); ++i) { if (form_structure->field(i)->section() != autofill_field->section()) @@ -1205,18 +1187,8 @@ void AutofillManager::FillOrPreviewDataModelForm( if (field_group_type == NO_GROUP) continue; - // If the field being filled is either - // (a) the field that the user initiated the fill from, or - // (b) part of the same logical unit, e.g. name or phone number, - // then take the multi-profile "variant" into account. - // Otherwise fill with the default (zeroth) variant. - size_t use_variant = 0; - if (result.fields[i].SameFieldAs(field) || - field_group_type == initiating_group_type) { - use_variant = variant; - } - base::string16 value = data_model.GetInfoForVariant( - cached_field->Type(), use_variant, app_locale_); + base::string16 value = + data_model.GetInfo(cached_field->Type(), app_locale_); if (is_credit_card && cached_field->Type().GetStorableType() == CREDIT_CARD_VERIFICATION_CODE) { @@ -1439,7 +1411,7 @@ std::vector<Suggestion> AutofillManager::GetProfileSuggestions( for (size_t i = 0; i < suggestions.size(); ++i) { suggestions[i].frontend_id = - MakeFrontendID(SuggestionBackendID(), suggestions[i].backend_id); + MakeFrontendID(std::string(), suggestions[i].backend_id); } return suggestions; } @@ -1451,7 +1423,7 @@ std::vector<Suggestion> AutofillManager::GetCreditCardSuggestions( personal_data_->GetCreditCardSuggestions(type, field.value); for (size_t i = 0; i < suggestions.size(); i++) { suggestions[i].frontend_id = - MakeFrontendID(suggestions[i].backend_id, SuggestionBackendID()); + MakeFrontendID(suggestions[i].backend_id, std::string()); } return suggestions; } @@ -1500,9 +1472,8 @@ void AutofillManager::ParseForms(const std::vector<FormData>& forms) { driver_->SendAutofillTypePredictionsToRenderer(non_queryable_forms); } -int AutofillManager::BackendIDToInt( - const SuggestionBackendID& backend_id) const { - if (!base::IsValidGUID(backend_id.guid)) +int AutofillManager::BackendIDToInt(const std::string& backend_id) const { + if (!base::IsValidGUID(backend_id)) return 0; const auto found = backend_to_int_map_.find(backend_id); @@ -1516,14 +1487,14 @@ int AutofillManager::BackendIDToInt( return found->second; } -SuggestionBackendID AutofillManager::IntToBackendID(int int_id) const { +std::string AutofillManager::IntToBackendID(int int_id) const { if (int_id == 0) - return SuggestionBackendID(); + return std::string(); const auto found = int_to_backend_map_.find(int_id); if (found == int_to_backend_map_.end()) { NOTREACHED(); - return SuggestionBackendID(); + return std::string(); } return found->second; } @@ -1532,8 +1503,8 @@ SuggestionBackendID AutofillManager::IntToBackendID(int int_id) const { // profile IDs into a single integer. Credit card IDs are sent in the high // word and profile IDs are sent in the low word. int AutofillManager::MakeFrontendID( - const SuggestionBackendID& cc_backend_id, - const SuggestionBackendID& profile_backend_id) const { + const std::string& cc_backend_id, + const std::string& profile_backend_id) const { int cc_int_id = BackendIDToInt(cc_backend_id); int profile_int_id = BackendIDToInt(profile_backend_id); @@ -1550,10 +1521,9 @@ int AutofillManager::MakeFrontendID( // When receiving IDs (across processes) from the renderer we unpack credit card // and profile IDs from a single integer. Credit card IDs are stored in the // high word and profile IDs are stored in the low word. -void AutofillManager::SplitFrontendID( - int frontend_id, - SuggestionBackendID* cc_backend_id, - SuggestionBackendID* profile_backend_id) const { +void AutofillManager::SplitFrontendID(int frontend_id, + std::string* cc_backend_id, + std::string* profile_backend_id) const { int cc_int_id = (frontend_id >> std::numeric_limits<uint16_t>::digits) & std::numeric_limits<uint16_t>::max(); int profile_int_id = frontend_id & std::numeric_limits<uint16_t>::max(); @@ -1586,9 +1556,8 @@ bool AutofillManager::ShouldUploadForm(const FormStructure& form) { #if defined(OS_MACOSX) && !defined(OS_IOS) void AutofillManager::EmitIsFromAddressBookMetric(int unique_id) { - size_t variant = 0; const AutofillProfile* profile = nullptr; - bool result = GetProfile(unique_id, &profile, &variant); + bool result = GetProfile(unique_id, &profile); if (!result) return; diff --git a/components/autofill/core/browser/autofill_manager.h b/components/autofill/core/browser/autofill_manager.h index 5fe3b63..1822b16 100644 --- a/components/autofill/core/browser/autofill_manager.h +++ b/components/autofill/core/browser/autofill_manager.h @@ -215,19 +215,19 @@ class AutofillManager : public AutofillDownloadManager::Observer, const base::TimeTicks& interaction_time, const base::TimeTicks& submission_time); - // Maps SuggestionBackendID to and from an integer identifying it. Two of + // Maps suggestion backend ID to and from an integer identifying it. Two of // these intermediate integers are packed by MakeFrontendID to make the IDs // that this class generates for the UI and for IPC. - virtual int BackendIDToInt(const SuggestionBackendID& backend_id) const; - virtual SuggestionBackendID IntToBackendID(int int_id) const; + virtual int BackendIDToInt(const std::string& backend_id) const; + virtual std::string IntToBackendID(int int_id) const; // Methods for packing and unpacking credit card and profile IDs for sending // and receiving to and from the renderer process. - int MakeFrontendID(const SuggestionBackendID& cc_backend_id, - const SuggestionBackendID& profile_backend_id) const; + int MakeFrontendID(const std::string& cc_backend_id, + const std::string& profile_backend_id) const; void SplitFrontendID(int frontend_id, - SuggestionBackendID* cc_backend_id, - SuggestionBackendID* profile_backend_id) const; + std::string* cc_backend_id, + std::string* profile_backend_id) const; ScopedVector<FormStructure>* form_structures() { return &form_structures_; } @@ -256,14 +256,12 @@ class AutofillManager : public AutofillDownloadManager::Observer, // it refers to a profile. bool IsCreditCard(int unique_id); - // Gets the profile referred by |unique_id| and populates |variant| - // based on it. Returns true if the profile exists. - bool GetProfile(int unique_id, - const AutofillProfile** profile, - size_t* variant); + // Gets the profile referred by |unique_id|. Returns true if the profile + // exists. + bool GetProfile(int unique_id, const AutofillProfile** profile); - // Gets the credit card referred by |unique_id| and populates |variant| - // based on it. Returns true if the credit card exists. + // Gets the credit card referred by |unique_id|. Returns true if the credit + // card exists. bool GetCreditCard(int unique_id, const CreditCard** credit_card); // Determines whether a fill on |form| initiated from |field| will wind up @@ -279,18 +277,15 @@ class AutofillManager : public AutofillDownloadManager::Observer, int query_id, const FormData& form, const FormFieldData& field, - const CreditCard& credit_card, - size_t variant); + const CreditCard& credit_card); // Fills or previews the profile form. // Assumes the form and field are valid. - void FillOrPreviewProfileForm( - AutofillDriver::RendererFormDataAction action, - int query_id, - const FormData& form, - const FormFieldData& field, - const AutofillProfile& profile, - size_t variant); + void FillOrPreviewProfileForm(AutofillDriver::RendererFormDataAction action, + int query_id, + const FormData& form, + const FormFieldData& field, + const AutofillProfile& profile); // Fills or previews |data_model| in the |form|. void FillOrPreviewDataModelForm(AutofillDriver::RendererFormDataAction action, @@ -298,7 +293,6 @@ class AutofillManager : public AutofillDownloadManager::Observer, const FormData& form, const FormFieldData& field, const AutofillDataModel& data_model, - size_t variant, bool is_credit_card); // Creates a FormStructure using the FormData received from the renderer. Will @@ -436,11 +430,11 @@ class AutofillManager : public AutofillDownloadManager::Observer, // save the card (in the prompt and in the infobar after submit). std::vector<CreditCard> recently_unmasked_cards_; - // SuggestionBackendID to ID mapping. We keep two maps to convert back and + // Suggestion backend ID to ID mapping. We keep two maps to convert back and // forth. These should be used only by BackendIDToInt and IntToBackendID. // Note that the integers are not frontend IDs. - mutable std::map<SuggestionBackendID, int> backend_to_int_map_; - mutable std::map<int, SuggestionBackendID> int_to_backend_map_; + mutable std::map<std::string, int> backend_to_int_map_; + mutable std::map<int, std::string> int_to_backend_map_; // Delegate to perform external processing (display, selection) on // our behalf. Weak. diff --git a/components/autofill/core/browser/autofill_manager_unittest.cc b/components/autofill/core/browser/autofill_manager_unittest.cc index 8dbf8ea..24f1ba8 100644 --- a/components/autofill/core/browser/autofill_manager_unittest.cc +++ b/components/autofill/core/browser/autofill_manager_unittest.cc @@ -510,8 +510,7 @@ class TestAutofillManager : public AutofillManager { std::string credit_card_guid = base::StringPrintf("00000000-0000-0000-0000-%012d", credit_card_id); - return MakeFrontendID(SuggestionBackendID(credit_card_guid, 0), - SuggestionBackendID()); + return MakeFrontendID(credit_card_guid, std::string()); } void AddSeenForm(FormStructure* form) { @@ -722,8 +721,8 @@ class AutofillManagerTest : public testing::Test { FillAutofillFormData(input_query_id, input_form, input_field, unique_id); } - int MakeFrontendID(const SuggestionBackendID& cc_sid, - const SuggestionBackendID& profile_sid) const { + int MakeFrontendID(const std::string& cc_sid, + const std::string& profile_sid) const { return autofill_manager_->MakeFrontendID(cc_sid, profile_sid); } @@ -1271,107 +1270,6 @@ TEST_F(AutofillManagerTest, GetFieldSuggestionsWithDuplicateValues) { Suggestion("Elvis", "", "", 1)); } -// Test that a non-default value is suggested for multi-valued profile, on an -// unfilled form. -TEST_F(AutofillManagerTest, GetFieldSuggestionsForMultiValuedProfileUnfilled) { - // Set up our form data. - FormData form; - test::CreateTestAddressFormData(&form); - std::vector<FormData> forms(1, form); - FormsSeen(forms); - - // |profile| will be owned by the mock PersonalDataManager. - AutofillProfile* profile = new AutofillProfile; - test::SetProfileInfo(profile, "Elvis", "", "Presley", "me@x.com", "", - "", "", "", "", "", "", ""); - profile->set_guid("00000000-0000-0000-0000-000000000101"); - std::vector<base::string16> multi_values(2); - multi_values[0] = ASCIIToUTF16("Elvis"); - multi_values[1] = ASCIIToUTF16("Elena"); - profile->SetRawMultiInfo(NAME_FIRST, multi_values); - multi_values[0] = ASCIIToUTF16("Presley"); - multi_values[1] = ASCIIToUTF16("Love"); - profile->SetRawMultiInfo(NAME_LAST, multi_values); - personal_data_.ClearAutofillProfiles(); - autofill_manager_->AddProfile(profile); - - { - // Get the first name field. - // Start out with "E", hoping for either "Elvis" or "Elena. - FormFieldData& field = form.fields[0]; - field.value = ASCIIToUTF16("E"); - field.is_autofilled = false; - GetAutofillSuggestions(form, field); - - // Trigger the |Send|. - AutocompleteSuggestionsReturned(std::vector<base::string16>()); - - // Test that we sent the right values to the external delegate. - external_delegate_->CheckSuggestions( - kDefaultPageID, - Suggestion("Elvis", "me@x.com", "", 1), - Suggestion("Elena", "me@x.com", "", 2)); - } - - { - // Get the first name field. - // This time, start out with "Ele", hoping for "Elena". - FormFieldData& field = form.fields[0]; - field.value = ASCIIToUTF16("Ele"); - field.is_autofilled = false; - GetAutofillSuggestions(form, field); - - // Trigger the |Send|. - AutocompleteSuggestionsReturned(std::vector<base::string16>()); - - // Test that we sent the right values to the external delegate. - external_delegate_->CheckSuggestions( - kDefaultPageID, - Suggestion("Elena", "me@x.com", "", 2)); - } -} - -// Test that all values are suggested for multi-valued profile, on a filled -// form. This is the per-field "override" case. -TEST_F(AutofillManagerTest, GetFieldSuggestionsForMultiValuedProfileFilled) { - // Set up our form data. - FormData form; - test::CreateTestAddressFormData(&form); - std::vector<FormData> forms(1, form); - FormsSeen(forms); - - // |profile| will be owned by the mock PersonalDataManager. - AutofillProfile* profile = new AutofillProfile; - profile->set_guid("00000000-0000-0000-0000-000000000102"); - std::vector<base::string16> multi_values(3); - multi_values[0] = ASCIIToUTF16("Travis"); - multi_values[1] = ASCIIToUTF16("Cynthia"); - multi_values[2] = ASCIIToUTF16("Zac"); - profile->SetRawMultiInfo(NAME_FIRST, multi_values); - multi_values[0] = ASCIIToUTF16("Smith"); - multi_values[1] = ASCIIToUTF16("Love"); - multi_values[2] = ASCIIToUTF16("Mango"); - profile->SetRawMultiInfo(NAME_LAST, multi_values); - autofill_manager_->AddProfile(profile); - - // Get the first name field. And start out with "Travis", hoping for all the - // multi-valued variants as suggestions. - FormFieldData& field = form.fields[0]; - field.value = ASCIIToUTF16("Travis"); - field.is_autofilled = true; - GetAutofillSuggestions(form, field); - - // Trigger the |Send|. - AutocompleteSuggestionsReturned(std::vector<base::string16>()); - - // Test that we sent the right values to the external delegate. - external_delegate_->CheckSuggestions( - kDefaultPageID, - Suggestion("Travis", "", "", 1), - Suggestion("Cynthia", "", "", 2), - Suggestion("Zac", "", "", 3)); -} - TEST_F(AutofillManagerTest, GetProfileSuggestionsFancyPhone) { // Set up our form data. FormData form; @@ -1438,11 +1336,7 @@ TEST_F(AutofillManagerTest, GetProfileSuggestionsForPhonePrefixOrSuffix) { AutofillProfile* profile = new AutofillProfile; profile->set_guid("00000000-0000-0000-0000-000000000104"); - std::vector<base::string16> multi_values(2); - multi_values[0] = ASCIIToUTF16("1800FLOWERS"); - multi_values[1] = ASCIIToUTF16("14158889999"); - - profile->SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, multi_values); + profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("1800FLOWERS")); personal_data_.ClearAutofillProfiles(); autofill_manager_->AddProfile(profile); @@ -1450,19 +1344,15 @@ TEST_F(AutofillManagerTest, GetProfileSuggestionsForPhonePrefixOrSuffix) { GetAutofillSuggestions(form, phone_prefix); AutocompleteSuggestionsReturned(std::vector<base::string16>()); // Test that we sent the right prefix values to the external delegate. - external_delegate_->CheckSuggestions( - kDefaultPageID, - Suggestion("356", "1", "", 1), - Suggestion("888", "1", "", 2)); + external_delegate_->CheckSuggestions(kDefaultPageID, + Suggestion("356", "1", "", 1)); const FormFieldData& phone_suffix = form.fields[3]; GetAutofillSuggestions(form, phone_suffix); AutocompleteSuggestionsReturned(std::vector<base::string16>()); // Test that we sent the right suffix values to the external delegate. - external_delegate_->CheckSuggestions( - kDefaultPageID, - Suggestion("9377", "1", "", 1), - Suggestion("9999", "1", "", 2)); + external_delegate_->CheckSuggestions(kDefaultPageID, + Suggestion("9377", "1", "", 1)); } // Test that we correctly fill an address form. @@ -1480,12 +1370,10 @@ TEST_F(AutofillManagerTest, FillAddressForm) { EXPECT_EQ(0U, profile->use_count()); EXPECT_EQ(base::Time(), profile->use_date()); - SuggestionBackendID profile_id(guid, 0); - SuggestionBackendID card_id(std::string(), 0); int response_page_id = 0; FormData response_data; FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[0], - MakeFrontendID(card_id, profile_id), + MakeFrontendID(std::string(), guid), &response_page_id, &response_data); ExpectFilledAddressFormElvis(response_page_id, response_data, kDefaultPageID, false, true); @@ -1559,12 +1447,12 @@ TEST_F(AutofillManagerTest, FillAddressFormFromAuxiliaryProfile) { std::vector<FormData> forms(1, form); FormsSeen(forms); - SuggestionBackendID guid("00000000-0000-0000-0000-000000000001", 0); - SuggestionBackendID empty(std::string(), 0); + std::string guid("00000000-0000-0000-0000-000000000001"); int response_page_id = 0; FormData response_data; FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[0], - MakeFrontendID(empty, guid), &response_page_id, &response_data); + MakeFrontendID(std::string(), guid), + &response_page_id, &response_data); ExpectFilledAddressFormElvis(response_page_id, response_data, kDefaultPageID, false, true); } @@ -1577,12 +1465,12 @@ TEST_F(AutofillManagerTest, FillCreditCardForm) { std::vector<FormData> forms(1, form); FormsSeen(forms); - SuggestionBackendID guid("00000000-0000-0000-0000-000000000004", 0); - SuggestionBackendID empty(std::string(), 0); + std::string guid("00000000-0000-0000-0000-000000000004"); int response_page_id = 0; FormData response_data; FillAutofillFormDataAndSaveResults(kDefaultPageID, form, *form.fields.begin(), - MakeFrontendID(guid, empty), &response_page_id, &response_data); + MakeFrontendID(guid, std::string()), + &response_page_id, &response_data); ExpectFilledCreditCardFormElvis( response_page_id, response_data, kDefaultPageID, false); } @@ -1599,12 +1487,12 @@ TEST_F(AutofillManagerTest, FillCreditCardFormNoYearNoMonth) { std::vector<FormData> forms(1, form); FormsSeen(forms); - SuggestionBackendID guid("00000000-0000-0000-0000-000000000007", 0); - SuggestionBackendID empty(std::string(), 0); + std::string guid("00000000-0000-0000-0000-000000000007"); int response_page_id = 0; FormData response_data; FillAutofillFormDataAndSaveResults(kDefaultPageID, form, *form.fields.begin(), - MakeFrontendID(guid, empty), &response_page_id, &response_data); + MakeFrontendID(guid, std::string()), + &response_page_id, &response_data); ExpectFilledCreditCardYearMonthWithYearMonth(response_page_id, response_data, kDefaultPageID, false, "", ""); } @@ -1622,12 +1510,12 @@ TEST_F(AutofillManagerTest, FillCreditCardFormNoYearMonth) { std::vector<FormData> forms(1, form); FormsSeen(forms); - SuggestionBackendID guid("00000000-0000-0000-0000-000000000007", 0); - SuggestionBackendID empty(std::string(), 0); + std::string guid("00000000-0000-0000-0000-000000000007"); int response_page_id = 0; FormData response_data; FillAutofillFormDataAndSaveResults(kDefaultPageID, form, *form.fields.begin(), - MakeFrontendID(guid, empty), &response_page_id, &response_data); + MakeFrontendID(guid, std::string()), + &response_page_id, &response_data); ExpectFilledCreditCardYearMonthWithYearMonth(response_page_id, response_data, kDefaultPageID, false, "", "04"); } @@ -1644,12 +1532,12 @@ TEST_F(AutofillManagerTest, FillCreditCardFormYearNoMonth) { std::vector<FormData> forms(1, form); FormsSeen(forms); - SuggestionBackendID guid("00000000-0000-0000-0000-000000000007", 0); - SuggestionBackendID empty(std::string(), 0); + std::string guid("00000000-0000-0000-0000-000000000007"); int response_page_id = 0; FormData response_data; FillAutofillFormDataAndSaveResults(kDefaultPageID, form, *form.fields.begin(), - MakeFrontendID(guid, empty), &response_page_id, &response_data); + MakeFrontendID(guid, std::string()), + &response_page_id, &response_data); ExpectFilledCreditCardYearMonthWithYearMonth(response_page_id, response_data, kDefaultPageID, false, "2012", ""); } @@ -1667,12 +1555,12 @@ TEST_F(AutofillManagerTest, FillCreditCardFormYearMonth) { std::vector<FormData> forms(1, form); FormsSeen(forms); - SuggestionBackendID guid("00000000-0000-0000-0000-000000000007", 0); - SuggestionBackendID empty(std::string(), 0); + std::string guid("00000000-0000-0000-0000-000000000007"); int response_page_id = 0; FormData response_data; FillAutofillFormDataAndSaveResults(kDefaultPageID, form, *form.fields.begin(), - MakeFrontendID(guid, empty), &response_page_id, &response_data); + MakeFrontendID(guid, std::string()), + &response_page_id, &response_data); ExpectFilledCreditCardYearMonthWithYearMonth(response_page_id, response_data, kDefaultPageID, false, "2012", "04"); } @@ -1687,25 +1575,26 @@ TEST_F(AutofillManagerTest, FillAddressAndCreditCardForm) { FormsSeen(forms); // First fill the address data. - SuggestionBackendID guid("00000000-0000-0000-0000-000000000001", 0); - SuggestionBackendID empty(std::string(), 0); + std::string guid("00000000-0000-0000-0000-000000000001"); int response_page_id = 0; FormData response_data; { SCOPED_TRACE("Address"); FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[0], - MakeFrontendID(empty, guid), &response_page_id, &response_data); + MakeFrontendID(std::string(), guid), + &response_page_id, &response_data); ExpectFilledAddressFormElvis(response_page_id, response_data, kDefaultPageID, true, true); } // Now fill the credit card data. const int kPageID2 = 2; - SuggestionBackendID guid2("00000000-0000-0000-0000-000000000004", 0); + std::string guid2("00000000-0000-0000-0000-000000000004"); response_page_id = 0; { FillAutofillFormDataAndSaveResults(kPageID2, form, form.fields.back(), - MakeFrontendID(guid2, empty), &response_page_id, &response_data); + MakeFrontendID(guid2, std::string()), + &response_page_id, &response_data); SCOPED_TRACE("Credit card"); ExpectFilledCreditCardFormElvis( response_page_id, response_data, kPageID2, true); @@ -1747,12 +1636,12 @@ TEST_F(AutofillManagerTest, FillFormWithNonFocusableFields) { FormsSeen(forms); // Fill the form - SuggestionBackendID guid("00000000-0000-0000-0000-000000000001", 0); - SuggestionBackendID empty(std::string(), 0); + std::string guid("00000000-0000-0000-0000-000000000001"); int response_page_id = 0; FormData response_data; FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[0], - MakeFrontendID(empty, guid), &response_page_id, &response_data); + MakeFrontendID(std::string(), guid), + &response_page_id, &response_data); // The whole form should be filled as all the fields belong to the same // logical section. @@ -1787,12 +1676,12 @@ TEST_F(AutofillManagerTest, FillFormWithMultipleSections) { FormsSeen(forms); // Fill the first section. - SuggestionBackendID guid("00000000-0000-0000-0000-000000000001", 0); - SuggestionBackendID empty(std::string(), 0); + std::string guid("00000000-0000-0000-0000-000000000001"); int response_page_id = 0; FormData response_data; FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[0], - MakeFrontendID(empty, guid), &response_page_id, &response_data); + MakeFrontendID(std::string(), guid), + &response_page_id, &response_data); { SCOPED_TRACE("Address 1"); // The second address section should be empty. @@ -1810,12 +1699,12 @@ TEST_F(AutofillManagerTest, FillFormWithMultipleSections) { // Fill the second section, with the initiating field somewhere in the middle // of the section. const int kPageID2 = 2; - SuggestionBackendID guid2("00000000-0000-0000-0000-000000000001", 0); + std::string guid2("00000000-0000-0000-0000-000000000001"); ASSERT_LT(9U, kAddressFormSize); response_page_id = 0; FillAutofillFormDataAndSaveResults( kPageID2, form, form.fields[kAddressFormSize + 9], - MakeFrontendID(empty, guid2), &response_page_id, &response_data); + MakeFrontendID(std::string(), guid2), &response_page_id, &response_data); { SCOPED_TRACE("Address 2"); ASSERT_EQ(response_data.fields.size(), form.fields.size()); @@ -1902,12 +1791,12 @@ TEST_F(AutofillManagerTest, FillFormWithAuthorSpecifiedSections) { FormsSeen(forms); // Fill the unnamed section. - SuggestionBackendID guid("00000000-0000-0000-0000-000000000001", 0); - SuggestionBackendID empty(std::string(), 0); + std::string guid("00000000-0000-0000-0000-000000000001"); int response_page_id = 0; FormData response_data; FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[1], - MakeFrontendID(empty, guid), &response_page_id, &response_data); + MakeFrontendID(std::string(), guid), + &response_page_id, &response_data); { SCOPED_TRACE("Unnamed section"); EXPECT_EQ(kDefaultPageID, response_page_id); @@ -1935,10 +1824,11 @@ TEST_F(AutofillManagerTest, FillFormWithAuthorSpecifiedSections) { // Fill the address portion of the billing section. const int kPageID2 = 2; - SuggestionBackendID guid2("00000000-0000-0000-0000-000000000001", 0); + std::string guid2("00000000-0000-0000-0000-000000000001"); response_page_id = 0; FillAutofillFormDataAndSaveResults(kPageID2, form, form.fields[0], - MakeFrontendID(empty, guid2), &response_page_id, &response_data); + MakeFrontendID(std::string(), guid2), + &response_page_id, &response_data); { SCOPED_TRACE("Billing address"); EXPECT_EQ(kPageID2, response_page_id); @@ -1966,11 +1856,11 @@ TEST_F(AutofillManagerTest, FillFormWithAuthorSpecifiedSections) { // Fill the credit card portion of the billing section. const int kPageID3 = 3; - SuggestionBackendID guid3("00000000-0000-0000-0000-000000000004", 0); + std::string guid3("00000000-0000-0000-0000-000000000004"); response_page_id = 0; FillAutofillFormDataAndSaveResults( kPageID3, form, form.fields[form.fields.size() - 2], - MakeFrontendID(guid3, empty), &response_page_id, &response_data); + MakeFrontendID(guid3, std::string()), &response_page_id, &response_data); { SCOPED_TRACE("Credit card"); EXPECT_EQ(kPageID3, response_page_id); @@ -2010,12 +1900,12 @@ TEST_F(AutofillManagerTest, FillFormWithMultipleEmails) { FormsSeen(forms); // Fill the form. - SuggestionBackendID guid("00000000-0000-0000-0000-000000000001", 0); - SuggestionBackendID empty(std::string(), 0); + std::string guid("00000000-0000-0000-0000-000000000001"); int response_page_id = 0; FormData response_data; FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[0], - MakeFrontendID(empty, guid), &response_page_id, &response_data); + MakeFrontendID(std::string(), guid), + &response_page_id, &response_data); // The second email address should be filled. EXPECT_EQ(ASCIIToUTF16("theking@gmail.com"), @@ -2039,12 +1929,12 @@ TEST_F(AutofillManagerTest, FillAutofilledForm) { FormsSeen(forms); // First fill the address data. - SuggestionBackendID guid("00000000-0000-0000-0000-000000000001", 0); - SuggestionBackendID empty(std::string(), 0); + std::string guid("00000000-0000-0000-0000-000000000001"); int response_page_id = 0; FormData response_data; FillAutofillFormDataAndSaveResults(kDefaultPageID, form, *form.fields.begin(), - MakeFrontendID(empty, guid), &response_page_id, &response_data); + MakeFrontendID(std::string(), guid), + &response_page_id, &response_data); { SCOPED_TRACE("Address"); ExpectFilledForm(response_page_id, response_data, kDefaultPageID, "Elvis", @@ -2054,10 +1944,11 @@ TEST_F(AutofillManagerTest, FillAutofilledForm) { // Now fill the credit card data. const int kPageID2 = 2; - SuggestionBackendID guid2("00000000-0000-0000-0000-000000000004", 0); + std::string guid2("00000000-0000-0000-0000-000000000004"); response_page_id = 0; FillAutofillFormDataAndSaveResults(kPageID2, form, form.fields.back(), - MakeFrontendID(guid2, empty), &response_page_id, &response_data); + MakeFrontendID(guid2, std::string()), + &response_page_id, &response_data); { SCOPED_TRACE("Credit card 1"); ExpectFilledCreditCardFormElvis( @@ -2075,7 +1966,8 @@ TEST_F(AutofillManagerTest, FillAutofilledForm) { const int kPageID3 = 3; response_page_id = 0; FillAutofillFormDataAndSaveResults(kPageID3, form, *form.fields.rbegin(), - MakeFrontendID(guid2, empty), &response_page_id, &response_data); + MakeFrontendID(guid2, std::string()), + &response_page_id, &response_data); { SCOPED_TRACE("Credit card 2"); ExpectFilledForm(response_page_id, response_data, kPageID3, "", "", "", "", @@ -2084,64 +1976,6 @@ TEST_F(AutofillManagerTest, FillAutofilledForm) { } } -// Test that we correctly fill an address form with a non-default variant for a -// multi-valued field. -TEST_F(AutofillManagerTest, FillAddressFormWithVariantType) { - // Set up our form data. - FormData form; - test::CreateTestAddressFormData(&form); - std::vector<FormData> forms(1, form); - FormsSeen(forms); - - // Add a name variant to the Elvis profile. - AutofillProfile* profile = autofill_manager_->GetProfileWithGUID( - "00000000-0000-0000-0000-000000000001"); - - std::vector<base::string16> name_variants; - name_variants.push_back(ASCIIToUTF16("Some")); - name_variants.push_back(profile->GetRawInfo(NAME_FIRST)); - profile->SetRawMultiInfo(NAME_FIRST, name_variants); - - name_variants.clear(); - name_variants.push_back(ASCIIToUTF16("Other")); - name_variants.push_back(profile->GetRawInfo(NAME_MIDDLE)); - profile->SetRawMultiInfo(NAME_MIDDLE, name_variants); - - name_variants.clear(); - name_variants.push_back(ASCIIToUTF16("Guy")); - name_variants.push_back(profile->GetRawInfo(NAME_LAST)); - profile->SetRawMultiInfo(NAME_LAST, name_variants); - - SuggestionBackendID guid(profile->guid(), 1); - SuggestionBackendID empty(std::string(), 0); - int response_page_id = 0; - FormData response_data1; - FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[0], - MakeFrontendID(empty, guid), &response_page_id, &response_data1); - { - SCOPED_TRACE("Valid variant"); - ExpectFilledAddressFormElvis(response_page_id, response_data1, - kDefaultPageID, false, true); - } - - // Try filling with a variant that doesn't exist. The fields to which this - // variant would normally apply should not be filled. - const int kPageID2 = 2; - SuggestionBackendID guid2(profile->guid(), 2); - response_page_id = 0; - FormData response_data2; - FillAutofillFormDataAndSaveResults(kPageID2, form, form.fields[0], - MakeFrontendID(empty, guid2), &response_page_id, &response_data2); - { - SCOPED_TRACE("Invalid variant"); - ExpectFilledForm(response_page_id, response_data2, kPageID2, "", "", "", - "3734 Elvis Presley Blvd.", "Apt. 10", "Memphis", - "Tennessee", "38116", "United States", "12345678901", - "theking@gmail.com", "", "", "", "", true, false, false, - true); - } -} - // Test that we correctly fill a phone number split across multiple fields. TEST_F(AutofillManagerTest, FillPhoneNumber) { // In one form, rely on the maxlength attribute to imply phone number parts. @@ -2193,14 +2027,13 @@ TEST_F(AutofillManagerTest, FillPhoneNumber) { work_profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("16505554567")); - SuggestionBackendID guid(work_profile->guid(), 0); - SuggestionBackendID empty(std::string(), 0); + std::string guid(work_profile->guid()); int page_id = 1; int response_page_id = 0; FormData response_data1; - FillAutofillFormDataAndSaveResults(page_id, form_with_maxlength, - *form_with_maxlength.fields.begin(), - MakeFrontendID(empty, guid), &response_page_id, &response_data1); + FillAutofillFormDataAndSaveResults( + page_id, form_with_maxlength, *form_with_maxlength.fields.begin(), + MakeFrontendID(std::string(), guid), &response_page_id, &response_data1); EXPECT_EQ(1, response_page_id); ASSERT_EQ(5U, response_data1.fields.size()); @@ -2214,8 +2047,9 @@ TEST_F(AutofillManagerTest, FillPhoneNumber) { response_page_id = 0; FormData response_data2; FillAutofillFormDataAndSaveResults(page_id, form_with_autocompletetype, - *form_with_autocompletetype.fields.begin(), - MakeFrontendID(empty, guid), &response_page_id, &response_data2); + *form_with_autocompletetype.fields.begin(), + MakeFrontendID(std::string(), guid), + &response_page_id, &response_data2); EXPECT_EQ(2, response_page_id); ASSERT_EQ(5U, response_data2.fields.size()); @@ -2233,9 +2067,9 @@ TEST_F(AutofillManagerTest, FillPhoneNumber) { page_id = 3; response_page_id = 0; FormData response_data3; - FillAutofillFormDataAndSaveResults(page_id, form_with_maxlength, - *form_with_maxlength.fields.begin(), - MakeFrontendID(empty, guid), &response_page_id, &response_data3); + FillAutofillFormDataAndSaveResults( + page_id, form_with_maxlength, *form_with_maxlength.fields.begin(), + MakeFrontendID(std::string(), guid), &response_page_id, &response_data3); EXPECT_EQ(3, response_page_id); ASSERT_EQ(5U, response_data3.fields.size()); @@ -2249,8 +2083,9 @@ TEST_F(AutofillManagerTest, FillPhoneNumber) { response_page_id = 0; FormData response_data4; FillAutofillFormDataAndSaveResults(page_id, form_with_autocompletetype, - *form_with_autocompletetype.fields.begin(), - MakeFrontendID(empty, guid), &response_page_id, &response_data4); + *form_with_autocompletetype.fields.begin(), + MakeFrontendID(std::string(), guid), + &response_page_id, &response_data4); EXPECT_EQ(4, response_page_id); ASSERT_EQ(5U, response_data4.fields.size()); @@ -2259,29 +2094,6 @@ TEST_F(AutofillManagerTest, FillPhoneNumber) { EXPECT_EQ(ASCIIToUTF16("954321"), response_data4.fields[2].value); EXPECT_EQ(ASCIIToUTF16("954321"), response_data4.fields[3].value); EXPECT_EQ(base::string16(), response_data4.fields[4].value); - - // We should fill all phone fields with the same phone number variant. - std::vector<base::string16> phone_variants; - phone_variants.push_back(ASCIIToUTF16("16505554567")); - phone_variants.push_back(ASCIIToUTF16("18887771234")); - work_profile->SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); - work_profile->SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, phone_variants); - - page_id = 5; - response_page_id = 0; - FormData response_data5; - SuggestionBackendID variant_guid(work_profile->guid(), 1); - FillAutofillFormDataAndSaveResults(page_id, form_with_maxlength, - *form_with_maxlength.fields.begin(), - MakeFrontendID(empty, variant_guid), &response_page_id, &response_data5); - EXPECT_EQ(5, response_page_id); - - ASSERT_EQ(5U, response_data5.fields.size()); - EXPECT_EQ(ASCIIToUTF16("1"), response_data5.fields[0].value); - EXPECT_EQ(ASCIIToUTF16("888"), response_data5.fields[1].value); - EXPECT_EQ(ASCIIToUTF16("777"), response_data5.fields[2].value); - EXPECT_EQ(ASCIIToUTF16("1234"), response_data5.fields[3].value); - EXPECT_EQ(base::string16(), response_data5.fields[4].value); } // Test that we can still fill a form when a field has been removed from it. @@ -2301,12 +2113,12 @@ TEST_F(AutofillManagerTest, FormChangesRemoveField) { // Now, after the call to |FormsSeen|, we remove the field before filling. form.fields.erase(form.fields.begin() + 3); - SuggestionBackendID guid("00000000-0000-0000-0000-000000000001", 0); - SuggestionBackendID empty(std::string(), 0); + std::string guid("00000000-0000-0000-0000-000000000001"); int response_page_id = 0; FormData response_data; FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[0], - MakeFrontendID(empty, guid), &response_page_id, &response_data); + MakeFrontendID(std::string(), guid), + &response_page_id, &response_data); ExpectFilledAddressFormElvis(response_page_id, response_data, kDefaultPageID, false, true); } @@ -2332,12 +2144,12 @@ TEST_F(AutofillManagerTest, FormChangesAddField) { // Now, after the call to |FormsSeen|, we restore the field before filling. form.fields.insert(pos, field); - SuggestionBackendID guid("00000000-0000-0000-0000-000000000001", 0); - SuggestionBackendID empty(std::string(), 0); + std::string guid("00000000-0000-0000-0000-000000000001"); int response_page_id = 0; FormData response_data; FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[0], - MakeFrontendID(empty, guid), &response_page_id, &response_data); + MakeFrontendID(std::string(), guid), + &response_page_id, &response_data); ExpectFilledAddressFormElvis(response_page_id, response_data, kDefaultPageID, false, true); } @@ -2351,12 +2163,12 @@ TEST_F(AutofillManagerTest, FormSubmitted) { FormsSeen(forms); // Fill the form. - SuggestionBackendID guid("00000000-0000-0000-0000-000000000001", 0); - SuggestionBackendID empty(std::string(), 0); + std::string guid("00000000-0000-0000-0000-000000000001"); int response_page_id = 0; FormData response_data; FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[0], - MakeFrontendID(empty, guid), &response_page_id, &response_data); + MakeFrontendID(std::string(), guid), + &response_page_id, &response_data); ExpectFilledAddressFormElvis(response_page_id, response_data, kDefaultPageID, false, true); @@ -2377,12 +2189,11 @@ TEST_F(AutofillManagerTest, FormSubmittedNotUserSubmitted) { FormsSeen(forms); // Fill the form. - SuggestionBackendID guid("00000000-0000-0000-0000-000000000001", 0); - SuggestionBackendID empty(std::string(), 0); + std::string guid("00000000-0000-0000-0000-000000000001"); int response_page_id = 0; FormData response_data; FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[0], - MakeFrontendID(empty, guid), + MakeFrontendID(std::string(), guid), &response_page_id, &response_data); ExpectFilledAddressFormElvis(response_page_id, response_data, kDefaultPageID, false, false); @@ -2403,12 +2214,11 @@ TEST_F(AutofillManagerTest, FormWillSubmitDoesNotSaveData) { FormsSeen(forms); // Fill the form. - SuggestionBackendID guid("00000000-0000-0000-0000-000000000001", 0); - SuggestionBackendID empty(std::string(), 0); + std::string guid("00000000-0000-0000-0000-000000000001"); int response_page_id = 0; FormData response_data; FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[0], - MakeFrontendID(empty, guid), + MakeFrontendID(std::string(), guid), &response_page_id, &response_data); ExpectFilledAddressFormElvis(response_page_id, response_data, kDefaultPageID, false, true); @@ -2520,12 +2330,12 @@ TEST_F(AutofillManagerTest, FormSubmittedServerTypes) { autofill_manager_->AddSeenForm(form_structure); // Fill the form. - SuggestionBackendID guid("00000000-0000-0000-0000-000000000001", 0); - SuggestionBackendID empty(std::string(), 0); + std::string guid("00000000-0000-0000-0000-000000000001"); int response_page_id = 0; FormData response_data; FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[0], - MakeFrontendID(empty, guid), &response_page_id, &response_data); + MakeFrontendID(std::string(), guid), + &response_page_id, &response_data); ExpectFilledAddressFormElvis(response_page_id, response_data, kDefaultPageID, false, true); @@ -2545,12 +2355,11 @@ TEST_F(AutofillManagerTest, FormSubmittedPossibleTypesTwoSubmissions) { test::CreateTestAddressFormData(&form, &expected_types); // Fill the form. - SuggestionBackendID guid("00000000-0000-0000-0000-000000000001", 0); - SuggestionBackendID empty(std::string(), 0); + std::string guid("00000000-0000-0000-0000-000000000001"); int response_page_id = 0; FormData response_data; FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[0], - MakeFrontendID(empty, guid), + MakeFrontendID(std::string(), guid), &response_page_id, &response_data); ExpectFilledAddressFormElvis(response_page_id, response_data, kDefaultPageID, false, true); @@ -2617,12 +2426,12 @@ TEST_F(AutofillManagerTest, FormSubmittedWithDefaultValues) { FormsSeen(forms); // Fill the form. - SuggestionBackendID guid("00000000-0000-0000-0000-000000000001", 0); - SuggestionBackendID empty(std::string(), 0); + std::string guid("00000000-0000-0000-0000-000000000001"); int response_page_id = 0; FormData response_data; FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[3], - MakeFrontendID(empty, guid), &response_page_id, &response_data); + MakeFrontendID(std::string(), guid), + &response_page_id, &response_data); // Simulate form submission. We should call into the PDM to try to save the // filled data. @@ -2994,9 +2803,7 @@ TEST_F(AutofillManagerTest, RemoveProfile) { profile->set_guid(guid.c_str()); autofill_manager_->AddProfile(profile); - SuggestionBackendID guid_pair(guid, 0); - SuggestionBackendID empty(std::string(), 0); - int id = MakeFrontendID(empty, guid_pair); + int id = MakeFrontendID(std::string(), guid); autofill_manager_->RemoveAutofillProfileOrCreditCard(id); @@ -3010,34 +2817,13 @@ TEST_F(AutofillManagerTest, RemoveCreditCard){ credit_card->set_guid(guid.c_str()); autofill_manager_->AddCreditCard(credit_card); - SuggestionBackendID guid_pair(guid, 0); - SuggestionBackendID empty(std::string(), 0); - int id = MakeFrontendID(guid_pair, empty); + int id = MakeFrontendID(guid, std::string()); autofill_manager_->RemoveAutofillProfileOrCreditCard(id); EXPECT_FALSE(autofill_manager_->GetCreditCardWithGUID(guid.c_str())); } -TEST_F(AutofillManagerTest, RemoveProfileVariant) { - // Add and remove an Autofill profile. - AutofillProfile* profile = new AutofillProfile; - std::string guid = "00000000-0000-0000-0000-000000000102"; - profile->set_guid(guid.c_str()); - autofill_manager_->AddProfile(profile); - - SuggestionBackendID guid_pair(guid, 1); - SuggestionBackendID empty(std::string(), 0); - int id = MakeFrontendID(empty, guid_pair); - - autofill_manager_->RemoveAutofillProfileOrCreditCard(id); - - // TODO(csharp): Currently variants should not be deleted, but once they are - // update these expectations. - // http://crbug.com/124211 - EXPECT_TRUE(autofill_manager_->GetProfileWithGUID(guid.c_str())); -} - #if defined(OS_MACOSX) && !defined(OS_IOS) TEST_F(AutofillManagerTest, AccessAddressBookPrompt) { // TODO(erikchen): After Address Book integration has been disabled for 6 @@ -3215,20 +3001,20 @@ TEST_F(AutofillManagerTest, DontOfferToSaveWalletCard) { #endif // defined(OS_IOS) autofill_manager_->FillOrPreviewCreditCardForm( AutofillDriver::FORM_DATA_ACTION_FILL, kDefaultPageID, form, - form.fields[0], card, 0); + form.fields[0], card); #if defined(OS_IOS) // Filling out the entire form on iOS requires requesting autofill on each of // the form fields. autofill_manager_->FillOrPreviewCreditCardForm( AutofillDriver::FORM_DATA_ACTION_FILL, kDefaultPageID, form, - form.fields[1], card, 0); + form.fields[1], card); autofill_manager_->FillOrPreviewCreditCardForm( AutofillDriver::FORM_DATA_ACTION_FILL, kDefaultPageID, form, - form.fields[2], card, 0); + form.fields[2], card); autofill_manager_->FillOrPreviewCreditCardForm( AutofillDriver::FORM_DATA_ACTION_FILL, kDefaultPageID, form, - form.fields[3], card, 0); + form.fields[3], card); #endif // defined(OS_IOS) // Manually fill out |form| so we can use it in OnFormSubmitted. @@ -3259,7 +3045,7 @@ TEST_F(AutofillManagerTest, DontOfferToSaveWalletCard) { } autofill_manager_->FillOrPreviewCreditCardForm( AutofillDriver::FORM_DATA_ACTION_FILL, kDefaultPageID, form, - form.fields[1], card, 0); + form.fields[1], card); autofill_manager_->OnUnmaskResponse(response); autofill_manager_->OnDidGetRealPan(AutofillClient::SUCCESS, "4012888888881881"); diff --git a/components/autofill/core/browser/autofill_metrics_unittest.cc b/components/autofill/core/browser/autofill_metrics_unittest.cc index b867153..c39436f 100644 --- a/components/autofill/core/browser/autofill_metrics_unittest.cc +++ b/components/autofill/core/browser/autofill_metrics_unittest.cc @@ -1306,12 +1306,11 @@ TEST_F(AutofillMetricsTest, CreditCardSelectedFormEvents) { { // Simulating selecting a masked card server suggestion. base::HistogramTester histogram_tester; - SuggestionBackendID guid( - "10000000-0000-0000-0000-000000000002", 0); // masked server card + std::string guid( + "10000000-0000-0000-0000-000000000002"); // masked server card autofill_manager_->FillOrPreviewForm( - AutofillDriver::FORM_DATA_ACTION_FILL, - 0, form, form.fields[2], - autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); + AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields[2], + autofill_manager_->MakeFrontendID(guid, std::string())); histogram_tester.ExpectBucketCount( "Autofill.FormEvents.CreditCard", AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED, 1); @@ -1328,16 +1327,14 @@ TEST_F(AutofillMetricsTest, CreditCardSelectedFormEvents) { { // Simulating selecting multiple times a masked card server. base::HistogramTester histogram_tester; - SuggestionBackendID guid( - "10000000-0000-0000-0000-000000000002", 0); // masked server card + std::string guid( + "10000000-0000-0000-0000-000000000002"); // masked server card autofill_manager_->FillOrPreviewForm( - AutofillDriver::FORM_DATA_ACTION_FILL, - 0, form, form.fields[2], - autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); + AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields[2], + autofill_manager_->MakeFrontendID(guid, std::string())); autofill_manager_->FillOrPreviewForm( - AutofillDriver::FORM_DATA_ACTION_FILL, - 0, form, form.fields[2], - autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); + AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields[2], + autofill_manager_->MakeFrontendID(guid, std::string())); histogram_tester.ExpectBucketCount( "Autofill.FormEvents.CreditCard", AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED, 2); @@ -1383,12 +1380,10 @@ TEST_F(AutofillMetricsTest, CreditCardFilledFormEvents) { { // Simulating filling a local card suggestion. base::HistogramTester histogram_tester; - SuggestionBackendID guid( - "10000000-0000-0000-0000-000000000001", 0); // local card + std::string guid("10000000-0000-0000-0000-000000000001"); // local card autofill_manager_->FillOrPreviewForm( - AutofillDriver::FORM_DATA_ACTION_FILL, - 0, form, form.fields.front(), - autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); + AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), + autofill_manager_->MakeFrontendID(guid, std::string())); histogram_tester.ExpectBucketCount( "Autofill.FormEvents.CreditCard", AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED, 1); @@ -1404,12 +1399,11 @@ TEST_F(AutofillMetricsTest, CreditCardFilledFormEvents) { { // Simulating filling a masked card server suggestion. base::HistogramTester histogram_tester; - SuggestionBackendID guid( - "10000000-0000-0000-0000-000000000002", 0); // masked server card + std::string guid( + "10000000-0000-0000-0000-000000000002"); // masked server card autofill_manager_->FillOrPreviewForm( - AutofillDriver::FORM_DATA_ACTION_FILL, - 0, form, form.fields.front(), - autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); + AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), + autofill_manager_->MakeFrontendID(guid, std::string())); autofill_manager_->OnDidGetRealPan(AutofillClient::SUCCESS, "6011000990139424"); histogram_tester.ExpectBucketCount( @@ -1435,12 +1429,11 @@ TEST_F(AutofillMetricsTest, CreditCardFilledFormEvents) { { // Simulating filling a full card server suggestion. base::HistogramTester histogram_tester; - SuggestionBackendID guid( - "10000000-0000-0000-0000-000000000003", 0); // full server card + std::string guid( + "10000000-0000-0000-0000-000000000003"); // full server card autofill_manager_->FillOrPreviewForm( - AutofillDriver::FORM_DATA_ACTION_FILL, - 0, form, form.fields.front(), - autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); + AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), + autofill_manager_->MakeFrontendID(guid, std::string())); histogram_tester.ExpectBucketCount( "Autofill.FormEvents.CreditCard", AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED, 1); @@ -1456,16 +1449,13 @@ TEST_F(AutofillMetricsTest, CreditCardFilledFormEvents) { { // Simulating filling multiple times. base::HistogramTester histogram_tester; - SuggestionBackendID guid( - "10000000-0000-0000-0000-000000000001", 0); // local card + std::string guid("10000000-0000-0000-0000-000000000001"); // local card autofill_manager_->FillOrPreviewForm( - AutofillDriver::FORM_DATA_ACTION_FILL, - 0, form, form.fields.front(), - autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); + AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), + autofill_manager_->MakeFrontendID(guid, std::string())); autofill_manager_->FillOrPreviewForm( - AutofillDriver::FORM_DATA_ACTION_FILL, - 0, form, form.fields.front(), - autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); + AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), + autofill_manager_->MakeFrontendID(guid, std::string())); histogram_tester.ExpectBucketCount( "Autofill.FormEvents.CreditCard", AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED, 2); @@ -1509,11 +1499,11 @@ TEST_F(AutofillMetricsTest, CreditCardGetRealPanDuration) { { // Simulating filling a masked card server suggestion. base::HistogramTester histogram_tester; - SuggestionBackendID guid("10000000-0000-0000-0000-000000000002", - 0); // masked server card + // Masked server card. + std::string guid("10000000-0000-0000-0000-000000000002"); autofill_manager_->FillOrPreviewForm( AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), - autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); + autofill_manager_->MakeFrontendID(guid, std::string())); autofill_manager_->OnDidGetRealPan(AutofillClient::SUCCESS, "6011000990139424"); histogram_tester.ExpectTotalCount( @@ -1534,11 +1524,11 @@ TEST_F(AutofillMetricsTest, CreditCardGetRealPanDuration) { { // Simulating filling a masked card server suggestion. base::HistogramTester histogram_tester; - SuggestionBackendID guid("10000000-0000-0000-0000-000000000002", - 0); // masked server card + // Masked server card. + std::string guid("10000000-0000-0000-0000-000000000002"); autofill_manager_->FillOrPreviewForm( AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), - autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); + autofill_manager_->MakeFrontendID(guid, std::string())); autofill_manager_->OnDidGetRealPan(AutofillClient::PERMANENT_FAILURE, std::string()); histogram_tester.ExpectTotalCount( @@ -1600,12 +1590,10 @@ TEST_F(AutofillMetricsTest, CreditCardSubmittedFormEvents) { // Simulating submission with filled local data. base::HistogramTester histogram_tester; autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); - SuggestionBackendID guid( - "10000000-0000-0000-0000-000000000001", 0); // local card + std::string guid("10000000-0000-0000-0000-000000000001"); // local card autofill_manager_->FillOrPreviewForm( - AutofillDriver::FORM_DATA_ACTION_FILL, - 0, form, form.fields.front(), - autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); + AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), + autofill_manager_->MakeFrontendID(guid, std::string())); autofill_manager_->SubmitForm(form, TimeTicks::Now()); histogram_tester.ExpectBucketCount( "Autofill.FormEvents.CreditCard", @@ -1623,12 +1611,11 @@ TEST_F(AutofillMetricsTest, CreditCardSubmittedFormEvents) { // Simulating submission with filled server data. base::HistogramTester histogram_tester; autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); - SuggestionBackendID guid( - "10000000-0000-0000-0000-000000000003", 0); // full server card + std::string guid( + "10000000-0000-0000-0000-000000000003"); // full server card autofill_manager_->FillOrPreviewForm( - AutofillDriver::FORM_DATA_ACTION_FILL, - 0, form, form.fields.front(), - autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); + AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), + autofill_manager_->MakeFrontendID(guid, std::string())); autofill_manager_->SubmitForm(form, TimeTicks::Now()); histogram_tester.ExpectBucketCount( "Autofill.FormEvents.CreditCard", @@ -1645,12 +1632,11 @@ TEST_F(AutofillMetricsTest, CreditCardSubmittedFormEvents) { { // Simulating submission with a masked card server suggestion. base::HistogramTester histogram_tester; - SuggestionBackendID guid( - "10000000-0000-0000-0000-000000000002", 0); // masked server card + std::string guid( + "10000000-0000-0000-0000-000000000002"); // masked server card autofill_manager_->FillOrPreviewForm( - AutofillDriver::FORM_DATA_ACTION_FILL, - 0, form, form.fields.front(), - autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); + AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), + autofill_manager_->MakeFrontendID(guid, std::string())); autofill_manager_->OnDidGetRealPan(AutofillClient::SUCCESS, "6011000990139424"); histogram_tester.ExpectBucketCount( @@ -1792,11 +1778,10 @@ TEST_F(AutofillMetricsTest, CreditCardWillSubmitFormEvents) { // Simulating submission with filled local data. base::HistogramTester histogram_tester; autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); - SuggestionBackendID guid("10000000-0000-0000-0000-000000000001", - 0); // local card + std::string guid("10000000-0000-0000-0000-000000000001"); // local card autofill_manager_->FillOrPreviewForm( AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), - autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); + autofill_manager_->MakeFrontendID(guid, std::string())); autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); histogram_tester.ExpectBucketCount( "Autofill.FormEvents.CreditCard", @@ -1814,11 +1799,11 @@ TEST_F(AutofillMetricsTest, CreditCardWillSubmitFormEvents) { // Simulating submission with filled server data. base::HistogramTester histogram_tester; autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); - SuggestionBackendID guid("10000000-0000-0000-0000-000000000003", - 0); // full server card + // Full server card. + std::string guid("10000000-0000-0000-0000-000000000003"); autofill_manager_->FillOrPreviewForm( AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), - autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); + autofill_manager_->MakeFrontendID(guid, std::string())); autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); histogram_tester.ExpectBucketCount( "Autofill.FormEvents.CreditCard", @@ -1835,11 +1820,11 @@ TEST_F(AutofillMetricsTest, CreditCardWillSubmitFormEvents) { { // Simulating submission with a masked card server suggestion. base::HistogramTester histogram_tester; - SuggestionBackendID guid("10000000-0000-0000-0000-000000000002", - 0); // masked server card + // Masked server card. + std::string guid("10000000-0000-0000-0000-000000000002"); autofill_manager_->FillOrPreviewForm( AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), - autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); + autofill_manager_->MakeFrontendID(guid, std::string())); autofill_manager_->OnDidGetRealPan(AutofillClient::SUCCESS, "6011000990139424"); histogram_tester.ExpectBucketCount( @@ -2084,12 +2069,10 @@ TEST_F(AutofillMetricsTest, AddressFilledFormEvents) { { // Simulating selecting/filling a local profile suggestion. base::HistogramTester histogram_tester; - SuggestionBackendID guid( - "00000000-0000-0000-0000-000000000001", 0); // local profile + std::string guid("00000000-0000-0000-0000-000000000001"); // local profile autofill_manager_->FillOrPreviewForm( - AutofillDriver::FORM_DATA_ACTION_FILL, - 0, form, form.fields.front(), - autofill_manager_->MakeFrontendID(SuggestionBackendID(), guid)); + AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), + autofill_manager_->MakeFrontendID(std::string(), guid)); histogram_tester.ExpectBucketCount( "Autofill.FormEvents.Address", AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED, 1); @@ -2105,12 +2088,10 @@ TEST_F(AutofillMetricsTest, AddressFilledFormEvents) { { // Simulating selecting/filling a server profile suggestion. base::HistogramTester histogram_tester; - SuggestionBackendID guid( - "00000000-0000-0000-0000-000000000002", 0); // server profile + std::string guid("00000000-0000-0000-0000-000000000002"); // server profile autofill_manager_->FillOrPreviewForm( - AutofillDriver::FORM_DATA_ACTION_FILL, - 0, form, form.fields.front(), - autofill_manager_->MakeFrontendID(SuggestionBackendID(), guid)); + AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), + autofill_manager_->MakeFrontendID(std::string(), guid)); histogram_tester.ExpectBucketCount( "Autofill.FormEvents.Address", AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED, 1); @@ -2126,16 +2107,13 @@ TEST_F(AutofillMetricsTest, AddressFilledFormEvents) { { // Simulating selecting/filling a local profile suggestion. base::HistogramTester histogram_tester; - SuggestionBackendID guid( - "00000000-0000-0000-0000-000000000001", 0); // local profile + std::string guid("00000000-0000-0000-0000-000000000001"); // local profile autofill_manager_->FillOrPreviewForm( - AutofillDriver::FORM_DATA_ACTION_FILL, - 0, form, form.fields.front(), - autofill_manager_->MakeFrontendID(SuggestionBackendID(), guid)); + AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), + autofill_manager_->MakeFrontendID(std::string(), guid)); autofill_manager_->FillOrPreviewForm( - AutofillDriver::FORM_DATA_ACTION_FILL, - 0, form, form.fields.front(), - autofill_manager_->MakeFrontendID(SuggestionBackendID(), guid)); + AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), + autofill_manager_->MakeFrontendID(std::string(), guid)); histogram_tester.ExpectBucketCount( "Autofill.FormEvents.Address", AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED, 2); @@ -2195,12 +2173,10 @@ TEST_F(AutofillMetricsTest, AddressSubmittedFormEvents) { // Simulating submission with filled local data. base::HistogramTester histogram_tester; autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); - SuggestionBackendID guid( - "00000000-0000-0000-0000-000000000001", 0); // local profile + std::string guid("00000000-0000-0000-0000-000000000001"); // local profile autofill_manager_->FillOrPreviewForm( - AutofillDriver::FORM_DATA_ACTION_FILL, - 0, form, form.fields.front(), - autofill_manager_->MakeFrontendID(SuggestionBackendID(), guid)); + AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), + autofill_manager_->MakeFrontendID(std::string(), guid)); autofill_manager_->SubmitForm(form, TimeTicks::Now()); histogram_tester.ExpectBucketCount( "Autofill.FormEvents.Address", @@ -2218,12 +2194,10 @@ TEST_F(AutofillMetricsTest, AddressSubmittedFormEvents) { // Simulating submission with filled server data. base::HistogramTester histogram_tester; autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); - SuggestionBackendID guid( - "00000000-0000-0000-0000-000000000002", 0); // server profile + std::string guid("00000000-0000-0000-0000-000000000002"); // server profile autofill_manager_->FillOrPreviewForm( - AutofillDriver::FORM_DATA_ACTION_FILL, - 0, form, form.fields.front(), - autofill_manager_->MakeFrontendID(SuggestionBackendID(), guid)); + AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), + autofill_manager_->MakeFrontendID(std::string(), guid)); autofill_manager_->SubmitForm(form, TimeTicks::Now()); histogram_tester.ExpectBucketCount( "Autofill.FormEvents.Address", @@ -2344,11 +2318,10 @@ TEST_F(AutofillMetricsTest, AddressWillSubmitFormEvents) { // Simulating submission with filled local data. base::HistogramTester histogram_tester; autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); - SuggestionBackendID guid("00000000-0000-0000-0000-000000000001", - 0); // local profile + std::string guid("00000000-0000-0000-0000-000000000001"); // local profile autofill_manager_->FillOrPreviewForm( AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), - autofill_manager_->MakeFrontendID(SuggestionBackendID(), guid)); + autofill_manager_->MakeFrontendID(std::string(), guid)); autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); histogram_tester.ExpectBucketCount( "Autofill.FormEvents.Address", @@ -2366,11 +2339,10 @@ TEST_F(AutofillMetricsTest, AddressWillSubmitFormEvents) { // Simulating submission with filled server data. base::HistogramTester histogram_tester; autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); - SuggestionBackendID guid("00000000-0000-0000-0000-000000000002", - 0); // server profile + std::string guid("00000000-0000-0000-0000-000000000002"); // server profile autofill_manager_->FillOrPreviewForm( AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), - autofill_manager_->MakeFrontendID(SuggestionBackendID(), guid)); + autofill_manager_->MakeFrontendID(std::string(), guid)); autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); histogram_tester.ExpectBucketCount( "Autofill.FormEvents.Address", @@ -2839,12 +2811,10 @@ TEST_F(AutofillMetricsTest, UserHappinessFormInteraction) { // Simulate editing an autofilled field. { base::HistogramTester histogram_tester; - SuggestionBackendID guid( - "00000000-0000-0000-0000-000000000001", 0); + std::string guid("00000000-0000-0000-0000-000000000001"); autofill_manager_->FillOrPreviewForm( - AutofillDriver::FORM_DATA_ACTION_FILL, - 0, form, form.fields.front(), - autofill_manager_->MakeFrontendID(SuggestionBackendID(), guid)); + AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), + autofill_manager_->MakeFrontendID(std::string(), guid)); autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), TimeTicks()); // Simulate a second keystroke; make sure we don't log the metric twice. diff --git a/components/autofill/core/browser/personal_data_manager.cc b/components/autofill/core/browser/personal_data_manager.cc index 5d234ad..b1ad2b06 100644 --- a/components/autofill/core/browser/personal_data_manager.cc +++ b/components/autofill/core/browser/personal_data_manager.cc @@ -143,16 +143,11 @@ bool IsValidFieldTypeAndValue(const std::set<ServerFieldType>& types_seen, return true; } -// Returns the list of values for the given type in the profile. There may be -// more than one (for example, the user can have more than one phone number per -// address). -// // In addition to just getting the values out of the autocomplete profile, this // function handles formatting of the street address into a single string. -std::vector<base::string16> GetMultiInfoInOneLine( - const AutofillProfile* profile, - const AutofillType& type, - const std::string app_locale) { +base::string16 GetInfoInOneLine(const AutofillProfile* profile, + const AutofillType& type, + const std::string app_locale) { std::vector<base::string16> results; AddressField address_field; @@ -162,35 +157,10 @@ std::vector<base::string16> GetMultiInfoInOneLine( GetStreetAddressLinesAsSingleLine( *i18n::CreateAddressDataFromAutofillProfile(*profile, app_locale), &street_address_line); - results.push_back(base::UTF8ToUTF16(street_address_line)); - } else { - profile->GetMultiInfo(type, app_locale, &results); + return base::UTF8ToUTF16(street_address_line); } - return results; -} -// Returns true if the current field contents match what's currently in the -// form field. The current field contents must be already canonicalized. In -// addition to doing a case-insensitive match, this will do special handling -// for phone numbers. -bool MatchesInput(const base::string16& profile_value, - const base::string16& field_contents_canon, - const AutofillType& type) { - base::string16 profile_value_canon = - AutofillProfile::CanonicalizeProfileString(profile_value); - - if (profile_value_canon == field_contents_canon) - return true; - - // Phone numbers could be split in US forms, so field value could be - // either prefix or suffix of the phone. - if (type.GetStorableType() == PHONE_HOME_NUMBER) { - return !field_contents_canon.empty() && - profile_value_canon.find(field_contents_canon) != - base::string16::npos; - } - - return false; + return profile->GetInfo(type, app_locale); } // Receives the loaded profiles from the web data service and stores them in @@ -813,70 +783,20 @@ std::vector<Suggestion> PersonalDataManager::GetProfileSuggestions( std::vector<AutofillProfile*> profiles = GetProfiles(true); std::sort(profiles.begin(), profiles.end(), RankByMfu); - if (field_is_autofilled) { - std::vector<Suggestion> suggestions; - // This field was previously autofilled. In this case, suggesting results - // based on prefix is useless since it will be the same thing. Instead, - // check for a field that may have multiple possible values (for example, - // multiple names for the same address) and suggest the alternates. This - // allows for easy correction of the data. - for (AutofillProfile* profile : profiles) { - std::vector<base::string16> values = - GetMultiInfoInOneLine(profile, type, app_locale_); - - // Check if the contents of this field match any of the inputs. - bool matches_field = false; - for (const base::string16& value : values) { - if (MatchesInput(value, field_contents_canon, type)) { - matches_field = true; - break; - } - } - - if (matches_field) { - // Field unmodified, make alternate suggestions. - for (size_t i = 0; i < values.size(); i++) { - if (values[i].empty()) - continue; - - bool is_unique = true; - for (size_t j = 0; j < suggestions.size(); ++j) { - if (values[i] == suggestions[j].value) { - is_unique = false; - break; - } - } - if (is_unique) { - suggestions.push_back(Suggestion(values[i])); - suggestions.back().backend_id.guid = profile->guid(); - suggestions.back().backend_id.variant = i; - } - } - } - } - - return suggestions; - } - std::vector<Suggestion> suggestions; // Match based on a prefix search. std::vector<AutofillProfile*> matched_profiles; for (AutofillProfile* profile : profiles) { - std::vector<base::string16> values = - GetMultiInfoInOneLine(profile, type, app_locale_); - for (size_t i = 0; i < values.size(); i++) { - if (values[i].empty()) - continue; - - base::string16 value_canon = - AutofillProfile::CanonicalizeProfileString(values[i]); - if (StartsWith(value_canon, field_contents_canon, true)) { - // Prefix match, add suggestion. - matched_profiles.push_back(profile); - suggestions.push_back(Suggestion(values[i])); - suggestions.back().backend_id.guid = profile->guid(); - suggestions.back().backend_id.variant = i; - } + base::string16 value = GetInfoInOneLine(profile, type, app_locale_); + if (value.empty()) + continue; + base::string16 value_canon = + AutofillProfile::CanonicalizeProfileString(value); + if (StartsWith(value_canon, field_contents_canon, true)) { + // Prefix match, add suggestion. + matched_profiles.push_back(profile); + suggestions.push_back(Suggestion(value)); + suggestions.back().backend_id = profile->guid(); } } @@ -988,7 +908,7 @@ std::vector<Suggestion> PersonalDataManager::GetCreditCardSuggestions( suggestion->value = credit_card->GetInfo(type, app_locale_); suggestion->icon = base::UTF8ToUTF16(credit_card->type()); - suggestion->backend_id.guid = credit_card->guid(); + suggestion->backend_id = credit_card->guid(); // If the value is the card number, the label is the expiration date. // Otherwise the label is the card number, or if that is empty the diff --git a/components/autofill/core/browser/personal_data_manager_unittest.cc b/components/autofill/core/browser/personal_data_manager_unittest.cc index dec3797..927638f 100644 --- a/components/autofill/core/browser/personal_data_manager_unittest.cc +++ b/components/autofill/core/browser/personal_data_manager_unittest.cc @@ -1244,98 +1244,6 @@ TEST_F(PersonalDataManagerTest, AggregateTwoDifferentProfiles) { ExpectSameElements(profiles, personal_data_->GetProfiles()); } -TEST_F(PersonalDataManagerTest, AggregateTwoProfilesWithMultiValue) { - FormData form1; - FormFieldData field; - test::CreateTestFormField( - "First name:", "first_name", "George", "text", &field); - form1.fields.push_back(field); - test::CreateTestFormField( - "Last name:", "last_name", "Washington", "text", &field); - form1.fields.push_back(field); - test::CreateTestFormField( - "Email:", "email", "theprez@gmail.com", "text", &field); - form1.fields.push_back(field); - test::CreateTestFormField( - "Address:", "address1", "21 Laussat St", "text", &field); - form1.fields.push_back(field); - test::CreateTestFormField("City:", "city", "San Francisco", "text", &field); - form1.fields.push_back(field); - test::CreateTestFormField("State:", "state", "California", "text", &field); - form1.fields.push_back(field); - test::CreateTestFormField("Zip:", "zip", "94102", "text", &field); - form1.fields.push_back(field); - - FormStructure form_structure1(form1); - form_structure1.DetermineHeuristicTypes(); - scoped_ptr<CreditCard> imported_credit_card; - EXPECT_TRUE(personal_data_->ImportFormData(form_structure1, - &imported_credit_card)); - ASSERT_FALSE(imported_credit_card); - - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); - - AutofillProfile expected(base::GenerateGUID(), "https://www.example.com"); - test::SetProfileInfo(&expected, "George", NULL, - "Washington", "theprez@gmail.com", NULL, "21 Laussat St", NULL, - "San Francisco", "California", "94102", NULL, NULL); - const std::vector<AutofillProfile*>& results1 = personal_data_->GetProfiles(); - ASSERT_EQ(1U, results1.size()); - EXPECT_EQ(0, expected.Compare(*results1[0])); - - // Now create a completely different profile. - FormData form2; - test::CreateTestFormField( - "First name:", "first_name", "John", "text", &field); - form2.fields.push_back(field); - test::CreateTestFormField("Last name:", "last_name", "Adams", "text", &field); - form2.fields.push_back(field); - test::CreateTestFormField( - "Email:", "email", "second@gmail.com", "text", &field); - form2.fields.push_back(field); - test::CreateTestFormField( - "Address:", "address1", "21 Laussat St", "text", &field); - form2.fields.push_back(field); - test::CreateTestFormField("City:", "city", "San Francisco", "text", &field); - form2.fields.push_back(field); - test::CreateTestFormField("State:", "state", "California", "text", &field); - form2.fields.push_back(field); - test::CreateTestFormField("Zip:", "zip", "94102", "text", &field); - form2.fields.push_back(field); - - FormStructure form_structure2(form2); - form_structure2.DetermineHeuristicTypes(); - EXPECT_TRUE(personal_data_->ImportFormData(form_structure2, - &imported_credit_card)); - ASSERT_FALSE(imported_credit_card); - - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); - - const std::vector<AutofillProfile*>& results2 = personal_data_->GetProfiles(); - - // Modify expected to include multi-valued fields. - std::vector<base::string16> first_names, last_names, emails; - expected.GetRawMultiInfo(NAME_FIRST, &first_names); - first_names.push_back(ASCIIToUTF16("John")); - expected.GetRawMultiInfo(NAME_LAST, &last_names); - last_names.push_back(ASCIIToUTF16("Adams")); - expected.SetRawMultiInfo(NAME_FIRST, first_names); - expected.SetRawMultiInfo(NAME_LAST, last_names); - - expected.GetRawMultiInfo(EMAIL_ADDRESS, &emails); - emails.push_back(ASCIIToUTF16("second@gmail.com")); - expected.SetRawMultiInfo(EMAIL_ADDRESS, emails); - - ASSERT_EQ(1U, results2.size()); - EXPECT_EQ(0, expected.Compare(*results2[0])); -} - TEST_F(PersonalDataManagerTest, AggregateSameProfileWithConflict) { FormData form1; FormFieldData field; @@ -2397,7 +2305,6 @@ TEST_F(PersonalDataManagerTest, SaveImportedProfileWithExistingVerifiedData) { AutofillProfile new_verified_profile = profile; new_verified_profile.set_guid(base::GenerateGUID()); new_verified_profile.SetRawInfo(COMPANY_NAME, ASCIIToUTF16("Fizzbang, Inc.")); - new_verified_profile.SetRawInfo(NAME_MIDDLE, base::string16()); EXPECT_TRUE(new_verified_profile.IsVerified()); personal_data_->SaveImportedProfile(new_verified_profile); @@ -2408,19 +2315,8 @@ TEST_F(PersonalDataManagerTest, SaveImportedProfileWithExistingVerifiedData) { base::MessageLoop::current()->Run(); // The new profile should be merged into the existing one. - AutofillProfile expected_profile = new_verified_profile; - expected_profile.set_guid(profile.guid()); - std::vector<base::string16> first_names, middle_names, last_names; - expected_profile.GetRawMultiInfo(NAME_FIRST, &first_names); - expected_profile.GetRawMultiInfo(NAME_MIDDLE, &middle_names); - expected_profile.GetRawMultiInfo(NAME_LAST, &last_names); - first_names.insert(first_names.begin(), ASCIIToUTF16("Marion")); - middle_names.insert(middle_names.begin(), ASCIIToUTF16("Mitchell")); - last_names.insert(last_names.begin(), ASCIIToUTF16("Morrison")); - expected_profile.SetRawMultiInfo(NAME_FIRST, first_names); - expected_profile.SetRawMultiInfo(NAME_MIDDLE, middle_names); - expected_profile.SetRawMultiInfo(NAME_LAST, last_names); - + AutofillProfile expected_profile = profile; + expected_profile.SetRawInfo(COMPANY_NAME, ASCIIToUTF16("Fizzbang, Inc.")); const std::vector<AutofillProfile*>& results = personal_data_->GetProfiles(); ASSERT_EQ(1U, results.size()); EXPECT_EQ(expected_profile, *results[0]); @@ -2584,110 +2480,6 @@ TEST_F(PersonalDataManagerTest, GetNonEmptyTypes) { EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR)); } -TEST_F(PersonalDataManagerTest, CaseInsensitiveMultiValueAggregation) { - FormData form1; - FormFieldData field; - test::CreateTestFormField( - "First name:", "first_name", "George", "text", &field); - form1.fields.push_back(field); - test::CreateTestFormField( - "Last name:", "last_name", "Washington", "text", &field); - form1.fields.push_back(field); - test::CreateTestFormField( - "Email:", "email", "theprez@gmail.com", "text", &field); - form1.fields.push_back(field); - test::CreateTestFormField( - "Address:", "address1", "21 Laussat St", "text", &field); - form1.fields.push_back(field); - test::CreateTestFormField( - "City:", "city", "San Francisco", "text", &field); - form1.fields.push_back(field); - test::CreateTestFormField("State:", "state", "California", "text", &field); - form1.fields.push_back(field); - test::CreateTestFormField( - "Zip:", "zip", "94102", "text", &field); - form1.fields.push_back(field); - test::CreateTestFormField( - "Phone number:", "phone_number", "817-555-6789", "text", &field); - form1.fields.push_back(field); - - FormStructure form_structure1(form1); - form_structure1.DetermineHeuristicTypes(); - scoped_ptr<CreditCard> imported_credit_card; - EXPECT_TRUE(personal_data_->ImportFormData(form_structure1, - &imported_credit_card)); - ASSERT_FALSE(imported_credit_card); - - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); - - AutofillProfile expected(base::GenerateGUID(), "https://www.example.com"); - test::SetProfileInfo(&expected, - "George", - NULL, - "Washington", - "theprez@gmail.com", - NULL, - "21 Laussat St", - NULL, - "San Francisco", - "California", - "94102", - NULL, - "817-555-6789"); - const std::vector<AutofillProfile*>& results1 = personal_data_->GetProfiles(); - ASSERT_EQ(1U, results1.size()); - EXPECT_EQ(0, expected.Compare(*results1[0])); - - // Upper-case the first name and change the phone number. - FormData form2; - test::CreateTestFormField( - "First name:", "first_name", "GEORGE", "text", &field); - form2.fields.push_back(field); - test::CreateTestFormField( - "Last name:", "last_name", "Washington", "text", &field); - form2.fields.push_back(field); - test::CreateTestFormField( - "Email:", "email", "theprez@gmail.com", "text", &field); - form2.fields.push_back(field); - test::CreateTestFormField( - "Address:", "address1", "21 Laussat St", "text", &field); - form2.fields.push_back(field); - test::CreateTestFormField("City:", "city", "San Francisco", "text", &field); - form2.fields.push_back(field); - test::CreateTestFormField("State:", "state", "California", "text", &field); - form2.fields.push_back(field); - test::CreateTestFormField("Zip:", "zip", "94102", "text", &field); - form2.fields.push_back(field); - test::CreateTestFormField( - "Phone number:", "phone_number", "214-555-1234", "text", &field); - form2.fields.push_back(field); - - FormStructure form_structure2(form2); - form_structure2.DetermineHeuristicTypes(); - EXPECT_TRUE(personal_data_->ImportFormData(form_structure2, - &imported_credit_card)); - ASSERT_FALSE(imported_credit_card); - - // Verify that the web database has been updated and the notification sent. - EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) - .WillOnce(QuitMainMessageLoop()); - base::MessageLoop::current()->Run(); - - const std::vector<AutofillProfile*>& results2 = personal_data_->GetProfiles(); - - // Modify expected to include multi-valued fields. - std::vector<base::string16> values; - expected.GetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values); - values.push_back(ASCIIToUTF16("214-555-1234")); - expected.SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, values); - - ASSERT_EQ(1U, results2.size()); - EXPECT_EQ(0, expected.Compare(*results2[0])); -} - TEST_F(PersonalDataManagerTest, IncognitoReadOnly) { ASSERT_TRUE(personal_data_->GetProfiles().empty()); ASSERT_TRUE(personal_data_->GetCreditCards().empty()); @@ -3022,13 +2814,13 @@ TEST_F(PersonalDataManagerTest, GetCreditCardSuggestions) { AutofillType(CREDIT_CARD_NAME), base::string16()); ASSERT_EQ(4U, suggestions.size()); EXPECT_EQ(ASCIIToUTF16("John Dillinger"), suggestions[0].value); - EXPECT_EQ(suggestions[0].backend_id.guid, credit_card1.guid()); + EXPECT_EQ(suggestions[0].backend_id, credit_card1.guid()); EXPECT_EQ(ASCIIToUTF16("Clyde Barrow"), suggestions[1].value); - EXPECT_NE(suggestions[1].backend_id.guid, credit_card0.guid()); + EXPECT_NE(suggestions[1].backend_id, credit_card0.guid()); EXPECT_EQ(ASCIIToUTF16("Bonnie Parker"), suggestions[2].value); - EXPECT_EQ(suggestions[2].backend_id.guid, credit_card2.guid()); + EXPECT_EQ(suggestions[2].backend_id, credit_card2.guid()); EXPECT_EQ(ASCIIToUTF16("Bonnie Parker"), suggestions[3].value); - EXPECT_NE(suggestions[3].backend_id.guid, credit_card2.guid()); + EXPECT_NE(suggestions[3].backend_id, credit_card2.guid()); suggestions = personal_data_->GetCreditCardSuggestions( AutofillType(CREDIT_CARD_NUMBER), base::string16()); diff --git a/components/autofill/core/browser/suggestion.cc b/components/autofill/core/browser/suggestion.cc index d906207..c46d302 100644 --- a/components/autofill/core/browser/suggestion.cc +++ b/components/autofill/core/browser/suggestion.cc @@ -10,24 +10,6 @@ namespace autofill { -SuggestionBackendID::SuggestionBackendID() - : variant(0) { -} - -SuggestionBackendID::SuggestionBackendID(const std::string& g, size_t v) - : guid(g), - variant(v) { -} - -SuggestionBackendID::~SuggestionBackendID() { -} - -bool SuggestionBackendID::operator<(const SuggestionBackendID& other) const { - if (variant != other.variant) - return variant < other.variant; - return guid < other.guid; -} - Suggestion::Suggestion() : frontend_id(0) { } diff --git a/components/autofill/core/browser/suggestion.h b/components/autofill/core/browser/suggestion.h index b962644..6077185 100644 --- a/components/autofill/core/browser/suggestion.h +++ b/components/autofill/core/browser/suggestion.h @@ -15,20 +15,6 @@ namespace autofill { class AutofillProfile; class CreditCard; -// Represents a single FormGroup and a specific data variant. This is assigned -// by the storage layer to uniquely identify the profile this came from. -struct SuggestionBackendID { - SuggestionBackendID(); - SuggestionBackendID(const std::string& guid, size_t variant); - ~SuggestionBackendID(); - - std::string guid; - size_t variant; - - // For using as a key in a map. - bool operator<(const SuggestionBackendID& other) const; -}; - struct Suggestion { public: Suggestion(); @@ -47,9 +33,9 @@ struct Suggestion { ~Suggestion(); - // ID generated by the backend layer. This identifies the exact autofill + // GUID generated by the backend layer. This identifies the exact autofill // profile that generated this suggestion. - SuggestionBackendID backend_id; + std::string backend_id; // ID for the frontend to use in identifying the particular result. Positive // values are sent over IPC to identify the item selected. Negative values |