| 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/browser/credential_manager_impl.h" | 5 #include "components/password_manager/content/browser/credential_manager_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/metrics/user_metrics.h" | 10 #include "base/metrics/user_metrics.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 std::move(form_manager_), CredentialSourceType::CREDENTIAL_SOURCE_API, | 111 std::move(form_manager_), CredentialSourceType::CREDENTIAL_SOURCE_API, |
| 112 false); | 112 false); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void CredentialManagerImpl::RequireUserMediation( | 115 void CredentialManagerImpl::RequireUserMediation( |
| 116 const RequireUserMediationCallback& callback) { | 116 const RequireUserMediationCallback& callback) { |
| 117 if (password_manager_util::IsLoggingActive(client_)) { | 117 if (password_manager_util::IsLoggingActive(client_)) { |
| 118 CredentialManagerLogger(client_->GetLogManager()) | 118 CredentialManagerLogger(client_->GetLogManager()) |
| 119 .LogRequireUserMediation(web_contents()->GetLastCommittedURL()); | 119 .LogRequireUserMediation(web_contents()->GetLastCommittedURL()); |
| 120 } | 120 } |
| 121 // Send acknowledge response back. |
| 122 callback.Run(); |
| 123 |
| 121 PasswordStore* store = GetPasswordStore(); | 124 PasswordStore* store = GetPasswordStore(); |
| 122 if (!store || !client_->IsSavingAndFillingEnabledForCurrentPage() || | 125 if (!store || !client_->IsSavingAndFillingEnabledForCurrentPage() || |
| 123 !client_->OnCredentialManagerUsed()) { | 126 !client_->OnCredentialManagerUsed()) |
| 124 callback.Run(); | |
| 125 return; | 127 return; |
| 126 } | |
| 127 | 128 |
| 128 if (store->affiliated_match_helper()) { | |
| 129 store->affiliated_match_helper()->GetAffiliatedAndroidRealms( | |
| 130 GetSynthesizedFormForOrigin(), | |
| 131 base::Bind(&CredentialManagerImpl::ScheduleRequireMediationTask, | |
| 132 weak_factory_.GetWeakPtr(), callback)); | |
| 133 } else { | |
| 134 std::vector<std::string> no_affiliated_realms; | |
| 135 ScheduleRequireMediationTask(callback, no_affiliated_realms); | |
| 136 } | |
| 137 } | |
| 138 | |
| 139 void CredentialManagerImpl::ScheduleRequireMediationTask( | |
| 140 const RequireUserMediationCallback& callback, | |
| 141 const std::vector<std::string>& android_realms) { | |
| 142 DCHECK(GetPasswordStore()); | |
| 143 if (!pending_require_user_mediation_) { | 129 if (!pending_require_user_mediation_) { |
| 144 pending_require_user_mediation_.reset( | 130 pending_require_user_mediation_.reset( |
| 145 new CredentialManagerPendingRequireUserMediationTask( | 131 new CredentialManagerPendingRequireUserMediationTask(this)); |
| 146 this, web_contents()->GetLastCommittedURL().GetOrigin(), | |
| 147 android_realms)); | |
| 148 | |
| 149 // This will result in a callback to | |
| 150 // CredentialManagerPendingRequireUserMediationTask:: | |
| 151 // OnGetPasswordStoreResults(). | |
| 152 GetPasswordStore()->GetAutofillableLogins( | |
| 153 pending_require_user_mediation_.get()); | |
| 154 } else { | |
| 155 pending_require_user_mediation_->AddOrigin( | |
| 156 web_contents()->GetLastCommittedURL().GetOrigin()); | |
| 157 } | 132 } |
| 158 | 133 pending_require_user_mediation_->AddOrigin(GetSynthesizedFormForOrigin()); |
| 159 // Send acknowledge response back. | |
| 160 callback.Run(); | |
| 161 } | 134 } |
| 162 | 135 |
| 163 void CredentialManagerImpl::Get(bool zero_click_only, | 136 void CredentialManagerImpl::Get(bool zero_click_only, |
| 164 bool include_passwords, | 137 bool include_passwords, |
| 165 const std::vector<GURL>& federations, | 138 const std::vector<GURL>& federations, |
| 166 const GetCallback& callback) { | 139 const GetCallback& callback) { |
| 167 using metrics_util::LogCredentialManagerGetResult; | 140 using metrics_util::LogCredentialManagerGetResult; |
| 168 metrics_util::CredentialManagerGetMediation mediation_status = | 141 metrics_util::CredentialManagerGetMediation mediation_status = |
| 169 zero_click_only ? metrics_util::CREDENTIAL_MANAGER_GET_UNMEDIATED | 142 zero_click_only ? metrics_util::CREDENTIAL_MANAGER_GET_UNMEDIATED |
| 170 : metrics_util::CREDENTIAL_MANAGER_GET_MEDIATED; | 143 : metrics_util::CREDENTIAL_MANAGER_GET_MEDIATED; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 digest.signon_realm = digest.origin.spec(); | 286 digest.signon_realm = digest.origin.spec(); |
| 314 return digest; | 287 return digest; |
| 315 } | 288 } |
| 316 | 289 |
| 317 void CredentialManagerImpl::DoneRequiringUserMediation() { | 290 void CredentialManagerImpl::DoneRequiringUserMediation() { |
| 318 DCHECK(pending_require_user_mediation_); | 291 DCHECK(pending_require_user_mediation_); |
| 319 pending_require_user_mediation_.reset(); | 292 pending_require_user_mediation_.reset(); |
| 320 } | 293 } |
| 321 | 294 |
| 322 } // namespace password_manager | 295 } // namespace password_manager |
| OLD | NEW |