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

Side by Side Diff: ios/chrome/browser/passwords/credential_manager.mm

Issue 2513033002: Refactor CredentialManagerImpl::RequireUserMediation method. (Closed)
Patch Set: ios Created 4 years 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #import "ios/chrome/browser/passwords/credential_manager.h" 5 #import "ios/chrome/browser/passwords/credential_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #import "base/ios/weak_nsobject.h" 9 #import "base/ios/weak_nsobject.h"
10 #include "base/mac/bind_objc_block.h" 10 #include "base/mac/bind_objc_block.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 return; 221 return;
222 } 222 }
223 223
224 // The user signed out of the current page, so future zero-click credential 224 // The user signed out of the current page, so future zero-click credential
225 // requests for this page should fail: otherwise, the next time the user 225 // requests for this page should fail: otherwise, the next time the user
226 // visits the page, if zero-click requests succeeded, the user might be auto- 226 // visits the page, if zero-click requests succeeded, the user might be auto-
227 // signed-in again with the credential that they just signed out. Forward this 227 // signed-in again with the credential that they just signed out. Forward this
228 // information to the PasswordStore via an asynchronous task. 228 // information to the PasswordStore via an asynchronous task.
229 password_manager::PasswordStore* store = GetPasswordStore(); 229 password_manager::PasswordStore* store = GetPasswordStore();
230 if (store) { 230 if (store) {
231 // Bundle the origins that are sent to the PasswordStore if the task hasn't 231 if (!pending_require_user_mediation_) {
232 // yet resolved. This task lives across page-loads to enable this bundling.
233 if (pending_require_user_mediation_) {
234 pending_require_user_mediation_->AddOrigin(page_url);
235 } else {
236 pending_require_user_mediation_.reset( 232 pending_require_user_mediation_.reset(
237 new password_manager:: 233 new password_manager::
238 CredentialManagerPendingRequireUserMediationTask( 234 CredentialManagerPendingRequireUserMediationTask(this));
239 this, page_url, std::vector<std::string>()));
240
241 // This will result in a callback to
242 // CredentialManagerPendingSignedOutTask::OnGetPasswordStoreResults().
243 store->GetAutofillableLogins(pending_require_user_mediation_.get());
244 } 235 }
236 password_manager::PasswordStore::FormDigest form = {
237 autofill::PasswordForm::SCHEME_HTML, source_url.spec(), source_url};
238 pending_require_user_mediation_->AddOrigin(form);
245 } 239 }
246 240
247 // Acknowledge the page's signOut notification without waiting for the 241 // Acknowledge the page's signOut notification without waiting for the
248 // PasswordStore interaction to complete. The implementation of the sign-out 242 // PasswordStore interaction to complete. The implementation of the sign-out
249 // notification isn't the page's concern. 243 // notification isn't the page's concern.
250 ResolvePromise(request_id); 244 ResolvePromise(request_id);
251 } 245 }
252 246
253 void CredentialManager::WebStateDestroyed() { 247 void CredentialManager::WebStateDestroyed() {
254 // When the WebState is destroyed, clean up everything that depends on it. 248 // When the WebState is destroyed, clean up everything that depends on it.
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 bool CredentialManager::GetUrlWithAbsoluteTrust(GURL* page_url) { 370 bool CredentialManager::GetUrlWithAbsoluteTrust(GURL* page_url) {
377 web::URLVerificationTrustLevel trust_level = 371 web::URLVerificationTrustLevel trust_level =
378 web::URLVerificationTrustLevel::kNone; 372 web::URLVerificationTrustLevel::kNone;
379 const GURL possibly_untrusted_url(web_state()->GetCurrentURL(&trust_level)); 373 const GURL possibly_untrusted_url(web_state()->GetCurrentURL(&trust_level));
380 if (trust_level == web::URLVerificationTrustLevel::kAbsolute) { 374 if (trust_level == web::URLVerificationTrustLevel::kAbsolute) {
381 *page_url = possibly_untrusted_url; 375 *page_url = possibly_untrusted_url;
382 return true; 376 return true;
383 } 377 }
384 return false; 378 return false;
385 } 379 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698