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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 !provisional_save_manager_->IsPendingCredentialsPublicSuffixMatch(); | 343 !provisional_save_manager_->IsPendingCredentialsPublicSuffixMatch(); |
344 } | 344 } |
345 | 345 |
346 void PasswordManager::OnPasswordFormsRendered( | 346 void PasswordManager::OnPasswordFormsRendered( |
347 const std::vector<PasswordForm>& visible_forms) { | 347 const std::vector<PasswordForm>& visible_forms) { |
348 if (!provisional_save_manager_.get()) | 348 if (!provisional_save_manager_.get()) |
349 return; | 349 return; |
350 | 350 |
351 DCHECK(IsSavingEnabled()); | 351 DCHECK(IsSavingEnabled()); |
352 | 352 |
353 // We now assume that if there is at least one visible password form | 353 // If we see the login form again, then the login failed. |
354 // that means that the previous login attempt failed. | 354 for (size_t i = 0; i < visible_forms.size(); ++i) { |
355 if (!visible_forms.empty()) { | 355 // TODO(vabr): The similarity check is just action equality for now. If it |
356 provisional_save_manager_->SubmitFailed(); | 356 // becomes more complex, it may make sense to consider modifying and using |
357 provisional_save_manager_.reset(); | 357 // PasswordFormManager::DoesManage for it. |
358 return; | 358 if (visible_forms[i].action.is_valid() && |
| 359 provisional_save_manager_->pending_credentials().action == |
| 360 visible_forms[i].action) { |
| 361 provisional_save_manager_->SubmitFailed(); |
| 362 provisional_save_manager_.reset(); |
| 363 return; |
| 364 } |
359 } | 365 } |
360 | 366 |
361 // Looks like a successful login attempt. Either show an infobar or | 367 // Looks like a successful login attempt. Either show an infobar or |
362 // automatically save the login data. We prompt when the user hasn't already | 368 // automatically save the login data. We prompt when the user hasn't already |
363 // given consent, either through previously accepting the infobar or by having | 369 // given consent, either through previously accepting the infobar or by having |
364 // the browser generate the password. | 370 // the browser generate the password. |
365 provisional_save_manager_->SubmitPassed(); | 371 provisional_save_manager_->SubmitPassed(); |
366 if (provisional_save_manager_->HasGeneratedPassword()) | 372 if (provisional_save_manager_->HasGeneratedPassword()) |
367 UMA_HISTOGRAM_COUNTS("PasswordGeneration.Submitted", 1); | 373 UMA_HISTOGRAM_COUNTS("PasswordGeneration.Submitted", 1); |
368 | 374 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 } | 465 } |
460 | 466 |
461 ManagePasswordsBubbleUIController* manage_passwords_bubble_ui_controller = | 467 ManagePasswordsBubbleUIController* manage_passwords_bubble_ui_controller = |
462 ManagePasswordsBubbleUIController::FromWebContents(web_contents()); | 468 ManagePasswordsBubbleUIController::FromWebContents(web_contents()); |
463 if (manage_passwords_bubble_ui_controller && | 469 if (manage_passwords_bubble_ui_controller && |
464 CommandLine::ForCurrentProcess()->HasSwitch( | 470 CommandLine::ForCurrentProcess()->HasSwitch( |
465 switches::kEnableSavePasswordBubble)) { | 471 switches::kEnableSavePasswordBubble)) { |
466 manage_passwords_bubble_ui_controller->OnPasswordAutofilled(best_matches); | 472 manage_passwords_bubble_ui_controller->OnPasswordAutofilled(best_matches); |
467 } | 473 } |
468 } | 474 } |
OLD | NEW |