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

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

Issue 1458903003: [Autofill] Deduplicate Autocomplete and Datalist suggestions, keeping the latter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initial Created 5 years, 1 month 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/autofill_external_delegate.cc
diff --git a/components/autofill/core/browser/autofill_external_delegate.cc b/components/autofill/core/browser/autofill_external_delegate.cc
index f06b2d51d7e82e732f1212098ff50369dae5c0e3..74e8a7f218af4a45fc47c7c4134d1293175e006d 100644
--- a/components/autofill/core/browser/autofill_external_delegate.cc
+++ b/components/autofill/core/browser/autofill_external_delegate.cc
@@ -309,9 +309,22 @@ void AutofillExternalDelegate::InsertDataListValues(
if (data_list_values_.empty())
return;
+ // Go through the list of autocomplete values and remove them if they are in
+ // the list of datalist values.
+ std::set<base::string16> datalist_set(data_list_values_.begin(),
Evan Stade 2015/11/19 03:13:03 please keep datalist/data_list consistent
Mathieu 2015/11/19 13:22:17 Done.
+ data_list_values_.end());
+ for (auto iter = suggestions->begin(); iter != suggestions->end();) {
Evan Stade 2015/11/19 03:13:03 std::remove_if(suggestions->begin(),
Evan Stade 2015/11/19 03:19:51 note that you might have to put a & or something i
vabr (Chromium) 2015/11/19 08:26:04 Please use [&datalist_set], not just [&], because
Mathieu 2015/11/19 13:22:16 Done.
Mathieu 2015/11/19 13:22:17 Done.
Mathieu 2015/11/19 13:22:17 Done.
+ if (datalist_set.count(iter->value) &&
vabr (Chromium) 2015/11/19 08:26:04 optional: While using .count() results in succinct
Mathieu 2015/11/19 13:22:17 Ah thanks! Done.
+ iter->frontend_id == POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY) {
+ iter = suggestions->erase(iter);
+ continue;
+ }
+ ++iter;
+ }
+
#if !defined(OS_ANDROID)
- // Insert the separator between the datalist and Autofill values (if there
- // are any).
+ // Insert the separator between the datalist and Autofill/Autocomplete values
+ // (if there are any).
if (!suggestions->empty()) {
suggestions->insert(suggestions->begin(), Suggestion());
(*suggestions)[0].frontend_id = POPUP_ITEM_ID_SEPARATOR;

Powered by Google App Engine
This is Rietveld 408576698