| 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/dom/ExecutionContext.h" | 9 #include "core/dom/ExecutionContext.h" |
| 10 #include "core/dom/URLSearchParams.h" | 10 #include "core/dom/URLSearchParams.h" |
| 11 #include "core/html/FormData.h" | 11 #include "core/html/FormData.h" |
| 12 #include "modules/credentialmanager/FormDataOptions.h" | 12 #include "modules/credentialmanager/FormDataOptions.h" |
| 13 #include "modules/credentialmanager/PasswordCredentialData.h" | 13 #include "modules/credentialmanager/PasswordCredentialData.h" |
| 14 #include "platform/credentialmanager/PlatformPasswordCredential.h" | 14 #include "platform/credentialmanager/PlatformPasswordCredential.h" |
| 15 #include "platform/weborigin/SecurityOrigin.h" | 15 #include "platform/weborigin/SecurityOrigin.h" |
| 16 #include "public/platform/WebCredential.h" | 16 #include "public/platform/WebCredential.h" |
| 17 #include "public/platform/WebPasswordCredential.h" | 17 #include "public/platform/WebPasswordCredential.h" |
| 18 | 18 |
| 19 namespace blink { | 19 namespace blink { |
| 20 | 20 |
| 21 PasswordCredential* PasswordCredential::create(WebPasswordCredential* webPasswor
dCredential) | 21 PasswordCredential* PasswordCredential::create(WebPasswordCredential* webPasswor
dCredential) |
| 22 { | 22 { |
| 23 return new PasswordCredential(webPasswordCredential); | 23 return new PasswordCredential(webPasswordCredential); |
| 24 } | 24 } |
| 25 | 25 |
| 26 PasswordCredential* PasswordCredential::create(const PasswordCredentialData& dat
a, ExceptionState& exceptionState) | 26 PasswordCredential* PasswordCredential::create(const PasswordCredentialData& dat
a, ExceptionState& exceptionState) |
| 27 { | 27 { |
| 28 if (data.id().isEmpty()) { |
| 29 exceptionState.throwTypeError("'id' must not be empty."); |
| 30 return nullptr; |
| 31 } |
| 32 if (data.password().isEmpty()) { |
| 33 exceptionState.throwTypeError("'password' must not be empty."); |
| 34 return nullptr; |
| 35 } |
| 36 |
| 28 KURL iconURL = parseStringAsURL(data.iconURL(), exceptionState); | 37 KURL iconURL = parseStringAsURL(data.iconURL(), exceptionState); |
| 29 if (exceptionState.hadException()) | 38 if (exceptionState.hadException()) |
| 30 return nullptr; | 39 return nullptr; |
| 40 |
| 31 return new PasswordCredential(data.id(), data.password(), data.name(), iconU
RL); | 41 return new PasswordCredential(data.id(), data.password(), data.name(), iconU
RL); |
| 32 } | 42 } |
| 33 | 43 |
| 34 PasswordCredential::PasswordCredential(WebPasswordCredential* webPasswordCredent
ial) | 44 PasswordCredential::PasswordCredential(WebPasswordCredential* webPasswordCredent
ial) |
| 35 : Credential(webPasswordCredential->platformCredential()) | 45 : Credential(webPasswordCredential->platformCredential()) |
| 36 , m_idName("username") | 46 , m_idName("username") |
| 37 , m_passwordName("password") | 47 , m_passwordName("password") |
| 38 { | 48 { |
| 39 } | 49 } |
| 40 | 50 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 return static_cast<PlatformPasswordCredential*>(m_platformCredential.get())-
>password(); | 102 return static_cast<PlatformPasswordCredential*>(m_platformCredential.get())-
>password(); |
| 93 } | 103 } |
| 94 | 104 |
| 95 DEFINE_TRACE(PasswordCredential) | 105 DEFINE_TRACE(PasswordCredential) |
| 96 { | 106 { |
| 97 Credential::trace(visitor); | 107 Credential::trace(visitor); |
| 98 visitor->trace(m_additionalData); | 108 visitor->trace(m_additionalData); |
| 99 } | 109 } |
| 100 | 110 |
| 101 } // namespace blink | 111 } // namespace blink |
| OLD | NEW |