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

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

Issue 1200603003: Integrate PasswordStoreProxyMac instead of PasswordStoreMac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add tests Created 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_MAC_H_ 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_MAC_H_
6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_MAC_H_ 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_MAC_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback_forward.h" 10 #include "base/callback_forward.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
14 #include "components/password_manager/core/browser/login_database.h" 14 #include "components/password_manager/core/browser/login_database.h"
15 #include "components/password_manager/core/browser/password_store.h" 15 #include "components/password_manager/core/browser/password_store.h"
16 16
17 namespace crypto { 17 namespace crypto {
18 class AppleKeychain; 18 class AppleKeychain;
19 } 19 }
20 20
21 namespace password_manager { 21 namespace password_manager {
22 class LoginDatabase; 22 class LoginDatabase;
23 } 23 }
24 24
25 // TODO(vasilii): deprecate. The class should be used by PasswordStoreProxyMac
Garrett Casto 2015/06/24 23:39:09 Nit: deprecate -> Deprecate this class.
vasilii 2015/06/25 08:23:23 Done.
26 // wrapper.
25 // Implements PasswordStore on top of the OS X Keychain, with an internal 27 // Implements PasswordStore on top of the OS X Keychain, with an internal
26 // database for extra metadata. For an overview of the interactions with the 28 // database for extra metadata. For an overview of the interactions with the
27 // Keychain, as well as the rationale for some of the behaviors, see the 29 // Keychain, as well as the rationale for some of the behaviors, see the
28 // Keychain integration design doc: 30 // Keychain integration design doc:
29 // http://dev.chromium.org/developers/design-documents/os-x-password-manager-key chain-integration 31 // http://dev.chromium.org/developers/design-documents/os-x-password-manager-key chain-integration
30 class PasswordStoreMac : public password_manager::PasswordStore { 32 class PasswordStoreMac : public password_manager::PasswordStore {
31 public: 33 public:
32 // The |login_db| must not have been Init()-ed yet. It will be initialized in
33 // a deferred manner on the background thread.
34 PasswordStoreMac( 34 PasswordStoreMac(
35 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner, 35 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner,
36 scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner, 36 scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner,
37 scoped_ptr<crypto::AppleKeychain> keychain, 37 scoped_ptr<crypto::AppleKeychain> keychain,
38 scoped_ptr<password_manager::LoginDatabase> login_db); 38 password_manager::LoginDatabase* login_db);
39 39
40 // Initializes |thread_|. 40 // Initializes |thread_|.
Garrett Casto 2015/06/24 23:39:10 Stale comment.
vasilii 2015/06/25 08:23:23 Done.
41 bool Init(const syncer::SyncableService::StartSyncFlare& flare) override; 41 void InitWithTaskRunner(
42 scoped_refptr<base::SingleThreadTaskRunner> background_task_runner);
42 43
43 // Stops |thread_|. 44 // Stops |thread_|.
Garrett Casto 2015/06/24 23:39:09 Stale comment.
vasilii 2015/06/25 08:23:23 Done.
44 void Shutdown() override; 45 void Shutdown() override;
45 46
46 // To be used for testing. 47 // To be used for testing.
47 password_manager::LoginDatabase* login_metadata_db() const { 48 password_manager::LoginDatabase* login_metadata_db() const {
48 return login_metadata_db_.get(); 49 return login_metadata_db_;
49 } 50 }
50 51
51 // To be used for testing. 52 // To be used for testing.
52 crypto::AppleKeychain* keychain() const { return keychain_.get(); } 53 crypto::AppleKeychain* keychain() const { return keychain_.get(); }
53 54
54 protected: 55 protected:
55 ~PasswordStoreMac() override; 56 ~PasswordStoreMac() override;
56 57
57 // Opens |login_metadata_db_| on the background |thread_|.
58 void InitOnBackgroundThread();
59
60 scoped_refptr<base::SingleThreadTaskRunner> GetBackgroundTaskRunner()
61 override;
62
63 private: 58 private:
59 bool Init(const syncer::SyncableService::StartSyncFlare& flare) override;
64 void ReportMetricsImpl(const std::string& sync_username, 60 void ReportMetricsImpl(const std::string& sync_username,
65 bool custom_passphrase_sync_enabled) override; 61 bool custom_passphrase_sync_enabled) override;
66 password_manager::PasswordStoreChangeList AddLoginImpl( 62 password_manager::PasswordStoreChangeList AddLoginImpl(
67 const autofill::PasswordForm& form) override; 63 const autofill::PasswordForm& form) override;
68 password_manager::PasswordStoreChangeList UpdateLoginImpl( 64 password_manager::PasswordStoreChangeList UpdateLoginImpl(
69 const autofill::PasswordForm& form) override; 65 const autofill::PasswordForm& form) override;
70 password_manager::PasswordStoreChangeList RemoveLoginImpl( 66 password_manager::PasswordStoreChangeList RemoveLoginImpl(
71 const autofill::PasswordForm& form) override; 67 const autofill::PasswordForm& form) override;
72 password_manager::PasswordStoreChangeList RemoveLoginsCreatedBetweenImpl( 68 password_manager::PasswordStoreChangeList RemoveLoginsCreatedBetweenImpl(
73 base::Time delete_begin, 69 base::Time delete_begin,
74 base::Time delete_end) override; 70 base::Time delete_end) override;
75 password_manager::PasswordStoreChangeList RemoveLoginsSyncedBetweenImpl( 71 password_manager::PasswordStoreChangeList RemoveLoginsSyncedBetweenImpl(
76 base::Time delete_begin, 72 base::Time delete_begin,
77 base::Time delete_end) override; 73 base::Time delete_end) override;
78 ScopedVector<autofill::PasswordForm> FillMatchingLogins( 74 ScopedVector<autofill::PasswordForm> FillMatchingLogins(
79 const autofill::PasswordForm& form, 75 const autofill::PasswordForm& form,
80 AuthorizationPromptPolicy prompt_policy) override; 76 AuthorizationPromptPolicy prompt_policy) override;
81 void GetAutofillableLoginsImpl(
82 scoped_ptr<PasswordStore::GetLoginsRequest> request) override;
83 void GetBlacklistLoginsImpl(
84 scoped_ptr<PasswordStore::GetLoginsRequest> request) override;
85 bool FillAutofillableLogins( 77 bool FillAutofillableLogins(
86 ScopedVector<autofill::PasswordForm>* forms) override; 78 ScopedVector<autofill::PasswordForm>* forms) override;
87 bool FillBlacklistLogins( 79 bool FillBlacklistLogins(
88 ScopedVector<autofill::PasswordForm>* forms) override; 80 ScopedVector<autofill::PasswordForm>* forms) override;
89 void AddSiteStatsImpl( 81 void AddSiteStatsImpl(
90 const password_manager::InteractionsStats& stats) override; 82 const password_manager::InteractionsStats& stats) override;
91 void RemoveSiteStatsImpl(const GURL& origin_domain) override; 83 void RemoveSiteStatsImpl(const GURL& origin_domain) override;
92 scoped_ptr<password_manager::InteractionsStats> GetSiteStatsImpl( 84 scoped_ptr<password_manager::InteractionsStats> GetSiteStatsImpl(
93 const GURL& origin_domain) override; 85 const GURL& origin_domain) override;
94 86
(...skipping 16 matching lines...) Expand all
111 void RemoveKeychainForms( 103 void RemoveKeychainForms(
112 const std::vector<autofill::PasswordForm*>& forms); 104 const std::vector<autofill::PasswordForm*>& forms);
113 105
114 // Searches the database for forms without a corresponding entry in the 106 // Searches the database for forms without a corresponding entry in the
115 // keychain. Removes those forms from the database, and adds them to 107 // keychain. Removes those forms from the database, and adds them to
116 // |orphaned_forms|. 108 // |orphaned_forms|.
117 void CleanOrphanedForms(ScopedVector<autofill::PasswordForm>* orphaned_forms); 109 void CleanOrphanedForms(ScopedVector<autofill::PasswordForm>* orphaned_forms);
118 110
119 scoped_ptr<crypto::AppleKeychain> keychain_; 111 scoped_ptr<crypto::AppleKeychain> keychain_;
120 112
121 // The login metadata SQL database. The LoginDatabase instance is received via 113 // The login metadata SQL database. The caller is resonsible for initializing
122 // the in an uninitialized state, so as to allow injecting mocks, then Init() 114 // it.
123 // is called on the DB thread in a deferred manner. If opening the DB fails, 115 password_manager::LoginDatabase* login_metadata_db_;
124 // |login_metadata_db_| will be reset to NULL for the lifetime of |this|.
125 scoped_ptr<password_manager::LoginDatabase> login_metadata_db_;
126
127 // Thread that the synchronous methods are run on.
128 scoped_ptr<base::Thread> thread_;
129 116
130 DISALLOW_COPY_AND_ASSIGN(PasswordStoreMac); 117 DISALLOW_COPY_AND_ASSIGN(PasswordStoreMac);
131 }; 118 };
132 119
133 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_MAC_H_ 120 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_MAC_H_
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_store_factory.cc ('k') | chrome/browser/password_manager/password_store_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698