Chromium Code Reviews| Index: chrome/browser/password_manager/kwallet_dbus.h |
| diff --git a/chrome/browser/password_manager/kwallet_dbus.h b/chrome/browser/password_manager/kwallet_dbus.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a760357d4bfcce2ff025d05012b0ae950c002630 |
| --- /dev/null |
| +++ b/chrome/browser/password_manager/kwallet_dbus.h |
| @@ -0,0 +1,117 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_PASSWORD_MANAGER_KWALLET_DBUS_H_ |
| +#define CHROME_BROWSER_PASSWORD_MANAGER_KWALLET_DBUS_H_ |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/macros.h" |
| +#include "base/nix/xdg_util.h" |
| +#include "dbus/bus.h" |
| + |
| +// Contains wrappers for dbus invocations related to KWallet. |
| +class KWalletDBus { |
| + public: |
| + // Error code for dbus calls to kwallet. |
| + enum Error { SUCCESS = 0, CANNOT_CONTACT, CANNOT_READ }; |
| + |
| + explicit KWalletDBus(base::nix::DesktopEnvironment desktop_env); |
| + ~KWalletDBus(); |
| + |
| + // Set the bus that we should use. Required before any other operation. |
| + // The owner of KWalletDBus is responsible for killing the bus. |
| + void SetSessionBus(scoped_refptr<dbus::Bus> session_bus); |
| + |
| + // Expose the bus so that shutdown can be scheduled asynchronously |
| + dbus::Bus* GetSessionBus(); |
| + |
| + // Use KLauncher to start the KWallet service. Returns true if successful. |
| + bool StartKWalletd() WARN_UNUSED_RESULT; |
| + |
| + // The functions below are wrappers for calling the eponymous KWallet dbus |
| + // methods. They take pointers to locations where the return values will be |
| + // written. More KWallet documentation at |
| + // https://api.kde.org/4.12-api/kdelibs-apidocs/kdeui/html/classKWallet_1_1Wallet.html |
| + |
| + // Determine if the KDE wallet is enabled. |
| + Error IsEnabled(bool* enabled) WARN_UNUSED_RESULT; |
| + |
| + // Get the name of the wallet used to store network passwords. |
| + Error NetworkWallet(std::string* wallet_name_ptr) WARN_UNUSED_RESULT; |
| + |
| + // Determine if the current folder has they entry key. |
| + Error HasEntry(const int wallet_handle, |
| + const std::string& folder_name, |
| + const std::string& signon_realm, |
| + const std::string& app_name, |
| + bool* has_entry_ptr) WARN_UNUSED_RESULT; |
| + |
| + // Read the entry key from the current folder. |
| + // Ownership of the instance assigned to |bytes_ptr| is passed to the caller |
|
vasilii
2016/06/16 17:54:43
Isn't it obvious?
cfroussios
2016/06/17 12:17:26
Done.
|
| + Error ReadEntry(const int wallet_handle, |
| + const std::string& folder_name, |
| + const std::string& signon_realm, |
| + const std::string& app_name, |
| + std::vector<uint8_t>* bytes_ptr) WARN_UNUSED_RESULT; |
| + |
| + // Return the list of keys of all entries in this folder. |
| + Error EntryList(const int wallet_handle, |
| + const std::string& folder_name, |
| + const std::string& app_name, |
| + std::vector<std::string>* entry_list_ptr) WARN_UNUSED_RESULT; |
| + |
| + // Remove the entry key from the current folder. |
| + // |*return_code_ptr| is 0 on success. |
| + Error RemoveEntry(const int wallet_handle, |
| + const std::string& folder_name, |
| + const std::string& signon_realm, |
| + const std::string& app_name, |
| + int* return_code_ptr) WARN_UNUSED_RESULT; |
| + |
| + // Write a binary entry to the current folder. |
| + // |*return_code_ptr| is 0 on success. |
| + Error WriteEntry(const int wallet_handle, |
| + const std::string& folder_name, |
| + const std::string& signon_realm, |
| + const std::string& app_name, |
| + const uint8_t* data, |
| + const size_t length, |
| + int* return_code_ptr) WARN_UNUSED_RESULT; |
| + |
| + // Open the |wallet_name| wallet for use. |
| + Error Open(const std::string& wallet_name, |
|
vasilii
2016/06/16 17:54:43
Probably should go to the top of the header.
cfroussios
2016/06/17 12:17:26
Done.
|
| + const std::string& app_name, |
| + int* handle_ptr) WARN_UNUSED_RESULT; |
| + |
| + // Determine if the folder |folder_name| exists in the wallet. |
| + Error HasFolder(const int handle, |
| + const std::string& folder_name, |
| + const std::string& app_name, |
| + bool* has_folder_ptr) WARN_UNUSED_RESULT; |
| + |
| + // Created the folder |folder_name|. |
| + Error CreateFolder(const int handle, |
| + const std::string& folder_name, |
| + const std::string& app_name, |
| + bool* success_ptr) WARN_UNUSED_RESULT; |
| + |
| + private: |
| + // DBus handle for communication with klauncher and kwalletd. |
| + scoped_refptr<dbus::Bus> session_bus_; |
| + // Object proxy for kwalletd. We do not own this. |
| + dbus::ObjectProxy* kwallet_proxy_; |
| + |
| + // KWallet DBus name |
| + std::string dbus_service_name_; |
| + // DBus path to KWallet interfaces |
| + std::string dbus_path_; |
| + // The name used for logging and by klauncher when starting KWallet |
| + std::string kwalletd_name_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(KWalletDBus); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_PASSWORD_MANAGER_KWALLET_DBUS_H_ |