| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // 'passwordName' attributes. If the form's 'enctype' is anything other than | 96 // 'passwordName' attributes. If the form's 'enctype' is anything other than |
| 97 // multipart, generate a URLSearchParams using the | 97 // multipart, generate a URLSearchParams using the |
| 98 // data in |formData|. | 98 // data in |formData|. |
| 99 credential->setIdName(idName); | 99 credential->setIdName(idName); |
| 100 credential->setPasswordName(passwordName); | 100 credential->setPasswordName(passwordName); |
| 101 | 101 |
| 102 FormDataOrURLSearchParams additionalData; | 102 FormDataOrURLSearchParams additionalData; |
| 103 if (form->enctype() == "multipart/form-data") { | 103 if (form->enctype() == "multipart/form-data") { |
| 104 additionalData.setFormData(formData); | 104 additionalData.setFormData(formData); |
| 105 } else { | 105 } else { |
| 106 URLSearchParams* params = URLSearchParams::create(URLSearchParamsInit()); | 106 URLSearchParams* params = URLSearchParams::create(String()); |
| 107 for (const FormData::Entry* entry : formData->entries()) { | 107 for (const FormData::Entry* entry : formData->entries()) { |
| 108 if (entry->isString()) | 108 if (entry->isString()) |
| 109 params->append(entry->name().data(), entry->value().data()); | 109 params->append(entry->name().data(), entry->value().data()); |
| 110 } | 110 } |
| 111 additionalData.setURLSearchParams(params); | 111 additionalData.setURLSearchParams(params); |
| 112 } | 112 } |
| 113 | 113 |
| 114 credential->setAdditionalData(additionalData); | 114 credential->setAdditionalData(additionalData); |
| 115 return credential; | 115 return credential; |
| 116 } | 116 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 128 : SiteBoundCredential( | 128 : SiteBoundCredential( |
| 129 PlatformPasswordCredential::create(id, password, name, icon)), | 129 PlatformPasswordCredential::create(id, password, name, icon)), |
| 130 m_idName("username"), | 130 m_idName("username"), |
| 131 m_passwordName("password") {} | 131 m_passwordName("password") {} |
| 132 | 132 |
| 133 PassRefPtr<EncodedFormData> PasswordCredential::encodeFormData( | 133 PassRefPtr<EncodedFormData> PasswordCredential::encodeFormData( |
| 134 String& contentType) const { | 134 String& contentType) const { |
| 135 if (m_additionalData.isURLSearchParams()) { | 135 if (m_additionalData.isURLSearchParams()) { |
| 136 // If |additionalData| is a 'URLSearchParams' object, build a urlencoded | 136 // If |additionalData| is a 'URLSearchParams' object, build a urlencoded |
| 137 // response. | 137 // response. |
| 138 URLSearchParams* params = URLSearchParams::create(URLSearchParamsInit()); | 138 URLSearchParams* params = URLSearchParams::create(String()); |
| 139 URLSearchParams* additionalData = m_additionalData.getAsURLSearchParams(); | 139 URLSearchParams* additionalData = m_additionalData.getAsURLSearchParams(); |
| 140 for (const auto& param : additionalData->params()) { | 140 for (const auto& param : additionalData->params()) { |
| 141 const String& name = param.first; | 141 const String& name = param.first; |
| 142 if (name != idName() && name != passwordName()) | 142 if (name != idName() && name != passwordName()) |
| 143 params->append(name, param.second); | 143 params->append(name, param.second); |
| 144 } | 144 } |
| 145 params->append(idName(), id()); | 145 params->append(idName(), id()); |
| 146 params->append(passwordName(), password()); | 146 params->append(passwordName(), password()); |
| 147 | 147 |
| 148 contentType = | 148 contentType = |
| (...skipping 30 matching lines...) Expand all Loading... |
| 179 return static_cast<PlatformPasswordCredential*>(m_platformCredential.get()) | 179 return static_cast<PlatformPasswordCredential*>(m_platformCredential.get()) |
| 180 ->password(); | 180 ->password(); |
| 181 } | 181 } |
| 182 | 182 |
| 183 DEFINE_TRACE(PasswordCredential) { | 183 DEFINE_TRACE(PasswordCredential) { |
| 184 SiteBoundCredential::trace(visitor); | 184 SiteBoundCredential::trace(visitor); |
| 185 visitor->trace(m_additionalData); | 185 visitor->trace(m_additionalData); |
| 186 } | 186 } |
| 187 | 187 |
| 188 } // namespace blink | 188 } // namespace blink |
| OLD | NEW |