Remove migrateNetworkPredictionPreferences().
[chromium-blink-merge.git] / chromeos / dbus / permission_broker_client.h
blobdd5eccaf7ed3a2cebe42569ca50a78939ccdb89f
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"
14 #include "dbus/file_descriptor.h"
16 namespace chromeos {
18 // PermissionBrokerClient is used to communicate with the permission broker, a
19 // process that allows requesting permission to access specific device nodes.
20 // For example, one place that this client is used is within the USB extension
21 // API code, where it is used to request explicit access to USB peripherals
22 // which the user the browser runs under normally wouldn't have access to. For
23 // more details on the permission broker see:
24 // http://git.chromium.org/gitweb/?p=chromiumos/platform/permission_broker.git
25 class CHROMEOS_EXPORT PermissionBrokerClient : public DBusClient {
26 public:
27 // The ResultCallback is used for both the RequestPathAccess and
28 // RequestUsbAccess methods. Its boolean parameter represents the result of
29 // the operation that it was submitted alongside.
30 typedef base::Callback<void(bool)> ResultCallback;
32 // An OpenPathCallback callback is run when an OpenPath request is completed.
33 typedef base::Callback<void(dbus::FileDescriptor)> OpenPathCallback;
35 ~PermissionBrokerClient() override;
37 static PermissionBrokerClient* Create();
39 // CheckPathAccess requests a hint from the permission broker about whether
40 // a later call to RequestPathAccess will be successful. It presumes that
41 // the |interface_id| value passed to RequestPathAccess will be
42 // UsbDevicePermissionsData::ANY_INTERFACE).
43 virtual void CheckPathAccess(const std::string& path,
44 const ResultCallback& callback) = 0;
46 // RequestPathAccess requests access to a single device node identified by
47 // |path|. If |interface_id| value is passed (different than
48 // UsbDevicePermissionData::ANY_INTERFACE), the request will check if a
49 // specific interface is claimed while requesting access.
50 // This allows devices with multiple interfaces to be accessed even if
51 // some of them are already claimed by kernel.
52 virtual void RequestPathAccess(const std::string& path,
53 int interface_id,
54 const ResultCallback& callback) = 0;
56 // OpenPath requests that the permission broker open the device node
57 // identified by |path| and return the resulting file descriptor.
58 virtual void OpenPath(const std::string& path,
59 const OpenPathCallback& callback) = 0;
61 // Requests the |port| be opened on the firewall for incoming TCP/IP
62 // connections received on |interface| (an empty string indicates all
63 // interfaces). An open pipe must be passed as |lifeline_fd| so that the
64 // permission broker can monitor the lifetime of the calling process.
65 virtual void RequestTcpPortAccess(uint16 port,
66 const std::string& interface,
67 const dbus::FileDescriptor& lifeline_fd,
68 const ResultCallback& callback) = 0;
70 // Requests the |port| be opened on the firewall for incoming UDP packets
71 // received on |interface| (an empty string indicates all interfaces). An open
72 // pipe must be passed as |lifeline_fd| so that the permission broker can
73 // monitor the lifetime of the calling process.
74 virtual void RequestUdpPortAccess(uint16 port,
75 const std::string& interface,
76 const dbus::FileDescriptor& lifeline_fd,
77 const ResultCallback& callback) = 0;
79 // Releases a request for an open firewall port for TCP/IP connections. The
80 // |port| and |interface| parameters must be the same as a previous call to
81 // RequestTcpPortAccess.
82 virtual void ReleaseTcpPort(uint16 port,
83 const std::string& interface,
84 const ResultCallback& callback) = 0;
86 // Releases a request for an open firewall port for UDP packets. The |port|
87 // and |interface| parameters must be the same as a previous call to
88 // RequestUdpPortAccess.
89 virtual void ReleaseUdpPort(uint16 port,
90 const std::string& interface,
91 const ResultCallback& callback) = 0;
93 protected:
94 PermissionBrokerClient();
96 private:
97 DISALLOW_COPY_AND_ASSIGN(PermissionBrokerClient);
100 } // namespace chromeos
102 #endif // CHROMEOS_DBUS_PERMISSION_BROKER_CLIENT_H_