| 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/metrics/field_trial.h" | 7 #include "base/metrics/field_trial.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 new PasswordFormManager(delegate_->GetProfile(), | 261 new PasswordFormManager(delegate_->GetProfile(), |
| 262 this, | 262 this, |
| 263 web_contents(), | 263 web_contents(), |
| 264 *iter, | 264 *iter, |
| 265 ssl_valid); | 265 ssl_valid); |
| 266 pending_login_managers_.push_back(manager); | 266 pending_login_managers_.push_back(manager); |
| 267 manager->FetchMatchingLoginsFromPasswordStore(); | 267 manager->FetchMatchingLoginsFromPasswordStore(); |
| 268 } | 268 } |
| 269 } | 269 } |
| 270 | 270 |
| 271 bool PasswordManager::ShouldShowSavePasswordInfoBar() const { |
| 272 return provisional_save_manager_->IsNewLogin() && |
| 273 !provisional_save_manager_->HasGeneratedPassword() && |
| 274 !provisional_save_manager_->IsPendingCredentialsPublicSuffixMatch(); |
| 275 } |
| 276 |
| 271 void PasswordManager::OnPasswordFormsRendered( | 277 void PasswordManager::OnPasswordFormsRendered( |
| 272 const std::vector<PasswordForm>& visible_forms) { | 278 const std::vector<PasswordForm>& visible_forms) { |
| 273 if (!provisional_save_manager_.get()) | 279 if (!provisional_save_manager_.get()) |
| 274 return; | 280 return; |
| 275 | 281 |
| 276 DCHECK(IsSavingEnabled()); | 282 DCHECK(IsSavingEnabled()); |
| 277 | 283 |
| 278 // First, check for a failed login attempt. | 284 // First, check for a failed login attempt. |
| 279 for (std::vector<PasswordForm>::const_iterator iter = visible_forms.begin(); | 285 for (std::vector<PasswordForm>::const_iterator iter = visible_forms.begin(); |
| 280 iter != visible_forms.end(); ++iter) { | 286 iter != visible_forms.end(); ++iter) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 295 return; | 301 return; |
| 296 } | 302 } |
| 297 | 303 |
| 298 // Looks like a successful login attempt. Either show an infobar or | 304 // Looks like a successful login attempt. Either show an infobar or |
| 299 // automatically save the login data. We prompt when the user hasn't already | 305 // automatically save the login data. We prompt when the user hasn't already |
| 300 // given consent, either through previously accepting the infobar or by having | 306 // given consent, either through previously accepting the infobar or by having |
| 301 // the browser generate the password. | 307 // the browser generate the password. |
| 302 provisional_save_manager_->SubmitPassed(); | 308 provisional_save_manager_->SubmitPassed(); |
| 303 if (provisional_save_manager_->HasGeneratedPassword()) | 309 if (provisional_save_manager_->HasGeneratedPassword()) |
| 304 UMA_HISTOGRAM_COUNTS("PasswordGeneration.Submitted", 1); | 310 UMA_HISTOGRAM_COUNTS("PasswordGeneration.Submitted", 1); |
| 305 if (provisional_save_manager_->IsNewLogin() && | 311 if (ShouldShowSavePasswordInfoBar()) { |
| 306 !provisional_save_manager_->HasGeneratedPassword()) { | |
| 307 delegate_->AddSavePasswordInfoBarIfPermitted( | 312 delegate_->AddSavePasswordInfoBarIfPermitted( |
| 308 provisional_save_manager_.release()); | 313 provisional_save_manager_.release()); |
| 309 } else { | 314 } else { |
| 310 provisional_save_manager_->Save(); | 315 provisional_save_manager_->Save(); |
| 311 provisional_save_manager_.reset(); | 316 provisional_save_manager_.reset(); |
| 312 } | 317 } |
| 313 } | 318 } |
| 314 | 319 |
| 315 void PasswordManager::PossiblyInitializeUsernamesExperiment( | 320 void PasswordManager::PossiblyInitializeUsernamesExperiment( |
| 316 const PasswordFormMap& best_matches) const { | 321 const PasswordFormMap& best_matches) const { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 return; | 380 return; |
| 376 } | 381 } |
| 377 default: | 382 default: |
| 378 FOR_EACH_OBSERVER( | 383 FOR_EACH_OBSERVER( |
| 379 LoginModelObserver, | 384 LoginModelObserver, |
| 380 observers_, | 385 observers_, |
| 381 OnAutofillDataAvailable(preferred_match.username_value, | 386 OnAutofillDataAvailable(preferred_match.username_value, |
| 382 preferred_match.password_value)); | 387 preferred_match.password_value)); |
| 383 } | 388 } |
| 384 } | 389 } |
| OLD | NEW |