| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> |
| 10 #include <utility> |
| 11 |
| 9 #include "components/password_manager/content/common/credential_manager_content_
utils.h" | 12 #include "components/password_manager/content/common/credential_manager_content_
utils.h" |
| 10 #include "components/password_manager/content/common/credential_manager_messages
.h" | 13 #include "components/password_manager/content/common/credential_manager_messages
.h" |
| 11 #include "components/password_manager/core/common/credential_manager_types.h" | 14 #include "components/password_manager/core/common/credential_manager_types.h" |
| 12 #include "content/public/renderer/render_view.h" | 15 #include "content/public/renderer/render_view.h" |
| 13 #include "third_party/WebKit/public/platform/WebCredential.h" | 16 #include "third_party/WebKit/public/platform/WebCredential.h" |
| 14 #include "third_party/WebKit/public/platform/WebCredentialManagerError.h" | 17 #include "third_party/WebKit/public/platform/WebCredentialManagerError.h" |
| 15 #include "third_party/WebKit/public/platform/WebFederatedCredential.h" | 18 #include "third_party/WebKit/public/platform/WebFederatedCredential.h" |
| 16 #include "third_party/WebKit/public/platform/WebPassOwnPtr.h" | |
| 17 #include "third_party/WebKit/public/platform/WebPasswordCredential.h" | 19 #include "third_party/WebKit/public/platform/WebPasswordCredential.h" |
| 18 #include "third_party/WebKit/public/web/WebView.h" | 20 #include "third_party/WebKit/public/web/WebView.h" |
| 19 | 21 |
| 20 namespace password_manager { | 22 namespace password_manager { |
| 21 | 23 |
| 22 namespace { | 24 namespace { |
| 23 | 25 |
| 24 template <typename T> | 26 template <typename T> |
| 25 void ClearCallbacksMapWithErrors(T* callbacks_map) { | 27 void ClearCallbacksMapWithErrors(T* callbacks_map) { |
| 26 typename T::iterator iter(callbacks_map); | 28 typename T::iterator iter(callbacks_map); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 71 |
| 70 void CredentialManagerClient::OnAcknowledgeRequireUserMediation( | 72 void CredentialManagerClient::OnAcknowledgeRequireUserMediation( |
| 71 int request_id) { | 73 int request_id) { |
| 72 RespondToNotificationCallback(request_id, &require_user_mediation_callbacks_); | 74 RespondToNotificationCallback(request_id, &require_user_mediation_callbacks_); |
| 73 } | 75 } |
| 74 | 76 |
| 75 void CredentialManagerClient::OnSendCredential(int request_id, | 77 void CredentialManagerClient::OnSendCredential(int request_id, |
| 76 const CredentialInfo& info) { | 78 const CredentialInfo& info) { |
| 77 RequestCallbacks* callbacks = get_callbacks_.Lookup(request_id); | 79 RequestCallbacks* callbacks = get_callbacks_.Lookup(request_id); |
| 78 DCHECK(callbacks); | 80 DCHECK(callbacks); |
| 79 std::unique_ptr<blink::WebCredential> credential = nullptr; | 81 std::unique_ptr<blink::WebCredential> credential; |
| 80 switch (info.type) { | 82 switch (info.type) { |
| 81 case CredentialType::CREDENTIAL_TYPE_FEDERATED: | 83 case CredentialType::CREDENTIAL_TYPE_FEDERATED: |
| 82 credential.reset(new blink::WebFederatedCredential( | 84 credential.reset(new blink::WebFederatedCredential( |
| 83 info.id, info.federation, info.name, info.icon)); | 85 info.id, info.federation, info.name, info.icon)); |
| 84 break; | 86 break; |
| 85 case CredentialType::CREDENTIAL_TYPE_PASSWORD: | 87 case CredentialType::CREDENTIAL_TYPE_PASSWORD: |
| 86 credential.reset(new blink::WebPasswordCredential( | 88 credential.reset(new blink::WebPasswordCredential( |
| 87 info.id, info.password, info.name, info.icon)); | 89 info.id, info.password, info.name, info.icon)); |
| 88 break; | 90 break; |
| 89 case CredentialType::CREDENTIAL_TYPE_EMPTY: | 91 case CredentialType::CREDENTIAL_TYPE_EMPTY: |
| 90 // Intentionally empty; we'll send nullptr to the onSuccess call below. | 92 // Intentionally empty; we'll send nullptr to the onSuccess call below. |
| 91 break; | 93 break; |
| 92 } | 94 } |
| 93 callbacks->onSuccess(adoptWebPtr(credential.release())); | 95 callbacks->onSuccess(std::move(credential)); |
| 94 get_callbacks_.Remove(request_id); | 96 get_callbacks_.Remove(request_id); |
| 95 } | 97 } |
| 96 | 98 |
| 97 void CredentialManagerClient::OnRejectCredentialRequest( | 99 void CredentialManagerClient::OnRejectCredentialRequest( |
| 98 int request_id, | 100 int request_id, |
| 99 blink::WebCredentialManagerError error) { | 101 blink::WebCredentialManagerError error) { |
| 100 RequestCallbacks* callbacks = get_callbacks_.Lookup(request_id); | 102 RequestCallbacks* callbacks = get_callbacks_.Lookup(request_id); |
| 101 DCHECK(callbacks); | 103 DCHECK(callbacks); |
| 102 callbacks->onError(error); | 104 callbacks->onError(error); |
| 103 get_callbacks_.Remove(request_id); | 105 get_callbacks_.Remove(request_id); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 int request_id, | 141 int request_id, |
| 140 CredentialManagerClient::NotificationCallbacksMap* map) { | 142 CredentialManagerClient::NotificationCallbacksMap* map) { |
| 141 blink::WebCredentialManagerClient::NotificationCallbacks* callbacks = | 143 blink::WebCredentialManagerClient::NotificationCallbacks* callbacks = |
| 142 map->Lookup(request_id); | 144 map->Lookup(request_id); |
| 143 DCHECK(callbacks); | 145 DCHECK(callbacks); |
| 144 callbacks->onSuccess(); | 146 callbacks->onSuccess(); |
| 145 map->Remove(request_id); | 147 map->Remove(request_id); |
| 146 } | 148 } |
| 147 | 149 |
| 148 } // namespace password_manager | 150 } // namespace password_manager |
| OLD | NEW |