Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Unified Diff: components/autofill/core/browser/personal_data_manager.cc

Issue 1943853003: [Autofill] Sort existing profiles by frecency before trying to merge. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();

Powered by Google App Engine
This is Rietveld 408576698