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