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

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

Issue 2740523002: [Password Manager] Fix saving for accounts.google.com. (Closed)
Patch Set: Small coments fixes 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
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 8c6eb9e245138e3c5fc4be2c347353f0bf5b7186..af37be8c190d9edb7fa168b87ddadc97e390b164 100644
--- a/components/password_manager/core/browser/password_form_manager.cc
+++ b/components/password_manager/core/browser/password_form_manager.cc
@@ -286,9 +286,11 @@ base::string16 PasswordFormManager::PasswordToSave(const PasswordForm& form) {
return form.new_password_value;
}
-// TODO(timsteele): use a hash of some sort in the future?
+// TODO(crbug.com/700420): Refactor this function, to make comparison more
+// reliable.
PasswordFormManager::MatchResultMask PasswordFormManager::DoesManage(
- const PasswordForm& form) const {
+ const PasswordForm& form,
+ const password_manager::PasswordManagerDriver* driver) const {
// Non-HTML form case.
if (observed_form_.scheme != PasswordForm::SCHEME_HTML ||
form.scheme != PasswordForm::SCHEME_HTML) {
@@ -300,6 +302,9 @@ PasswordFormManager::MatchResultMask PasswordFormManager::DoesManage(
// HTML form case.
MatchResultMask result = RESULT_NO_MATCH;
+ if (observed_form_.signon_realm != form.signon_realm)
+ return result;
+
// Easiest case of matching origins.
bool origins_match = form.origin == observed_form_.origin;
// If this is a replay of the same form in the case a user entered an invalid
@@ -321,10 +326,18 @@ PasswordFormManager::MatchResultMask PasswordFormManager::DoesManage(
base::StartsWith(new_path, old_path, base::CompareCase::SENSITIVE);
}
+ if (driver)
+ origins_match =
+ origins_match ||
+ std::any_of(drivers_.begin(), drivers_.end(),
+ [driver](const base::WeakPtr<PasswordManagerDriver>& d) {
+ return d.get() == driver;
+ });
+
if (!origins_match)
return result;
- result |= RESULT_ORIGINS_MATCH;
+ result |= RESULT_ORIGINS_OR_FRAMES_MATCH;
// Autofill predictions can overwrite our default username selection so
// if this form was parsed with autofill predictions then allow the username
@@ -372,8 +385,6 @@ bool PasswordFormManager::IsPendingCredentialsPublicSuffixMatch() const {
void PasswordFormManager::ProvisionallySave(
const PasswordForm& credentials,
OtherPossibleUsernamesAction action) {
- DCHECK_NE(RESULT_NO_MATCH, DoesManage(credentials));
-
std::unique_ptr<autofill::PasswordForm> mutable_submitted_form(
new PasswordForm(credentials));
if (credentials.IsPossibleChangePasswordForm() &&

Powered by Google App Engine
This is Rietveld 408576698