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/memory/scoped_vector.h" | |
|
vasilii
2016/06/10 16:58:09
Used?
cfroussios
2016/06/16 12:29:08
Done.
| |
| 13 #include "base/nix/xdg_util.h" | |
| 14 #include "dbus/bus.h" | |
|
vasilii
2016/06/10 16:58:09
Used?
cfroussios
2016/06/16 12:29:08
For GetBus() and SetSessionBus()
vasilii
2016/06/16 17:54:43
Can be forward declared.
cfroussios
2016/06/17 12:17:26
Done.
| |
| 15 | |
|
vasilii
2016/06/10 16:58:10
A comment.
cfroussios
2016/06/16 12:29:08
Done.
| |
| 16 class KWalletDBus { | |
| 17 public: | |
| 18 // Error code for dbus calls to kwallet. | |
| 19 enum Error { SUCCESS = 0, CANNOT_CONTACT, CANNOT_READ }; | |
|
vasilii
2016/06/10 16:58:09
What about enum class?
vasilii
2016/06/10 16:58:09
split one per line; Optionally remove 0. It's by d
cfroussios
2016/06/16 12:29:08
The style was chosen by the formatter.
Success =
cfroussios
2016/06/16 12:29:08
An enum class complicated error handling code, bec
| |
| 20 | |
| 21 explicit KWalletDBus(base::nix::DesktopEnvironment desktop_env); | |
| 22 virtual ~KWalletDBus(); | |
|
vasilii
2016/06/10 16:58:09
Is there any reason for 'virtual'?
cfroussios
2016/06/16 12:29:08
Done.
| |
| 23 | |
| 24 // Set the bus that we should use. Required before any other operation. | |
| 25 void SetSessionBus(scoped_refptr<dbus::Bus> session_bus); | |
| 26 | |
| 27 // Expose the bus so that shutdown can be scheduled asynchronously | |
| 28 dbus::Bus* GetBus(); | |
|
vasilii
2016/06/10 16:58:09
Name consistently with SetSessionBus. GetSessionBu
cfroussios
2016/06/16 12:29:08
Done.
| |
| 29 | |
| 30 // Use KLauncher to start the KWallet service. Returns true if successful. | |
| 31 bool StartKWalletd(); | |
| 32 | |
| 33 // The functions below are wrappers for calling the eponymous KWallet dbus | |
| 34 // methods. They take pointers to locations where the return values will be | |
| 35 // written. More KWallet documentation at | |
| 36 // https://api.kde.org/4.12-api/kdelibs-apidocs/kdeui/html/classKWallet_1_1Wal let.html | |
| 37 | |
| 38 // Determine if the KDE wallet is enabled. | |
| 39 Error IsEnabled(bool* enabled); | |
| 40 | |
| 41 // The name of the wallet used to store network passwords. | |
|
vasilii
2016/06/10 16:58:09
Sets the name or gets the name?
cfroussios
2016/06/16 12:29:08
Done.
| |
| 42 Error NetworkWallet(std::string* wallet_name_ptr); | |
| 43 | |
| 44 // Determine if the current folder has they entry key. | |
| 45 Error HasEntry(bool* has_entry_ptr, | |
|
vasilii
2016/06/10 16:58:10
Here and below: the out parameters should be the l
cfroussios
2016/06/16 12:29:08
Done.
| |
| 46 const int wallet_handle, | |
|
vasilii
2016/06/10 16:58:09
const int and const size_t don't really make sense
cfroussios
2016/06/16 12:29:08
const means that it's a value and not a variable.
vasilii
2016/06/16 17:54:43
You could have 'const' in .cc only. In the header
cfroussios
2016/06/17 12:17:26
Done.
| |
| 47 const std::string& folder_name, | |
| 48 const std::string& signon_realm, | |
| 49 const std::string& app_name); | |
| 50 | |
| 51 // Read the entry key from the current folder. | |
| 52 Error ReadEntry(const uint8_t** bytes_ptr, | |
|
vasilii
2016/06/10 16:58:10
You can apply WARN_UNUSED_RESULT to all the method
cfroussios
2016/06/16 12:29:08
Done.
| |
| 53 size_t* length_ptr, | |
| 54 const int wallet_handle, | |
| 55 const std::string& folder_name, | |
| 56 const std::string& signon_realm, | |
| 57 const std::string& app_name); | |
| 58 | |
| 59 // Return the list of keys of all entries in this folder. | |
| 60 Error EntryList(std::vector<std::string>* entry_list_ptr, | |
| 61 const int wallet_handle, | |
| 62 const std::string& folder_name, | |
| 63 const std::string& app_name); | |
| 64 | |
| 65 // Remove the entry key from the current folder. | |
| 66 Error RemoveEntry(int* rv_ptr, | |
| 67 const int wallet_handle, | |
| 68 const std::string& folder_name, | |
| 69 const std::string& signon_realm, | |
| 70 const std::string& app_name); | |
| 71 | |
| 72 // Write a binary entry to the current folder. | |
| 73 Error WriteEntry(int* rv_ptr, | |
|
vasilii
2016/06/10 16:58:09
What's this?
cfroussios
2016/06/16 12:29:08
Done.
| |
| 74 const int wallet_handle, | |
| 75 const std::string& folder_name, | |
| 76 const std::string& signon_realm, | |
| 77 const uint8_t* data, | |
| 78 const size_t length, | |
| 79 const std::string& app_name); | |
| 80 | |
| 81 // Open the |wallet_name| wallet for use. | |
| 82 Error Open(int* handle_ptr, | |
| 83 const std::string& wallet_name, | |
| 84 const std::string& app_name); | |
| 85 | |
| 86 // Determine if the folder |folder_name| exists in the wallet. | |
| 87 Error HasFolder(bool* has_folder_ptr, | |
| 88 const int handle, | |
| 89 const std::string& folder_name, | |
| 90 const std::string& app_name); | |
| 91 | |
| 92 // Created the folder |fodler_name|. | |
| 93 Error CreateFolder(bool* success_ptr, | |
| 94 const int handle, | |
| 95 const std::string& folder_name, | |
| 96 const std::string& app_name); | |
| 97 | |
| 98 private: | |
| 99 // DBus handle for communication with klauncher and kwalletd. | |
| 100 scoped_refptr<dbus::Bus> session_bus_; | |
| 101 // Object proxy for kwalletd. We do not own this. | |
| 102 dbus::ObjectProxy* kwallet_proxy_; | |
| 103 | |
| 104 // KWallet DBus name | |
| 105 std::string dbus_service_name_; | |
| 106 // DBus path to KWallet interfaces | |
| 107 std::string dbus_path_; | |
| 108 // The name used for logging and by klauncher when starting KWallet | |
| 109 std::string kwalletd_name_; | |
| 110 | |
| 111 DISALLOW_COPY_AND_ASSIGN(KWalletDBus); | |
| 112 }; | |
| 113 | |
| 114 #endif // CHROME_BROWSER_PASSWORD_MANAGER_KWALLET_DBUS_H_ | |
| OLD | NEW |