Chromium Code Reviews| Index: third_party/WebKit/Source/modules/credentialmanager/PasswordCredential.cpp |
| diff --git a/third_party/WebKit/Source/modules/credentialmanager/PasswordCredential.cpp b/third_party/WebKit/Source/modules/credentialmanager/PasswordCredential.cpp |
| index ed79cfe61ff52871a165ef77b80ba56e2b4ca8f9..40abadd696b671fb197c5da6d7a2d1566cbd016a 100644 |
| --- a/third_party/WebKit/Source/modules/credentialmanager/PasswordCredential.cpp |
| +++ b/third_party/WebKit/Source/modules/credentialmanager/PasswordCredential.cpp |
| @@ -64,18 +64,26 @@ PasswordCredential* PasswordCredential::create(HTMLFormElement* form, |
| if (!result.isUSVString()) |
| continue; |
| - AtomicString autocomplete = |
| - toHTMLElement(element)->fastGetAttribute(HTMLNames::autocompleteAttr); |
| - if (equalIgnoringCase(autocomplete, "current-password") || |
| - equalIgnoringCase(autocomplete, "new-password")) { |
| + Vector<String> autofillTokens; |
| + toHTMLElement(element) |
| + ->fastGetAttribute(HTMLNames::autocompleteAttr) |
| + .getString() |
| + .split(' ', autofillTokens); |
| + auto hasToken = [&autofillTokens](const StringView& expectedToken) { |
|
haraken
2016/11/10 02:01:51
Nit: The lambda function is allowed in the style g
Mike West
2016/11/10 07:46:39
It also seems like it would be more efficient to l
vasilii
2016/11/10 09:21:55
Done.
|
| + for (const auto& token : autofillTokens) { |
| + if (equalIgnoringASCIICase(token, expectedToken)) |
| + return true; |
| + } |
| + return false; |
| + }; |
| + if (hasToken("current-password") || hasToken("new-password")) { |
| data.setPassword(result.getAsUSVString()); |
| passwordName = element->name(); |
| - } else if (equalIgnoringCase(autocomplete, "photo")) { |
| + } else if (hasToken("photo")) { |
| data.setIconURL(result.getAsUSVString()); |
| - } else if (equalIgnoringCase(autocomplete, "name") || |
| - equalIgnoringCase(autocomplete, "nickname")) { |
| + } else if (hasToken("name") || hasToken("nickname")) { |
| data.setName(result.getAsUSVString()); |
| - } else if (equalIgnoringCase(autocomplete, "username")) { |
| + } else if (hasToken("username")) { |
| data.setId(result.getAsUSVString()); |
| idName = element->name(); |
| } |