| 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.h" | 12 #include "base/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; | 19 class PrefService; |
| 20 | 20 |
| 21 namespace webkit { | 21 namespace content { |
| 22 namespace forms { | |
| 23 struct PasswordForm; | 22 struct PasswordForm; |
| 24 } | 23 } |
| 25 } | |
| 26 | 24 |
| 27 namespace base { | 25 namespace base { |
| 28 class WaitableEvent; | 26 class WaitableEvent; |
| 29 } | 27 } |
| 30 | 28 |
| 31 namespace dbus { | 29 namespace dbus { |
| 32 class Bus; | 30 class Bus; |
| 33 class ObjectProxy; | 31 class ObjectProxy; |
| 34 } | 32 } |
| 35 | 33 |
| 36 // NativeBackend implementation using KWallet. | 34 // NativeBackend implementation using KWallet. |
| 37 class NativeBackendKWallet : public PasswordStoreX::NativeBackend { | 35 class NativeBackendKWallet : public PasswordStoreX::NativeBackend { |
| 38 public: | 36 public: |
| 39 NativeBackendKWallet(LocalProfileId id, PrefService* prefs); | 37 NativeBackendKWallet(LocalProfileId id, PrefService* prefs); |
| 40 | 38 |
| 41 virtual ~NativeBackendKWallet(); | 39 virtual ~NativeBackendKWallet(); |
| 42 | 40 |
| 43 virtual bool Init() OVERRIDE; | 41 virtual bool Init() OVERRIDE; |
| 44 | 42 |
| 45 // Implements NativeBackend interface. | 43 // Implements NativeBackend interface. |
| 46 virtual bool AddLogin(const webkit::forms::PasswordForm& form) OVERRIDE; | 44 virtual bool AddLogin(const content::PasswordForm& form) OVERRIDE; |
| 47 virtual bool UpdateLogin(const webkit::forms::PasswordForm& form) OVERRIDE; | 45 virtual bool UpdateLogin(const content::PasswordForm& form) OVERRIDE; |
| 48 virtual bool RemoveLogin(const webkit::forms::PasswordForm& form) OVERRIDE; | 46 virtual bool RemoveLogin(const content::PasswordForm& form) OVERRIDE; |
| 49 virtual bool RemoveLoginsCreatedBetween( | 47 virtual bool RemoveLoginsCreatedBetween( |
| 50 const base::Time& delete_begin, const base::Time& delete_end) OVERRIDE; | 48 const base::Time& delete_begin, const base::Time& delete_end) OVERRIDE; |
| 51 virtual bool GetLogins(const webkit::forms::PasswordForm& form, | 49 virtual bool GetLogins(const content::PasswordForm& form, |
| 52 PasswordFormList* forms) OVERRIDE; | 50 PasswordFormList* forms) OVERRIDE; |
| 53 virtual bool GetLoginsCreatedBetween(const base::Time& get_begin, | 51 virtual bool GetLoginsCreatedBetween(const base::Time& get_begin, |
| 54 const base::Time& get_end, | 52 const base::Time& get_end, |
| 55 PasswordFormList* forms) OVERRIDE; | 53 PasswordFormList* forms) OVERRIDE; |
| 56 virtual bool GetAutofillableLogins(PasswordFormList* forms) OVERRIDE; | 54 virtual bool GetAutofillableLogins(PasswordFormList* forms) OVERRIDE; |
| 57 virtual bool GetBlacklistLogins(PasswordFormList* forms) OVERRIDE; | 55 virtual bool GetBlacklistLogins(PasswordFormList* forms) OVERRIDE; |
| 58 | 56 |
| 59 protected: | 57 protected: |
| 60 // Invalid handle returned by WalletHandle(). | 58 // Invalid handle returned by WalletHandle(). |
| 61 static const int kInvalidKWalletHandle = -1; | 59 static const int kInvalidKWalletHandle = -1; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 int wallet_handle); | 118 int wallet_handle); |
| 121 | 119 |
| 122 // Opens the wallet and ensures that the "Chrome Form Data" folder exists. | 120 // Opens the wallet and ensures that the "Chrome Form Data" folder exists. |
| 123 // Returns kInvalidWalletHandle on error. | 121 // Returns kInvalidWalletHandle on error. |
| 124 int WalletHandle(); | 122 int WalletHandle(); |
| 125 | 123 |
| 126 // Compares two PasswordForms and returns true if they are the same. | 124 // Compares two PasswordForms and returns true if they are the same. |
| 127 // If |update_check| is false, we only check the fields that are checked by | 125 // If |update_check| is false, we only check the fields that are checked by |
| 128 // LoginDatabase::UpdateLogin() when updating logins; otherwise, we check the | 126 // LoginDatabase::UpdateLogin() when updating logins; otherwise, we check the |
| 129 // fields that are checked by LoginDatabase::RemoveLogin() for removing them. | 127 // fields that are checked by LoginDatabase::RemoveLogin() for removing them. |
| 130 static bool CompareForms(const webkit::forms::PasswordForm& a, | 128 static bool CompareForms(const content::PasswordForm& a, |
| 131 const webkit::forms::PasswordForm& b, | 129 const content::PasswordForm& b, |
| 132 bool update_check); | 130 bool update_check); |
| 133 | 131 |
| 134 // Serializes a list of PasswordForms to be stored in the wallet. | 132 // Serializes a list of PasswordForms to be stored in the wallet. |
| 135 static void SerializeValue(const PasswordFormList& forms, Pickle* pickle); | 133 static void SerializeValue(const PasswordFormList& forms, Pickle* pickle); |
| 136 | 134 |
| 137 // Checks a serialized list of PasswordForms for sanity. Returns true if OK. | 135 // Checks a serialized list of PasswordForms for sanity. Returns true if OK. |
| 138 // Note that |realm| is only used for generating a useful warning message. | 136 // Note that |realm| is only used for generating a useful warning message. |
| 139 static bool CheckSerializedValue(const uint8_t* byte_array, size_t length, | 137 static bool CheckSerializedValue(const uint8_t* byte_array, size_t length, |
| 140 const std::string& realm); | 138 const std::string& realm); |
| 141 | 139 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 | 181 |
| 184 // The name of the wallet we've opened. Set during Init(). | 182 // The name of the wallet we've opened. Set during Init(). |
| 185 std::string wallet_name_; | 183 std::string wallet_name_; |
| 186 // The application name (e.g. "Chromium"), shown in KWallet auth dialogs. | 184 // The application name (e.g. "Chromium"), shown in KWallet auth dialogs. |
| 187 const std::string app_name_; | 185 const std::string app_name_; |
| 188 | 186 |
| 189 DISALLOW_COPY_AND_ASSIGN(NativeBackendKWallet); | 187 DISALLOW_COPY_AND_ASSIGN(NativeBackendKWallet); |
| 190 }; | 188 }; |
| 191 | 189 |
| 192 #endif // CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_KWALLET_X_H_ | 190 #endif // CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_KWALLET_X_H_ |
| OLD | NEW |