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_NATIVE_BACKEND_KWALLET_X_H_ | 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_KWALLET_X_H_ |
6 #define CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_KWALLET_X_H_ | 6 #define CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_KWALLET_X_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "chrome/browser/password_manager/password_store_factory.h" | 13 #include "chrome/browser/password_manager/password_store_factory.h" |
14 #include "chrome/browser/password_manager/password_store_x.h" | 14 #include "chrome/browser/password_manager/password_store_x.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 | 16 |
17 class Pickle; | 17 class Pickle; |
18 class PickleIterator; | 18 class PickleIterator; |
19 class PrefService; | |
20 | 19 |
21 namespace autofill { | 20 namespace autofill { |
22 struct PasswordForm; | 21 struct PasswordForm; |
23 } | 22 } |
24 | 23 |
25 namespace base { | 24 namespace base { |
26 class WaitableEvent; | 25 class WaitableEvent; |
27 } | 26 } |
28 | 27 |
29 namespace dbus { | 28 namespace dbus { |
30 class Bus; | 29 class Bus; |
31 class ObjectProxy; | 30 class ObjectProxy; |
32 } | 31 } |
33 | 32 |
34 // NativeBackend implementation using KWallet. | 33 // NativeBackend implementation using KWallet. |
35 class NativeBackendKWallet : public PasswordStoreX::NativeBackend { | 34 class NativeBackendKWallet : public PasswordStoreX::NativeBackend { |
36 public: | 35 public: |
37 NativeBackendKWallet(LocalProfileId id, PrefService* prefs); | 36 explicit NativeBackendKWallet(LocalProfileId id); |
38 | 37 |
39 virtual ~NativeBackendKWallet(); | 38 virtual ~NativeBackendKWallet(); |
40 | 39 |
41 virtual bool Init() OVERRIDE; | 40 virtual bool Init() OVERRIDE; |
42 | 41 |
43 // Implements NativeBackend interface. | 42 // Implements NativeBackend interface. |
44 virtual bool AddLogin(const autofill::PasswordForm& form) OVERRIDE; | 43 virtual bool AddLogin(const autofill::PasswordForm& form) OVERRIDE; |
45 virtual bool UpdateLogin(const autofill::PasswordForm& form) OVERRIDE; | 44 virtual bool UpdateLogin(const autofill::PasswordForm& form) OVERRIDE; |
46 virtual bool RemoveLogin(const autofill::PasswordForm& form) OVERRIDE; | 45 virtual bool RemoveLogin(const autofill::PasswordForm& form) OVERRIDE; |
47 virtual bool RemoveLoginsCreatedBetween( | 46 virtual bool RemoveLoginsCreatedBetween( |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 int version, bool size_32, bool warn_only, | 123 int version, bool size_32, bool warn_only, |
125 PasswordFormList* forms); | 124 PasswordFormList* forms); |
126 | 125 |
127 // In case the fields in the pickle ever change, version them so we can try to | 126 // In case the fields in the pickle ever change, version them so we can try to |
128 // read old pickles. (Note: do not eat old pickles past the expiration date.) | 127 // read old pickles. (Note: do not eat old pickles past the expiration date.) |
129 static const int kPickleVersion = 2; | 128 static const int kPickleVersion = 2; |
130 | 129 |
131 // Generates a profile-specific folder name based on profile_id_. | 130 // Generates a profile-specific folder name based on profile_id_. |
132 std::string GetProfileSpecificFolderName() const; | 131 std::string GetProfileSpecificFolderName() const; |
133 | 132 |
134 // Migrates non-profile-specific logins to be profile-specific. | |
135 void MigrateToProfileSpecificLogins(); | |
136 | |
137 // The local profile id, used to generate the folder name. | 133 // The local profile id, used to generate the folder name. |
138 const LocalProfileId profile_id_; | 134 const LocalProfileId profile_id_; |
139 | 135 |
140 // The pref service to use for persistent migration settings. | |
141 PrefService* prefs_; | |
142 | |
143 // The KWallet folder name, possibly based on the local profile id. | 136 // The KWallet folder name, possibly based on the local profile id. |
144 std::string folder_name_; | 137 std::string folder_name_; |
145 | 138 |
146 // True once MigrateToProfileSpecificLogins() has been attempted. | |
147 bool migrate_tried_; | |
148 | |
149 // DBus handle for communication with klauncher and kwalletd. | 139 // DBus handle for communication with klauncher and kwalletd. |
150 scoped_refptr<dbus::Bus> session_bus_; | 140 scoped_refptr<dbus::Bus> session_bus_; |
151 // Object proxy for kwalletd. We do not own this. | 141 // Object proxy for kwalletd. We do not own this. |
152 dbus::ObjectProxy* kwallet_proxy_; | 142 dbus::ObjectProxy* kwallet_proxy_; |
153 | 143 |
154 // The name of the wallet we've opened. Set during Init(). | 144 // The name of the wallet we've opened. Set during Init(). |
155 std::string wallet_name_; | 145 std::string wallet_name_; |
156 // The application name (e.g. "Chromium"), shown in KWallet auth dialogs. | 146 // The application name (e.g. "Chromium"), shown in KWallet auth dialogs. |
157 const std::string app_name_; | 147 const std::string app_name_; |
158 | 148 |
159 DISALLOW_COPY_AND_ASSIGN(NativeBackendKWallet); | 149 DISALLOW_COPY_AND_ASSIGN(NativeBackendKWallet); |
160 }; | 150 }; |
161 | 151 |
162 #endif // CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_KWALLET_X_H_ | 152 #endif // CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_KWALLET_X_H_ |
OLD | NEW |