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

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

Issue 1828923003: CREDENTIAL: Teach the 'PasswordCredential(HTMLFormElement)' constructor about URLSearchParams (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@HTMLFormElement
Patch Set: Created 4 years, 9 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: 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 743bb10745e0b6960d88be09327e989c75b7be36..1eb135cf0fc74374aaebb9cc59d37eda9fc92f31 100644
--- a/third_party/WebKit/Source/modules/credentialmanager/PasswordCredential.cpp
+++ b/third_party/WebKit/Source/modules/credentialmanager/PasswordCredential.cpp
@@ -81,11 +81,24 @@ PasswordCredential* PasswordCredential::create(HTMLFormElement* form, ExceptionS
ASSERT(credential);
// After creating the Credential, populate its 'additionalData', 'idName', and 'passwordName' attributes.
- FormDataOrURLSearchParams additionalData;
- additionalData.setFormData(formData);
- credential->setAdditionalData(additionalData);
+ // If the form's 'enctype' is anything other than multipart, generate a URLSearchParams using the
+ // data in |formData|.
credential->setIdName(idName);
credential->setPasswordName(passwordName);
+
+ FormDataOrURLSearchParams additionalData;
+ if (equalIgnoringCase(form->fastGetAttribute(HTMLNames::enctypeAttr), "multipart/form-data")) {
philipj_slow 2016/03/29 06:07:34 The spec doesn't say "ASCII case-insensitive" here
Mike West 2016/03/31 08:53:17 Well, the spec says that the content attribute is
+ additionalData.setFormData(formData);
+ } else {
+ URLSearchParams* params = URLSearchParams::create(URLSearchParamsInit());
+ for (const FormData::Entry* entry : formData->entries()) {
+ if (entry->isString())
+ params->append(entry->name().data(), entry->value().data());
+ }
+ additionalData.setURLSearchParams(params);
+ }
+
+ credential->setAdditionalData(additionalData);
return credential;
}

Powered by Google App Engine
This is Rietveld 408576698