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" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 101 |
102 static bool checkBoilerplate(ScriptPromiseResolver* resolver) | 102 static bool checkBoilerplate(ScriptPromiseResolver* resolver) |
103 { | 103 { |
104 CredentialManagerClient* client = CredentialManagerClient::from(resolver->sc
riptState()->executionContext()); | 104 CredentialManagerClient* client = CredentialManagerClient::from(resolver->sc
riptState()->executionContext()); |
105 if (!client) { | 105 if (!client) { |
106 resolver->reject(DOMException::create(InvalidStateError, "Could not esta
blish connection to the credential manager.")); | 106 resolver->reject(DOMException::create(InvalidStateError, "Could not esta
blish connection to the credential manager.")); |
107 return false; | 107 return false; |
108 } | 108 } |
109 | 109 |
110 String errorMessage; | 110 String errorMessage; |
111 if (!resolver->scriptState()->executionContext()->isPrivilegedContext(errorM
essage)) { | 111 if (!resolver->scriptState()->executionContext()->isSecureContext(errorMessa
ge)) { |
112 resolver->reject(DOMException::create(SecurityError, errorMessage)); | 112 resolver->reject(DOMException::create(SecurityError, errorMessage)); |
113 return false; | 113 return false; |
114 } | 114 } |
115 | 115 |
116 return true; | 116 return true; |
117 } | 117 } |
118 | 118 |
119 ScriptPromise CredentialsContainer::get(ScriptState* scriptState, const Credenti
alRequestOptions& options) | 119 ScriptPromise CredentialsContainer::get(ScriptState* scriptState, const Credenti
alRequestOptions& options) |
120 { | 120 { |
121 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 121 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
(...skipping 30 matching lines...) Expand all Loading... |
152 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 152 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
153 ScriptPromise promise = resolver->promise(); | 153 ScriptPromise promise = resolver->promise(); |
154 if (!checkBoilerplate(resolver)) | 154 if (!checkBoilerplate(resolver)) |
155 return promise; | 155 return promise; |
156 | 156 |
157 CredentialManagerClient::from(scriptState->executionContext())->dispatchRequ
ireUserMediation(new NotificationCallbacks(resolver)); | 157 CredentialManagerClient::from(scriptState->executionContext())->dispatchRequ
ireUserMediation(new NotificationCallbacks(resolver)); |
158 return promise; | 158 return promise; |
159 } | 159 } |
160 | 160 |
161 } // namespace blink | 161 } // namespace blink |
OLD | NEW |