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

Side by Side Diff: chrome/browser/password_manager/native_backend_kwallet_x.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/password_manager/native_backend_kwallet_x.h" 5 #include "chrome/browser/password_manager/native_backend_kwallet_x.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 changes.push_back(password_manager::PasswordStoreChange( 294 changes.push_back(password_manager::PasswordStoreChange(
295 password_manager::PasswordStoreChange::ADD, form)); 295 password_manager::PasswordStoreChange::ADD, form));
296 296
297 bool ok = SetLoginsList(forms.get(), form.signon_realm, wallet_handle); 297 bool ok = SetLoginsList(forms.get(), form.signon_realm, wallet_handle);
298 if (!ok) 298 if (!ok)
299 changes.clear(); 299 changes.clear();
300 300
301 return changes; 301 return changes;
302 } 302 }
303 303
304 bool NativeBackendKWallet::UpdateLogin(const PasswordForm& form) { 304 bool NativeBackendKWallet::UpdateLogin(
305 const PasswordForm& form,
306 password_manager::PasswordStoreChangeList* changes) {
307 DCHECK(changes);
308 changes->clear();
305 int wallet_handle = WalletHandle(); 309 int wallet_handle = WalletHandle();
306 if (wallet_handle == kInvalidKWalletHandle) 310 if (wallet_handle == kInvalidKWalletHandle)
307 return false; 311 return false;
308 312
309 PasswordFormList forms; 313 ScopedVector<autofill::PasswordForm> forms;
310 GetLoginsList(&forms, form.signon_realm, wallet_handle); 314 GetLoginsList(&forms.get(), form.signon_realm, wallet_handle);
311 315
316 bool updated = false;
312 for (size_t i = 0; i < forms.size(); ++i) { 317 for (size_t i = 0; i < forms.size(); ++i) {
313 if (CompareForms(form, *forms[i], true)) 318 if (CompareForms(form, *forms[i], true)) {
314 *forms[i] = form; 319 *forms[i] = form;
320 updated = true;
321 }
322 }
323 if (!updated)
324 return true;
325
326 if (SetLoginsList(forms.get(), form.signon_realm, wallet_handle)) {
327 changes->push_back(password_manager::PasswordStoreChange(
328 password_manager::PasswordStoreChange::UPDATE, form));
329 return true;
315 } 330 }
316 331
317 bool ok = SetLoginsList(forms, form.signon_realm, wallet_handle); 332 return false;
318
319 STLDeleteElements(&forms);
320 return ok;
321 } 333 }
322 334
323 bool NativeBackendKWallet::RemoveLogin(const PasswordForm& form) { 335 bool NativeBackendKWallet::RemoveLogin(const PasswordForm& form) {
324 int wallet_handle = WalletHandle(); 336 int wallet_handle = WalletHandle();
325 if (wallet_handle == kInvalidKWalletHandle) 337 if (wallet_handle == kInvalidKWalletHandle)
326 return false; 338 return false;
327 339
328 PasswordFormList all_forms; 340 PasswordFormList all_forms;
329 GetLoginsList(&all_forms, form.signon_realm, wallet_handle); 341 GetLoginsList(&all_forms, form.signon_realm, wallet_handle);
330 342
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 } 934 }
923 935
924 return handle; 936 return handle;
925 } 937 }
926 938
927 std::string NativeBackendKWallet::GetProfileSpecificFolderName() const { 939 std::string NativeBackendKWallet::GetProfileSpecificFolderName() const {
928 // Originally, the folder name was always just "Chrome Form Data". 940 // Originally, the folder name was always just "Chrome Form Data".
929 // Now we use it to distinguish passwords for different profiles. 941 // Now we use it to distinguish passwords for different profiles.
930 return base::StringPrintf("%s (%d)", kKWalletFolder, profile_id_); 942 return base::StringPrintf("%s (%d)", kKWalletFolder, profile_id_);
931 } 943 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698