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

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

Issue 1226303003: Start the migration of passwords from the Keychain. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix the test Created 5 years, 5 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 <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 }
48
49 scoped_refptr<PasswordStoreMac> password_store_mac() {
50 return password_store_mac_;
51 }
42 #endif 52 #endif
43 53
44 private: 54 private:
45 ~PasswordStoreProxyMac() override; 55 ~PasswordStoreProxyMac() override;
46 56
47 password_manager::PasswordStore* GetBackend() const; 57 password_manager::PasswordStore* GetBackend() const;
48 58
49 // Opens LoginDatabase on the background |thread_|. 59 // Opens LoginDatabase on the background |thread_|.
50 void InitOnBackgroundThread(); 60 void InitOnBackgroundThread(password_manager::MigrationStatus status);
61
62 // Writes status to the prefs.
63 void UpdateStatusPref(password_manager::MigrationStatus status);
64
65 // Executes |pending_ui_tasks_| on the UI thread.
66 void FlushPendingTasks();
51 67
52 // PasswordStore: 68 // PasswordStore:
53 void ReportMetricsImpl(const std::string& sync_username, 69 void ReportMetricsImpl(const std::string& sync_username,
54 bool custom_passphrase_sync_enabled) override; 70 bool custom_passphrase_sync_enabled) override;
55 password_manager::PasswordStoreChangeList AddLoginImpl( 71 password_manager::PasswordStoreChangeList AddLoginImpl(
56 const autofill::PasswordForm& form) override; 72 const autofill::PasswordForm& form) override;
57 password_manager::PasswordStoreChangeList UpdateLoginImpl( 73 password_manager::PasswordStoreChangeList UpdateLoginImpl(
58 const autofill::PasswordForm& form) override; 74 const autofill::PasswordForm& form) override;
59 password_manager::PasswordStoreChangeList RemoveLoginImpl( 75 password_manager::PasswordStoreChangeList RemoveLoginImpl(
60 const autofill::PasswordForm& form) override; 76 const autofill::PasswordForm& form) override;
(...skipping 14 matching lines...) Expand all
75 const password_manager::InteractionsStats& stats) override; 91 const password_manager::InteractionsStats& stats) override;
76 void RemoveSiteStatsImpl(const GURL& origin_domain) override; 92 void RemoveSiteStatsImpl(const GURL& origin_domain) override;
77 scoped_ptr<password_manager::InteractionsStats> GetSiteStatsImpl( 93 scoped_ptr<password_manager::InteractionsStats> GetSiteStatsImpl(
78 const GURL& origin_domain) override; 94 const GURL& origin_domain) override;
79 95
80 scoped_refptr<PasswordStoreMac> password_store_mac_; 96 scoped_refptr<PasswordStoreMac> password_store_mac_;
81 scoped_refptr<SimplePasswordStoreMac> password_store_simple_; 97 scoped_refptr<SimplePasswordStoreMac> password_store_simple_;
82 98
83 // The login metadata SQL database. If opening the DB on |thread_| fails, 99 // 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|. 100 // |login_metadata_db_| will be reset to NULL for the lifetime of |this|.
101 // The ownership may be transferred to |password_store_simple_|.
85 scoped_ptr<password_manager::LoginDatabase> login_metadata_db_; 102 scoped_ptr<password_manager::LoginDatabase> login_metadata_db_;
86 103
87 // Thread that the synchronous methods are run on. 104 // Thread that the synchronous methods are run on.
88 scoped_ptr<base::Thread> thread_; 105 scoped_ptr<base::Thread> thread_;
89 106
107 // Current migration status for the profile.
108 IntegerPrefMember migration_status_;
109
110 // List of tasks filled by InitOnBackgroundThread. They can't be just posted
111 // to the UI thread because the message loop can shut down before executing
112 // them. If this is the case then Shutdown() flushes the tasks after stopping
113 // the background thread.
114 // After InitOnBackgroundThread is run once, the queue may not be modified on
115 // the background thread any more.
116 std::vector<base::Closure> pending_ui_tasks_;
117
90 DISALLOW_COPY_AND_ASSIGN(PasswordStoreProxyMac); 118 DISALLOW_COPY_AND_ASSIGN(PasswordStoreProxyMac);
91 }; 119 };
92 120
93 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_PROXY_MAC_H_ 121 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_PROXY_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698