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

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

Issue 299443002: Password Login Database: report correct changes from UpdateLogin(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added UpdateNonexistentLogin tests Created 6 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: 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 ed2981c663a507e5d0aa4c5e4056d99678c34574..5f7d21fe499d74f674d9b1950df562abe54acdb1 100644
--- a/components/password_manager/core/browser/password_form_manager.cc
+++ b/components/password_manager/core/browser/password_form_manager.cc
@@ -270,13 +270,6 @@ void PasswordFormManager::ProvisionallySave(
// bless it with the action URL from the observed form. See bug 1107719.
if (pending_credentials_.action.is_empty())
pending_credentials_.action = observed_form_.action;
- // Similarly, bless incomplete credentials with *_element info.
- if (pending_credentials_.password_element.empty())
- pending_credentials_.password_element = observed_form_.password_element;
- if (pending_credentials_.username_element.empty())
- pending_credentials_.username_element = observed_form_.username_element;
- if (pending_credentials_.submit_element.empty())
- pending_credentials_.submit_element = observed_form_.submit_element;
pending_credentials_.password_value = credentials.password_value;
pending_credentials_.preferred = credentials.preferred;
@@ -581,6 +574,17 @@ void PasswordFormManager::UpdateLogin() {
copy.origin = observed_form_.origin;
copy.action = observed_form_.action;
password_store->AddLogin(copy);
+ } else if (pending_credentials_.password_element.empty() ||
+ pending_credentials_.username_element.empty() ||
+ pending_credentials_.submit_element.empty()) {
+ // password_element and username_element can't be updated because they are
+ // part of Sync and PasswordStore primary key. Thus, we must delete the old
+ // one and add again.
+ password_store->RemoveLogin(pending_credentials_);
+ pending_credentials_.password_element = observed_form_.password_element;
+ pending_credentials_.username_element = observed_form_.username_element;
+ pending_credentials_.submit_element = observed_form_.submit_element;
+ password_store->AddLogin(pending_credentials_);
} else {
password_store->UpdateLogin(pending_credentials_);
}

Powered by Google App Engine
This is Rietveld 408576698