| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_PROXY_MAC_H_ | 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_PROXY_MAC_H_ |
| 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_PROXY_MAC_H_ | 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_PROXY_MAC_H_ |
| 7 | 7 |
| 8 #include "base/threading/thread.h" |
| 8 #include "components/password_manager/core/browser/password_store.h" | 9 #include "components/password_manager/core/browser/password_store.h" |
| 9 | 10 |
| 10 namespace crypto { | 11 namespace crypto { |
| 11 class AppleKeychain; | 12 class AppleKeychain; |
| 12 } | 13 } |
| 13 | 14 |
| 14 namespace password_manager { | 15 namespace password_manager { |
| 15 class LoginDatabase; | 16 class LoginDatabase; |
| 16 } | 17 } |
| 17 | 18 |
| 18 class PasswordStoreMac; | 19 class PasswordStoreMac; |
| 19 class SimplePasswordStoreMac; | 20 class SimplePasswordStoreMac; |
| 20 | 21 |
| 21 // The class is a proxy for either PasswordStoreMac or SimplePasswordStoreMac. | 22 // The class is a proxy for either PasswordStoreMac or SimplePasswordStoreMac. |
| 22 // It is responsible for performing migration from PasswordStoreMac to | 23 // It is responsible for performing migration from PasswordStoreMac to |
| 23 // SimplePasswordStoreMac and instantiating a correct backend according to the | 24 // SimplePasswordStoreMac and instantiating a correct backend according to the |
| 24 // user's state. | 25 // user's state. |
| 25 class PasswordStoreProxyMac : public password_manager::PasswordStore { | 26 class PasswordStoreProxyMac : public password_manager::PasswordStore { |
| 26 public: | 27 public: |
| 27 PasswordStoreProxyMac( | 28 PasswordStoreProxyMac( |
| 28 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner, | 29 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner, |
| 29 scoped_ptr<crypto::AppleKeychain> keychain, | 30 scoped_ptr<crypto::AppleKeychain> keychain, |
| 30 scoped_ptr<password_manager::LoginDatabase> login_db); | 31 scoped_ptr<password_manager::LoginDatabase> login_db); |
| 31 | 32 |
| 32 bool Init(const syncer::SyncableService::StartSyncFlare& flare) override; | 33 bool Init(const syncer::SyncableService::StartSyncFlare& flare) override; |
| 33 void Shutdown() override; | 34 void Shutdown() override; |
| 35 scoped_refptr<base::SingleThreadTaskRunner> GetBackgroundTaskRunner() |
| 36 override; |
| 37 |
| 38 #if defined(UNIT_TEST) |
| 39 password_manager::LoginDatabase* login_metadata_db() { |
| 40 return login_metadata_db_.get(); |
| 41 } |
| 42 #endif |
| 34 | 43 |
| 35 private: | 44 private: |
| 36 ~PasswordStoreProxyMac() override; | 45 ~PasswordStoreProxyMac() override; |
| 37 | 46 |
| 38 password_manager::PasswordStore* GetBackend() const; | 47 password_manager::PasswordStore* GetBackend() const; |
| 39 | 48 |
| 49 // Opens LoginDatabase on the background |thread_|. |
| 50 void InitOnBackgroundThread(); |
| 51 |
| 40 // PasswordStore: | 52 // PasswordStore: |
| 41 scoped_refptr<base::SingleThreadTaskRunner> GetBackgroundTaskRunner() | |
| 42 override; | |
| 43 void ReportMetricsImpl(const std::string& sync_username, | 53 void ReportMetricsImpl(const std::string& sync_username, |
| 44 bool custom_passphrase_sync_enabled) override; | 54 bool custom_passphrase_sync_enabled) override; |
| 45 password_manager::PasswordStoreChangeList AddLoginImpl( | 55 password_manager::PasswordStoreChangeList AddLoginImpl( |
| 46 const autofill::PasswordForm& form) override; | 56 const autofill::PasswordForm& form) override; |
| 47 password_manager::PasswordStoreChangeList UpdateLoginImpl( | 57 password_manager::PasswordStoreChangeList UpdateLoginImpl( |
| 48 const autofill::PasswordForm& form) override; | 58 const autofill::PasswordForm& form) override; |
| 49 password_manager::PasswordStoreChangeList RemoveLoginImpl( | 59 password_manager::PasswordStoreChangeList RemoveLoginImpl( |
| 50 const autofill::PasswordForm& form) override; | 60 const autofill::PasswordForm& form) override; |
| 51 password_manager::PasswordStoreChangeList RemoveLoginsCreatedBetweenImpl( | 61 password_manager::PasswordStoreChangeList RemoveLoginsCreatedBetweenImpl( |
| 52 base::Time delete_begin, | 62 base::Time delete_begin, |
| 53 base::Time delete_end) override; | 63 base::Time delete_end) override; |
| 54 password_manager::PasswordStoreChangeList RemoveLoginsSyncedBetweenImpl( | 64 password_manager::PasswordStoreChangeList RemoveLoginsSyncedBetweenImpl( |
| 55 base::Time delete_begin, | 65 base::Time delete_begin, |
| 56 base::Time delete_end) override; | 66 base::Time delete_end) override; |
| 57 ScopedVector<autofill::PasswordForm> FillMatchingLogins( | 67 ScopedVector<autofill::PasswordForm> FillMatchingLogins( |
| 58 const autofill::PasswordForm& form, | 68 const autofill::PasswordForm& form, |
| 59 AuthorizationPromptPolicy prompt_policy) override; | 69 AuthorizationPromptPolicy prompt_policy) override; |
| 60 void GetAutofillableLoginsImpl( | |
| 61 scoped_ptr<PasswordStore::GetLoginsRequest> request) override; | |
| 62 void GetBlacklistLoginsImpl( | |
| 63 scoped_ptr<PasswordStore::GetLoginsRequest> request) override; | |
| 64 bool FillAutofillableLogins( | 70 bool FillAutofillableLogins( |
| 65 ScopedVector<autofill::PasswordForm>* forms) override; | 71 ScopedVector<autofill::PasswordForm>* forms) override; |
| 66 bool FillBlacklistLogins( | 72 bool FillBlacklistLogins( |
| 67 ScopedVector<autofill::PasswordForm>* forms) override; | 73 ScopedVector<autofill::PasswordForm>* forms) override; |
| 68 void AddSiteStatsImpl( | 74 void AddSiteStatsImpl( |
| 69 const password_manager::InteractionsStats& stats) override; | 75 const password_manager::InteractionsStats& stats) override; |
| 70 void RemoveSiteStatsImpl(const GURL& origin_domain) override; | 76 void RemoveSiteStatsImpl(const GURL& origin_domain) override; |
| 71 scoped_ptr<password_manager::InteractionsStats> GetSiteStatsImpl( | 77 scoped_ptr<password_manager::InteractionsStats> GetSiteStatsImpl( |
| 72 const GURL& origin_domain) override; | 78 const GURL& origin_domain) override; |
| 73 | 79 |
| 74 scoped_refptr<PasswordStoreMac> password_store_mac_; | 80 scoped_refptr<PasswordStoreMac> password_store_mac_; |
| 75 scoped_refptr<SimplePasswordStoreMac> password_store_simple_; | 81 scoped_refptr<SimplePasswordStoreMac> password_store_simple_; |
| 76 | 82 |
| 83 // The login metadata SQL database. If opening the DB on |thread_| fails, |
| 84 // |login_metadata_db_| will be reset to NULL for the lifetime of |this|. |
| 85 scoped_ptr<password_manager::LoginDatabase> login_metadata_db_; |
| 86 |
| 87 // Thread that the synchronous methods are run on. |
| 88 scoped_ptr<base::Thread> thread_; |
| 89 |
| 77 DISALLOW_COPY_AND_ASSIGN(PasswordStoreProxyMac); | 90 DISALLOW_COPY_AND_ASSIGN(PasswordStoreProxyMac); |
| 78 }; | 91 }; |
| 79 | 92 |
| 80 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_PROXY_MAC_H_ | 93 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_PROXY_MAC_H_ |
| OLD | NEW |