| 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 "config.h" | 5 #include "config.h" |
| 6 #include "modules/credentialmanager/PasswordCredential.h" | 6 #include "modules/credentialmanager/PasswordCredential.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/Dictionary.h" |
| 8 #include "bindings/core/v8/ExceptionState.h" | 9 #include "bindings/core/v8/ExceptionState.h" |
| 10 #include "core/dom/ExecutionContext.h" |
| 9 #include "core/html/DOMFormData.h" | 11 #include "core/html/DOMFormData.h" |
| 12 #include "modules/credentialmanager/FormDataOptions.h" |
| 10 #include "platform/credentialmanager/PlatformPasswordCredential.h" | 13 #include "platform/credentialmanager/PlatformPasswordCredential.h" |
| 14 #include "platform/weborigin/SecurityOrigin.h" |
| 11 #include "public/platform/WebCredential.h" | 15 #include "public/platform/WebCredential.h" |
| 12 #include "public/platform/WebPasswordCredential.h" | 16 #include "public/platform/WebPasswordCredential.h" |
| 13 | 17 |
| 14 namespace blink { | 18 namespace blink { |
| 15 | 19 |
| 16 PasswordCredential* PasswordCredential::create(WebPasswordCredential* webPasswor
dCredential) | 20 PasswordCredential* PasswordCredential::create(WebPasswordCredential* webPasswor
dCredential) |
| 17 { | 21 { |
| 18 return new PasswordCredential(webPasswordCredential); | 22 return new PasswordCredential(webPasswordCredential); |
| 19 } | 23 } |
| 20 | 24 |
| 21 PasswordCredential* PasswordCredential::create(const String& id, const String& p
assword, const String& name, const String& icon, ExceptionState& exceptionState) | 25 PasswordCredential* PasswordCredential::create(const String& id, const String& p
assword, const String& name, const String& icon, ExceptionState& exceptionState) |
| 22 { | 26 { |
| 23 KURL iconURL = parseStringAsURL(icon, exceptionState); | 27 KURL iconURL = parseStringAsURL(icon, exceptionState); |
| 24 if (exceptionState.hadException()) | 28 if (exceptionState.hadException()) |
| 25 return nullptr; | 29 return nullptr; |
| 26 return new PasswordCredential(id, password, name, iconURL); | 30 return new PasswordCredential(id, password, name, iconURL); |
| 27 } | 31 } |
| 28 | 32 |
| 29 PasswordCredential::PasswordCredential(WebPasswordCredential* webPasswordCredent
ial) | 33 PasswordCredential::PasswordCredential(WebPasswordCredential* webPasswordCredent
ial) |
| 30 : Credential(webPasswordCredential->platformCredential()) | 34 : Credential(webPasswordCredential->platformCredential()) |
| 31 { | 35 { |
| 32 } | 36 } |
| 33 | 37 |
| 34 PasswordCredential::PasswordCredential(const String& id, const String& password,
const String& name, const KURL& icon) | 38 PasswordCredential::PasswordCredential(const String& id, const String& password,
const String& name, const KURL& icon) |
| 35 : Credential(PlatformPasswordCredential::create(id, password, name, icon)) | 39 : Credential(PlatformPasswordCredential::create(id, password, name, icon)) |
| 36 , m_formData(DOMFormData::create()) | |
| 37 { | 40 { |
| 38 m_formData->append("username", id); | 41 } |
| 39 m_formData->append("password", password); | 42 |
| 43 DOMFormData* PasswordCredential::toFormData(ScriptState* scriptState, const Form
DataOptions& options) |
| 44 { |
| 45 DOMFormData* fd = DOMFormData::create(); |
| 46 |
| 47 String errorMessage; |
| 48 if (!scriptState->executionContext()->isPrivilegedContext(errorMessage)) |
| 49 return fd; |
| 50 |
| 51 fd->append(options.idName(), id()); |
| 52 fd->append(options.passwordName(), password()); |
| 53 fd->makeOpaque(); |
| 54 return fd; |
| 40 } | 55 } |
| 41 | 56 |
| 42 const String& PasswordCredential::password() const | 57 const String& PasswordCredential::password() const |
| 43 { | 58 { |
| 44 return static_cast<PlatformPasswordCredential*>(m_platformCredential.get())-
>password(); | 59 return static_cast<PlatformPasswordCredential*>(m_platformCredential.get())-
>password(); |
| 45 } | 60 } |
| 46 | 61 |
| 47 DEFINE_TRACE(PasswordCredential) | 62 DEFINE_TRACE(PasswordCredential) |
| 48 { | 63 { |
| 49 visitor->trace(m_formData); | |
| 50 Credential::trace(visitor); | 64 Credential::trace(visitor); |
| 51 } | 65 } |
| 52 | 66 |
| 53 } // namespace blink | 67 } // namespace blink |
| OLD | NEW |