| 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 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
| 15 #include "base/nix/xdg_util.h" | 15 #include "base/nix/xdg_util.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "chrome/browser/password_manager/kwallet_dbus.h" |
| 17 #include "chrome/browser/password_manager/password_store_factory.h" | 18 #include "chrome/browser/password_manager/password_store_factory.h" |
| 18 #include "chrome/browser/password_manager/password_store_x.h" | 19 #include "chrome/browser/password_manager/password_store_x.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 20 | 21 |
| 21 namespace autofill { | 22 namespace autofill { |
| 22 struct PasswordForm; | 23 struct PasswordForm; |
| 23 } | 24 } |
| 24 | 25 |
| 25 namespace base { | 26 namespace base { |
| 26 class Pickle; | 27 class Pickle; |
| 27 class PickleIterator; | 28 class PickleIterator; |
| 28 class WaitableEvent; | 29 class WaitableEvent; |
| 29 } | 30 } |
| 30 | 31 |
| 31 namespace dbus { | |
| 32 class Bus; | |
| 33 class ObjectProxy; | |
| 34 } | |
| 35 | |
| 36 // NativeBackend implementation using KWallet. | 32 // NativeBackend implementation using KWallet. |
| 37 class NativeBackendKWallet : public PasswordStoreX::NativeBackend { | 33 class NativeBackendKWallet : public PasswordStoreX::NativeBackend { |
| 38 public: | 34 public: |
| 39 NativeBackendKWallet(LocalProfileId id, | 35 NativeBackendKWallet(LocalProfileId id, |
| 40 base::nix::DesktopEnvironment desktop_env); | 36 base::nix::DesktopEnvironment desktop_env); |
| 41 | 37 |
| 42 ~NativeBackendKWallet() override; | 38 ~NativeBackendKWallet() override; |
| 43 | 39 |
| 44 bool Init() override; | 40 bool Init() override; |
| 45 | 41 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 }; | 83 }; |
| 88 | 84 |
| 89 enum TimestampToCompare { | 85 enum TimestampToCompare { |
| 90 CREATION_TIMESTAMP, | 86 CREATION_TIMESTAMP, |
| 91 SYNC_TIMESTAMP, | 87 SYNC_TIMESTAMP, |
| 92 }; | 88 }; |
| 93 | 89 |
| 94 enum class BlacklistOptions { AUTOFILLABLE, BLACKLISTED }; | 90 enum class BlacklistOptions { AUTOFILLABLE, BLACKLISTED }; |
| 95 | 91 |
| 96 // Initialization. | 92 // Initialization. |
| 97 bool StartKWalletd(); | |
| 98 InitResult InitWallet(); | 93 InitResult InitWallet(); |
| 99 void InitOnDBThread(scoped_refptr<dbus::Bus> optional_bus, | 94 void InitOnDBThread(scoped_refptr<dbus::Bus> optional_bus, |
| 100 base::WaitableEvent* event, | 95 base::WaitableEvent* event, |
| 101 bool* success); | 96 bool* success); |
| 102 | 97 |
| 103 // Overwrites |forms| with all credentials matching |signon_realm|. Returns | 98 // Overwrites |forms| with all credentials matching |signon_realm|. Returns |
| 104 // true on success. | 99 // true on success. |
| 105 bool GetLoginsList(const std::string& signon_realm, | 100 bool GetLoginsList(const std::string& signon_realm, |
| 106 int wallet_handle, | 101 int wallet_handle, |
| 107 ScopedVector<autofill::PasswordForm>* forms) | 102 ScopedVector<autofill::PasswordForm>* forms) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 136 // Opens the wallet and ensures that the "Chrome Form Data" folder exists. | 131 // Opens the wallet and ensures that the "Chrome Form Data" folder exists. |
| 137 // Returns kInvalidWalletHandle on error. | 132 // Returns kInvalidWalletHandle on error. |
| 138 int WalletHandle(); | 133 int WalletHandle(); |
| 139 | 134 |
| 140 // Generates a profile-specific folder name based on profile_id_. | 135 // Generates a profile-specific folder name based on profile_id_. |
| 141 std::string GetProfileSpecificFolderName() const; | 136 std::string GetProfileSpecificFolderName() const; |
| 142 | 137 |
| 143 // The local profile id, used to generate the folder name. | 138 // The local profile id, used to generate the folder name. |
| 144 const LocalProfileId profile_id_; | 139 const LocalProfileId profile_id_; |
| 145 | 140 |
| 141 KWalletDBus kwallet_dbus_; |
| 142 |
| 146 // The KWallet folder name, possibly based on the local profile id. | 143 // The KWallet folder name, possibly based on the local profile id. |
| 147 std::string folder_name_; | 144 std::string folder_name_; |
| 148 | 145 |
| 149 // DBus handle for communication with klauncher and kwalletd. | |
| 150 scoped_refptr<dbus::Bus> session_bus_; | |
| 151 // Object proxy for kwalletd. We do not own this. | |
| 152 dbus::ObjectProxy* kwallet_proxy_; | |
| 153 | |
| 154 // The name of the wallet we've opened. Set during Init(). | 146 // The name of the wallet we've opened. Set during Init(). |
| 155 std::string wallet_name_; | 147 std::string wallet_name_; |
| 156 // The application name (e.g. "Chromium"), shown in KWallet auth dialogs. | 148 // The application name (e.g. "Chromium"), shown in KWallet auth dialogs. |
| 157 const std::string app_name_; | 149 const std::string app_name_; |
| 158 | 150 |
| 159 // KWallet DBus name | |
| 160 std::string dbus_service_name_; | |
| 161 // DBus path to KWallet interfaces | |
| 162 std::string dbus_path_; | |
| 163 // The name used for logging and by klauncher when starting KWallet | |
| 164 std::string kwalletd_name_; | |
| 165 | |
| 166 DISALLOW_COPY_AND_ASSIGN(NativeBackendKWallet); | 151 DISALLOW_COPY_AND_ASSIGN(NativeBackendKWallet); |
| 167 }; | 152 }; |
| 168 | 153 |
| 169 #endif // CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_KWALLET_X_H_ | 154 #endif // CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_KWALLET_X_H_ |
| OLD | NEW |