Chromium Code Reviews| Index: components/autofill/core/browser/personal_data_manager.h |
| diff --git a/components/autofill/core/browser/personal_data_manager.h b/components/autofill/core/browser/personal_data_manager.h |
| index 3513d9e21f2d6fa9a335644a9bd78417fcc5a656..67f465b6c7557eaae542fa8d50a534ca1660f88c 100644 |
| --- a/components/autofill/core/browser/personal_data_manager.h |
| +++ b/components/autofill/core/browser/personal_data_manager.h |
| @@ -214,11 +214,10 @@ class PersonalDataManager : public KeyedService, |
| // otherwise appends |new_profile| to the end of that list. Fills |
| // |merged_profiles| with the result. Returns the |guid| of the new or updated |
| // profile. |
| - static std::string MergeProfile( |
| - const AutofillProfile& new_profile, |
| - std::vector<AutofillProfile*> existing_profiles, |
| - const std::string& app_locale, |
| - std::vector<AutofillProfile>* merged_profiles); |
| + std::string MergeProfile(const AutofillProfile& new_profile, |
| + std::vector<AutofillProfile*> existing_profiles, |
| + const std::string& app_locale, |
| + std::vector<AutofillProfile>* merged_profiles); |
| // Returns true if |country_code| is a country that the user is likely to |
| // be associated with the user. More concretely, it checks if there are any |
| @@ -242,6 +241,10 @@ class PersonalDataManager : public KeyedService, |
| // PersonalDataManager. |
| FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FirstMiddleLast); |
| FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AutofillIsEnabledAtStartup); |
| + FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| + FindAndMergeDuplicateProfiles_ProfilesToDelete); |
| + FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| + FindAndMergeDuplicateProfiles_MergedProfileValues); |
| friend class autofill::AutofillInteractiveTest; |
| friend class autofill::AutofillTest; |
| friend class autofill::PersonalDataManagerFactory; |
| @@ -397,6 +400,30 @@ class PersonalDataManager : public KeyedService, |
| const base::string16& field_contents, |
| const std::list<const CreditCard*>& cards_to_suggest) const; |
| + // Goes through the |existing_profiles| to find similar profiles to |
| + // |profile_to_merge|. If a similar profile is found |profile_to_merge| is |
| + // merged into it, gets deleted and the result becomes the new |
| + // |profile_to_merge|. The process continues until the end of |
| + // |existing_profiles| is reached. |
| + // |
| + // |existing_profiles| should be sorted by frecency to ensure that the more |
| + // relevant profiles get merged into the less relevant ones. |
| + void FindMergeAndDeleteDuplicateProfiles( |
| + const std::vector<AutofillProfile*>& existing_profiles, |
| + AutofillProfile* profile_to_merge, |
| + const std::string& app_locale); |
| + |
| + // Goes through the |existing_profiles| to find similar profiles to |
| + // |profile_to_merge|. If a similar profile is found |profile_to_merge| is |
| + // merged into it, its GUID gets added to |profile_guids_to_delete| and the |
| + // result becomes the new |profile_to_merge|. The process continues until the |
| + // end of |existing_profiles| is reached. |
| + void FindAndMergeDuplicateProfiles( |
|
Roger McFarlane (Chromium)
2016/06/08 18:55:38
a comment that this is exposed for testability.
sebsg
2016/06/08 21:58:46
Done.
|
| + const std::vector<AutofillProfile*>& existing_profiles, |
| + AutofillProfile* profile_to_merge, |
| + std::vector<std::string>* profile_guids_to_delete, |
| + const std::string& app_locale); |
| + |
| const std::string app_locale_; |
| // The default country code for new addresses. |