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 "components/password_manager/content/renderer/credential_manager_client
.h" | 5 #include "components/password_manager/content/renderer/credential_manager_client
.h" |
6 | 6 |
7 #include "components/password_manager/content/common/credential_manager_messages
.h" | 7 #include "components/password_manager/content/common/credential_manager_messages
.h" |
8 #include "components/password_manager/content/common/credential_manager_types.h" | 8 #include "components/password_manager/content/common/credential_manager_types.h" |
9 #include "content/public/renderer/render_view.h" | 9 #include "content/public/renderer/render_view.h" |
10 #include "third_party/WebKit/public/platform/WebCredential.h" | 10 #include "third_party/WebKit/public/platform/WebCredential.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 bool CredentialManagerClient::OnMessageReceived(const IPC::Message& message) { | 49 bool CredentialManagerClient::OnMessageReceived(const IPC::Message& message) { |
50 bool handled = true; | 50 bool handled = true; |
51 IPC_BEGIN_MESSAGE_MAP(CredentialManagerClient, message) | 51 IPC_BEGIN_MESSAGE_MAP(CredentialManagerClient, message) |
52 IPC_MESSAGE_HANDLER(CredentialManagerMsg_AcknowledgeFailedSignIn, | 52 IPC_MESSAGE_HANDLER(CredentialManagerMsg_AcknowledgeFailedSignIn, |
53 OnAcknowledgeFailedSignIn) | 53 OnAcknowledgeFailedSignIn) |
54 IPC_MESSAGE_HANDLER(CredentialManagerMsg_AcknowledgeSignedIn, | 54 IPC_MESSAGE_HANDLER(CredentialManagerMsg_AcknowledgeSignedIn, |
55 OnAcknowledgeSignedIn) | 55 OnAcknowledgeSignedIn) |
56 IPC_MESSAGE_HANDLER(CredentialManagerMsg_AcknowledgeSignedOut, | 56 IPC_MESSAGE_HANDLER(CredentialManagerMsg_AcknowledgeSignedOut, |
57 OnAcknowledgeSignedOut) | 57 OnAcknowledgeSignedOut) |
58 IPC_MESSAGE_HANDLER(CredentialManagerMsg_SendCredential, OnSendCredential) | 58 IPC_MESSAGE_HANDLER(CredentialManagerMsg_SendCredential, OnSendCredential) |
| 59 IPC_MESSAGE_HANDLER(CredentialManagerMsg_RejectCredentialRequest, |
| 60 OnRejectCredentialRequest) |
59 IPC_MESSAGE_UNHANDLED(handled = false) | 61 IPC_MESSAGE_UNHANDLED(handled = false) |
60 IPC_END_MESSAGE_MAP() | 62 IPC_END_MESSAGE_MAP() |
61 return handled; | 63 return handled; |
62 } | 64 } |
63 | 65 |
64 void CredentialManagerClient::OnAcknowledgeFailedSignIn(int request_id) { | 66 void CredentialManagerClient::OnAcknowledgeFailedSignIn(int request_id) { |
65 RespondToNotificationCallback(request_id, &failed_sign_in_callbacks_); | 67 RespondToNotificationCallback(request_id, &failed_sign_in_callbacks_); |
66 } | 68 } |
67 | 69 |
68 void CredentialManagerClient::OnAcknowledgeSignedIn(int request_id) { | 70 void CredentialManagerClient::OnAcknowledgeSignedIn(int request_id) { |
69 RespondToNotificationCallback(request_id, &signed_in_callbacks_); | 71 RespondToNotificationCallback(request_id, &signed_in_callbacks_); |
70 } | 72 } |
71 | 73 |
72 void CredentialManagerClient::OnAcknowledgeSignedOut(int request_id) { | 74 void CredentialManagerClient::OnAcknowledgeSignedOut(int request_id) { |
73 RespondToNotificationCallback(request_id, &signed_out_callbacks_); | 75 RespondToNotificationCallback(request_id, &signed_out_callbacks_); |
74 } | 76 } |
75 | 77 |
76 void CredentialManagerClient::OnSendCredential(int request_id, | 78 void CredentialManagerClient::OnSendCredential(int request_id, |
77 const CredentialInfo& info) { | 79 const CredentialInfo& info) { |
78 RequestCallbacks* callbacks = request_callbacks_.Lookup(request_id); | 80 RequestCallbacks* callbacks = request_callbacks_.Lookup(request_id); |
79 DCHECK(callbacks); | 81 DCHECK(callbacks); |
80 // TODO(mkwst): Split into local/federated credentials. | 82 // TODO(mkwst): Split into local/federated credentials. |
81 blink::WebCredential credential(info.id, info.name, info.avatar); | 83 blink::WebCredential credential(info.id, info.name, info.avatar); |
82 callbacks->onSuccess(&credential); | 84 callbacks->onSuccess(&credential); |
83 request_callbacks_.Remove(request_id); | 85 request_callbacks_.Remove(request_id); |
84 } | 86 } |
85 | 87 |
| 88 void CredentialManagerClient::OnRejectCredentialRequest(int request_id) { |
| 89 RequestCallbacks* callbacks = request_callbacks_.Lookup(request_id); |
| 90 DCHECK(callbacks); |
| 91 // We don't expose an internal failure to the page directly; model it as |
| 92 // though no credentials were available. |
| 93 callbacks->onSuccess(nullptr); |
| 94 request_callbacks_.Remove(request_id); |
| 95 } |
| 96 |
86 // ----------------------------------------------------------------------------- | 97 // ----------------------------------------------------------------------------- |
87 // Dispatch messages from the renderer to the browser. | 98 // Dispatch messages from the renderer to the browser. |
88 | 99 |
89 void CredentialManagerClient::dispatchFailedSignIn( | 100 void CredentialManagerClient::dispatchFailedSignIn( |
90 const blink::WebCredential& credential, | 101 const blink::WebCredential& credential, |
91 blink::WebCredentialManagerClient::NotificationCallbacks* callbacks) { | 102 blink::WebCredentialManagerClient::NotificationCallbacks* callbacks) { |
92 int request_id = failed_sign_in_callbacks_.Add(callbacks); | 103 int request_id = failed_sign_in_callbacks_.Add(callbacks); |
93 CredentialInfo info( | 104 CredentialInfo info( |
94 credential.id(), credential.name(), credential.avatarURL()); | 105 credential.id(), credential.name(), credential.avatarURL()); |
95 Send(new CredentialManagerHostMsg_NotifyFailedSignIn( | 106 Send(new CredentialManagerHostMsg_NotifyFailedSignIn( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 int request_id, | 139 int request_id, |
129 CredentialManagerClient::NotificationCallbacksMap* map) { | 140 CredentialManagerClient::NotificationCallbacksMap* map) { |
130 blink::WebCredentialManagerClient::NotificationCallbacks* callbacks = | 141 blink::WebCredentialManagerClient::NotificationCallbacks* callbacks = |
131 map->Lookup(request_id); | 142 map->Lookup(request_id); |
132 DCHECK(callbacks); | 143 DCHECK(callbacks); |
133 callbacks->onSuccess(); | 144 callbacks->onSuccess(); |
134 map->Remove(request_id); | 145 map->Remove(request_id); |
135 } | 146 } |
136 | 147 |
137 } // namespace password_manager | 148 } // namespace password_manager |
OLD | NEW |