OLD | NEW |
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_X_H_ | 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_X_H_ |
6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_X_H_ | 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_X_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 // login database like PasswordStoreDefault. It also handles automatically | 25 // login database like PasswordStoreDefault. It also handles automatically |
26 // migrating password data to a native backend from the login database. | 26 // migrating password data to a native backend from the login database. |
27 // | 27 // |
28 // There are currently native backends for GNOME Keyring and KWallet. | 28 // There are currently native backends for GNOME Keyring and KWallet. |
29 class PasswordStoreX : public PasswordStoreDefault { | 29 class PasswordStoreX : public PasswordStoreDefault { |
30 public: | 30 public: |
31 // NativeBackends more or less implement the PaswordStore interface, but | 31 // NativeBackends more or less implement the PaswordStore interface, but |
32 // with return values rather than implicit consumer notification. | 32 // with return values rather than implicit consumer notification. |
33 class NativeBackend { | 33 class NativeBackend { |
34 public: | 34 public: |
35 typedef std::vector<content::PasswordForm*> PasswordFormList; | 35 typedef std::vector<autofill::PasswordForm*> PasswordFormList; |
36 | 36 |
37 virtual ~NativeBackend() {} | 37 virtual ~NativeBackend() {} |
38 | 38 |
39 virtual bool Init() = 0; | 39 virtual bool Init() = 0; |
40 | 40 |
41 virtual bool AddLogin(const content::PasswordForm& form) = 0; | 41 virtual bool AddLogin(const autofill::PasswordForm& form) = 0; |
42 virtual bool UpdateLogin(const content::PasswordForm& form) = 0; | 42 virtual bool UpdateLogin(const autofill::PasswordForm& form) = 0; |
43 virtual bool RemoveLogin(const content::PasswordForm& form) = 0; | 43 virtual bool RemoveLogin(const autofill::PasswordForm& form) = 0; |
44 virtual bool RemoveLoginsCreatedBetween(const base::Time& delete_begin, | 44 virtual bool RemoveLoginsCreatedBetween(const base::Time& delete_begin, |
45 const base::Time& delete_end) = 0; | 45 const base::Time& delete_end) = 0; |
46 virtual bool GetLogins(const content::PasswordForm& form, | 46 virtual bool GetLogins(const autofill::PasswordForm& form, |
47 PasswordFormList* forms) = 0; | 47 PasswordFormList* forms) = 0; |
48 virtual bool GetLoginsCreatedBetween(const base::Time& get_begin, | 48 virtual bool GetLoginsCreatedBetween(const base::Time& get_begin, |
49 const base::Time& get_end, | 49 const base::Time& get_end, |
50 PasswordFormList* forms) = 0; | 50 PasswordFormList* forms) = 0; |
51 virtual bool GetAutofillableLogins(PasswordFormList* forms) = 0; | 51 virtual bool GetAutofillableLogins(PasswordFormList* forms) = 0; |
52 virtual bool GetBlacklistLogins(PasswordFormList* forms) = 0; | 52 virtual bool GetBlacklistLogins(PasswordFormList* forms) = 0; |
53 }; | 53 }; |
54 | 54 |
55 // Takes ownership of |login_db| and |backend|. |backend| may be NULL in which | 55 // Takes ownership of |login_db| and |backend|. |backend| may be NULL in which |
56 // case this PasswordStoreX will act the same as PasswordStoreDefault. | 56 // case this PasswordStoreX will act the same as PasswordStoreDefault. |
(...skipping 13 matching lines...) Expand all Loading... |
70 // The caller promises that |prefs| will not be deleted any time soon. | 70 // The caller promises that |prefs| will not be deleted any time soon. |
71 static void SetPasswordsUseLocalProfileId(PrefService* prefs); | 71 static void SetPasswordsUseLocalProfileId(PrefService* prefs); |
72 #endif // !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX) | 72 #endif // !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX) |
73 | 73 |
74 private: | 74 private: |
75 friend class PasswordStoreXTest; | 75 friend class PasswordStoreXTest; |
76 | 76 |
77 virtual ~PasswordStoreX(); | 77 virtual ~PasswordStoreX(); |
78 | 78 |
79 // Implements PasswordStore interface. | 79 // Implements PasswordStore interface. |
80 virtual void AddLoginImpl(const content::PasswordForm& form) OVERRIDE; | 80 virtual void AddLoginImpl(const autofill::PasswordForm& form) OVERRIDE; |
81 virtual void UpdateLoginImpl( | 81 virtual void UpdateLoginImpl( |
82 const content::PasswordForm& form) OVERRIDE; | 82 const autofill::PasswordForm& form) OVERRIDE; |
83 virtual void RemoveLoginImpl( | 83 virtual void RemoveLoginImpl( |
84 const content::PasswordForm& form) OVERRIDE; | 84 const autofill::PasswordForm& form) OVERRIDE; |
85 virtual void RemoveLoginsCreatedBetweenImpl( | 85 virtual void RemoveLoginsCreatedBetweenImpl( |
86 const base::Time& delete_begin, const base::Time& delete_end) OVERRIDE; | 86 const base::Time& delete_begin, const base::Time& delete_end) OVERRIDE; |
87 virtual void GetLoginsImpl( | 87 virtual void GetLoginsImpl( |
88 const content::PasswordForm& form, | 88 const autofill::PasswordForm& form, |
89 const ConsumerCallbackRunner& callback_runner) OVERRIDE; | 89 const ConsumerCallbackRunner& callback_runner) OVERRIDE; |
90 virtual void GetAutofillableLoginsImpl(GetLoginsRequest* request) OVERRIDE; | 90 virtual void GetAutofillableLoginsImpl(GetLoginsRequest* request) OVERRIDE; |
91 virtual void GetBlacklistLoginsImpl(GetLoginsRequest* request) OVERRIDE; | 91 virtual void GetBlacklistLoginsImpl(GetLoginsRequest* request) OVERRIDE; |
92 virtual bool FillAutofillableLogins( | 92 virtual bool FillAutofillableLogins( |
93 std::vector<content::PasswordForm*>* forms) OVERRIDE; | 93 std::vector<autofill::PasswordForm*>* forms) OVERRIDE; |
94 virtual bool FillBlacklistLogins( | 94 virtual bool FillBlacklistLogins( |
95 std::vector<content::PasswordForm*>* forms) OVERRIDE; | 95 std::vector<autofill::PasswordForm*>* forms) OVERRIDE; |
96 | 96 |
97 // Sort logins by origin, like the ORDER BY clause in login_database.cc. | 97 // Sort logins by origin, like the ORDER BY clause in login_database.cc. |
98 void SortLoginsByOrigin(NativeBackend::PasswordFormList* list); | 98 void SortLoginsByOrigin(NativeBackend::PasswordFormList* list); |
99 | 99 |
100 // Check to see whether migration is necessary, and perform it if so. | 100 // Check to see whether migration is necessary, and perform it if so. |
101 void CheckMigration(); | 101 void CheckMigration(); |
102 | 102 |
103 // Return true if we should try using the native backend. | 103 // Return true if we should try using the native backend. |
104 bool use_native_backend() { return !!backend_.get(); } | 104 bool use_native_backend() { return !!backend_.get(); } |
105 | 105 |
(...skipping 14 matching lines...) Expand all Loading... |
120 // Whether we should allow falling back to the default store. If there is | 120 // Whether we should allow falling back to the default store. If there is |
121 // nothing to migrate, then the first attempt to use the native store will | 121 // nothing to migrate, then the first attempt to use the native store will |
122 // be the first time we try to use it and we should allow falling back. If | 122 // be the first time we try to use it and we should allow falling back. If |
123 // we have migrated successfully, then we do not allow falling back. | 123 // we have migrated successfully, then we do not allow falling back. |
124 bool allow_fallback_; | 124 bool allow_fallback_; |
125 | 125 |
126 DISALLOW_COPY_AND_ASSIGN(PasswordStoreX); | 126 DISALLOW_COPY_AND_ASSIGN(PasswordStoreX); |
127 }; | 127 }; |
128 | 128 |
129 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_X_H_ | 129 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_X_H_ |
OLD | NEW |