Chromium Code Reviews| Index: components/autofill/core/browser/form_structure.cc |
| diff --git a/components/autofill/core/browser/form_structure.cc b/components/autofill/core/browser/form_structure.cc |
| index fb0c4954a4752b5bf92cd71b3cc6f19eda23fe04..561b65bdc69bfb87195a07b2f6d97ca5b14bc6ef 100644 |
| --- a/components/autofill/core/browser/form_structure.cc |
| +++ b/components/autofill/core/browser/form_structure.cc |
| @@ -897,17 +897,16 @@ void FormStructure::ParseFieldTypesFromAutocompleteAttributes() { |
| // section names. |
| field->set_section(kDefaultSection); |
| - // Canonicalize the attribute value by trimming whitespace, collapsing |
| - // non-space characters (e.g. tab) to spaces, and converting to lowercase. |
| - std::string autocomplete_attribute = |
| - base::CollapseWhitespaceASCII(field->autocomplete_attribute, false); |
| - autocomplete_attribute = base::ToLowerASCII(autocomplete_attribute); |
| + // Lowercase and tokenize the attribute value. Per the spec, the tokens are |
|
vabr (Chromium)
2016/10/13 12:49:31
nit: The comment about the reverse order is relate
vabr (Chromium)
2016/10/13 12:49:31
nit: The first sentence of the comment can probabl
jdoerrie
2016/10/13 13:45:07
Done.
jdoerrie
2016/10/13 13:45:07
Done.
|
| + // parsed in reverse order. |
| + std::vector<std::string> tokens = |
| + LowercaseAndTokenizeAttributeString(field->autocomplete_attribute); |
| // The autocomplete attribute is overloaded: it can specify either a field |
| // type hint or whether autocomplete should be enabled at all. Ignore the |
| // latter type of attribute value. |
| - if (autocomplete_attribute.empty() || autocomplete_attribute == "on" || |
| - autocomplete_attribute == "off") { |
| + if (tokens.empty() || |
| + (tokens.size() == 1 && (tokens[0] == "on" || tokens[0] == "off"))) { |
| continue; |
| } |
| @@ -917,12 +916,6 @@ void FormStructure::ParseFieldTypesFromAutocompleteAttributes() { |
| // the form. |
| has_author_specified_types_ = true; |
| - // Tokenize the attribute value. Per the spec, the tokens are parsed in |
| - // reverse order. |
| - std::vector<std::string> tokens = |
| - base::SplitString(autocomplete_attribute, " ", base::KEEP_WHITESPACE, |
| - base::SPLIT_WANT_NONEMPTY); |
| - |
| // The final token must be the field type. |
| // If it is not one of the known types, abort. |
| DCHECK(!tokens.empty()); |