Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / content / common / bluetooth / bluetooth_messages.h
blobf496f9d4858ab8b3f90071cb858e07ce7ad84a11
1 // Copyright 2014 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 // Messages for Web Bluetooth API.
6 // Multiply-included message file, hence no include guard.
8 // Web Bluetooth Security
9 // The security mechanisms of Bluetooth are described in the specification:
10 // https://webbluetoothcg.github.io/web-bluetooth
12 // Exerpts:
14 // From: Security and privacy considerations
15 // http://webbluetoothcg.github.io/web-bluetooth/#security-and-privacy-considerations
16 // """
17 // When a website requests access to devices using requestDevice, it gets the
18 // ability to access all GATT services mentioned in the call. The UA must inform
19 // the user what capabilities these services give the website before asking
20 // which devices to entrust to it. If any services in the list aren't known to
21 // the UA, the UA must assume they give the site complete control over the
22 // device and inform the user of this risk. The UA must also allow the user to
23 // inspect what sites have access to what devices and revoke these pairings.
25 // The UA must not allow the user to pair entire classes of devices with a
26 // website. It is possible to construct a class of devices for which each
27 // individual device sends the same Bluetooth-level identifying information. UAs
28 // are not required to attempt to detect this sort of forgery and may let a user
29 // pair this pseudo-device with a website.
31 // To help ensure that only the entity the user approved for access actually has
32 // access, this specification requires that only authenticated environments can
33 // access Bluetooth devices (requestDevice).
34 // """
36 // From: Per-origin Bluetooth device properties:
37 // """
38 // For each origin, the UA must maintain an allowed devices map, whose keys are
39 // the Bluetooth devices the origin is allowed to access, and whose values are
40 // pairs of a DOMString device id and an allowed services list consisting of
41 // UUIDs for GATT Primary Services the origin is allowed to access on the
42 // device.
44 // The UA may remove devices from the allowed devices map at any time based on
45 // signals from the user. This needs a definition involving removing
46 // BluetoothDevice instances from device instance maps and clearing out their
47 // [[representedDevice]] fields. For example, if the user chooses not to
48 // remember access, the UA might remove a device when the tab that was granted
49 // access to it is closed. Or the UA might provide a revocation UI that allows
50 // the user to explicitly remove a device even while a tab is actively using
51 // that device. If a device is removed from this list while a Promise is pending
52 // to do something with the device, it must be treated the same as if the device
53 // moved out of Bluetooth range.
54 // """
56 // From: Device Discovery: requestDevice
57 // http://webbluetoothcg.github.io/web-bluetooth/#device-discovery
58 // """
59 // Display a prompt to the user requesting that the user specify some devices
60 // from the result of the scan. The UA should show the user the human-readable
61 // name of each device. If this name is not available because the UA's Bluetooth
62 // system doesn't support privacy-enabled scans, the UA should allow the user to
63 // indicate interest and then perform a privacy-disabled scan to retrieve the
64 // name.
66 // The UA may allow the user to select a nearby device that does not match
67 // filters.
69 // Wait for the user to have made their selection.
71 // If the user cancels the prompt, reject the Promise with a NotFoundError and
72 // abort these steps.
74 // Record the selected device in the origin's allowed devices list and the union
75 // of the service UUIDs from filters and options.optionalServices in the device
76 // and origin's allowed services list.
78 // Connect to the device. ([BLUETOOTH41] 3.G.6.2.1) If the connection fails,
79 // reject the Promise with a NetworkError and abort these steps.
81 // Resolve the Promise with a BluetoothDevice instance representing the selected
82 // device.
83 // """
85 #include "ipc/ipc_message_macros.h"
86 #include "content/common/bluetooth/bluetooth_device.h"
87 #include "content/common/bluetooth/bluetooth_error.h"
89 #define IPC_MESSAGE_START BluetoothMsgStart
91 IPC_ENUM_TRAITS_MAX_VALUE(
92 device::BluetoothDevice::VendorIDSource,
93 device::BluetoothDevice::VendorIDSource::VENDOR_ID_MAX_VALUE)
95 IPC_STRUCT_TRAITS_BEGIN(content::BluetoothDevice)
96 IPC_STRUCT_TRAITS_MEMBER(instance_id)
97 IPC_STRUCT_TRAITS_MEMBER(name)
98 IPC_STRUCT_TRAITS_MEMBER(device_class)
99 IPC_STRUCT_TRAITS_MEMBER(vendor_id_source)
100 IPC_STRUCT_TRAITS_MEMBER(vendor_id)
101 IPC_STRUCT_TRAITS_MEMBER(product_id)
102 IPC_STRUCT_TRAITS_MEMBER(product_version)
103 IPC_STRUCT_TRAITS_MEMBER(paired)
104 IPC_STRUCT_TRAITS_MEMBER(uuids)
105 IPC_STRUCT_TRAITS_END()
107 IPC_ENUM_TRAITS_MAX_VALUE(content::BluetoothError,
108 content::BluetoothError::ENUM_MAX_VALUE)
110 // Messages sent from the browser to the renderer.
112 // Informs the renderer that the device request |request_id| succeeded.
113 IPC_MESSAGE_CONTROL3(BluetoothMsg_RequestDeviceSuccess,
114 int /* thread_id */,
115 int /* request_id */,
116 content::BluetoothDevice /* device */)
118 // Informs the renderer that the device request |request_id| failed.
119 IPC_MESSAGE_CONTROL3(BluetoothMsg_RequestDeviceError,
120 int /* thread_id */,
121 int /* request_id */,
122 content::BluetoothError /* result */)
124 // Informs the renderer that the connection request |request_id| succeeded.
125 IPC_MESSAGE_CONTROL3(BluetoothMsg_ConnectGATTSuccess,
126 int /* thread_id */,
127 int /* request_id */,
128 std::string /* device_instance_id */)
130 // Messages sent from the renderer to the browser.
132 // Requests a bluetooth device from the browser.
133 // TODO(scheib): UI to select and permit access to a device crbug.com/436280.
134 // This will include refactoring messages to be associated with an origin
135 // and making this initial requestDevice call with an associated frame.
136 // This work is deferred to simplify initial prototype patches.
137 // The Bluetooth feature, and the BluetoothDispatcherHost are behind
138 // the --enable-experimental-web-platform-features flag.
139 IPC_MESSAGE_CONTROL2(BluetoothHostMsg_RequestDevice,
140 int /* thread_id */,
141 int /* request_id */)
143 // Connects to a bluetooth device.
144 IPC_MESSAGE_CONTROL3(BluetoothHostMsg_ConnectGATT,
145 int /* thread_id */,
146 int /* request_id */,
147 std::string /* device_instance_id */)
149 // Configures the mock data set in the browser used while under test.
150 // TODO(scheib): Disable testing in non-test executables. crbug.com/436284.
151 IPC_MESSAGE_CONTROL1(BluetoothHostMsg_SetBluetoothMockDataSetForTesting,
152 std::string /* name */)