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