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

Side by Side Diff: components/password_manager/core/browser/password_form_manager.cc

Issue 707173004: Refactor Autofill for out of process iframes (OOPIF). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mem leak Created 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/core/browser/password_form_manager.h" 5 #include "components/password_manager/core/browser/password_form_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 !has_generated_password_) { 348 !has_generated_password_) {
349 LogPasswordGenerationSubmissionEvent(PASSWORD_OVERRIDDEN); 349 LogPasswordGenerationSubmissionEvent(PASSWORD_OVERRIDDEN);
350 } 350 }
351 351
352 if (has_generated_password_) 352 if (has_generated_password_)
353 pending_credentials_.type = PasswordForm::TYPE_GENERATED; 353 pending_credentials_.type = PasswordForm::TYPE_GENERATED;
354 } 354 }
355 355
356 void PasswordFormManager::Save() { 356 void PasswordFormManager::Save() {
357 DCHECK_EQ(state_, POST_MATCHING_PHASE); 357 DCHECK_EQ(state_, POST_MATCHING_PHASE);
358 DCHECK(!driver_->IsOffTheRecord()); 358 DCHECK(!client_->IsOffTheRecord());
359 359
360 if (IsNewLogin()) 360 if (IsNewLogin())
361 SaveAsNewLogin(true); 361 SaveAsNewLogin(true);
362 else 362 else
363 UpdateLogin(); 363 UpdateLogin();
364 } 364 }
365 365
366 void PasswordFormManager::FetchMatchingLoginsFromPasswordStore( 366 void PasswordFormManager::FetchMatchingLoginsFromPasswordStore(
367 PasswordStore::AuthorizationPromptPolicy prompt_policy) { 367 PasswordStore::AuthorizationPromptPolicy prompt_policy) {
368 DCHECK_EQ(state_, PRE_MATCHING_PHASE); 368 DCHECK_EQ(state_, PRE_MATCHING_PHASE);
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 } 509 }
510 510
511 // If not blacklisted, inform the driver that password generation is allowed 511 // If not blacklisted, inform the driver that password generation is allowed
512 // for |observed_form_|. 512 // for |observed_form_|.
513 driver_->AllowPasswordGenerationForForm(observed_form_); 513 driver_->AllowPasswordGenerationForForm(observed_form_);
514 514
515 // Proceed to autofill. 515 // Proceed to autofill.
516 // Note that we provide the choices but don't actually prefill a value if: 516 // Note that we provide the choices but don't actually prefill a value if:
517 // (1) we are in Incognito mode, (2) the ACTION paths don't match, 517 // (1) we are in Incognito mode, (2) the ACTION paths don't match,
518 // or (3) if it matched using public suffix domain matching. 518 // or (3) if it matched using public suffix domain matching.
519 bool wait_for_username = 519 bool wait_for_username = client_->IsOffTheRecord() ||
520 driver_->IsOffTheRecord() || 520 observed_form_.action.GetWithEmptyPath() !=
521 observed_form_.action.GetWithEmptyPath() != 521 preferred_match_->action.GetWithEmptyPath() ||
522 preferred_match_->action.GetWithEmptyPath() || 522 preferred_match_->IsPublicSuffixMatch();
523 preferred_match_->IsPublicSuffixMatch();
524 if (wait_for_username) 523 if (wait_for_username)
525 manager_action_ = kManagerActionNone; 524 manager_action_ = kManagerActionNone;
526 else 525 else
527 manager_action_ = kManagerActionAutofilled; 526 manager_action_ = kManagerActionAutofilled;
528 password_manager_->Autofill(observed_form_, best_matches_, 527 password_manager_->Autofill(driver_, observed_form_, best_matches_,
529 *preferred_match_, wait_for_username); 528 *preferred_match_, wait_for_username);
530 } 529 }
531 530
532 void PasswordFormManager::OnGetPasswordStoreResults( 531 void PasswordFormManager::OnGetPasswordStoreResults(
533 const std::vector<autofill::PasswordForm*>& results) { 532 const std::vector<autofill::PasswordForm*>& results) {
534 DCHECK_EQ(state_, MATCHING_PHASE); 533 DCHECK_EQ(state_, MATCHING_PHASE);
535 534
536 scoped_ptr<BrowserSavePasswordProgressLogger> logger; 535 scoped_ptr<BrowserSavePasswordProgressLogger> logger;
537 if (client_->IsLoggingActive()) { 536 if (client_->IsLoggingActive()) {
538 logger.reset(new BrowserSavePasswordProgressLogger(client_)); 537 logger.reset(new BrowserSavePasswordProgressLogger(client_));
(...skipping 28 matching lines...) Expand all
567 } 566 }
568 567
569 void PasswordFormManager::SaveAsNewLogin(bool reset_preferred_login) { 568 void PasswordFormManager::SaveAsNewLogin(bool reset_preferred_login) {
570 DCHECK_EQ(state_, POST_MATCHING_PHASE); 569 DCHECK_EQ(state_, POST_MATCHING_PHASE);
571 DCHECK(IsNewLogin()); 570 DCHECK(IsNewLogin());
572 // The new_form is being used to sign in, so it is preferred. 571 // The new_form is being used to sign in, so it is preferred.
573 DCHECK(pending_credentials_.preferred); 572 DCHECK(pending_credentials_.preferred);
574 // new_form contains the same basic data as observed_form_ (because its the 573 // new_form contains the same basic data as observed_form_ (because its the
575 // same form), but with the newly added credentials. 574 // same form), but with the newly added credentials.
576 575
577 DCHECK(!driver_->IsOffTheRecord()); 576 DCHECK(!client_->IsOffTheRecord());
578 577
579 PasswordStore* password_store = client_->GetPasswordStore(); 578 PasswordStore* password_store = client_->GetPasswordStore();
580 if (!password_store) { 579 if (!password_store) {
581 NOTREACHED(); 580 NOTREACHED();
582 return; 581 return;
583 } 582 }
584 583
585 // Upload credentials the first time they are saved. This data is used 584 // Upload credentials the first time they are saved. This data is used
586 // by password generation to help determine account creation sites. 585 // by password generation to help determine account creation sites.
587 // Blacklisted credentials will never be used, so don't upload a vote for 586 // Blacklisted credentials will never be used, so don't upload a vote for
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 } 640 }
642 641
643 void PasswordFormManager::UpdateLogin() { 642 void PasswordFormManager::UpdateLogin() {
644 DCHECK_EQ(state_, POST_MATCHING_PHASE); 643 DCHECK_EQ(state_, POST_MATCHING_PHASE);
645 DCHECK(preferred_match_); 644 DCHECK(preferred_match_);
646 // If we're doing an Update, we either autofilled correctly and need to 645 // If we're doing an Update, we either autofilled correctly and need to
647 // update the stats, or the user typed in a new password for autofilled 646 // update the stats, or the user typed in a new password for autofilled
648 // username, or the user selected one of the non-preferred matches, 647 // username, or the user selected one of the non-preferred matches,
649 // thus requiring a swap of preferred bits. 648 // thus requiring a swap of preferred bits.
650 DCHECK(!IsNewLogin() && pending_credentials_.preferred); 649 DCHECK(!IsNewLogin() && pending_credentials_.preferred);
651 DCHECK(!driver_->IsOffTheRecord()); 650 DCHECK(!client_->IsOffTheRecord());
652 651
653 PasswordStore* password_store = client_->GetPasswordStore(); 652 PasswordStore* password_store = client_->GetPasswordStore();
654 if (!password_store) { 653 if (!password_store) {
655 NOTREACHED(); 654 NOTREACHED();
656 return; 655 return;
657 } 656 }
658 657
659 UpdateMetadataForUsage(pending_credentials_); 658 UpdateMetadataForUsage(pending_credentials_);
660 659
661 if (client_->IsSyncAccountCredential( 660 if (client_->IsSyncAccountCredential(
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 LogPasswordGenerationSubmissionEvent(PASSWORD_SUBMITTED); 851 LogPasswordGenerationSubmissionEvent(PASSWORD_SUBMITTED);
853 } 852 }
854 853
855 void PasswordFormManager::SubmitFailed() { 854 void PasswordFormManager::SubmitFailed() {
856 submit_result_ = kSubmitResultFailed; 855 submit_result_ = kSubmitResultFailed;
857 if (has_generated_password_) 856 if (has_generated_password_)
858 LogPasswordGenerationSubmissionEvent(PASSWORD_SUBMISSION_FAILED); 857 LogPasswordGenerationSubmissionEvent(PASSWORD_SUBMISSION_FAILED);
859 } 858 }
860 859
861 } // namespace password_manager 860 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698