| Index: components/autofill/core/browser/personal_data_manager.cc
|
| diff --git a/components/autofill/core/browser/personal_data_manager.cc b/components/autofill/core/browser/personal_data_manager.cc
|
| index 9a0423c19a6fc25bf4678a19f7a856d0f109bf56..564f23e74a5e38938a7ed23e0d3f10982a38b442 100644
|
| --- a/components/autofill/core/browser/personal_data_manager.cc
|
| +++ b/components/autofill/core/browser/personal_data_manager.cc
|
| @@ -866,11 +866,20 @@ bool PersonalDataManager::IsValidLearnableProfile(
|
| // static
|
| std::string PersonalDataManager::MergeProfile(
|
| const AutofillProfile& new_profile,
|
| - const std::vector<AutofillProfile*>& existing_profiles,
|
| + std::vector<AutofillProfile*> existing_profiles,
|
| const std::string& app_locale,
|
| std::vector<AutofillProfile>* merged_profiles) {
|
| merged_profiles->clear();
|
|
|
| + // Sort the existing profiles in decreasing order of frecency, so the "best"
|
| + // profiles are checked first.
|
| + base::Time comparison_time = base::Time::Now();
|
| + std::sort(existing_profiles.begin(), existing_profiles.end(),
|
| + [comparison_time](const AutofillDataModel* a,
|
| + const AutofillDataModel* b) {
|
| + return a->CompareFrecency(b, comparison_time);
|
| + });
|
| +
|
| // Set to true if |existing_profiles| already contains an equivalent profile.
|
| bool matching_profile_found = false;
|
| std::string guid = new_profile.guid();
|
|
|