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

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: Fixed compile error for browsertests Created 7 years, 7 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..3f732ff8cb88fe07a7780f532bc9e139eba26860 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;
+}
+
void PasswordFormManager::Save() {
DCHECK_EQ(state_, POST_MATCHING_PHASE);
DCHECK(!profile_->IsOffTheRecord());
@@ -342,7 +349,8 @@ void PasswordFormManager::OnRequestDone(
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 +388,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 &&
+ !observed_form_.ssl_valid &&
+ !form.is_psl_origin_match) {
return true;
}
return false;
@@ -540,7 +550,7 @@ int PasswordFormManager::ScoreResult(const PasswordForm& candidate) const {
// 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 +565,12 @@ 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) {
+ // PSL origin matched domains should have lower score than perfect matches.
+ 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