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..44b1bb73d6944fd88e2f892ed277ea238064d71e 100644 |
--- a/components/autofill/core/browser/autofill_external_delegate.cc |
+++ b/components/autofill/core/browser/autofill_external_delegate.cc |
@@ -10,6 +10,7 @@ |
#include "base/message_loop/message_loop.h" |
#include "base/metrics/histogram_macros.h" |
#include "base/metrics/sparse_histogram.h" |
+#include "base/stl_util.h" |
#include "base/strings/string_util.h" |
#include "base/strings/utf_string_conversions.h" |
#include "components/autofill/core/browser/autocomplete_history_manager.h" |
@@ -309,9 +310,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> data_list_set(data_list_values_.begin(), |
+ data_list_values_.end()); |
+ suggestions->erase( |
+ std::remove_if(suggestions->begin(), suggestions->end(), |
+ [&data_list_set](const Suggestion& suggestion) { |
+ return ContainsKey(data_list_set, suggestion.value) && |
+ suggestion.frontend_id == |
+ POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY; |
Evan Stade
2015/11/19 16:40:10
nit: i'd reverse the order of these checks since t
Mathieu
2015/11/19 17:06:21
Done.
|
+ }), |
+ suggestions->end()); |
+ |
#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; |