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

Unified Diff: chrome/browser/password_manager/password_form_manager.cc

Issue 15660018: [autofill] Add support for PSL domain matching for password autofill. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated regexp, sanitized result, escaped form domain and added comments. Created 7 years, 6 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
Index: chrome/browser/password_manager/password_form_manager.cc
diff --git a/chrome/browser/password_manager/password_form_manager.cc b/chrome/browser/password_manager/password_form_manager.cc
index de736eb0480676235ab60efeb5e524aabd3f8b42..3f7f7d8f7e34f8e0c6b13933f73e6adad70db1a2 100644
--- a/chrome/browser/password_manager/password_form_manager.cc
+++ b/chrome/browser/password_manager/password_form_manager.cc
@@ -189,7 +189,10 @@ void PasswordFormManager::ProvisionallySave(
if (it != best_matches_.end()) {
// The user signed in with a login we autofilled.
pending_credentials_ = *it->second;
- is_new_login_ = false;
+
+ // PSL origin matches should always be new logins, since we want to store
+ // them so they can automatically be filled in later.
+ is_new_login_ = pending_credentials_.is_psl_origin_match;
// Check to see if we're using a known username but a new password.
if (pending_credentials_.password_value != credentials.password_value)
@@ -226,6 +229,10 @@ void PasswordFormManager::ProvisionallySave(
pending_credentials_.type = PasswordForm::TYPE_GENERATED;
}
+bool PasswordFormManager::IsPSLOriginMatched() {
+ return pending_credentials_.is_psl_origin_match;
palmer 2013/06/06 21:16:42 Nit: Some people prefer to see these getter functi
nyquist 2013/06/07 22:51:10 Done.
+}
+
void PasswordFormManager::Save() {
DCHECK_EQ(state_, POST_MATCHING_PHASE);
DCHECK(!profile_->IsOffTheRecord());
@@ -337,12 +344,14 @@ void PasswordFormManager::OnRequestDone(
SendNotBlacklistedToRenderer();
// Proceed to autofill.
- // Note that we provide the choices but don't actually prefill a value if
- // either: (1) we are in Incognito mode, or (2) the ACTION paths don't match.
+ // Note that we provide the choices but don't actually prefill a value if:
+ // (1) we are in Incognito mode, (2) the ACTION paths don't match,
+ // or (3) if it matched using PSL domain matching.
bool wait_for_username =
profile_->IsOffTheRecord() ||
observed_form_.action.GetWithEmptyPath() !=
- preferred_match_->action.GetWithEmptyPath();
+ preferred_match_->action.GetWithEmptyPath() ||
+ preferred_match_->is_psl_origin_match;
if (wait_for_username)
manager_action_ = kManagerActionNone;
else
@@ -380,8 +389,10 @@ bool PasswordFormManager::IgnoreResult(const PasswordForm& form) const {
return true;
}
// Don't match an invalid SSL form with one saved under secure
- // circumstances.
- if (form.ssl_valid && !observed_form_.ssl_valid) {
+ // circumstances unless it was found as a PSL origin domain match.
+ if (form.ssl_valid &&
palmer 2013/06/06 21:16:42 Hmm, I am not sure I like either the old or the ne
nyquist 2013/06/07 22:51:10 I've gone back to the old way which never autofill
+ !observed_form_.ssl_valid &&
+ !form.is_psl_origin_match) {
return true;
}
return false;
@@ -528,19 +539,20 @@ int PasswordFormManager::ScoreResult(const PasswordForm& candidate) const {
// The most important element that should match is the origin, followed by
// the action, the password name, the submit button name, and finally the
// username input field name.
- // Exact origin match gives an addition of 32 (1 << 5) + # of matching url
+ // Exact origin match gives an addition of 64 (1 << 6) + # of matching url
// dirs.
- // Partial match gives an addition of 16 (1 << 4) + # matching url dirs
+ // Partial match gives an addition of 16 (1 << 5) + # matching url dirs
Ilya Sherman 2013/06/06 09:25:35 16 -> 32?
nyquist 2013/06/07 22:51:10 Done.
// That way, a partial match cannot trump an exact match even if
// the partial one matches all other attributes (action, elements) (and
// regardless of the matching depth in the URL path).
+ // If PSL origin match was not used, it gives an addition of 16 (1 << 4).
int score = 0;
if (candidate.origin == observed_form_.origin) {
// This check is here for the most common case which
// is we have a single match in the db for the given host,
// so we don't generally need to walk the entire URL path (the else
// clause).
- score += (1 << 5) + static_cast<int>(form_path_tokens_.size());
+ score += (1 << 6) + static_cast<int>(form_path_tokens_.size());
} else {
// Walk the origin URL paths one directory at a time to see how
// deep the two match.
@@ -555,9 +567,11 @@ int PasswordFormManager::ScoreResult(const PasswordForm& candidate) const {
score++;
}
// do we have a partial match?
- score += (depth > 0) ? 1 << 4 : 0;
+ score += (depth > 0) ? 1 << 5 : 0;
}
if (observed_form_.scheme == PasswordForm::SCHEME_HTML) {
+ if (!candidate.is_psl_origin_match)
+ score += 1 << 4;
if (candidate.action == observed_form_.action)
score += 1 << 3;
if (candidate.password_element == observed_form_.password_element)

Powered by Google App Engine
This is Rietveld 408576698