Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Side by Side Diff: Source/modules/credentialmanager/CredentialsContainer.cpp

Issue 488993003: Credential Manager: Migrate to WebView client-based approach. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: feedback. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "platform/weborigin/SecurityOrigin.h" 15 #include "platform/weborigin/SecurityOrigin.h"
16 #include "public/platform/Platform.h" 16 #include "public/platform/Platform.h"
17 #include "public/platform/WebCredential.h" 17 #include "public/platform/WebCredential.h"
18 #include "public/platform/WebCredentialManager.h" 18 #include "public/platform/WebCredentialManagerClient.h"
19 #include "public/platform/WebCredentialManagerError.h" 19 #include "public/platform/WebCredentialManagerError.h"
20 20
21 namespace blink { 21 namespace blink {
22 22
23 static void rejectDueToCredentialManagerError(PassRefPtr<ScriptPromiseResolver> resolver, WebCredentialManagerError* reason) 23 static void rejectDueToCredentialManagerError(PassRefPtr<ScriptPromiseResolver> resolver, WebCredentialManagerError* reason)
24 { 24 {
25 25
26 switch (reason->errorType) { 26 switch (reason->errorType) {
27 case WebCredentialManagerError::ErrorTypeDisabled: 27 case WebCredentialManagerError::ErrorTypeDisabled:
28 resolver->reject(DOMException::create(InvalidStateError, "The credential manager is disabled.")); 28 resolver->reject(DOMException::create(InvalidStateError, "The credential manager is disabled."));
29 break; 29 break;
30 case WebCredentialManagerError::ErrorTypeUnknown: 30 case WebCredentialManagerError::ErrorTypeUnknown:
31 default: 31 default:
32 resolver->reject(DOMException::create(NotReadableError, "An unknown erro r occured while talking to the credential manager.")); 32 resolver->reject(DOMException::create(NotReadableError, "An unknown erro r occured while talking to the credential manager."));
33 break; 33 break;
34 } 34 }
35 } 35 }
36 36
37 class NotificationCallbacks : public WebCredentialManager::NotificationCallbacks { 37 class NotificationCallbacks : public WebCredentialManagerClient::NotificationCal lbacks {
38 WTF_MAKE_NONCOPYABLE(NotificationCallbacks); 38 WTF_MAKE_NONCOPYABLE(NotificationCallbacks);
39 public: 39 public:
40 explicit NotificationCallbacks(PassRefPtr<ScriptPromiseResolver> resolver) : m_resolver(resolver) { } 40 explicit NotificationCallbacks(PassRefPtr<ScriptPromiseResolver> resolver) : m_resolver(resolver) { }
41 virtual ~NotificationCallbacks() { } 41 virtual ~NotificationCallbacks() { }
42 42
43 virtual void onSuccess() OVERRIDE 43 virtual void onSuccess() OVERRIDE
44 { 44 {
45 m_resolver->resolve(); 45 m_resolver->resolve();
46 } 46 }
47 47
48 virtual void onError(WebCredentialManagerError* reason) OVERRIDE 48 virtual void onError(WebCredentialManagerError* reason) OVERRIDE
49 { 49 {
50 rejectDueToCredentialManagerError(m_resolver, reason); 50 rejectDueToCredentialManagerError(m_resolver, reason);
51 } 51 }
52 52
53 private: 53 private:
54 const RefPtr<ScriptPromiseResolver> m_resolver; 54 const RefPtr<ScriptPromiseResolver> m_resolver;
55 }; 55 };
56 56
57 class RequestCallbacks : public WebCredentialManager::RequestCallbacks { 57 class RequestCallbacks : public WebCredentialManagerClient::RequestCallbacks {
58 WTF_MAKE_NONCOPYABLE(RequestCallbacks); 58 WTF_MAKE_NONCOPYABLE(RequestCallbacks);
59 public: 59 public:
60 explicit RequestCallbacks(PassRefPtr<ScriptPromiseResolver> resolver) : m_re solver(resolver) { } 60 explicit RequestCallbacks(PassRefPtr<ScriptPromiseResolver> resolver) : m_re solver(resolver) { }
61 virtual ~RequestCallbacks() { } 61 virtual ~RequestCallbacks() { }
62 62
63 virtual void onSuccess(WebCredential* credential) OVERRIDE 63 virtual void onSuccess(WebCredential* credential) OVERRIDE
64 { 64 {
65 // FIXME: Split this into Local/Federated types. 65 // FIXME: Split this into Local/Federated types.
66 m_resolver->resolve(Credential::create(credential->id(), credential->nam e(), credential->avatarURL())); 66 m_resolver->resolve(Credential::create(credential->id(), credential->nam e(), credential->avatarURL()));
67 } 67 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 { 123 {
124 return stubImplementation(scriptState); 124 return stubImplementation(scriptState);
125 } 125 }
126 126
127 ScriptPromise CredentialsContainer::notifySignedOut(ScriptState* scriptState) 127 ScriptPromise CredentialsContainer::notifySignedOut(ScriptState* scriptState)
128 { 128 {
129 return stubImplementation(scriptState); 129 return stubImplementation(scriptState);
130 } 130 }
131 131
132 } // namespace blink 132 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/credentialmanager/CredentialManagerClient.cpp ('k') | Source/modules/modules.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698