| 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/CredentialsContainer.h" | 6 #include "modules/credentialmanager/CredentialsContainer.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/Dictionary.h" | 8 #include "bindings/core/v8/Dictionary.h" |
| 9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
| 10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 11 #include "core/dom/DOMException.h" | 11 #include "core/dom/DOMException.h" |
| 12 #include "core/dom/ExceptionCode.h" | 12 #include "core/dom/ExceptionCode.h" |
| 13 #include "core/dom/ExecutionContext.h" | 13 #include "core/dom/ExecutionContext.h" |
| 14 #include "modules/credentialmanager/Credential.h" | 14 #include "modules/credentialmanager/Credential.h" |
| 15 #include "modules/credentialmanager/CredentialManagerClient.h" | 15 #include "modules/credentialmanager/CredentialManagerClient.h" |
| 16 #include "modules/credentialmanager/FederatedCredential.h" | 16 #include "modules/credentialmanager/FederatedCredential.h" |
| 17 #include "modules/credentialmanager/LocalCredential.h" | 17 #include "modules/credentialmanager/PasswordCredential.h" |
| 18 #include "platform/weborigin/SecurityOrigin.h" | 18 #include "platform/weborigin/SecurityOrigin.h" |
| 19 #include "public/platform/Platform.h" | 19 #include "public/platform/Platform.h" |
| 20 #include "public/platform/WebCredential.h" | 20 #include "public/platform/WebCredential.h" |
| 21 #include "public/platform/WebCredentialManagerClient.h" | 21 #include "public/platform/WebCredentialManagerClient.h" |
| 22 #include "public/platform/WebCredentialManagerError.h" | 22 #include "public/platform/WebCredentialManagerError.h" |
| 23 #include "public/platform/WebFederatedCredential.h" | 23 #include "public/platform/WebFederatedCredential.h" |
| 24 #include "public/platform/WebLocalCredential.h" | 24 #include "public/platform/WebPasswordCredential.h" |
| 25 | 25 |
| 26 namespace blink { | 26 namespace blink { |
| 27 | 27 |
| 28 static void rejectDueToCredentialManagerError(PassRefPtrWillBeRawPtr<ScriptPromi
seResolver> resolver, WebCredentialManagerError* reason) | 28 static void rejectDueToCredentialManagerError(PassRefPtrWillBeRawPtr<ScriptPromi
seResolver> resolver, WebCredentialManagerError* reason) |
| 29 { | 29 { |
| 30 switch (reason->errorType) { | 30 switch (reason->errorType) { |
| 31 case WebCredentialManagerError::ErrorTypeDisabled: | 31 case WebCredentialManagerError::ErrorTypeDisabled: |
| 32 resolver->reject(DOMException::create(InvalidStateError, "The credential
manager is disabled.")); | 32 resolver->reject(DOMException::create(InvalidStateError, "The credential
manager is disabled.")); |
| 33 break; | 33 break; |
| 34 case WebCredentialManagerError::ErrorTypeUnknown: | 34 case WebCredentialManagerError::ErrorTypeUnknown: |
| (...skipping 29 matching lines...) Expand all Loading... |
| 64 explicit RequestCallbacks(PassRefPtrWillBeRawPtr<ScriptPromiseResolver> reso
lver) : m_resolver(resolver) { } | 64 explicit RequestCallbacks(PassRefPtrWillBeRawPtr<ScriptPromiseResolver> reso
lver) : m_resolver(resolver) { } |
| 65 virtual ~RequestCallbacks() { } | 65 virtual ~RequestCallbacks() { } |
| 66 | 66 |
| 67 virtual void onSuccess(WebCredential* credential) override | 67 virtual void onSuccess(WebCredential* credential) override |
| 68 { | 68 { |
| 69 if (!credential) { | 69 if (!credential) { |
| 70 m_resolver->resolve(); | 70 m_resolver->resolve(); |
| 71 return; | 71 return; |
| 72 } | 72 } |
| 73 | 73 |
| 74 ASSERT(credential->isLocalCredential() || credential->isFederatedCredent
ial()); | 74 ASSERT(credential->isPasswordCredential() || credential->isFederatedCred
ential()); |
| 75 if (credential->isLocalCredential()) | 75 if (credential->isPasswordCredential()) |
| 76 m_resolver->resolve(LocalCredential::create(static_cast<WebLocalCred
ential*>(credential))); | 76 m_resolver->resolve(PasswordCredential::create(static_cast<WebPasswo
rdCredential*>(credential))); |
| 77 else | 77 else |
| 78 m_resolver->resolve(FederatedCredential::create(static_cast<WebFeder
atedCredential*>(credential))); | 78 m_resolver->resolve(FederatedCredential::create(static_cast<WebFeder
atedCredential*>(credential))); |
| 79 } | 79 } |
| 80 | 80 |
| 81 virtual void onError(WebCredentialManagerError* reason) override | 81 virtual void onError(WebCredentialManagerError* reason) override |
| 82 { | 82 { |
| 83 rejectDueToCredentialManagerError(m_resolver, reason); | 83 rejectDueToCredentialManagerError(m_resolver, reason); |
| 84 } | 84 } |
| 85 | 85 |
| 86 private: | 86 private: |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | 153 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); |
| 154 ScriptPromise promise = resolver->promise(); | 154 ScriptPromise promise = resolver->promise(); |
| 155 if (!checkBoilerplate(resolver)) | 155 if (!checkBoilerplate(resolver)) |
| 156 return promise; | 156 return promise; |
| 157 | 157 |
| 158 CredentialManagerClient::from(scriptState->executionContext())->dispatchSign
edOut(new NotificationCallbacks(resolver)); | 158 CredentialManagerClient::from(scriptState->executionContext())->dispatchSign
edOut(new NotificationCallbacks(resolver)); |
| 159 return promise; | 159 return promise; |
| 160 } | 160 } |
| 161 | 161 |
| 162 } // namespace blink | 162 } // namespace blink |
| OLD | NEW |