Adding Peter Thatcher to the owners file.
[chromium-blink-merge.git] / chromeos / dbus / permission_broker_client.h
blobaa14757418bb4f0ce98533ffb869da33899e02f1
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
3 // found in the LICENSE file.
5 #ifndef CHROMEOS_DBUS_PERMISSION_BROKER_CLIENT_H_
6 #define CHROMEOS_DBUS_PERMISSION_BROKER_CLIENT_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "chromeos/chromeos_export.h"
13 #include "chromeos/dbus/dbus_client.h"
15 namespace dbus {
16 class FileDescriptor;
19 namespace chromeos {
21 // PermissionBrokerClient is used to communicate with the permission broker, a
22 // process that allows requesting permission to access specific device nodes.
23 // For example, one place that this client is used is within the USB extension
24 // API code, where it is used to request explicit access to USB peripherals
25 // which the user the browser runs under normally wouldn't have access to. For
26 // more details on the permission broker see:
27 // http://git.chromium.org/gitweb/?p=chromiumos/platform/permission_broker.git
28 class CHROMEOS_EXPORT PermissionBrokerClient : public DBusClient {
29 public:
30 // The ResultCallback is used for both the RequestPathAccess and
31 // RequestUsbAccess methods. Its boolean parameter represents the result of
32 // the operation that it was submitted alongside.
33 typedef base::Callback<void(bool)> ResultCallback;
35 ~PermissionBrokerClient() override;
37 static PermissionBrokerClient* Create();
39 // RequestPathAccess requests access to a single device node identified by
40 // |path|. If |interface_id| value is passed (different than
41 // UsbDevicePermissionData::ANY_INTERFACE), the request will check if a
42 // specific interface is claimed while requesting access.
43 // This allows devices with multiple interfaces to be accessed even if
44 // some of them are already claimed by kernel.
45 virtual void RequestPathAccess(const std::string& path,
46 int interface_id,
47 const ResultCallback& callback) = 0;
49 // Requests the |port| be opened on the firewall for incoming TCP/IP
50 // connections received on |interface| (an empty string indicates all
51 // interfaces). An open pipe must be passed as |lifeline_fd| so that the
52 // permission broker can monitor the lifetime of the calling process.
53 virtual void RequestTcpPortAccess(uint16 port,
54 const std::string& interface,
55 const dbus::FileDescriptor& lifeline_fd,
56 const ResultCallback& callback) = 0;
58 // Requests the |port| be opened on the firewall for incoming UDP packets
59 // received on |interface| (an empty string indicates all interfaces). An open
60 // pipe must be passed as |lifeline_fd| so that the permission broker can
61 // monitor the lifetime of the calling process.
62 virtual void RequestUdpPortAccess(uint16 port,
63 const std::string& interface,
64 const dbus::FileDescriptor& lifeline_fd,
65 const ResultCallback& callback) = 0;
67 // Releases a request for an open firewall port for TCP/IP connections. The
68 // |port| and |interface| parameters must be the same as a previous call to
69 // RequestTcpPortAccess.
70 virtual void ReleaseTcpPort(uint16 port,
71 const std::string& interface,
72 const ResultCallback& callback) = 0;
74 // Releases a request for an open firewall port for UDP packets. The |port|
75 // and |interface| parameters must be the same as a previous call to
76 // RequestUdpPortAccess.
77 virtual void ReleaseUdpPort(uint16 port,
78 const std::string& interface,
79 const ResultCallback& callback) = 0;
81 protected:
82 PermissionBrokerClient();
84 private:
85 DISALLOW_COPY_AND_ASSIGN(PermissionBrokerClient);
88 } // namespace chromeos
90 #endif // CHROMEOS_DBUS_PERMISSION_BROKER_CLIENT_H_