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" |
11 #include "third_party/WebKit/public/platform/WebCredentialManagerError.h" | 11 #include "third_party/WebKit/public/platform/WebCredentialManagerError.h" |
| 12 #include "third_party/WebKit/public/platform/WebFederatedCredential.h" |
| 13 #include "third_party/WebKit/public/platform/WebLocalCredential.h" |
12 #include "third_party/WebKit/public/web/WebView.h" | 14 #include "third_party/WebKit/public/web/WebView.h" |
13 | 15 |
14 namespace password_manager { | 16 namespace password_manager { |
15 | 17 |
16 namespace { | 18 namespace { |
17 | 19 |
18 template <typename T> | 20 template <typename T> |
19 void ClearCallbacksMapWithErrors(T* callbacks_map) { | 21 void ClearCallbacksMapWithErrors(T* callbacks_map) { |
20 typename T::iterator iter(callbacks_map); | 22 typename T::iterator iter(callbacks_map); |
21 while (!iter.IsAtEnd()) { | 23 while (!iter.IsAtEnd()) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 } | 73 } |
72 | 74 |
73 void CredentialManagerClient::OnAcknowledgeSignedOut(int request_id) { | 75 void CredentialManagerClient::OnAcknowledgeSignedOut(int request_id) { |
74 RespondToNotificationCallback(request_id, &signed_out_callbacks_); | 76 RespondToNotificationCallback(request_id, &signed_out_callbacks_); |
75 } | 77 } |
76 | 78 |
77 void CredentialManagerClient::OnSendCredential(int request_id, | 79 void CredentialManagerClient::OnSendCredential(int request_id, |
78 const CredentialInfo& info) { | 80 const CredentialInfo& info) { |
79 RequestCallbacks* callbacks = request_callbacks_.Lookup(request_id); | 81 RequestCallbacks* callbacks = request_callbacks_.Lookup(request_id); |
80 DCHECK(callbacks); | 82 DCHECK(callbacks); |
81 // TODO(mkwst): Split into local/federated credentials. | 83 scoped_ptr<blink::WebCredential> credential; |
82 blink::WebCredential credential(info.id, info.name, info.avatar); | 84 switch (info.type) { |
83 callbacks->onSuccess(&credential); | 85 case CREDENTIAL_TYPE_FEDERATED: |
| 86 credential.reset(new blink::WebFederatedCredential( |
| 87 info.id, info.name, info.avatar, info.federation)); |
| 88 break; |
| 89 case CREDENTIAL_TYPE_LOCAL: |
| 90 credential.reset(new blink::WebLocalCredential(info.id, info.name, |
| 91 info.avatar, info.password)); |
| 92 break; |
| 93 case CREDENTIAL_TYPE_UNKNOWN: |
| 94 NOTREACHED(); |
| 95 break; |
| 96 } |
| 97 callbacks->onSuccess(credential.get()); |
84 request_callbacks_.Remove(request_id); | 98 request_callbacks_.Remove(request_id); |
85 } | 99 } |
86 | 100 |
87 void CredentialManagerClient::OnRejectCredentialRequest(int request_id) { | 101 void CredentialManagerClient::OnRejectCredentialRequest(int request_id) { |
88 RequestCallbacks* callbacks = request_callbacks_.Lookup(request_id); | 102 RequestCallbacks* callbacks = request_callbacks_.Lookup(request_id); |
89 DCHECK(callbacks); | 103 DCHECK(callbacks); |
90 // We don't expose an internal failure to the page directly; model it as | 104 // We don't expose an internal failure to the page directly; model it as |
91 // though no credentials were available. | 105 // though no credentials were available. |
92 callbacks->onSuccess(nullptr); | 106 callbacks->onSuccess(nullptr); |
93 request_callbacks_.Remove(request_id); | 107 request_callbacks_.Remove(request_id); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 int request_id, | 152 int request_id, |
139 CredentialManagerClient::NotificationCallbacksMap* map) { | 153 CredentialManagerClient::NotificationCallbacksMap* map) { |
140 blink::WebCredentialManagerClient::NotificationCallbacks* callbacks = | 154 blink::WebCredentialManagerClient::NotificationCallbacks* callbacks = |
141 map->Lookup(request_id); | 155 map->Lookup(request_id); |
142 DCHECK(callbacks); | 156 DCHECK(callbacks); |
143 callbacks->onSuccess(); | 157 callbacks->onSuccess(); |
144 map->Remove(request_id); | 158 map->Remove(request_id); |
145 } | 159 } |
146 | 160 |
147 } // namespace password_manager | 161 } // namespace password_manager |
OLD | NEW |