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

Unified Diff: third_party/WebKit/Source/modules/credentialmanager/PasswordCredential.cpp

Issue 2492553002: Allow PasswordCredential instantiation when an input element has multiple 'autocomplete' tokens. (Closed)
Patch Set: Created 4 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
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();
}

Powered by Google App Engine
This is Rietveld 408576698