Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_KWALLET_DBUS_H_ | |
| 6 #define CHROME_BROWSER_PASSWORD_MANAGER_KWALLET_DBUS_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/macros.h" | |
| 12 #include "base/nix/xdg_util.h" | |
| 13 #include "dbus/bus.h" | |
| 14 | |
| 15 // Contains wrappers for dbus invocations related to KWallet. | |
| 16 class KWalletDBus { | |
| 17 public: | |
| 18 // Error code for dbus calls to kwallet. | |
| 19 enum Error { SUCCESS = 0, CANNOT_CONTACT, CANNOT_READ }; | |
| 20 | |
| 21 explicit KWalletDBus(base::nix::DesktopEnvironment desktop_env); | |
| 22 ~KWalletDBus(); | |
| 23 | |
| 24 // Set the bus that we should use. Required before any other operation. | |
| 25 // The owner of KWalletDBus is responsible for killing the bus. | |
| 26 void SetSessionBus(scoped_refptr<dbus::Bus> session_bus); | |
| 27 | |
| 28 // Expose the bus so that shutdown can be scheduled asynchronously | |
| 29 dbus::Bus* GetSessionBus(); | |
| 30 | |
| 31 // Use KLauncher to start the KWallet service. Returns true if successful. | |
| 32 bool StartKWalletd() WARN_UNUSED_RESULT; | |
| 33 | |
| 34 // The functions below are wrappers for calling the eponymous KWallet dbus | |
| 35 // methods. They take pointers to locations where the return values will be | |
| 36 // written. More KWallet documentation at | |
| 37 // https://api.kde.org/4.12-api/kdelibs-apidocs/kdeui/html/classKWallet_1_1Wal let.html | |
| 38 | |
| 39 // Determine if the KDE wallet is enabled. | |
| 40 Error IsEnabled(bool* enabled) WARN_UNUSED_RESULT; | |
| 41 | |
| 42 // Get the name of the wallet used to store network passwords. | |
| 43 Error NetworkWallet(std::string* wallet_name_ptr) WARN_UNUSED_RESULT; | |
| 44 | |
| 45 // Determine if the current folder has they entry key. | |
| 46 Error HasEntry(const int wallet_handle, | |
| 47 const std::string& folder_name, | |
| 48 const std::string& signon_realm, | |
| 49 const std::string& app_name, | |
| 50 bool* has_entry_ptr) WARN_UNUSED_RESULT; | |
| 51 | |
| 52 // Read the entry key from the current folder. | |
| 53 // 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.
| |
| 54 Error ReadEntry(const int wallet_handle, | |
| 55 const std::string& folder_name, | |
| 56 const std::string& signon_realm, | |
| 57 const std::string& app_name, | |
| 58 std::vector<uint8_t>* bytes_ptr) WARN_UNUSED_RESULT; | |
| 59 | |
| 60 // Return the list of keys of all entries in this folder. | |
| 61 Error EntryList(const int wallet_handle, | |
| 62 const std::string& folder_name, | |
| 63 const std::string& app_name, | |
| 64 std::vector<std::string>* entry_list_ptr) WARN_UNUSED_RESULT; | |
| 65 | |
| 66 // Remove the entry key from the current folder. | |
| 67 // |*return_code_ptr| is 0 on success. | |
| 68 Error RemoveEntry(const int wallet_handle, | |
| 69 const std::string& folder_name, | |
| 70 const std::string& signon_realm, | |
| 71 const std::string& app_name, | |
| 72 int* return_code_ptr) WARN_UNUSED_RESULT; | |
| 73 | |
| 74 // Write a binary entry to the current folder. | |
| 75 // |*return_code_ptr| is 0 on success. | |
| 76 Error WriteEntry(const int wallet_handle, | |
| 77 const std::string& folder_name, | |
| 78 const std::string& signon_realm, | |
| 79 const std::string& app_name, | |
| 80 const uint8_t* data, | |
| 81 const size_t length, | |
| 82 int* return_code_ptr) WARN_UNUSED_RESULT; | |
| 83 | |
| 84 // Open the |wallet_name| wallet for use. | |
| 85 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.
| |
| 86 const std::string& app_name, | |
| 87 int* handle_ptr) WARN_UNUSED_RESULT; | |
| 88 | |
| 89 // Determine if the folder |folder_name| exists in the wallet. | |
| 90 Error HasFolder(const int handle, | |
| 91 const std::string& folder_name, | |
| 92 const std::string& app_name, | |
| 93 bool* has_folder_ptr) WARN_UNUSED_RESULT; | |
| 94 | |
| 95 // Created the folder |folder_name|. | |
| 96 Error CreateFolder(const int handle, | |
| 97 const std::string& folder_name, | |
| 98 const std::string& app_name, | |
| 99 bool* success_ptr) WARN_UNUSED_RESULT; | |
| 100 | |
| 101 private: | |
| 102 // DBus handle for communication with klauncher and kwalletd. | |
| 103 scoped_refptr<dbus::Bus> session_bus_; | |
| 104 // Object proxy for kwalletd. We do not own this. | |
| 105 dbus::ObjectProxy* kwallet_proxy_; | |
| 106 | |
| 107 // KWallet DBus name | |
| 108 std::string dbus_service_name_; | |
| 109 // DBus path to KWallet interfaces | |
| 110 std::string dbus_path_; | |
| 111 // The name used for logging and by klauncher when starting KWallet | |
| 112 std::string kwalletd_name_; | |
| 113 | |
| 114 DISALLOW_COPY_AND_ASSIGN(KWalletDBus); | |
| 115 }; | |
| 116 | |
| 117 #endif // CHROME_BROWSER_PASSWORD_MANAGER_KWALLET_DBUS_H_ | |
| OLD | NEW |