Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Side by Side Diff: components/password_manager/content/browser/credential_manager_impl.cc

Issue 2447813002: Strengthen the rules when the Credential Manager API is disabled. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 false); 110 false);
111 } 111 }
112 112
113 void CredentialManagerImpl::RequireUserMediation( 113 void CredentialManagerImpl::RequireUserMediation(
114 const RequireUserMediationCallback& callback) { 114 const RequireUserMediationCallback& callback) {
115 if (password_manager_util::IsLoggingActive(client_)) { 115 if (password_manager_util::IsLoggingActive(client_)) {
116 CredentialManagerLogger(client_->GetLogManager()) 116 CredentialManagerLogger(client_->GetLogManager())
117 .LogRequireUserMediation(web_contents()->GetLastCommittedURL()); 117 .LogRequireUserMediation(web_contents()->GetLastCommittedURL());
118 } 118 }
119 PasswordStore* store = GetPasswordStore(); 119 PasswordStore* store = GetPasswordStore();
120 if (!store || !IsUpdatingCredentialAllowed()) { 120 if (!store || !client_->IsSavingAndFillingEnabledForCurrentPage()) {
121 callback.Run(); 121 callback.Run();
122 return; 122 return;
123 } 123 }
124 124
125 if (store->affiliated_match_helper()) { 125 if (store->affiliated_match_helper()) {
126 store->affiliated_match_helper()->GetAffiliatedAndroidRealms( 126 store->affiliated_match_helper()->GetAffiliatedAndroidRealms(
127 GetSynthesizedFormForOrigin(), 127 GetSynthesizedFormForOrigin(),
128 base::Bind(&CredentialManagerImpl::ScheduleRequireMediationTask, 128 base::Bind(&CredentialManagerImpl::ScheduleRequireMediationTask,
129 weak_factory_.GetWeakPtr(), callback)); 129 weak_factory_.GetWeakPtr(), callback));
130 } else { 130 } else {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 // Callback error. 171 // Callback error.
172 callback.Run(pending_request_ 172 callback.Run(pending_request_
173 ? mojom::CredentialManagerError::PENDINGREQUEST 173 ? mojom::CredentialManagerError::PENDINGREQUEST
174 : mojom::CredentialManagerError::PASSWORDSTOREUNAVAILABLE, 174 : mojom::CredentialManagerError::PASSWORDSTOREUNAVAILABLE,
175 base::nullopt); 175 base::nullopt);
176 return; 176 return;
177 } 177 }
178 178
179 // Return an empty credential if zero-click is required but disabled, or if 179 // Return an empty credential if zero-click is required but disabled, or if
180 // the current page has TLS errors. 180 // the current page has TLS errors.
181 if ((zero_click_only && !IsZeroClickAllowed()) || 181 if (!client_->IsFillingEnabledForCurrentPage() ||
182 client_->DidLastPageLoadEncounterSSLErrors()) { 182 (zero_click_only && !IsZeroClickAllowed())) {
183 // Callback with empty credential info. 183 // Callback with empty credential info.
184 callback.Run(mojom::CredentialManagerError::SUCCESS, CredentialInfo()); 184 callback.Run(mojom::CredentialManagerError::SUCCESS, CredentialInfo());
185 return; 185 return;
186 } 186 }
187 187
188 if (store->affiliated_match_helper()) { 188 if (store->affiliated_match_helper()) {
189 store->affiliated_match_helper()->GetAffiliatedAndroidRealms( 189 store->affiliated_match_helper()->GetAffiliatedAndroidRealms(
190 GetSynthesizedFormForOrigin(), 190 GetSynthesizedFormForOrigin(),
191 base::Bind(&CredentialManagerImpl::ScheduleRequestTask, 191 base::Bind(&CredentialManagerImpl::ScheduleRequestTask,
192 weak_factory_.GetWeakPtr(), callback, zero_click_only, 192 weak_factory_.GetWeakPtr(), callback, zero_click_only,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 const autofill::PasswordForm* form) { 255 const autofill::PasswordForm* form) {
256 CredentialInfo info; 256 CredentialInfo info;
257 if (form) { 257 if (form) {
258 password_manager::CredentialType type_to_return = 258 password_manager::CredentialType type_to_return =
259 form->federation_origin.unique() 259 form->federation_origin.unique()
260 ? CredentialType::CREDENTIAL_TYPE_PASSWORD 260 ? CredentialType::CREDENTIAL_TYPE_PASSWORD
261 : CredentialType::CREDENTIAL_TYPE_FEDERATED; 261 : CredentialType::CREDENTIAL_TYPE_FEDERATED;
262 info = CredentialInfo(*form, type_to_return); 262 info = CredentialInfo(*form, type_to_return);
263 if (PasswordStore* store = GetPasswordStore()) { 263 if (PasswordStore* store = GetPasswordStore()) {
264 if (form->skip_zero_click && IsZeroClickAllowed()) { 264 if (form->skip_zero_click && IsZeroClickAllowed()) {
265 DCHECK(IsUpdatingCredentialAllowed());
266 autofill::PasswordForm update_form = *form; 265 autofill::PasswordForm update_form = *form;
267 update_form.skip_zero_click = false; 266 update_form.skip_zero_click = false;
268 store->UpdateLogin(update_form); 267 store->UpdateLogin(update_form);
269 } 268 }
270 } 269 }
271 base::RecordAction( 270 base::RecordAction(
272 base::UserMetricsAction("CredentialManager_AccountChooser_Accepted")); 271 base::UserMetricsAction("CredentialManager_AccountChooser_Accepted"));
273 } else { 272 } else {
274 base::RecordAction( 273 base::RecordAction(
275 base::UserMetricsAction("CredentialManager_AccountChooser_Dismissed")); 274 base::UserMetricsAction("CredentialManager_AccountChooser_Dismissed"));
(...skipping 12 matching lines...) Expand all
288 web_contents()->GetLastCommittedURL().GetOrigin()}; 287 web_contents()->GetLastCommittedURL().GetOrigin()};
289 digest.signon_realm = digest.origin.spec(); 288 digest.signon_realm = digest.origin.spec();
290 return digest; 289 return digest;
291 } 290 }
292 291
293 void CredentialManagerImpl::DoneRequiringUserMediation() { 292 void CredentialManagerImpl::DoneRequiringUserMediation() {
294 DCHECK(pending_require_user_mediation_); 293 DCHECK(pending_require_user_mediation_);
295 pending_require_user_mediation_.reset(); 294 pending_require_user_mediation_.reset();
296 } 295 }
297 296
298 bool CredentialManagerImpl::IsUpdatingCredentialAllowed() const {
299 return !client_->DidLastPageLoadEncounterSSLErrors() &&
300 !client_->IsOffTheRecord();
301 }
302
303 } // namespace password_manager 297 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698