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