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

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

Issue 283563002: Password Login Database: report correct changes from AddLogin(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: the nit addressed 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_kwallet_x.cc
diff --git a/chrome/browser/password_manager/native_backend_kwallet_x.cc b/chrome/browser/password_manager/native_backend_kwallet_x.cc
index 03cecfe265149e6c7ee3d62b15767cbb5e55ec9b..c9ec8c4d9ffdea5ed76df923fa62877505365503 100644
--- a/chrome/browser/password_manager/native_backend_kwallet_x.cc
+++ b/chrome/browser/password_manager/native_backend_kwallet_x.cc
@@ -265,33 +265,40 @@ NativeBackendKWallet::InitResult NativeBackendKWallet::InitWallet() {
return INIT_SUCCESS;
}
-bool NativeBackendKWallet::AddLogin(const PasswordForm& form) {
+password_manager::PasswordStoreChangeList NativeBackendKWallet::AddLogin(
+ const PasswordForm& form) {
int wallet_handle = WalletHandle();
if (wallet_handle == kInvalidKWalletHandle)
- return false;
+ return password_manager::PasswordStoreChangeList();
- PasswordFormList forms;
- GetLoginsList(&forms, form.signon_realm, wallet_handle);
+ ScopedVector<autofill::PasswordForm> forms;
+ GetLoginsList(&forms.get(), form.signon_realm, wallet_handle);
// We search for a login to update, rather than unconditionally appending the
// login, because in some cases (especially involving sync) we can be asked to
// add a login that already exists. In these cases we want to just update.
bool updated = false;
+ password_manager::PasswordStoreChangeList changes;
for (size_t i = 0; i < forms.size(); ++i) {
// Use the more restrictive removal comparison, so that we never have
// duplicate logins that would all be removed together by RemoveLogin().
if (CompareForms(form, *forms[i], false)) {
+ changes.push_back(password_manager::PasswordStoreChange(
+ password_manager::PasswordStoreChange::REMOVE, *forms[i]));
*forms[i] = form;
updated = true;
}
}
if (!updated)
forms.push_back(new PasswordForm(form));
+ changes.push_back(password_manager::PasswordStoreChange(
+ password_manager::PasswordStoreChange::ADD, form));
- bool ok = SetLoginsList(forms, form.signon_realm, wallet_handle);
+ bool ok = SetLoginsList(forms.get(), form.signon_realm, wallet_handle);
+ if (!ok)
+ changes.clear();
- STLDeleteElements(&forms);
- return ok;
+ return changes;
}
bool NativeBackendKWallet::UpdateLogin(const PasswordForm& form) {

Powered by Google App Engine
This is Rietveld 408576698