| 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 <vector> | |
| 9 | |
| 10 #include "base/prefs/pref_member.h" | |
| 11 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
| 12 #include "components/password_manager/core/browser/keychain_migration_status_mac
.h" | |
| 13 #include "components/password_manager/core/browser/password_store.h" | 9 #include "components/password_manager/core/browser/password_store.h" |
| 14 #include "components/password_manager/core/common/password_manager_pref_names.h" | |
| 15 | 10 |
| 16 namespace crypto { | 11 namespace crypto { |
| 17 class AppleKeychain; | 12 class AppleKeychain; |
| 18 } | 13 } |
| 19 | 14 |
| 20 namespace password_manager { | 15 namespace password_manager { |
| 21 class LoginDatabase; | 16 class LoginDatabase; |
| 22 } | 17 } |
| 23 | 18 |
| 24 class PasswordStoreMac; | 19 class PasswordStoreMac; |
| 25 class SimplePasswordStoreMac; | 20 class SimplePasswordStoreMac; |
| 26 | 21 |
| 27 // The class is a proxy for either PasswordStoreMac or SimplePasswordStoreMac. | 22 // The class is a proxy for either PasswordStoreMac or SimplePasswordStoreMac. |
| 28 // It is responsible for performing migration from PasswordStoreMac to | 23 // It is responsible for performing migration from PasswordStoreMac to |
| 29 // SimplePasswordStoreMac and instantiating a correct backend according to the | 24 // SimplePasswordStoreMac and instantiating a correct backend according to the |
| 30 // user's state. | 25 // user's state. |
| 31 class PasswordStoreProxyMac : public password_manager::PasswordStore { | 26 class PasswordStoreProxyMac : public password_manager::PasswordStore { |
| 32 public: | 27 public: |
| 33 PasswordStoreProxyMac( | 28 PasswordStoreProxyMac( |
| 34 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner, | 29 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner, |
| 35 scoped_ptr<crypto::AppleKeychain> keychain, | 30 scoped_ptr<crypto::AppleKeychain> keychain, |
| 36 scoped_ptr<password_manager::LoginDatabase> login_db, | 31 scoped_ptr<password_manager::LoginDatabase> login_db); |
| 37 PrefService* prefs); | |
| 38 | 32 |
| 39 bool Init(const syncer::SyncableService::StartSyncFlare& flare) override; | 33 bool Init(const syncer::SyncableService::StartSyncFlare& flare) override; |
| 40 void Shutdown() override; | 34 void Shutdown() override; |
| 41 scoped_refptr<base::SingleThreadTaskRunner> GetBackgroundTaskRunner() | 35 scoped_refptr<base::SingleThreadTaskRunner> GetBackgroundTaskRunner() |
| 42 override; | 36 override; |
| 43 | 37 |
| 44 #if defined(UNIT_TEST) | 38 #if defined(UNIT_TEST) |
| 45 password_manager::LoginDatabase* login_metadata_db() { | 39 password_manager::LoginDatabase* login_metadata_db() { |
| 46 return login_metadata_db_.get(); | 40 return login_metadata_db_.get(); |
| 47 } | 41 } |
| 48 #endif | 42 #endif |
| 49 | 43 |
| 50 private: | 44 private: |
| 51 ~PasswordStoreProxyMac() override; | 45 ~PasswordStoreProxyMac() override; |
| 52 | 46 |
| 53 password_manager::PasswordStore* GetBackend() const; | 47 password_manager::PasswordStore* GetBackend() const; |
| 54 | 48 |
| 55 // Opens LoginDatabase on the background |thread_|. | 49 // Opens LoginDatabase on the background |thread_|. |
| 56 void InitOnBackgroundThread(password_manager::MigrationStatus status); | 50 void InitOnBackgroundThread(); |
| 57 | |
| 58 // Writes status to the prefs. | |
| 59 void UpdateStatusPref(password_manager::MigrationStatus status); | |
| 60 | |
| 61 // Executes |pending_ui_tasks_| on the UI thread. | |
| 62 void FlushPendingTasks(); | |
| 63 | 51 |
| 64 // PasswordStore: | 52 // PasswordStore: |
| 65 void ReportMetricsImpl(const std::string& sync_username, | 53 void ReportMetricsImpl(const std::string& sync_username, |
| 66 bool custom_passphrase_sync_enabled) override; | 54 bool custom_passphrase_sync_enabled) override; |
| 67 password_manager::PasswordStoreChangeList AddLoginImpl( | 55 password_manager::PasswordStoreChangeList AddLoginImpl( |
| 68 const autofill::PasswordForm& form) override; | 56 const autofill::PasswordForm& form) override; |
| 69 password_manager::PasswordStoreChangeList UpdateLoginImpl( | 57 password_manager::PasswordStoreChangeList UpdateLoginImpl( |
| 70 const autofill::PasswordForm& form) override; | 58 const autofill::PasswordForm& form) override; |
| 71 password_manager::PasswordStoreChangeList RemoveLoginImpl( | 59 password_manager::PasswordStoreChangeList RemoveLoginImpl( |
| 72 const autofill::PasswordForm& form) override; | 60 const autofill::PasswordForm& form) override; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 87 const password_manager::InteractionsStats& stats) override; | 75 const password_manager::InteractionsStats& stats) override; |
| 88 void RemoveSiteStatsImpl(const GURL& origin_domain) override; | 76 void RemoveSiteStatsImpl(const GURL& origin_domain) override; |
| 89 scoped_ptr<password_manager::InteractionsStats> GetSiteStatsImpl( | 77 scoped_ptr<password_manager::InteractionsStats> GetSiteStatsImpl( |
| 90 const GURL& origin_domain) override; | 78 const GURL& origin_domain) override; |
| 91 | 79 |
| 92 scoped_refptr<PasswordStoreMac> password_store_mac_; | 80 scoped_refptr<PasswordStoreMac> password_store_mac_; |
| 93 scoped_refptr<SimplePasswordStoreMac> password_store_simple_; | 81 scoped_refptr<SimplePasswordStoreMac> password_store_simple_; |
| 94 | 82 |
| 95 // The login metadata SQL database. If opening the DB on |thread_| fails, | 83 // The login metadata SQL database. If opening the DB on |thread_| fails, |
| 96 // |login_metadata_db_| will be reset to NULL for the lifetime of |this|. | 84 // |login_metadata_db_| will be reset to NULL for the lifetime of |this|. |
| 97 // The ownership may be transferred to |password_store_simple_|. | |
| 98 scoped_ptr<password_manager::LoginDatabase> login_metadata_db_; | 85 scoped_ptr<password_manager::LoginDatabase> login_metadata_db_; |
| 99 | 86 |
| 100 // Thread that the synchronous methods are run on. | 87 // Thread that the synchronous methods are run on. |
| 101 scoped_ptr<base::Thread> thread_; | 88 scoped_ptr<base::Thread> thread_; |
| 102 | 89 |
| 103 // Current migration status for the profile. | |
| 104 IntegerPrefMember migration_status_; | |
| 105 | |
| 106 // List of tasks filled by InitOnBackgroundThread. They can't be just posted | |
| 107 // to the UI thread because the message loop can shut down before executing | |
| 108 // them. If this is the case then Shutdown() flushes the tasks after stopping | |
| 109 // the background thread. | |
| 110 // After InitOnBackgroundThread is run once, the queue may not be modified on | |
| 111 // the background thread any more. | |
| 112 std::vector<base::Closure> pending_ui_tasks_; | |
| 113 | |
| 114 DISALLOW_COPY_AND_ASSIGN(PasswordStoreProxyMac); | 90 DISALLOW_COPY_AND_ASSIGN(PasswordStoreProxyMac); |
| 115 }; | 91 }; |
| 116 | 92 |
| 117 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_PROXY_MAC_H_ | 93 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_PROXY_MAC_H_ |
| OLD | NEW |