| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 56 |
| 57 if (password_manager_util::IsLoggingActive(client_)) { | 57 if (password_manager_util::IsLoggingActive(client_)) { |
| 58 CredentialManagerLogger(client_->GetLogManager()) | 58 CredentialManagerLogger(client_->GetLogManager()) |
| 59 .LogStoreCredential(web_contents()->GetLastCommittedURL(), | 59 .LogStoreCredential(web_contents()->GetLastCommittedURL(), |
| 60 credential.type); | 60 credential.type); |
| 61 } | 61 } |
| 62 | 62 |
| 63 // Send acknowledge response back. | 63 // Send acknowledge response back. |
| 64 callback.Run(); | 64 callback.Run(); |
| 65 | 65 |
| 66 if (!client_->IsSavingAndFillingEnabledForCurrentPage()) | 66 if (!client_->IsSavingAndFillingEnabledForCurrentPage() || |
| 67 !client_->OnCredentialManagerUsed()) |
| 67 return; | 68 return; |
| 68 | 69 |
| 69 client_->NotifyStorePasswordCalled(); | 70 client_->NotifyStorePasswordCalled(); |
| 70 | 71 |
| 71 GURL origin = web_contents()->GetLastCommittedURL().GetOrigin(); | 72 GURL origin = web_contents()->GetLastCommittedURL().GetOrigin(); |
| 72 std::unique_ptr<autofill::PasswordForm> form( | 73 std::unique_ptr<autofill::PasswordForm> form( |
| 73 CreatePasswordFormFromCredentialInfo(credential, origin)); | 74 CreatePasswordFormFromCredentialInfo(credential, origin)); |
| 74 | 75 |
| 75 form_manager_.reset(new CredentialManagerPasswordFormManager( | 76 form_manager_.reset(new CredentialManagerPasswordFormManager( |
| 76 client_, GetDriver(), *CreateObservedPasswordFormFromOrigin(origin), | 77 client_, GetDriver(), *CreateObservedPasswordFormFromOrigin(origin), |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 false); | 111 false); |
| 111 } | 112 } |
| 112 | 113 |
| 113 void CredentialManagerImpl::RequireUserMediation( | 114 void CredentialManagerImpl::RequireUserMediation( |
| 114 const RequireUserMediationCallback& callback) { | 115 const RequireUserMediationCallback& callback) { |
| 115 if (password_manager_util::IsLoggingActive(client_)) { | 116 if (password_manager_util::IsLoggingActive(client_)) { |
| 116 CredentialManagerLogger(client_->GetLogManager()) | 117 CredentialManagerLogger(client_->GetLogManager()) |
| 117 .LogRequireUserMediation(web_contents()->GetLastCommittedURL()); | 118 .LogRequireUserMediation(web_contents()->GetLastCommittedURL()); |
| 118 } | 119 } |
| 119 PasswordStore* store = GetPasswordStore(); | 120 PasswordStore* store = GetPasswordStore(); |
| 120 if (!store || !client_->IsSavingAndFillingEnabledForCurrentPage()) { | 121 if (!store || !client_->IsSavingAndFillingEnabledForCurrentPage() || |
| 122 !client_->OnCredentialManagerUsed()) { |
| 121 callback.Run(); | 123 callback.Run(); |
| 122 return; | 124 return; |
| 123 } | 125 } |
| 124 | 126 |
| 125 if (store->affiliated_match_helper()) { | 127 if (store->affiliated_match_helper()) { |
| 126 store->affiliated_match_helper()->GetAffiliatedAndroidRealms( | 128 store->affiliated_match_helper()->GetAffiliatedAndroidRealms( |
| 127 GetSynthesizedFormForOrigin(), | 129 GetSynthesizedFormForOrigin(), |
| 128 base::Bind(&CredentialManagerImpl::ScheduleRequireMediationTask, | 130 base::Bind(&CredentialManagerImpl::ScheduleRequireMediationTask, |
| 129 weak_factory_.GetWeakPtr(), callback)); | 131 weak_factory_.GetWeakPtr(), callback)); |
| 130 } else { | 132 } else { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 callback.Run(pending_request_ | 174 callback.Run(pending_request_ |
| 173 ? mojom::CredentialManagerError::PENDINGREQUEST | 175 ? mojom::CredentialManagerError::PENDINGREQUEST |
| 174 : mojom::CredentialManagerError::PASSWORDSTOREUNAVAILABLE, | 176 : mojom::CredentialManagerError::PASSWORDSTOREUNAVAILABLE, |
| 175 base::nullopt); | 177 base::nullopt); |
| 176 return; | 178 return; |
| 177 } | 179 } |
| 178 | 180 |
| 179 // Return an empty credential if zero-click is required but disabled, or if | 181 // Return an empty credential if zero-click is required but disabled, or if |
| 180 // the current page has TLS errors. | 182 // the current page has TLS errors. |
| 181 if (!client_->IsFillingEnabledForCurrentPage() || | 183 if (!client_->IsFillingEnabledForCurrentPage() || |
| 184 !client_->OnCredentialManagerUsed() || |
| 182 (zero_click_only && !IsZeroClickAllowed())) { | 185 (zero_click_only && !IsZeroClickAllowed())) { |
| 183 // Callback with empty credential info. | 186 // Callback with empty credential info. |
| 184 callback.Run(mojom::CredentialManagerError::SUCCESS, CredentialInfo()); | 187 callback.Run(mojom::CredentialManagerError::SUCCESS, CredentialInfo()); |
| 185 return; | 188 return; |
| 186 } | 189 } |
| 187 | 190 |
| 188 if (store->affiliated_match_helper()) { | 191 if (store->affiliated_match_helper()) { |
| 189 store->affiliated_match_helper()->GetAffiliatedAndroidRealms( | 192 store->affiliated_match_helper()->GetAffiliatedAndroidRealms( |
| 190 GetSynthesizedFormForOrigin(), | 193 GetSynthesizedFormForOrigin(), |
| 191 base::Bind(&CredentialManagerImpl::ScheduleRequestTask, | 194 base::Bind(&CredentialManagerImpl::ScheduleRequestTask, |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 digest.signon_realm = digest.origin.spec(); | 291 digest.signon_realm = digest.origin.spec(); |
| 289 return digest; | 292 return digest; |
| 290 } | 293 } |
| 291 | 294 |
| 292 void CredentialManagerImpl::DoneRequiringUserMediation() { | 295 void CredentialManagerImpl::DoneRequiringUserMediation() { |
| 293 DCHECK(pending_require_user_mediation_); | 296 DCHECK(pending_require_user_mediation_); |
| 294 pending_require_user_mediation_.reset(); | 297 pending_require_user_mediation_.reset(); |
| 295 } | 298 } |
| 296 | 299 |
| 297 } // namespace password_manager | 300 } // namespace password_manager |
| OLD | NEW |