Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "chrome/browser/password_manager/password_manager.h" | 5 #include "chrome/browser/password_manager/password_manager.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 358 | 358 |
| 359 // Looks like a successful login attempt. Either show an infobar or | 359 // Looks like a successful login attempt. Either show an infobar or |
| 360 // automatically save the login data. We prompt when the user hasn't already | 360 // automatically save the login data. We prompt when the user hasn't already |
| 361 // given consent, either through previously accepting the infobar or by having | 361 // given consent, either through previously accepting the infobar or by having |
| 362 // the browser generate the password. | 362 // the browser generate the password. |
| 363 provisional_save_manager_->SubmitPassed(); | 363 provisional_save_manager_->SubmitPassed(); |
| 364 if (provisional_save_manager_->HasGeneratedPassword()) | 364 if (provisional_save_manager_->HasGeneratedPassword()) |
| 365 UMA_HISTOGRAM_COUNTS("PasswordGeneration.Submitted", 1); | 365 UMA_HISTOGRAM_COUNTS("PasswordGeneration.Submitted", 1); |
| 366 | 366 |
| 367 if (ShouldShowSavePasswordInfoBar()) { | 367 if (ShouldShowSavePasswordInfoBar()) { |
| 368 if (CommandLine::ForCurrentProcess()->HasSwitch( | 368 #if defined(USE_AURA) |
|
markusheintz_
2013/12/18 09:32:54
I guess this could be USE_AURA or OS_WIN.
npentrel
2013/12/18 13:28:47
Done.
| |
| 369 NotifyPasswordObserver(PasswordObserver::SAVE_NEW_PASSWORD, | |
| 370 provisional_save_manager_->best_matches(), | |
| 371 provisional_save_manager_->pending_credentials()); | |
| 372 #else | |
| 373 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 369 switches::kEnableSavePasswordBubble)) { | 374 switches::kEnableSavePasswordBubble)) { |
| 370 NotifyPasswordObserver(PasswordObserver::SAVE_NEW_PASSWORD, | 375 NotifyPasswordObserver(PasswordObserver::SAVE_NEW_PASSWORD, |
| 371 provisional_save_manager_->best_matches(), | 376 provisional_save_manager_->best_matches(), |
| 372 provisional_save_manager_->pending_credentials()); | 377 provisional_save_manager_->pending_credentials()); |
| 373 } else { | 378 } else { |
| 374 delegate_->AddSavePasswordInfoBarIfPermitted( | 379 delegate_->AddSavePasswordInfoBarIfPermitted( |
| 375 provisional_save_manager_.release()); | 380 provisional_save_manager_.release()); |
| 376 } | 381 } |
| 382 #endif | |
| 377 } else { | 383 } else { |
| 378 provisional_save_manager_->Save(); | 384 provisional_save_manager_->Save(); |
| 379 provisional_save_manager_.reset(); | 385 provisional_save_manager_.reset(); |
| 380 } | 386 } |
| 381 } | 387 } |
| 382 | 388 |
| 383 void PasswordManager::PossiblyInitializeUsernamesExperiment( | 389 void PasswordManager::PossiblyInitializeUsernamesExperiment( |
| 384 const PasswordFormMap& best_matches) const { | 390 const PasswordFormMap& best_matches) const { |
| 385 if (base::FieldTrialList::Find(kOtherPossibleUsernamesExperiment)) | 391 if (base::FieldTrialList::Find(kOtherPossibleUsernamesExperiment)) |
| 386 return; | 392 return; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 444 } | 450 } |
| 445 default: | 451 default: |
| 446 FOR_EACH_OBSERVER( | 452 FOR_EACH_OBSERVER( |
| 447 LoginModelObserver, | 453 LoginModelObserver, |
| 448 observers_, | 454 observers_, |
| 449 OnAutofillDataAvailable(preferred_match.username_value, | 455 OnAutofillDataAvailable(preferred_match.username_value, |
| 450 preferred_match.password_value)); | 456 preferred_match.password_value)); |
| 451 break; | 457 break; |
| 452 } | 458 } |
| 453 | 459 |
| 454 if (CommandLine::ForCurrentProcess()->HasSwitch( | 460 #if defined(USE_AURA) |
|
markusheintz_
2013/12/18 09:32:54
Same as above
npentrel
2013/12/18 13:28:47
Done.
| |
| 455 switches::kEnableSavePasswordBubble)) { | |
| 456 NotifyPasswordObserver(PasswordObserver::AUTOFILL_PASSWORDS, best_matches, | 461 NotifyPasswordObserver(PasswordObserver::AUTOFILL_PASSWORDS, best_matches, |
| 457 form_for_autofill); | 462 form_for_autofill); |
| 458 } | 463 #else |
| 464 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 465 switches::kEnableSavePasswordBubble)) { | |
| 466 NotifyPasswordObserver(PasswordObserver::AUTOFILL_PASSWORDS, best_matches, | |
| 467 form_for_autofill); | |
| 468 } | |
| 469 #endif | |
| 459 } | 470 } |
| 460 | 471 |
| 461 void PasswordManager::UpdateBestMatches( | 472 void PasswordManager::UpdateBestMatches( |
| 462 const autofill::PasswordForm& password_form) { | 473 const autofill::PasswordForm& password_form) { |
| 463 update_best_matches_password_form_manager_.reset( | 474 update_best_matches_password_form_manager_.reset( |
| 464 new PasswordFormManager(delegate_->GetProfile(), | 475 new PasswordFormManager(delegate_->GetProfile(), |
| 465 this, | 476 this, |
| 466 web_contents(), | 477 web_contents(), |
| 467 password_form, | 478 password_form, |
| 468 true)); | 479 true)); |
| 469 update_best_matches_password_form_manager_-> | 480 update_best_matches_password_form_manager_-> |
| 470 FetchMatchingLoginsFromPasswordStoreForBubble(); | 481 FetchMatchingLoginsFromPasswordStoreForBubble(); |
| 471 } | 482 } |
| 472 | 483 |
| 473 void PasswordManager::SendBestMatchesToManagePasswordsBubble( | 484 void PasswordManager::SendBestMatchesToManagePasswordsBubble( |
| 474 const PasswordFormMap& best_matches) const { | 485 const PasswordFormMap& best_matches) const { |
| 475 NotifyPasswordObserverUpdatePasswords(best_matches); | 486 NotifyPasswordObserverUpdatePasswords(best_matches); |
| 476 } | 487 } |
| OLD | NEW |