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

Unified Diff: Source/modules/credentialmanager/CredentialsContainer.cpp

Issue 456293002: Credential manager: Introduce platform interface. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | public/platform/Platform.h » ('j') | public/platform/WebCredentialManager.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/credentialmanager/CredentialsContainer.cpp
diff --git a/Source/modules/credentialmanager/CredentialsContainer.cpp b/Source/modules/credentialmanager/CredentialsContainer.cpp
index 2d99b217bd655653874452fc07320a4fd7e2c457..4e17565ce071ff2178fe18bdb98df2390753d929 100644
--- a/Source/modules/credentialmanager/CredentialsContainer.cpp
+++ b/Source/modules/credentialmanager/CredentialsContainer.cpp
@@ -14,9 +14,68 @@
#include "modules/credentialmanager/Credential.h"
#include "platform/weborigin/SecurityOrigin.h"
#include "public/platform/Platform.h"
+#include "public/platform/WebCredential.h"
+#include "public/platform/WebCredentialManager.h"
+#include "public/platform/WebCredentialManagerError.h"
namespace blink {
+static void rejectDueToCredentialManagerError(PassRefPtr<ScriptPromiseResolver> resolver, WebCredentialManagerError* reason)
+{
+
+ switch (reason->errorType) {
+ case WebCredentialManagerError::DisabledErrorType:
+ resolver->reject(DOMException::create(InvalidStateError, "The credential manager is disabled."));
+ break;
+ case WebCredentialManagerError::UnknownErrorType:
+ resolver->reject(DOMException::create(NotReadableError, "An unknown error occured while talking to the credential manager."));
+ break;
tkent 2014/08/11 08:43:50 Will the break-then-ASSERT_NO_REACHED work well?
Mike West 2014/08/11 09:13:40 You're right, this is still prototypey-enough that
+ };
tkent 2014/08/11 08:43:50 ; is unnecessary.
Mike West 2014/08/11 09:13:40 Done.
+ ASSERT_NOT_REACHED();
+ resolver->reject(DOMException::create(InvalidStateError));
+}
+
+class NotificationCallbacks : public WebCredentialManager::NotificationCallbacks {
yhirano 2014/08/11 08:58:48 How about enclosing this class with an unnamed nam
+ WTF_MAKE_NONCOPYABLE(NotificationCallbacks);
+public:
+ explicit NotificationCallbacks(PassRefPtr<ScriptPromiseResolver> resolver) : m_resolver(resolver) { }
+ virtual ~NotificationCallbacks() { }
+
+ virtual void onSuccess() OVERRIDE
+ {
+ m_resolver->resolve();
+ }
+
+ virtual void onError(WebCredentialManagerError* reason) OVERRIDE
yhirano 2014/08/11 08:58:48 IIRC WebCallbacks handler parameter ownership is t
Mike West 2014/08/11 09:13:40 Hrm. My impression was that CallbackPromiseAdaptor
yhirano 2014/08/12 06:55:28 OK, I see.
+ {
+ rejectDueToCredentialManagerError(m_resolver, reason);
+ }
+
+private:
+ const RefPtr<ScriptPromiseResolver> m_resolver;
+};
+
+class RequestCallbacks : public WebCredentialManager::RequestCallbacks {
yhirano 2014/08/11 08:58:48 ditto
+ WTF_MAKE_NONCOPYABLE(RequestCallbacks);
+public:
+ explicit RequestCallbacks(PassRefPtr<ScriptPromiseResolver> resolver) : m_resolver(resolver) { }
+ virtual ~RequestCallbacks() { }
+
+ virtual void onSuccess(WebCredential* credential) OVERRIDE
yhirano 2014/08/11 08:58:48 ditto
+ {
+ m_resolver->resolve(Credential::create(credential->id(), credential->name(), credential->avatarURL()));
+ }
+
+ virtual void onError(WebCredentialManagerError* reason) OVERRIDE
yhirano 2014/08/11 08:58:48 ditto
+ {
+ rejectDueToCredentialManagerError(m_resolver, reason);
+ }
+
+private:
+ const RefPtr<ScriptPromiseResolver> m_resolver;
+};
+
+
CredentialsContainer* CredentialsContainer::create()
{
return new CredentialsContainer();
« no previous file with comments | « no previous file | public/platform/Platform.h » ('j') | public/platform/WebCredentialManager.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698