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 CHROMEOS_DBUS_PERMISSION_BROKER_CLIENT_H_ | 5 #ifndef CHROMEOS_DBUS_PERMISSION_BROKER_CLIENT_H_ |
6 #define CHROMEOS_DBUS_PERMISSION_BROKER_CLIENT_H_ | 6 #define CHROMEOS_DBUS_PERMISSION_BROKER_CLIENT_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 16 matching lines...) Expand all Loading... |
27 class CHROMEOS_EXPORT PermissionBrokerClient : public DBusClient { | 27 class CHROMEOS_EXPORT PermissionBrokerClient : public DBusClient { |
28 public: | 28 public: |
29 // The ResultCallback is used for both the RequestPathAccess and | 29 // The ResultCallback is used for both the RequestPathAccess and |
30 // RequestUsbAccess methods. Its boolean parameter represents the result of | 30 // RequestUsbAccess methods. Its boolean parameter represents the result of |
31 // the operation that it was submitted alongside. | 31 // the operation that it was submitted alongside. |
32 typedef base::Callback<void(bool)> ResultCallback; | 32 typedef base::Callback<void(bool)> ResultCallback; |
33 | 33 |
34 // An OpenPathCallback callback is run when an OpenPath request is completed. | 34 // An OpenPathCallback callback is run when an OpenPath request is completed. |
35 typedef base::Callback<void(dbus::FileDescriptor)> OpenPathCallback; | 35 typedef base::Callback<void(dbus::FileDescriptor)> OpenPathCallback; |
36 | 36 |
| 37 // An ErrorCallback callback is run when an error is returned by the |
| 38 // permission broker. |
| 39 typedef base::Callback<void(const std::string& error_name, |
| 40 const std::string& message)> |
| 41 ErrorCallback; |
| 42 |
37 ~PermissionBrokerClient() override; | 43 ~PermissionBrokerClient() override; |
38 | 44 |
39 static PermissionBrokerClient* Create(); | 45 static PermissionBrokerClient* Create(); |
40 | 46 |
41 // CheckPathAccess requests a hint from the permission broker about whether | 47 // CheckPathAccess requests a hint from the permission broker about whether |
42 // a later call to RequestPathAccess will be successful. It presumes that | 48 // a later call to RequestPathAccess will be successful. It presumes that |
43 // the |interface_id| value passed to RequestPathAccess will be | 49 // the |interface_id| value passed to RequestPathAccess will be |
44 // UsbDevicePermissionsData::ANY_INTERFACE). | 50 // UsbDevicePermissionsData::ANY_INTERFACE). |
45 virtual void CheckPathAccess(const std::string& path, | 51 virtual void CheckPathAccess(const std::string& path, |
46 const ResultCallback& callback) = 0; | 52 const ResultCallback& callback) = 0; |
47 | 53 |
48 // OpenPath requests that the permission broker open the device node | 54 // OpenPath requests that the permission broker open the device node |
49 // identified by |path| and return the resulting file descriptor. | 55 // identified by |path| and return the resulting file descriptor. One of |
| 56 // |callback| or |error_callback| is called. |
50 virtual void OpenPath(const std::string& path, | 57 virtual void OpenPath(const std::string& path, |
51 const OpenPathCallback& callback) = 0; | 58 const OpenPathCallback& callback, |
| 59 const ErrorCallback& error_callback) = 0; |
52 | 60 |
53 // Requests the |port| be opened on the firewall for incoming TCP/IP | 61 // Requests the |port| be opened on the firewall for incoming TCP/IP |
54 // connections received on |interface| (an empty string indicates all | 62 // connections received on |interface| (an empty string indicates all |
55 // interfaces). An open pipe must be passed as |lifeline_fd| so that the | 63 // interfaces). An open pipe must be passed as |lifeline_fd| so that the |
56 // permission broker can monitor the lifetime of the calling process. | 64 // permission broker can monitor the lifetime of the calling process. |
57 virtual void RequestTcpPortAccess(uint16_t port, | 65 virtual void RequestTcpPortAccess(uint16_t port, |
58 const std::string& interface, | 66 const std::string& interface, |
59 const dbus::FileDescriptor& lifeline_fd, | 67 const dbus::FileDescriptor& lifeline_fd, |
60 const ResultCallback& callback) = 0; | 68 const ResultCallback& callback) = 0; |
61 | 69 |
(...skipping 23 matching lines...) Expand all Loading... |
85 protected: | 93 protected: |
86 PermissionBrokerClient(); | 94 PermissionBrokerClient(); |
87 | 95 |
88 private: | 96 private: |
89 DISALLOW_COPY_AND_ASSIGN(PermissionBrokerClient); | 97 DISALLOW_COPY_AND_ASSIGN(PermissionBrokerClient); |
90 }; | 98 }; |
91 | 99 |
92 } // namespace chromeos | 100 } // namespace chromeos |
93 | 101 |
94 #endif // CHROMEOS_DBUS_PERMISSION_BROKER_CLIENT_H_ | 102 #endif // CHROMEOS_DBUS_PERMISSION_BROKER_CLIENT_H_ |
OLD | NEW |