Chromium Code Reviews| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 | 76 |
| 77 // Create a PasswordCredential using the data gathered above. | 77 // Create a PasswordCredential using the data gathered above. |
| 78 PasswordCredential* credential = PasswordCredential::create(data, exceptionS tate); | 78 PasswordCredential* credential = PasswordCredential::create(data, exceptionS tate); |
| 79 if (exceptionState.hadException()) | 79 if (exceptionState.hadException()) |
| 80 return nullptr; | 80 return nullptr; |
| 81 ASSERT(credential); | 81 ASSERT(credential); |
| 82 | 82 |
| 83 // After creating the Credential, populate its 'additionalData', 'idName', a nd 'passwordName' attributes. | 83 // After creating the Credential, populate its 'additionalData', 'idName', a nd 'passwordName' attributes. |
| 84 FormDataOrURLSearchParams additionalData; | 84 // If the form's 'enctype' is anything other than multipart, generate a URLS earchParams using the |
| 85 additionalData.setFormData(formData); | 85 // data in |formData|. |
| 86 credential->setAdditionalData(additionalData); | |
| 87 credential->setIdName(idName); | 86 credential->setIdName(idName); |
| 88 credential->setPasswordName(passwordName); | 87 credential->setPasswordName(passwordName); |
| 88 | |
| 89 FormDataOrURLSearchParams additionalData; | |
| 90 if (equalIgnoringCase(form->fastGetAttribute(HTMLNames::enctypeAttr), "multi part/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
| |
| 91 additionalData.setFormData(formData); | |
| 92 } else { | |
| 93 URLSearchParams* params = URLSearchParams::create(URLSearchParamsInit()) ; | |
| 94 for (const FormData::Entry* entry : formData->entries()) { | |
| 95 if (entry->isString()) | |
| 96 params->append(entry->name().data(), entry->value().data()); | |
| 97 } | |
| 98 additionalData.setURLSearchParams(params); | |
| 99 } | |
| 100 | |
| 101 credential->setAdditionalData(additionalData); | |
| 89 return credential; | 102 return credential; |
| 90 } | 103 } |
| 91 | 104 |
| 92 PasswordCredential::PasswordCredential(WebPasswordCredential* webPasswordCredent ial) | 105 PasswordCredential::PasswordCredential(WebPasswordCredential* webPasswordCredent ial) |
| 93 : Credential(webPasswordCredential->getPlatformCredential()) | 106 : Credential(webPasswordCredential->getPlatformCredential()) |
| 94 , m_idName("username") | 107 , m_idName("username") |
| 95 , m_passwordName("password") | 108 , m_passwordName("password") |
| 96 { | 109 { |
| 97 } | 110 } |
| 98 | 111 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 return static_cast<PlatformPasswordCredential*>(m_platformCredential.get())- >password(); | 163 return static_cast<PlatformPasswordCredential*>(m_platformCredential.get())- >password(); |
| 151 } | 164 } |
| 152 | 165 |
| 153 DEFINE_TRACE(PasswordCredential) | 166 DEFINE_TRACE(PasswordCredential) |
| 154 { | 167 { |
| 155 Credential::trace(visitor); | 168 Credential::trace(visitor); |
| 156 visitor->trace(m_additionalData); | 169 visitor->trace(m_additionalData); |
| 157 } | 170 } |
| 158 | 171 |
| 159 } // namespace blink | 172 } // namespace blink |
| OLD | NEW |