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

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

Issue 2298733002: Filter out credentials with non-matching schemes (Closed)
Patch Set: Created 4 years, 4 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 | components/password_manager/core/browser/password_form_manager_unittest.cc » ('j') | 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 d1f35e2b919dfc50bf189b55899d35c27e75c08a..6254471c1c2aa52fd0c595bcdb756d3939b708a0 100644
--- a/components/password_manager/core/browser/password_form_manager.cc
+++ b/components/password_manager/core/browser/password_form_manager.cc
@@ -481,16 +481,25 @@ void PasswordFormManager::ProcessMatches(
// Create a copy of |non_federated| which we can reorder and prune.
std::vector<const PasswordForm*> all_matches(non_federated);
- // The next step is to reorder |all_matches| into three consequent blocks:
+ // The next step is to reorder |all_matches| into four consequent blocks:
// (A) relevant blacklist entries
// (B) non-relevant blacklist entries
- // (C) non-blacklisted matches
+ // (C) relevant non-blacklisted matches
+ // (D) non-relevant non-blacklisted matches
auto begin_nonblacklisted = // start of block (C)
std::partition(
all_matches.begin(), all_matches.end(),
[](const PasswordForm* form) { return form->blacklisted_by_user; });
+ // Block (D) can be removed immediately.
+ const PasswordForm::Scheme observed_scheme = observed_form_.scheme;
+ all_matches.erase(std::remove_if(begin_nonblacklisted, all_matches.end(),
+ [observed_scheme](const PasswordForm* form) {
+ return form->scheme != observed_scheme;
+ }),
+ all_matches.end());
+
auto begin_nonrelevant = // start of block (B)
std::partition(
all_matches.begin(), begin_nonblacklisted,
« no previous file with comments | « no previous file | components/password_manager/core/browser/password_form_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698