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

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

Issue 1455093004: [Autofill] Remove datalist flash when there is an existing entry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 f15a5806089307374c129c07574cdb94b8797764..fbcfeabf6940af0ea3f25b7d6ef335e21bbf6e29 100644
--- a/components/autofill/content/renderer/autofill_agent.cc
+++ b/components/autofill/content/renderer/autofill_agent.cc
@@ -78,26 +78,25 @@ namespace {
// Gets all the data list values (with corresponding label) for the given
// element.
void GetDataListSuggestions(const WebInputElement& element,
- bool ignore_current_value,
std::vector<base::string16>* values,
std::vector<base::string16>* labels) {
WebElementCollection options = element.dataListOptions();
if (options.isNull())
return;
- base::string16 prefix;
- if (!ignore_current_value) {
- prefix = element.editingValue();
- if (element.isMultiple() && element.isEmailField()) {
- const base::char16 comma[2] = { ',', 0 };
- std::vector<base::string16> parts = base::SplitString(
- prefix, comma, base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
- if (parts.size() > 0) {
- base::TrimWhitespace(parts[parts.size() - 1], base::TRIM_LEADING,
- &prefix);
- }
+ // 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[parts.size() - 1], 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>()) {
@@ -739,7 +738,6 @@ void AutofillAgent::QueryAutofillSuggestions(
if (input_element) {
// Find the datalist values and send them to the browser process.
GetDataListSuggestions(*input_element,
- datalist_only,
&data_list_values,
&data_list_labels);
TrimStringVectorForIPC(&data_list_values);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698