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 26 matching lines...) Expand all Loading... |
37 break; | 37 break; |
38 } | 38 } |
39 } | 39 } |
40 | 40 |
41 class NotificationCallbacks : public WebCredentialManagerClient::NotificationCal
lbacks { | 41 class NotificationCallbacks : public WebCredentialManagerClient::NotificationCal
lbacks { |
42 WTF_MAKE_NONCOPYABLE(NotificationCallbacks); | 42 WTF_MAKE_NONCOPYABLE(NotificationCallbacks); |
43 public: | 43 public: |
44 explicit NotificationCallbacks(PassRefPtr<ScriptPromiseResolver> resolver) :
m_resolver(resolver) { } | 44 explicit NotificationCallbacks(PassRefPtr<ScriptPromiseResolver> resolver) :
m_resolver(resolver) { } |
45 virtual ~NotificationCallbacks() { } | 45 virtual ~NotificationCallbacks() { } |
46 | 46 |
47 virtual void onSuccess() OVERRIDE | 47 virtual void onSuccess() override |
48 { | 48 { |
49 m_resolver->resolve(); | 49 m_resolver->resolve(); |
50 } | 50 } |
51 | 51 |
52 virtual void onError(WebCredentialManagerError* reason) OVERRIDE | 52 virtual void onError(WebCredentialManagerError* reason) override |
53 { | 53 { |
54 rejectDueToCredentialManagerError(m_resolver, reason); | 54 rejectDueToCredentialManagerError(m_resolver, reason); |
55 } | 55 } |
56 | 56 |
57 private: | 57 private: |
58 const RefPtr<ScriptPromiseResolver> m_resolver; | 58 const RefPtr<ScriptPromiseResolver> m_resolver; |
59 }; | 59 }; |
60 | 60 |
61 class RequestCallbacks : public WebCredentialManagerClient::RequestCallbacks { | 61 class RequestCallbacks : public WebCredentialManagerClient::RequestCallbacks { |
62 WTF_MAKE_NONCOPYABLE(RequestCallbacks); | 62 WTF_MAKE_NONCOPYABLE(RequestCallbacks); |
63 public: | 63 public: |
64 explicit RequestCallbacks(PassRefPtr<ScriptPromiseResolver> resolver) : m_re
solver(resolver) { } | 64 explicit RequestCallbacks(PassRefPtr<ScriptPromiseResolver> resolver) : m_re
solver(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->isLocalCredential() || credential->isFederatedCredent
ial()); |
75 if (credential->isLocalCredential()) | 75 if (credential->isLocalCredential()) |
76 m_resolver->resolve(LocalCredential::create(static_cast<WebLocalCred
ential*>(credential))); | 76 m_resolver->resolve(LocalCredential::create(static_cast<WebLocalCred
ential*>(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: |
87 const RefPtr<ScriptPromiseResolver> m_resolver; | 87 const RefPtr<ScriptPromiseResolver> m_resolver; |
88 }; | 88 }; |
89 | 89 |
90 | 90 |
91 CredentialsContainer* CredentialsContainer::create() | 91 CredentialsContainer* CredentialsContainer::create() |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip
tState); | 154 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip
tState); |
155 ScriptPromise promise = resolver->promise(); | 155 ScriptPromise promise = resolver->promise(); |
156 if (!checkBoilerplate(resolver)) | 156 if (!checkBoilerplate(resolver)) |
157 return promise; | 157 return promise; |
158 | 158 |
159 CredentialManagerClient::from(scriptState->executionContext())->dispatchSign
edOut(new NotificationCallbacks(resolver)); | 159 CredentialManagerClient::from(scriptState->executionContext())->dispatchSign
edOut(new NotificationCallbacks(resolver)); |
160 return promise; | 160 return promise; |
161 } | 161 } |
162 | 162 |
163 } // namespace blink | 163 } // namespace blink |
OLD | NEW |