| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/credentialmanager/PasswordCredential.h" | 5 #include "modules/credentialmanager/PasswordCredential.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/Dictionary.h" | 7 #include "bindings/core/v8/Dictionary.h" |
| 8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
| 9 #include "core/HTMLNames.h" | 9 #include "core/HTMLNames.h" |
| 10 #include "core/dom/ExecutionContext.h" | 10 #include "core/dom/ExecutionContext.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 | 78 |
| 79 // Create a PasswordCredential using the data gathered above. | 79 // Create a PasswordCredential using the data gathered above. |
| 80 PasswordCredential* credential = PasswordCredential::create(data, exceptionS
tate); | 80 PasswordCredential* credential = PasswordCredential::create(data, exceptionS
tate); |
| 81 if (exceptionState.hadException()) | 81 if (exceptionState.hadException()) |
| 82 return nullptr; | 82 return nullptr; |
| 83 ASSERT(credential); | 83 ASSERT(credential); |
| 84 | 84 |
| 85 // After creating the Credential, populate its 'additionalData', 'idName', a
nd 'passwordName' attributes. | 85 // After creating the Credential, populate its 'additionalData', 'idName', a
nd 'passwordName' attributes. |
| 86 FormDataOrURLSearchParams additionalData; | 86 // If the form's 'enctype' is anything other than multipart, generate a URLS
earchParams using the |
| 87 additionalData.setFormData(formData); | 87 // data in |formData|. |
| 88 credential->setAdditionalData(additionalData); | |
| 89 credential->setIdName(idName); | 88 credential->setIdName(idName); |
| 90 credential->setPasswordName(passwordName); | 89 credential->setPasswordName(passwordName); |
| 90 |
| 91 FormDataOrURLSearchParams additionalData; |
| 92 if (form->enctype() == "multipart/form-data") { |
| 93 additionalData.setFormData(formData); |
| 94 } else { |
| 95 URLSearchParams* params = URLSearchParams::create(URLSearchParamsInit())
; |
| 96 for (const FormData::Entry* entry : formData->entries()) { |
| 97 if (entry->isString()) |
| 98 params->append(entry->name().data(), entry->value().data()); |
| 99 } |
| 100 additionalData.setURLSearchParams(params); |
| 101 } |
| 102 |
| 103 credential->setAdditionalData(additionalData); |
| 91 return credential; | 104 return credential; |
| 92 } | 105 } |
| 93 | 106 |
| 94 PasswordCredential::PasswordCredential(WebPasswordCredential* webPasswordCredent
ial) | 107 PasswordCredential::PasswordCredential(WebPasswordCredential* webPasswordCredent
ial) |
| 95 : Credential(webPasswordCredential->getPlatformCredential()) | 108 : Credential(webPasswordCredential->getPlatformCredential()) |
| 96 , m_idName("username") | 109 , m_idName("username") |
| 97 , m_passwordName("password") | 110 , m_passwordName("password") |
| 98 { | 111 { |
| 99 } | 112 } |
| 100 | 113 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 return static_cast<PlatformPasswordCredential*>(m_platformCredential.get())-
>password(); | 165 return static_cast<PlatformPasswordCredential*>(m_platformCredential.get())-
>password(); |
| 153 } | 166 } |
| 154 | 167 |
| 155 DEFINE_TRACE(PasswordCredential) | 168 DEFINE_TRACE(PasswordCredential) |
| 156 { | 169 { |
| 157 Credential::trace(visitor); | 170 Credential::trace(visitor); |
| 158 visitor->trace(m_additionalData); | 171 visitor->trace(m_additionalData); |
| 159 } | 172 } |
| 160 | 173 |
| 161 } // namespace blink | 174 } // namespace blink |
| OLD | NEW |