OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/time.h" | 13 #include "base/time.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 PrefService; | 18 class PrefService; |
19 | 19 |
20 namespace webkit_glue { | 20 namespace webkit { |
| 21 namespace forms { |
21 struct PasswordForm; | 22 struct PasswordForm; |
22 } | 23 } |
| 24 } |
23 | 25 |
24 namespace base { | 26 namespace base { |
25 class WaitableEvent; | 27 class WaitableEvent; |
26 } | 28 } |
27 | 29 |
28 namespace dbus { | 30 namespace dbus { |
29 class Bus; | 31 class Bus; |
30 class ObjectProxy; | 32 class ObjectProxy; |
31 } | 33 } |
32 | 34 |
33 // NativeBackend implementation using KWallet. | 35 // NativeBackend implementation using KWallet. |
34 class NativeBackendKWallet : public PasswordStoreX::NativeBackend { | 36 class NativeBackendKWallet : public PasswordStoreX::NativeBackend { |
35 public: | 37 public: |
36 NativeBackendKWallet(LocalProfileId id, PrefService* prefs); | 38 NativeBackendKWallet(LocalProfileId id, PrefService* prefs); |
37 | 39 |
38 virtual ~NativeBackendKWallet(); | 40 virtual ~NativeBackendKWallet(); |
39 | 41 |
40 virtual bool Init() OVERRIDE; | 42 virtual bool Init() OVERRIDE; |
41 | 43 |
42 // Implements NativeBackend interface. | 44 // Implements NativeBackend interface. |
43 virtual bool AddLogin(const webkit_glue::PasswordForm& form) OVERRIDE; | 45 virtual bool AddLogin(const webkit::forms::PasswordForm& form) OVERRIDE; |
44 virtual bool UpdateLogin(const webkit_glue::PasswordForm& form) OVERRIDE; | 46 virtual bool UpdateLogin(const webkit::forms::PasswordForm& form) OVERRIDE; |
45 virtual bool RemoveLogin(const webkit_glue::PasswordForm& form) OVERRIDE; | 47 virtual bool RemoveLogin(const webkit::forms::PasswordForm& form) OVERRIDE; |
46 virtual bool RemoveLoginsCreatedBetween( | 48 virtual bool RemoveLoginsCreatedBetween( |
47 const base::Time& delete_begin, const base::Time& delete_end) OVERRIDE; | 49 const base::Time& delete_begin, const base::Time& delete_end) OVERRIDE; |
48 virtual bool GetLogins(const webkit_glue::PasswordForm& form, | 50 virtual bool GetLogins(const webkit::forms::PasswordForm& form, |
49 PasswordFormList* forms) OVERRIDE; | 51 PasswordFormList* forms) OVERRIDE; |
50 virtual bool GetLoginsCreatedBetween(const base::Time& get_begin, | 52 virtual bool GetLoginsCreatedBetween(const base::Time& get_begin, |
51 const base::Time& get_end, | 53 const base::Time& get_end, |
52 PasswordFormList* forms) OVERRIDE; | 54 PasswordFormList* forms) OVERRIDE; |
53 virtual bool GetAutofillableLogins(PasswordFormList* forms) OVERRIDE; | 55 virtual bool GetAutofillableLogins(PasswordFormList* forms) OVERRIDE; |
54 virtual bool GetBlacklistLogins(PasswordFormList* forms) OVERRIDE; | 56 virtual bool GetBlacklistLogins(PasswordFormList* forms) OVERRIDE; |
55 | 57 |
56 protected: | 58 protected: |
57 // Invalid handle returned by WalletHandle(). | 59 // Invalid handle returned by WalletHandle(). |
58 static const int kInvalidKWalletHandle = -1; | 60 static const int kInvalidKWalletHandle = -1; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 int wallet_handle); | 108 int wallet_handle); |
107 | 109 |
108 // Opens the wallet and ensures that the "Chrome Form Data" folder exists. | 110 // Opens the wallet and ensures that the "Chrome Form Data" folder exists. |
109 // Returns kInvalidWalletHandle on error. | 111 // Returns kInvalidWalletHandle on error. |
110 int WalletHandle(); | 112 int WalletHandle(); |
111 | 113 |
112 // Compares two PasswordForms and returns true if they are the same. | 114 // Compares two PasswordForms and returns true if they are the same. |
113 // If |update_check| is false, we only check the fields that are checked by | 115 // If |update_check| is false, we only check the fields that are checked by |
114 // LoginDatabase::UpdateLogin() when updating logins; otherwise, we check the | 116 // LoginDatabase::UpdateLogin() when updating logins; otherwise, we check the |
115 // fields that are checked by LoginDatabase::RemoveLogin() for removing them. | 117 // fields that are checked by LoginDatabase::RemoveLogin() for removing them. |
116 static bool CompareForms(const webkit_glue::PasswordForm& a, | 118 static bool CompareForms(const webkit::forms::PasswordForm& a, |
117 const webkit_glue::PasswordForm& b, | 119 const webkit::forms::PasswordForm& b, |
118 bool update_check); | 120 bool update_check); |
119 | 121 |
120 // Serializes a list of PasswordForms to be stored in the wallet. | 122 // Serializes a list of PasswordForms to be stored in the wallet. |
121 static void SerializeValue(const PasswordFormList& forms, Pickle* pickle); | 123 static void SerializeValue(const PasswordFormList& forms, Pickle* pickle); |
122 | 124 |
123 // Checks a serialized list of PasswordForms for sanity. Returns true if OK. | 125 // Checks a serialized list of PasswordForms for sanity. Returns true if OK. |
124 // Note that |realm| is only used for generating a useful warning message. | 126 // Note that |realm| is only used for generating a useful warning message. |
125 static bool CheckSerializedValue(const uint8_t* byte_array, size_t length, | 127 static bool CheckSerializedValue(const uint8_t* byte_array, size_t length, |
126 const std::string& realm); | 128 const std::string& realm); |
127 | 129 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 171 |
170 // The name of the wallet we've opened. Set during Init(). | 172 // The name of the wallet we've opened. Set during Init(). |
171 std::string wallet_name_; | 173 std::string wallet_name_; |
172 // The application name (e.g. "Chromium"), shown in KWallet auth dialogs. | 174 // The application name (e.g. "Chromium"), shown in KWallet auth dialogs. |
173 const std::string app_name_; | 175 const std::string app_name_; |
174 | 176 |
175 DISALLOW_COPY_AND_ASSIGN(NativeBackendKWallet); | 177 DISALLOW_COPY_AND_ASSIGN(NativeBackendKWallet); |
176 }; | 178 }; |
177 | 179 |
178 #endif // CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_KWALLET_X_H_ | 180 #endif // CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_KWALLET_X_H_ |
OLD | NEW |