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

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: Rebase+Feedback 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 9fcbacbfa87eeffff5f96106b0cc66f2886d0420..969ddccc232377b994dcf272cc4a74fb368a8510 100644
--- a/third_party/WebKit/Source/modules/credentialmanager/PasswordCredential.cpp
+++ b/third_party/WebKit/Source/modules/credentialmanager/PasswordCredential.cpp
@@ -83,11 +83,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 (form->enctype() == "multipart/form-data") {
+ 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