| 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/CredentialRequestOptions.h" |
| 16 #include "modules/credentialmanager/FederatedCredential.h" | 17 #include "modules/credentialmanager/FederatedCredential.h" |
| 18 #include "modules/credentialmanager/FederatedCredentialRequestOptions.h" |
| 17 #include "modules/credentialmanager/PasswordCredential.h" | 19 #include "modules/credentialmanager/PasswordCredential.h" |
| 18 #include "platform/weborigin/SecurityOrigin.h" | 20 #include "platform/weborigin/SecurityOrigin.h" |
| 19 #include "public/platform/Platform.h" | 21 #include "public/platform/Platform.h" |
| 20 #include "public/platform/WebCredential.h" | 22 #include "public/platform/WebCredential.h" |
| 21 #include "public/platform/WebCredentialManagerClient.h" | 23 #include "public/platform/WebCredentialManagerClient.h" |
| 22 #include "public/platform/WebCredentialManagerError.h" | 24 #include "public/platform/WebCredentialManagerError.h" |
| 23 #include "public/platform/WebFederatedCredential.h" | 25 #include "public/platform/WebFederatedCredential.h" |
| 24 #include "public/platform/WebPasswordCredential.h" | 26 #include "public/platform/WebPasswordCredential.h" |
| 25 | 27 |
| 26 namespace blink { | 28 namespace blink { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 109 |
| 108 String errorMessage; | 110 String errorMessage; |
| 109 if (!resolver->scriptState()->executionContext()->isPrivilegedContext(errorM
essage)) { | 111 if (!resolver->scriptState()->executionContext()->isPrivilegedContext(errorM
essage)) { |
| 110 resolver->reject(DOMException::create(SecurityError, errorMessage)); | 112 resolver->reject(DOMException::create(SecurityError, errorMessage)); |
| 111 return false; | 113 return false; |
| 112 } | 114 } |
| 113 | 115 |
| 114 return true; | 116 return true; |
| 115 } | 117 } |
| 116 | 118 |
| 117 ScriptPromise CredentialsContainer::request(ScriptState* scriptState, const Dict
ionary&) | 119 ScriptPromise CredentialsContainer::request(ScriptState* scriptState, const Cred
entialRequestOptions& options) |
| 118 { | 120 { |
| 119 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | 121 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); |
| 120 ScriptPromise promise = resolver->promise(); | 122 ScriptPromise promise = resolver->promise(); |
| 121 if (!checkBoilerplate(resolver)) | 123 if (!checkBoilerplate(resolver)) |
| 122 return promise; | 124 return promise; |
| 123 | 125 |
| 124 WebVector<WebURL> tempVector; | 126 Vector<KURL> providers; |
| 125 CredentialManagerClient::from(scriptState->executionContext())->dispatchRequ
est(false, tempVector, new RequestCallbacks(resolver)); | 127 if (options.hasFederated() && options.federated().hasProviders()) { |
| 128 for (const auto& string : options.federated().providers()) { |
| 129 KURL url = KURL(KURL(), string); |
| 130 if (url.isValid()) |
| 131 providers.append(url); |
| 132 } |
| 133 } |
| 134 |
| 135 CredentialManagerClient::from(scriptState->executionContext())->dispatchRequ
est(options.suppressUI(), providers, new RequestCallbacks(resolver)); |
| 126 return promise; | 136 return promise; |
| 127 } | 137 } |
| 128 | 138 |
| 129 ScriptPromise CredentialsContainer::notifySignedIn(ScriptState* scriptState, Cre
dential* credential) | 139 ScriptPromise CredentialsContainer::notifySignedIn(ScriptState* scriptState, Cre
dential* credential) |
| 130 { | 140 { |
| 131 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | 141 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); |
| 132 ScriptPromise promise = resolver->promise(); | 142 ScriptPromise promise = resolver->promise(); |
| 133 if (!checkBoilerplate(resolver)) | 143 if (!checkBoilerplate(resolver)) |
| 134 return promise; | 144 return promise; |
| 135 | 145 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 153 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | 163 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); |
| 154 ScriptPromise promise = resolver->promise(); | 164 ScriptPromise promise = resolver->promise(); |
| 155 if (!checkBoilerplate(resolver)) | 165 if (!checkBoilerplate(resolver)) |
| 156 return promise; | 166 return promise; |
| 157 | 167 |
| 158 CredentialManagerClient::from(scriptState->executionContext())->dispatchSign
edOut(new NotificationCallbacks(resolver)); | 168 CredentialManagerClient::from(scriptState->executionContext())->dispatchSign
edOut(new NotificationCallbacks(resolver)); |
| 159 return promise; | 169 return promise; |
| 160 } | 170 } |
| 161 | 171 |
| 162 } // namespace blink | 172 } // namespace blink |
| OLD | NEW |