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()); |
373 delegate_->AddSavePasswordInfoBarIfPermitted( | 374 } else { |
markusheintz_
2013/12/18 14:49:15
Wrong indentation. Please move two spaces to the l
npentrel
2013/12/18 15:01:10
Done.
| |
374 provisional_save_manager_.release()); | 375 delegate_->AddSavePasswordInfoBarIfPermitted( |
375 } | 376 provisional_save_manager_.release()); |
markusheintz_
2013/12/18 14:49:15
I guess this block should also be non WIN and non
npentrel
2013/12/18 15:01:10
Done.
| |
377 } | |
378 #endif | |
376 } else { | 379 } else { |
377 provisional_save_manager_->Save(); | 380 provisional_save_manager_->Save(); |
378 provisional_save_manager_.reset(); | 381 provisional_save_manager_.reset(); |
379 } | 382 } |
380 } | 383 } |
381 | 384 |
382 void PasswordManager::PossiblyInitializeUsernamesExperiment( | 385 void PasswordManager::PossiblyInitializeUsernamesExperiment( |
383 const PasswordFormMap& best_matches) const { | 386 const PasswordFormMap& best_matches) const { |
384 if (base::FieldTrialList::Find(kOtherPossibleUsernamesExperiment)) | 387 if (base::FieldTrialList::Find(kOtherPossibleUsernamesExperiment)) |
385 return; | 388 return; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
443 } | 446 } |
444 default: | 447 default: |
445 FOR_EACH_OBSERVER( | 448 FOR_EACH_OBSERVER( |
446 LoginModelObserver, | 449 LoginModelObserver, |
447 observers_, | 450 observers_, |
448 OnAutofillDataAvailable(preferred_match.username_value, | 451 OnAutofillDataAvailable(preferred_match.username_value, |
449 preferred_match.password_value)); | 452 preferred_match.password_value)); |
450 break; | 453 break; |
451 } | 454 } |
452 | 455 |
453 if (CommandLine::ForCurrentProcess()->HasSwitch( | 456 #if defined(USE_AURA) || defined(OS_WIN) |
454 switches::kEnableSavePasswordBubble)) { | 457 if (CommandLine::ForCurrentProcess()->HasSwitch( |
455 NotifyPasswordObserver(PasswordObserver::AUTOFILL_PASSWORDS, best_matches, | 458 switches::kEnableSavePasswordBubble)) { |
456 form_for_autofill); | 459 NotifyPasswordObserver(PasswordObserver::AUTOFILL_PASSWORDS, best_matches, |
457 } | 460 form_for_autofill); |
461 } | |
462 #endif | |
458 } | 463 } |
459 | 464 |
460 void PasswordManager::UpdateBestMatches( | 465 void PasswordManager::UpdateBestMatches( |
461 const autofill::PasswordForm& password_form) { | 466 const autofill::PasswordForm& password_form) { |
462 update_best_matches_password_form_manager_.reset( | 467 update_best_matches_password_form_manager_.reset( |
463 new PasswordFormManager(delegate_->GetProfile(), | 468 new PasswordFormManager(delegate_->GetProfile(), |
464 this, | 469 this, |
465 web_contents(), | 470 web_contents(), |
466 password_form, | 471 password_form, |
467 true)); | 472 true)); |
468 update_best_matches_password_form_manager_-> | 473 update_best_matches_password_form_manager_-> |
469 FetchMatchingLoginsFromPasswordStoreForBubble(); | 474 FetchMatchingLoginsFromPasswordStoreForBubble(); |
470 } | 475 } |
471 | 476 |
472 void PasswordManager::SendBestMatchesToManagePasswordsBubble( | 477 void PasswordManager::SendBestMatchesToManagePasswordsBubble( |
473 const PasswordFormMap& best_matches) const { | 478 const PasswordFormMap& best_matches) const { |
474 NotifyPasswordObserverUpdatePasswords(best_matches); | 479 NotifyPasswordObserverUpdatePasswords(best_matches); |
475 } | 480 } |
OLD | NEW |