#include "content/public/renderer/render_view.h"
#include "third_party/WebKit/public/platform/WebCredential.h"
#include "third_party/WebKit/public/platform/WebCredentialManagerError.h"
+#include "third_party/WebKit/public/platform/WebFederatedCredential.h"
+#include "third_party/WebKit/public/platform/WebLocalCredential.h"
#include "third_party/WebKit/public/web/WebView.h"
namespace password_manager {
typename T::iterator iter(callbacks_map);
while (!iter.IsAtEnd()) {
blink::WebCredentialManagerError reason(
- blink::WebCredentialManagerError::ErrorTypeUnknown,
- "An unknown error occurred.");
+ blink::WebCredentialManagerError::ErrorTypeUnknown);
iter.GetCurrentValue()->onError(&reason);
callbacks_map->Remove(iter.GetCurrentKey());
iter.Advance();
IPC_MESSAGE_HANDLER(CredentialManagerMsg_AcknowledgeSignedOut,
OnAcknowledgeSignedOut)
IPC_MESSAGE_HANDLER(CredentialManagerMsg_SendCredential, OnSendCredential)
+ IPC_MESSAGE_HANDLER(CredentialManagerMsg_RejectCredentialRequest,
+ OnRejectCredentialRequest)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
const CredentialInfo& info) {
RequestCallbacks* callbacks = request_callbacks_.Lookup(request_id);
DCHECK(callbacks);
- // TODO(mkwst): Split into local/federated credentials.
- blink::WebCredential credential(info.id, info.name, info.avatar);
- callbacks->onSuccess(&credential);
+ scoped_ptr<blink::WebCredential> credential = nullptr;
+ switch (info.type) {
+ case CREDENTIAL_TYPE_FEDERATED:
+ credential.reset(new blink::WebFederatedCredential(
+ info.id, info.name, info.avatar, info.federation));
+ break;
+ case CREDENTIAL_TYPE_LOCAL:
+ credential.reset(new blink::WebLocalCredential(info.id, info.name,
+ info.avatar, info.password));
+ break;
+ case CREDENTIAL_TYPE_EMPTY:
+ // Intentionally empty; we'll send nullptr to the onSuccess call below.
+ break;
+ }
+ callbacks->onSuccess(credential.get());
+ request_callbacks_.Remove(request_id);
+}
+
+void CredentialManagerClient::OnRejectCredentialRequest(
+ int request_id,
+ blink::WebCredentialManagerError::ErrorType error_type) {
+ RequestCallbacks* callbacks = request_callbacks_.Lookup(request_id);
+ DCHECK(callbacks);
+ scoped_ptr<blink::WebCredentialManagerError> error(
+ new blink::WebCredentialManagerError(error_type));
+ callbacks->onError(error.get());
request_callbacks_.Remove(request_id);
}
const blink::WebCredential& credential,
blink::WebCredentialManagerClient::NotificationCallbacks* callbacks) {
int request_id = failed_sign_in_callbacks_.Add(callbacks);
- CredentialInfo info(
- credential.id(), credential.name(), credential.avatarURL());
+ CredentialInfo info(credential);
Send(new CredentialManagerHostMsg_NotifyFailedSignIn(
routing_id(), request_id, info));
}
const blink::WebCredential& credential,
blink::WebCredentialManagerClient::NotificationCallbacks* callbacks) {
int request_id = signed_in_callbacks_.Add(callbacks);
- CredentialInfo info(
- credential.id(), credential.name(), credential.avatarURL());
+ CredentialInfo info(credential);
Send(new CredentialManagerHostMsg_NotifySignedIn(
routing_id(), request_id, info));
}