Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(406)

Unified Diff: components/password_manager/core/browser/password_form_manager.cc

Issue 2776943003: Use base::EraseIf in Password Form Manager (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/password_manager/core/browser/password_form_manager.cc
diff --git a/components/password_manager/core/browser/password_form_manager.cc b/components/password_manager/core/browser/password_form_manager.cc
index 1e570ec17049d40ef34a3e732d309255854a3424..c4ad94d5ed6c368ab3ecb10b22145a76110a2829 100644
--- a/components/password_manager/core/browser/password_form_manager.cc
+++ b/components/password_manager/core/browser/password_form_manager.cc
@@ -14,6 +14,7 @@
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
+#include "base/stl_util.h"
#include "base/strings/string16.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
@@ -109,25 +110,16 @@ void SanitizePossibleUsernames(PasswordForm* form) {
// Deduplicate.
std::sort(usernames.begin(), usernames.end());
- auto new_end = std::unique(usernames.begin(), usernames.end());
+ usernames.erase(std::unique(usernames.begin(), usernames.end()),
+ usernames.end());
- // Filter out |form->username_value|.
+ // Filter out |form->username_value| and sensitive information.
const base::string16& username_value = form->username_value;
- new_end = std::remove_if(usernames.begin(), new_end,
- [&username_value](const PossibleUsernamePair& pair) {
- return pair.first == username_value;
- });
-
- // Filter out sensitive information.
- new_end = std::remove_if(
- usernames.begin(), new_end, [](const PossibleUsernamePair& pair) {
- return autofill::IsValidCreditCardNumber(pair.first);
- });
- new_end = std::remove_if(usernames.begin(), new_end,
- [](const PossibleUsernamePair& pair) {
- return autofill::IsSSN(pair.first);
- });
- usernames.erase(new_end, usernames.end());
+ base::EraseIf(usernames, [&username_value](const PossibleUsernamePair& pair) {
+ return pair.first == username_value ||
+ autofill::IsValidCreditCardNumber(pair.first) ||
+ autofill::IsSSN(pair.first);
+ });
}
// Copies field properties masks from the form |from| to the form |to|.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698