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

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

Issue 283563002: Password Login Database: report correct changes from AddLogin(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: unused variable 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: chrome/browser/password_manager/native_backend_gnome_x.cc
diff --git a/chrome/browser/password_manager/native_backend_gnome_x.cc b/chrome/browser/password_manager/native_backend_gnome_x.cc
index ef33e1f4c13dfb7b6debc2627fff704cb896e8aa..460326776cc8c1db7704c7f988725e4f5196c3ac 100644
--- a/chrome/browser/password_manager/native_backend_gnome_x.cc
+++ b/chrome/browser/password_manager/native_backend_gnome_x.cc
@@ -534,7 +534,8 @@ bool NativeBackendGnome::RawAddLogin(const PasswordForm& form) {
return true;
}
-bool NativeBackendGnome::AddLogin(const PasswordForm& form) {
+password_manager::PasswordStoreChangeList NativeBackendGnome::AddLogin(
+ const PasswordForm& form) {
// Based on LoginDatabase::AddLogin(), we search for an existing match based
// on origin_url, username_element, username_value, password_element, submit
// element, and signon_realm first, remove that, and then add the new entry.
@@ -546,25 +547,31 @@ bool NativeBackendGnome::AddLogin(const PasswordForm& form) {
base::Bind(&GKRMethod::AddLoginSearch,
base::Unretained(&method),
form, app_string_.c_str()));
- PasswordFormList forms;
- GnomeKeyringResult result = method.WaitResult(&forms);
+ ScopedVector<autofill::PasswordForm> forms;
+ GnomeKeyringResult result = method.WaitResult(&forms.get());
if (result != GNOME_KEYRING_RESULT_OK &&
result != GNOME_KEYRING_RESULT_NO_MATCH) {
LOG(ERROR) << "Keyring find failed: "
<< gnome_keyring_result_to_message(result);
- return false;
+ return password_manager::PasswordStoreChangeList();
}
+ password_manager::PasswordStoreChangeList changes;
if (forms.size() > 0) {
if (forms.size() > 1) {
LOG(WARNING) << "Adding login when there are " << forms.size()
<< " matching logins already! Will replace only the first.";
}
- RemoveLogin(*forms[0]);
- for (size_t i = 0; i < forms.size(); ++i)
- delete forms[i];
+ if (RemoveLogin(*forms[0])) {
+ changes.push_back(password_manager::PasswordStoreChange(
+ password_manager::PasswordStoreChange::REMOVE, *forms[0]));
+ }
+ }
+ if (RawAddLogin(form)) {
+ changes.push_back(password_manager::PasswordStoreChange(
+ password_manager::PasswordStoreChange::ADD, form));
}
- return RawAddLogin(form);
+ return changes;
}
bool NativeBackendGnome::UpdateLogin(const PasswordForm& form) {

Powered by Google App Engine
This is Rietveld 408576698