| 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_content_
utils.h" | 7 #include "components/password_manager/content/common/credential_manager_content_
utils.h" |
| 8 #include "components/password_manager/content/common/credential_manager_messages
.h" | 8 #include "components/password_manager/content/common/credential_manager_messages
.h" |
| 9 #include "components/password_manager/core/common/credential_manager_types.h" | 9 #include "components/password_manager/core/common/credential_manager_types.h" |
| 10 #include "content/public/renderer/render_view.h" | 10 #include "content/public/renderer/render_view.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 ClearCallbacksMapWithErrors(&require_user_mediation_callbacks_); | 44 ClearCallbacksMapWithErrors(&require_user_mediation_callbacks_); |
| 45 ClearCallbacksMapWithErrors(&request_callbacks_); | 45 ClearCallbacksMapWithErrors(&request_callbacks_); |
| 46 } | 46 } |
| 47 | 47 |
| 48 // ----------------------------------------------------------------------------- | 48 // ----------------------------------------------------------------------------- |
| 49 // Handle messages from the browser. | 49 // Handle messages from the browser. |
| 50 | 50 |
| 51 bool CredentialManagerClient::OnMessageReceived(const IPC::Message& message) { | 51 bool CredentialManagerClient::OnMessageReceived(const IPC::Message& message) { |
| 52 bool handled = true; | 52 bool handled = true; |
| 53 IPC_BEGIN_MESSAGE_MAP(CredentialManagerClient, message) | 53 IPC_BEGIN_MESSAGE_MAP(CredentialManagerClient, message) |
| 54 IPC_MESSAGE_HANDLER(CredentialManagerMsg_AcknowledgeFailedSignIn, | |
| 55 OnAcknowledgeFailedSignIn) | |
| 56 IPC_MESSAGE_HANDLER(CredentialManagerMsg_AcknowledgeSignedIn, | 54 IPC_MESSAGE_HANDLER(CredentialManagerMsg_AcknowledgeSignedIn, |
| 57 OnAcknowledgeSignedIn) | 55 OnAcknowledgeSignedIn) |
| 58 IPC_MESSAGE_HANDLER(CredentialManagerMsg_AcknowledgeRequireUserMediation, | 56 IPC_MESSAGE_HANDLER(CredentialManagerMsg_AcknowledgeRequireUserMediation, |
| 59 OnAcknowledgeRequireUserMediation) | 57 OnAcknowledgeRequireUserMediation) |
| 60 IPC_MESSAGE_HANDLER(CredentialManagerMsg_SendCredential, OnSendCredential) | 58 IPC_MESSAGE_HANDLER(CredentialManagerMsg_SendCredential, OnSendCredential) |
| 61 IPC_MESSAGE_HANDLER(CredentialManagerMsg_RejectCredentialRequest, | 59 IPC_MESSAGE_HANDLER(CredentialManagerMsg_RejectCredentialRequest, |
| 62 OnRejectCredentialRequest) | 60 OnRejectCredentialRequest) |
| 63 IPC_MESSAGE_UNHANDLED(handled = false) | 61 IPC_MESSAGE_UNHANDLED(handled = false) |
| 64 IPC_END_MESSAGE_MAP() | 62 IPC_END_MESSAGE_MAP() |
| 65 return handled; | 63 return handled; |
| 66 } | 64 } |
| 67 | 65 |
| 68 void CredentialManagerClient::OnAcknowledgeFailedSignIn(int request_id) { | |
| 69 RespondToNotificationCallback(request_id, &failed_sign_in_callbacks_); | |
| 70 } | |
| 71 | |
| 72 void CredentialManagerClient::OnAcknowledgeSignedIn(int request_id) { | 66 void CredentialManagerClient::OnAcknowledgeSignedIn(int request_id) { |
| 73 RespondToNotificationCallback(request_id, &signed_in_callbacks_); | 67 RespondToNotificationCallback(request_id, &signed_in_callbacks_); |
| 74 } | 68 } |
| 75 | 69 |
| 76 void CredentialManagerClient::OnAcknowledgeRequireUserMediation( | 70 void CredentialManagerClient::OnAcknowledgeRequireUserMediation( |
| 77 int request_id) { | 71 int request_id) { |
| 78 RespondToNotificationCallback(request_id, &require_user_mediation_callbacks_); | 72 RespondToNotificationCallback(request_id, &require_user_mediation_callbacks_); |
| 79 } | 73 } |
| 80 | 74 |
| 81 void CredentialManagerClient::OnSendCredential(int request_id, | 75 void CredentialManagerClient::OnSendCredential(int request_id, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 107 DCHECK(callbacks); | 101 DCHECK(callbacks); |
| 108 scoped_ptr<blink::WebCredentialManagerError> error( | 102 scoped_ptr<blink::WebCredentialManagerError> error( |
| 109 new blink::WebCredentialManagerError(error_type)); | 103 new blink::WebCredentialManagerError(error_type)); |
| 110 callbacks->onError(error.get()); | 104 callbacks->onError(error.get()); |
| 111 request_callbacks_.Remove(request_id); | 105 request_callbacks_.Remove(request_id); |
| 112 } | 106 } |
| 113 | 107 |
| 114 // ----------------------------------------------------------------------------- | 108 // ----------------------------------------------------------------------------- |
| 115 // Dispatch messages from the renderer to the browser. | 109 // Dispatch messages from the renderer to the browser. |
| 116 | 110 |
| 117 void CredentialManagerClient::dispatchFailedSignIn( | |
| 118 const blink::WebCredential& credential, | |
| 119 blink::WebCredentialManagerClient::NotificationCallbacks* callbacks) { | |
| 120 int request_id = failed_sign_in_callbacks_.Add(callbacks); | |
| 121 CredentialInfo info(WebCredentialToCredentialInfo(credential)); | |
| 122 Send(new CredentialManagerHostMsg_NotifyFailedSignIn( | |
| 123 routing_id(), request_id, info)); | |
| 124 } | |
| 125 | |
| 126 void CredentialManagerClient::dispatchSignedIn( | 111 void CredentialManagerClient::dispatchSignedIn( |
| 127 const blink::WebCredential& credential, | 112 const blink::WebCredential& credential, |
| 128 blink::WebCredentialManagerClient::NotificationCallbacks* callbacks) { | 113 blink::WebCredentialManagerClient::NotificationCallbacks* callbacks) { |
| 129 int request_id = signed_in_callbacks_.Add(callbacks); | 114 int request_id = signed_in_callbacks_.Add(callbacks); |
| 130 CredentialInfo info(WebCredentialToCredentialInfo(credential)); | 115 CredentialInfo info(WebCredentialToCredentialInfo(credential)); |
| 131 Send(new CredentialManagerHostMsg_NotifySignedIn( | 116 Send(new CredentialManagerHostMsg_NotifySignedIn( |
| 132 routing_id(), request_id, info)); | 117 routing_id(), request_id, info)); |
| 133 } | 118 } |
| 134 | 119 |
| 135 void CredentialManagerClient::dispatchRequireUserMediation( | 120 void CredentialManagerClient::dispatchRequireUserMediation( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 155 int request_id, | 140 int request_id, |
| 156 CredentialManagerClient::NotificationCallbacksMap* map) { | 141 CredentialManagerClient::NotificationCallbacksMap* map) { |
| 157 blink::WebCredentialManagerClient::NotificationCallbacks* callbacks = | 142 blink::WebCredentialManagerClient::NotificationCallbacks* callbacks = |
| 158 map->Lookup(request_id); | 143 map->Lookup(request_id); |
| 159 DCHECK(callbacks); | 144 DCHECK(callbacks); |
| 160 callbacks->onSuccess(); | 145 callbacks->onSuccess(); |
| 161 map->Remove(request_id); | 146 map->Remove(request_id); |
| 162 } | 147 } |
| 163 | 148 |
| 164 } // namespace password_manager | 149 } // namespace password_manager |
| OLD | NEW |