#include "base/basictypes.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
-#include "base/file_util.h"
+#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
-#include "base/platform_file.h"
#include "base/prefs/pref_service.h"
#include "base/run_loop.h"
#include "base/stl_util.h"
using content::BrowserThread;
using password_manager::ContainsAllPasswordForms;
using password_manager::PasswordStoreChange;
+using password_manager::PasswordStoreChangeList;
using testing::_;
using testing::DoAll;
using testing::ElementsAreArray;
public:
virtual bool Init() OVERRIDE { return true; }
- virtual bool AddLogin(const PasswordForm& form) OVERRIDE { return false; }
- virtual bool UpdateLogin(const PasswordForm& form) OVERRIDE { return false; }
+ virtual PasswordStoreChangeList AddLogin(const PasswordForm& form) OVERRIDE {
+ return PasswordStoreChangeList();
+ }
+ virtual bool UpdateLogin(const PasswordForm& form,
+ PasswordStoreChangeList* changes) OVERRIDE {
+ return false;
+ }
virtual bool RemoveLogin(const PasswordForm& form) OVERRIDE { return false; }
virtual bool RemoveLoginsCreatedBetween(
- const base::Time& delete_begin,
- const base::Time& delete_end) OVERRIDE {
+ base::Time delete_begin,
+ base::Time delete_end,
+ password_manager::PasswordStoreChangeList* changes) OVERRIDE {
return false;
}
- virtual bool GetLogins(const PasswordForm& form,
- PasswordFormList* forms) OVERRIDE {
+ virtual bool RemoveLoginsSyncedBetween(
+ base::Time delete_begin,
+ base::Time delete_end,
+ password_manager::PasswordStoreChangeList* changes) OVERRIDE {
return false;
}
- virtual bool GetLoginsCreatedBetween(const base::Time& get_begin,
- const base::Time& get_end,
- PasswordFormList* forms) OVERRIDE {
+ virtual bool GetLogins(const PasswordForm& form,
+ PasswordFormList* forms) OVERRIDE {
return false;
}
public:
virtual bool Init() OVERRIDE { return true; }
- virtual bool AddLogin(const PasswordForm& form) OVERRIDE {
+ virtual PasswordStoreChangeList AddLogin(const PasswordForm& form) OVERRIDE {
all_forms_.push_back(form);
- return true;
+ PasswordStoreChange change(PasswordStoreChange::ADD, form);
+ return PasswordStoreChangeList(1, change);
}
- virtual bool UpdateLogin(const PasswordForm& form) OVERRIDE {
+ virtual bool UpdateLogin(const PasswordForm& form,
+ PasswordStoreChangeList* changes) OVERRIDE {
for (size_t i = 0; i < all_forms_.size(); ++i)
- if (CompareForms(all_forms_[i], form, true))
+ if (CompareForms(all_forms_[i], form, true)) {
all_forms_[i] = form;
+ changes->push_back(PasswordStoreChange(PasswordStoreChange::UPDATE,
+ form));
+ }
return true;
}
}
virtual bool RemoveLoginsCreatedBetween(
- const base::Time& delete_begin,
- const base::Time& delete_end) OVERRIDE {
+ base::Time delete_begin,
+ base::Time delete_end,
+ password_manager::PasswordStoreChangeList* changes) OVERRIDE {
for (size_t i = 0; i < all_forms_.size(); ++i) {
if (delete_begin <= all_forms_[i].date_created &&
(delete_end.is_null() || all_forms_[i].date_created < delete_end))
return true;
}
- virtual bool GetLogins(const PasswordForm& form,
- PasswordFormList* forms) OVERRIDE {
- for (size_t i = 0; i < all_forms_.size(); ++i)
- if (all_forms_[i].signon_realm == form.signon_realm)
- forms->push_back(new PasswordForm(all_forms_[i]));
+ virtual bool RemoveLoginsSyncedBetween(
+ base::Time delete_begin,
+ base::Time delete_end,
+ password_manager::PasswordStoreChangeList* changes) OVERRIDE {
+ DCHECK(changes);
+ for (size_t i = 0; i < all_forms_.size(); ++i) {
+ if (delete_begin <= all_forms_[i].date_synced &&
+ (delete_end.is_null() || all_forms_[i].date_synced < delete_end)) {
+ changes->push_back(password_manager::PasswordStoreChange(
+ password_manager::PasswordStoreChange::REMOVE, all_forms_[i]));
+ erase(i--);
+ }
+ }
return true;
}
- virtual bool GetLoginsCreatedBetween(const base::Time& get_begin,
- const base::Time& get_end,
- PasswordFormList* forms) OVERRIDE {
+ virtual bool GetLogins(const PasswordForm& form,
+ PasswordFormList* forms) OVERRIDE {
for (size_t i = 0; i < all_forms_.size(); ++i)
- if (get_begin <= all_forms_[i].date_created &&
- (get_end.is_null() || all_forms_[i].date_created < get_end))
+ if (all_forms_[i].signon_realm == form.signon_realm)
forms->push_back(new PasswordForm(all_forms_[i]));
return true;
}
base::MessageLoopProxy::current(),
login_db_.release(),
GetBackend()));
- store->Init(syncer::SyncableService::StartSyncFlare());
+ store->Init(syncer::SyncableService::StartSyncFlare(), "");
password_manager::PasswordFormData form_data = {
PasswordForm::SCHEME_HTML, "http://bar.example.com",
base::MessageLoopProxy::current(),
login_db_.release(),
GetBackend()));
- store->Init(syncer::SyncableService::StartSyncFlare());
+ store->Init(syncer::SyncableService::StartSyncFlare(), "");
MockPasswordStoreConsumer consumer;