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/CredentialsContainer.h" | 5 #include "modules/credentialmanager/CredentialsContainer.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 | 82 |
83 class RequestCallbacks : public WebCredentialManagerClient::RequestCallbacks { | 83 class RequestCallbacks : public WebCredentialManagerClient::RequestCallbacks { |
84 WTF_MAKE_NONCOPYABLE(RequestCallbacks); | 84 WTF_MAKE_NONCOPYABLE(RequestCallbacks); |
85 | 85 |
86 public: | 86 public: |
87 explicit RequestCallbacks(ScriptPromiseResolver* resolver) | 87 explicit RequestCallbacks(ScriptPromiseResolver* resolver) |
88 : resolver_(resolver) {} | 88 : resolver_(resolver) {} |
89 ~RequestCallbacks() override {} | 89 ~RequestCallbacks() override {} |
90 | 90 |
91 void OnSuccess(std::unique_ptr<WebCredential> web_credential) override { | 91 void OnSuccess(std::unique_ptr<WebCredential> web_credential) override { |
92 Frame* frame = | 92 ExecutionContext* context = |
93 ToDocument(ExecutionContext::From(resolver_->GetScriptState())) | 93 ExecutionContext::From(resolver_->GetScriptState()); |
94 ->GetFrame(); | 94 if (!context) |
95 return; | |
Mike West
2017/05/03 07:54:31
I think we need to call `resolver_->Clear()` in th
vasilii
2017/05/03 09:05:19
there is no such a method.
| |
96 Frame* frame = ToDocument(context)->GetFrame(); | |
95 SECURITY_CHECK(!frame || frame == frame->Tree().Top()); | 97 SECURITY_CHECK(!frame || frame == frame->Tree().Top()); |
96 | 98 |
97 std::unique_ptr<WebCredential> credential = | 99 std::unique_ptr<WebCredential> credential = |
98 WTF::WrapUnique(web_credential.release()); | 100 WTF::WrapUnique(web_credential.release()); |
99 if (!credential || !frame) { | 101 if (!credential || !frame) { |
100 resolver_->Resolve(); | 102 resolver_->Resolve(); |
101 return; | 103 return; |
102 } | 104 } |
103 | 105 |
104 ASSERT(credential->IsPasswordCredential() || | 106 ASSERT(credential->IsPasswordCredential() || |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
212 ScriptPromise promise = resolver->Promise(); | 214 ScriptPromise promise = resolver->Promise(); |
213 if (!CheckBoilerplate(resolver)) | 215 if (!CheckBoilerplate(resolver)) |
214 return promise; | 216 return promise; |
215 | 217 |
216 CredentialManagerClient::From(ExecutionContext::From(script_state)) | 218 CredentialManagerClient::From(ExecutionContext::From(script_state)) |
217 ->DispatchRequireUserMediation(new NotificationCallbacks(resolver)); | 219 ->DispatchRequireUserMediation(new NotificationCallbacks(resolver)); |
218 return promise; | 220 return promise; |
219 } | 221 } |
220 | 222 |
221 } // namespace blink | 223 } // namespace blink |
OLD | NEW |