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