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 "components/password_manager/core/browser/password_form_manager.h" | 5 #include "components/password_manager/core/browser/password_form_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/metrics/user_metrics.h" | 10 #include "base/metrics/user_metrics.h" |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
383 // distinguish between those forms and two different login forms on the | 383 // distinguish between those forms and two different login forms on the |
384 // same domain. Filed http://crbug.com/294468 to look into this. | 384 // same domain. Filed http://crbug.com/294468 to look into this. |
385 if (logins_result[i]->type == PasswordForm::TYPE_GENERATED) | 385 if (logins_result[i]->type == PasswordForm::TYPE_GENERATED) |
386 credentials_to_keep.push_back(*logins_result[i]); | 386 credentials_to_keep.push_back(*logins_result[i]); |
387 | 387 |
388 if (current_score < best_score) { | 388 if (current_score < best_score) { |
389 delete logins_result[i]; | 389 delete logins_result[i]; |
390 continue; | 390 continue; |
391 } | 391 } |
392 if (current_score == best_score) { | 392 if (current_score == best_score) { |
393 PasswordForm* old_form = best_matches_[logins_result[i]->username_value]; | |
394 if (old_form) { | |
395 if (preferred_match_ == old_form) | |
396 preferred_match_ = NULL; | |
397 delete old_form; | |
398 } | |
393 best_matches_[logins_result[i]->username_value] = logins_result[i]; | 399 best_matches_[logins_result[i]->username_value] = logins_result[i]; |
394 } else if (current_score > best_score) { | 400 } else if (current_score > best_score) { |
395 best_score = current_score; | 401 best_score = current_score; |
396 // This new login has a better score than all those up to this point | 402 // This new login has a better score than all those up to this point |
397 // Note 'this' owns all the PasswordForms in best_matches_. | 403 // Note 'this' owns all the PasswordForms in best_matches_. |
398 STLDeleteValues(&best_matches_); | 404 STLDeleteValues(&best_matches_); |
399 best_matches_.clear(); | |
Garrett Casto
2014/07/22 21:06:44
Was this intentional? I'm not sure why you don't w
Lukasz Jagielski
2014/07/23 14:52:18
I removed this, because STLDeleteValues does that
| |
400 preferred_match_ = NULL; // Don't delete, its owned by best_matches_. | 405 preferred_match_ = NULL; // Don't delete, its owned by best_matches_. |
401 best_matches_[logins_result[i]->username_value] = logins_result[i]; | 406 best_matches_[logins_result[i]->username_value] = logins_result[i]; |
402 } | 407 } |
403 preferred_match_ = logins_result[i]->preferred ? logins_result[i] | 408 preferred_match_ = logins_result[i]->preferred ? logins_result[i] |
404 : preferred_match_; | 409 : preferred_match_; |
405 } | 410 } |
406 // We're done matching now. | 411 // We're done matching now. |
407 state_ = POST_MATCHING_PHASE; | 412 state_ = POST_MATCHING_PHASE; |
408 | 413 |
409 if (best_score <= 0) { | 414 if (best_score <= 0) { |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
734 LogPasswordGenerationSubmissionEvent(PASSWORD_SUBMITTED); | 739 LogPasswordGenerationSubmissionEvent(PASSWORD_SUBMITTED); |
735 } | 740 } |
736 | 741 |
737 void PasswordFormManager::SubmitFailed() { | 742 void PasswordFormManager::SubmitFailed() { |
738 submit_result_ = kSubmitResultFailed; | 743 submit_result_ = kSubmitResultFailed; |
739 if (has_generated_password_) | 744 if (has_generated_password_) |
740 LogPasswordGenerationSubmissionEvent(PASSWORD_SUBMISSION_FAILED); | 745 LogPasswordGenerationSubmissionEvent(PASSWORD_SUBMISSION_FAILED); |
741 } | 746 } |
742 | 747 |
743 } // namespace password_manager | 748 } // namespace password_manager |
OLD | NEW |