Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: chrome/browser/password_manager/password_store_proxy_mac.h

Issue 2909283002: Delete PasswordStoreMac and SimplePasswordStoreMac. (Closed)
Patch Set: test Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <string> 8 #include <memory>
9 #include <vector>
10 9
11 #include "base/macros.h" 10 #include "base/macros.h"
12 #include "base/single_thread_task_runner.h"
13 #include "base/threading/thread.h" 11 #include "base/threading/thread.h"
14 #include "components/password_manager/core/browser/keychain_migration_status_mac .h" 12 #include "components/password_manager/core/browser/keychain_migration_status_mac .h"
15 #include "components/password_manager/core/browser/password_store.h" 13 #include "components/password_manager/core/browser/password_store_default.h"
16 #include "components/password_manager/core/common/password_manager_pref_names.h"
17 #include "components/prefs/pref_member.h" 14 #include "components/prefs/pref_member.h"
18 15
19 namespace crypto {
20 class AppleKeychain;
21 }
22
23 namespace password_manager { 16 namespace password_manager {
24 class LoginDatabase; 17 class LoginDatabase;
25 } 18 }
26 19
27 class SimplePasswordStoreMac; 20 // Password store for Mac. It creates a dedicated background thread
28 21 class PasswordStoreProxyMac : public password_manager::PasswordStoreDefault {
29 // The class is a proxy for either PasswordStoreMac or SimplePasswordStoreMac.
30 // It is responsible for performing migration from PasswordStoreMac to
31 // SimplePasswordStoreMac and instantiating a correct backend according to the
32 // user's state.
33 class PasswordStoreProxyMac : public password_manager::PasswordStore {
34 public: 22 public:
35 PasswordStoreProxyMac( 23 PasswordStoreProxyMac(
36 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner, 24 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner,
37 std::unique_ptr<crypto::AppleKeychain> keychain,
38 std::unique_ptr<password_manager::LoginDatabase> login_db, 25 std::unique_ptr<password_manager::LoginDatabase> login_db,
39 PrefService* prefs); 26 PrefService* prefs);
40 27
28 // PasswordStore:
41 bool Init(const syncer::SyncableService::StartSyncFlare& flare, 29 bool Init(const syncer::SyncableService::StartSyncFlare& flare,
42 PrefService* prefs) override; 30 PrefService* prefs) override;
43 void ShutdownOnUIThread() override; 31 void ShutdownOnUIThread() override;
44 scoped_refptr<base::SingleThreadTaskRunner> GetBackgroundTaskRunner() 32 scoped_refptr<base::SingleThreadTaskRunner> GetBackgroundTaskRunner()
45 override; 33 override;
46 34
47 #if defined(UNIT_TEST) 35 #if defined(UNIT_TEST)
48 password_manager::LoginDatabase* login_metadata_db() { 36 password_manager::LoginDatabase* login_metadata_db() { return login_db(); }
49 return login_metadata_db_.get();
50 }
51
52 crypto::AppleKeychain* keychain() {
53 return keychain_.get();
54 }
55 #endif 37 #endif
56 38
57 private: 39 private:
58 ~PasswordStoreProxyMac() override; 40 ~PasswordStoreProxyMac() override;
59 41
60 password_manager::PasswordStore* GetBackend() const;
61
62 // Opens LoginDatabase on the background |thread_|.
63 void InitOnBackgroundThread(password_manager::MigrationStatus status); 42 void InitOnBackgroundThread(password_manager::MigrationStatus status);
64 43
65 // Writes status to the prefs. 44 // Writes status to the prefs.
66 void UpdateStatusPref(password_manager::MigrationStatus status); 45 void UpdateStatusPref(password_manager::MigrationStatus status);
67 46
68 // Executes |pending_ui_tasks_| on the UI thread.
69 void FlushPendingTasks();
70
71 // PasswordStore:
72 void ReportMetricsImpl(const std::string& sync_username,
73 bool custom_passphrase_sync_enabled) override;
74 password_manager::PasswordStoreChangeList AddLoginImpl(
75 const autofill::PasswordForm& form) override;
76 password_manager::PasswordStoreChangeList UpdateLoginImpl(
77 const autofill::PasswordForm& form) override;
78 password_manager::PasswordStoreChangeList RemoveLoginImpl(
79 const autofill::PasswordForm& form) override;
80 password_manager::PasswordStoreChangeList RemoveLoginsByURLAndTimeImpl(
81 const base::Callback<bool(const GURL&)>& url_filter,
82 base::Time delete_begin,
83 base::Time delete_end) override;
84 password_manager::PasswordStoreChangeList RemoveLoginsCreatedBetweenImpl(
85 base::Time delete_begin,
86 base::Time delete_end) override;
87 password_manager::PasswordStoreChangeList RemoveLoginsSyncedBetweenImpl(
88 base::Time delete_begin,
89 base::Time delete_end) override;
90 password_manager::PasswordStoreChangeList DisableAutoSignInForOriginsImpl(
91 const base::Callback<bool(const GURL&)>& origin_filter) override;
92 bool RemoveStatisticsByOriginAndTimeImpl(
93 const base::Callback<bool(const GURL&)>& origin_filter,
94 base::Time delete_begin,
95 base::Time delete_end) override;
96 std::vector<std::unique_ptr<autofill::PasswordForm>> FillMatchingLogins(
97 const FormDigest& form) override;
98 std::vector<std::unique_ptr<autofill::PasswordForm>>
99 FillLoginsForSameOrganizationName(const std::string& signon_realm) override;
100 bool FillAutofillableLogins(
101 std::vector<std::unique_ptr<autofill::PasswordForm>>* forms) override;
102 bool FillBlacklistLogins(
103 std::vector<std::unique_ptr<autofill::PasswordForm>>* forms) override;
104 void AddSiteStatsImpl(
105 const password_manager::InteractionsStats& stats) override;
106 void RemoveSiteStatsImpl(const GURL& origin_domain) override;
107 std::vector<password_manager::InteractionsStats> GetAllSiteStatsImpl()
108 override;
109 std::vector<password_manager::InteractionsStats> GetSiteStatsImpl(
110 const GURL& origin_domain) override;
111
112 scoped_refptr<SimplePasswordStoreMac> password_store_simple_;
113
114 // The login metadata SQL database. If opening the DB on |thread_| fails,
115 // |login_metadata_db_| will be reset to NULL for the lifetime of |this|.
116 // The ownership may be transferred to |password_store_simple_|.
117 std::unique_ptr<password_manager::LoginDatabase> login_metadata_db_;
118
119 // Keychain wrapper.
120 const std::unique_ptr<crypto::AppleKeychain> keychain_;
121
122 // Thread that the synchronous methods are run on. 47 // Thread that the synchronous methods are run on.
123 std::unique_ptr<base::Thread> thread_; 48 std::unique_ptr<base::Thread> thread_;
124 49
125 // Current migration status for the profile. 50 // Current migration status for the profile.
126 IntegerPrefMember migration_status_; 51 IntegerPrefMember migration_status_;
127 52
128 // List of tasks filled by InitOnBackgroundThread. They can't be just posted
129 // to the UI thread because the message loop can shut down before executing
130 // them. If this is the case then Shutdown() flushes the tasks after stopping
131 // the background thread.
132 // After InitOnBackgroundThread is run once, the queue may not be modified on
133 // the background thread any more.
134 std::vector<base::Closure> pending_ui_tasks_;
135
136 DISALLOW_COPY_AND_ASSIGN(PasswordStoreProxyMac); 53 DISALLOW_COPY_AND_ASSIGN(PasswordStoreProxyMac);
137 }; 54 };
138 55
139 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_PROXY_MAC_H_ 56 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_PROXY_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698