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

Unified Diff: components/autofill/content/renderer/autofill_agent.cc

Issue 2174303002: Move filtering logic in GetDataListSuggestions() to Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move implementation to HTMLInputElement Created 4 years, 5 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/content/renderer/autofill_agent.cc
diff --git a/components/autofill/content/renderer/autofill_agent.cc b/components/autofill/content/renderer/autofill_agent.cc
index 44cee7f999683977b765b9e6ff070731fc4e4ee8..c6003cd24ee5984ddc597dd7a24f232b27899eca 100644
--- a/components/autofill/content/renderer/autofill_agent.cc
+++ b/components/autofill/content/renderer/autofill_agent.cc
@@ -110,29 +110,7 @@ bool IsSingleClickEnabled() {
void GetDataListSuggestions(const WebInputElement& element,
std::vector<base::string16>* values,
std::vector<base::string16>* labels) {
- WebElementCollection options = element.dataListOptions();
- if (options.isNull())
- return;
-
- // If the field accepts multiple email addresses, filter only on the last one.
- base::string16 prefix = element.editingValue();
- if (element.isMultiple() && element.isEmailField()) {
- std::vector<base::string16> parts = base::SplitString(
- prefix, base::ASCIIToUTF16(","), base::TRIM_WHITESPACE,
- base::SPLIT_WANT_ALL);
- if (!parts.empty())
- base::TrimWhitespace(parts.back(), base::TRIM_LEADING, &prefix);
- }
-
- // Prefix filtering.
- prefix = base::i18n::ToLower(prefix);
- for (WebOptionElement option = options.firstItem().to<WebOptionElement>();
- !option.isNull(); option = options.nextItem().to<WebOptionElement>()) {
- if (!base::StartsWith(base::i18n::ToLower(base::string16(option.value())),
- prefix, base::CompareCase::SENSITIVE) ||
- !element.isValidValue(option.value()))
- continue;
-
+ for (const auto& option : element.filteredDataListOptions()) {
values->push_back(option.value());
if (option.value() != option.label())
labels->push_back(option.label());

Powered by Google App Engine
This is Rietveld 408576698