diff options
author | zork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-11 23:15:23 +0000 |
---|---|---|
committer | zork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-11 23:15:23 +0000 |
commit | f3f948d10db9eeff0980cc9020c895ccb8c0dd42 (patch) | |
tree | 4805dd68ed6244d2cf7f55bce06e6b6bc6b7b8f4 /chrome | |
parent | a70d9cf0db8414b4495de849004157cb32658975 (diff) | |
download | chromium_src-f3f948d10db9eeff0980cc9020c895ccb8c0dd42.zip chromium_src-f3f948d10db9eeff0980cc9020c895ccb8c0dd42.tar.gz chromium_src-f3f948d10db9eeff0980cc9020c895ccb8c0dd42.tar.bz2 |
Update password store for sync
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/1999005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46978 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
6 files changed, 63 insertions, 5 deletions
diff --git a/chrome/browser/password_manager/password_manager_unittest.cc b/chrome/browser/password_manager/password_manager_unittest.cc index 8bb6fc7..7d21c47 100644 --- a/chrome/browser/password_manager/password_manager_unittest.cc +++ b/chrome/browser/password_manager/password_manager_unittest.cc @@ -53,6 +53,10 @@ class MockPasswordStore : public PasswordStore { MOCK_METHOD2(GetLoginsImpl, void(GetLoginsRequest*, const PasswordForm&)); MOCK_METHOD1(GetAutofillableLoginsImpl, void(GetLoginsRequest*)); MOCK_METHOD1(GetBlacklistLoginsImpl, void(GetLoginsRequest*)); + MOCK_METHOD1(FillAutofillableLogins, + bool(std::vector<webkit_glue::PasswordForm*>*)); + MOCK_METHOD1(FillBlacklistLogins, + bool(std::vector<webkit_glue::PasswordForm*>*)); }; ACTION_P2(InvokeConsumer, handle, forms) { diff --git a/chrome/browser/password_manager/password_store.h b/chrome/browser/password_manager/password_store.h index d105240..b2e6ef0 100644 --- a/chrome/browser/password_manager/password_store.h +++ b/chrome/browser/password_manager/password_store.h @@ -17,6 +17,12 @@ class Profile; class Task; +namespace browser_sync { +class PasswordDataTypeController; +class PasswordModelAssociator; +class PasswordModelWorker; +}; + class PasswordStoreConsumer { public: virtual ~PasswordStoreConsumer() {} @@ -70,6 +76,9 @@ class PasswordStore : public base::RefCountedThreadSafe<PasswordStore> { protected: friend class base::RefCountedThreadSafe<PasswordStore>; + friend class browser_sync::PasswordDataTypeController; + friend class browser_sync::PasswordModelAssociator; + friend class browser_sync::PasswordModelWorker; virtual ~PasswordStore() {} @@ -113,6 +122,13 @@ class PasswordStore : public base::RefCountedThreadSafe<PasswordStore> { // Finds all blacklist PasswordForms, and notifies the consumer. virtual void GetBlacklistLoginsImpl(GetLoginsRequest* request) = 0; + // Finds all non-blacklist PasswordForms, and fills the vector. + virtual bool FillAutofillableLogins( + std::vector<webkit_glue::PasswordForm*>* forms) = 0; + // Finds all blacklist PasswordForms, and fills the vector. + virtual bool FillBlacklistLogins( + std::vector<webkit_glue::PasswordForm*>* forms) = 0; + // Notifies the consumer that a Get*Logins() request is complete. virtual void NotifyConsumer( GetLoginsRequest* request, diff --git a/chrome/browser/password_manager/password_store_default.cc b/chrome/browser/password_manager/password_store_default.cc index 6c0a8fe..781b37c 100644 --- a/chrome/browser/password_manager/password_store_default.cc +++ b/chrome/browser/password_manager/password_store_default.cc @@ -2,8 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/password_manager/password_store_change.h" #include "chrome/browser/password_manager/password_store_default.h" + +#include "chrome/browser/chrome_thread.h" +#include "chrome/browser/password_manager/password_store_change.h" #include "chrome/browser/pref_service.h" #include "chrome/browser/webdata/web_data_service.h" #include "chrome/common/chrome_constants.h" @@ -91,17 +93,29 @@ void PasswordStoreDefault::GetLoginsImpl( void PasswordStoreDefault::GetAutofillableLoginsImpl( GetLoginsRequest* request) { std::vector<PasswordForm*> forms; - login_db_->GetAutofillableLogins(&forms); + FillAutofillableLogins(&forms); NotifyConsumer(request, forms); } void PasswordStoreDefault::GetBlacklistLoginsImpl( GetLoginsRequest* request) { std::vector<PasswordForm*> forms; - login_db_->GetBlacklistLogins(&forms); + FillBlacklistLogins(&forms); NotifyConsumer(request, forms); } +bool PasswordStoreDefault::FillAutofillableLogins( + std::vector<PasswordForm*>* forms) { + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::DB)); + return login_db_->GetAutofillableLogins(forms); +} + +bool PasswordStoreDefault::FillBlacklistLogins( + std::vector<PasswordForm*>* forms) { + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::DB)); + return login_db_->GetBlacklistLogins(forms); +} + void PasswordStoreDefault::MigrateIfNecessary() { PrefService* prefs = profile_->GetPrefs(); if (prefs->FindPreference(prefs::kLoginDatabaseMigrated)) diff --git a/chrome/browser/password_manager/password_store_default.h b/chrome/browser/password_manager/password_store_default.h index 47408fb..4243812 100644 --- a/chrome/browser/password_manager/password_store_default.h +++ b/chrome/browser/password_manager/password_store_default.h @@ -40,6 +40,10 @@ class PasswordStoreDefault : public PasswordStore, const webkit_glue::PasswordForm& form); void GetAutofillableLoginsImpl(GetLoginsRequest* request); void GetBlacklistLoginsImpl(GetLoginsRequest* request); + bool FillAutofillableLogins( + std::vector<webkit_glue::PasswordForm*>* forms); + bool FillBlacklistLogins( + std::vector<webkit_glue::PasswordForm*>* forms); scoped_refptr<WebDataService> web_data_service_; diff --git a/chrome/browser/password_manager/password_store_mac.cc b/chrome/browser/password_manager/password_store_mac.cc index 02f7eef..d31e89b 100644 --- a/chrome/browser/password_manager/password_store_mac.cc +++ b/chrome/browser/password_manager/password_store_mac.cc @@ -883,12 +883,21 @@ void PasswordStoreMac::GetLoginsImpl(GetLoginsRequest* request, void PasswordStoreMac::GetBlacklistLoginsImpl(GetLoginsRequest* request) { std::vector<PasswordForm*> database_forms; - login_metadata_db_->GetBlacklistLogins(&database_forms); + FillBlacklistLogins(&database_forms); NotifyConsumer(request, database_forms); } void PasswordStoreMac::GetAutofillableLoginsImpl(GetLoginsRequest* request) { std::vector<PasswordForm*> database_forms; + FillAutofillableLogins(&database_forms); + NotifyConsumer(request, database_forms); +} + +bool PasswordStoreMac::FillAutofillableLogins( + std::vector<PasswordForm*>* forms) { + DCHECK(thread_->message_loop() == MessageLoop::current()); + + std::vector<PasswordForm*> database_forms; login_metadata_db_->GetAutofillableLogins(&database_forms); std::vector<PasswordForm*> merged_forms = @@ -899,7 +908,14 @@ void PasswordStoreMac::GetAutofillableLoginsImpl(GetLoginsRequest* request) { RemoveDatabaseForms(database_forms); STLDeleteElements(&database_forms); - NotifyConsumer(request, merged_forms); + forms->insert(forms->end(), merged_forms.begin(), merged_forms.end()); + return true; +} + +bool PasswordStoreMac::FillBlacklistLogins( + std::vector<PasswordForm*>* forms) { + DCHECK(thread_->message_loop() == MessageLoop::current()); + return login_metadata_db_->GetBlacklistLogins(forms); } bool PasswordStoreMac::AddToKeychainIfNecessary(const PasswordForm& form) { diff --git a/chrome/browser/password_manager/password_store_mac.h b/chrome/browser/password_manager/password_store_mac.h index 36dc7b4..381cb81 100644 --- a/chrome/browser/password_manager/password_store_mac.h +++ b/chrome/browser/password_manager/password_store_mac.h @@ -45,6 +45,10 @@ class PasswordStoreMac : public PasswordStore { const webkit_glue::PasswordForm& form); void GetAutofillableLoginsImpl(GetLoginsRequest* request); void GetBlacklistLoginsImpl(GetLoginsRequest* request); + bool FillAutofillableLogins( + std::vector<webkit_glue::PasswordForm*>* forms); + bool FillBlacklistLogins( + std::vector<webkit_glue::PasswordForm*>* forms); // Adds the given form to the Keychain if it's something we want to store // there (i.e., not a blacklist entry). Returns true if the operation |