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

Unified Diff: chrome/browser/password_manager/password_store_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/password_store_x.cc
diff --git a/chrome/browser/password_manager/password_store_x.cc b/chrome/browser/password_manager/password_store_x.cc
index 36e0bc80f6774cc0734492d5f1cf56a474126fbc..d6e4a3966bfa7599e812b790e1fa81d99a574057 100644
--- a/chrome/browser/password_manager/password_store_x.cc
+++ b/chrome/browser/password_manager/password_store_x.cc
@@ -26,6 +26,18 @@ using password_manager::PasswordStoreChangeList;
using password_manager::PasswordStoreDefault;
using std::vector;
+namespace {
+
+bool AddLoginToBackend(const scoped_ptr<PasswordStoreX::NativeBackend>& backend,
+ const PasswordForm& form,
+ PasswordStoreChangeList* changes) {
+ *changes = backend->AddLogin(form);
+ return (!changes->empty() &&
+ changes->back().type() == PasswordStoreChange::ADD);
+}
+
+} // namespace
+
PasswordStoreX::PasswordStoreX(
scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner,
scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner,
@@ -41,8 +53,7 @@ PasswordStoreX::~PasswordStoreX() {}
PasswordStoreChangeList PasswordStoreX::AddLoginImpl(const PasswordForm& form) {
CheckMigration();
PasswordStoreChangeList changes;
- if (use_native_backend() && backend_->AddLogin(form)) {
- changes.push_back(PasswordStoreChange(PasswordStoreChange::ADD, form));
+ if (use_native_backend() && AddLoginToBackend(backend_, form, &changes)) {
allow_fallback_ = false;
} else if (allow_default_store()) {
changes = PasswordStoreDefault::AddLoginImpl(form);
@@ -237,7 +248,8 @@ ssize_t PasswordStoreX::MigrateLogins() {
// don't somehow end up with some of the passwords in one store and some in
// another. We'll always have at least one intact store this way.
for (size_t i = 0; i < forms.size(); ++i) {
- if (!backend_->AddLogin(*forms[i])) {
+ PasswordStoreChangeList changes;
+ if (!AddLoginToBackend(backend_, *forms[i], &changes)) {
ok = false;
break;
}
« no previous file with comments | « chrome/browser/password_manager/password_store_x.h ('k') | chrome/browser/password_manager/password_store_x_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698