[Android] Implement 3-way sensor fallback for Device Orientation.
[chromium-blink-merge.git] / content / common / bluetooth / bluetooth_messages.h
blob6e05cb4aa7400ac1b0aa5d0c2ca8caeb120a1136
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://webbluetoothchrome.github.io/web-bluetooth
12 // Exerpts:
14 // From: Security and privacy considerations
15 // http://webbluetoothchrome.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://webbluetoothchrome.github.io/web-bluetooth/#device-discovery
58 // """
59 // Even if scanResult is empty, display a prompt to the user requesting that the
60 // user select a device from it. 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 selected a device or cancelled the prompt.
71 // If the user cancels the prompt, reject promise with a NotFoundError and abort
72 // these steps.
74 // Add device to the origin's allowed devices map. with the union of the service
75 // UUIDs from filters and options.optionalServices as allowed services.
77 // Get the BluetoothDevice representing device and resolve promise with the
78 // result.
79 // """
81 #include "ipc/ipc_message_macros.h"
82 #include "content/common/bluetooth/bluetooth_device.h"
83 #include "content/common/bluetooth/bluetooth_scan_filter.h"
84 #include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothError.h"
86 #define IPC_MESSAGE_START BluetoothMsgStart
88 IPC_ENUM_TRAITS_MAX_VALUE(
89 device::BluetoothDevice::VendorIDSource,
90 device::BluetoothDevice::VendorIDSource::VENDOR_ID_MAX_VALUE)
92 IPC_STRUCT_TRAITS_BEGIN(content::BluetoothDevice)
93 IPC_STRUCT_TRAITS_MEMBER(instance_id)
94 IPC_STRUCT_TRAITS_MEMBER(name)
95 IPC_STRUCT_TRAITS_MEMBER(device_class)
96 IPC_STRUCT_TRAITS_MEMBER(vendor_id_source)
97 IPC_STRUCT_TRAITS_MEMBER(vendor_id)
98 IPC_STRUCT_TRAITS_MEMBER(product_id)
99 IPC_STRUCT_TRAITS_MEMBER(product_version)
100 IPC_STRUCT_TRAITS_MEMBER(paired)
101 IPC_STRUCT_TRAITS_MEMBER(uuids)
102 IPC_STRUCT_TRAITS_END()
104 IPC_ENUM_TRAITS_MAX_VALUE(blink::WebBluetoothError,
105 blink::WebBluetoothError::ENUM_MAX_VALUE)
107 IPC_STRUCT_TRAITS_BEGIN(content::BluetoothScanFilter)
108 IPC_STRUCT_TRAITS_MEMBER(services)
109 IPC_STRUCT_TRAITS_END()
111 // Messages sent from the browser to the renderer.
113 // Informs the renderer that the device request |request_id| succeeded.
114 IPC_MESSAGE_CONTROL3(BluetoothMsg_RequestDeviceSuccess,
115 int /* thread_id */,
116 int /* request_id */,
117 content::BluetoothDevice /* device */)
119 // Informs the renderer that the device request |request_id| failed.
120 IPC_MESSAGE_CONTROL3(BluetoothMsg_RequestDeviceError,
121 int /* thread_id */,
122 int /* request_id */,
123 blink::WebBluetoothError /* result */)
125 // Informs the renderer that the connection request |request_id| succeeded.
126 IPC_MESSAGE_CONTROL3(BluetoothMsg_ConnectGATTSuccess,
127 int /* thread_id */,
128 int /* request_id */,
129 std::string /* device_instance_id */)
131 // Informs the renderer that the connection request |request_id| failed.
132 IPC_MESSAGE_CONTROL3(BluetoothMsg_ConnectGATTError,
133 int /* thread_id */,
134 int /* request_id */,
135 blink::WebBluetoothError /* result */)
137 // Informs the renderer that primary service request |request_id| succeeded.
138 IPC_MESSAGE_CONTROL3(BluetoothMsg_GetPrimaryServiceSuccess,
139 int /* thread_id */,
140 int /* request_id */,
141 std::string /* service_instance_id */)
143 // Informs the renderer that the primary service request |request_id| failed.
144 IPC_MESSAGE_CONTROL3(BluetoothMsg_GetPrimaryServiceError,
145 int /* thread_id */,
146 int /* request_id */,
147 blink::WebBluetoothError /* result */)
149 // Informs the renderer that characteristic request |request_id| succeeded.
150 IPC_MESSAGE_CONTROL3(BluetoothMsg_GetCharacteristicSuccess,
151 int /* thread_id */,
152 int /* request_id */,
153 std::string /* characteristic_instance_id */)
155 // Informs the renderer that the characteristic request |request_id| failed.
156 IPC_MESSAGE_CONTROL3(BluetoothMsg_GetCharacteristicError,
157 int /* thread_id */,
158 int /* request_id */,
159 blink::WebBluetoothError /* result */)
161 // Informs the renderer that the value has been read.
162 IPC_MESSAGE_CONTROL3(BluetoothMsg_ReadCharacteristicValueSuccess,
163 int /* thread_id */,
164 int /* request_id */,
165 std::vector<uint8_t> /* value */)
167 // Informs the renderer that an error occurred while reading the value.
168 IPC_MESSAGE_CONTROL3(BluetoothMsg_ReadCharacteristicValueError,
169 int /* thread_id */,
170 int /* request_id */,
171 blink::WebBluetoothError /* result */)
173 // Informs the renderer that the value has been successfully written to
174 // the characteristic.
175 IPC_MESSAGE_CONTROL2(BluetoothMsg_WriteCharacteristicValueSuccess,
176 int /* thread_id */,
177 int /* request_id */)
179 // Informs the renderer that an error occurred while writing a value to a
180 // characteristic.
181 IPC_MESSAGE_CONTROL3(BluetoothMsg_WriteCharacteristicValueError,
182 int /* thread_id */,
183 int /* request_id */,
184 blink::WebBluetoothError /* result */)
186 // Messages sent from the renderer to the browser.
188 // Requests a bluetooth device from the browser.
189 IPC_MESSAGE_CONTROL5(BluetoothHostMsg_RequestDevice,
190 int /* thread_id */,
191 int /* request_id */,
192 int /* frame_routing_id */,
193 std::vector<content::BluetoothScanFilter>,
194 std::vector<device::BluetoothUUID> /* optional_services */)
196 // Connects to a bluetooth device.
197 IPC_MESSAGE_CONTROL3(BluetoothHostMsg_ConnectGATT,
198 int /* thread_id */,
199 int /* request_id */,
200 std::string /* device_instance_id */)
202 // Gets primary service from bluetooth device.
203 IPC_MESSAGE_CONTROL4(BluetoothHostMsg_GetPrimaryService,
204 int /* thread_id */,
205 int /* request_id */,
206 std::string /* device_instance_id */,
207 std::string /* service_uuid */)
209 // Gets a GATT Characteristic within a GATT Service.
210 IPC_MESSAGE_CONTROL4(BluetoothHostMsg_GetCharacteristic,
211 int /* thread_id */,
212 int /* request_id */,
213 std::string /* service_instance_id */,
214 std::string /* characteristic_uuid */)
216 // Reads the characteristics value from a bluetooth device.
217 IPC_MESSAGE_CONTROL3(BluetoothHostMsg_ReadValue,
218 int /* thread_id */,
219 int /* request_id */,
220 std::string /* characteristic_instance_id */)
222 // Writes a value to a bluetooth device's characteristic.
223 IPC_MESSAGE_CONTROL4(BluetoothHostMsg_WriteValue,
224 int /* thread_id */,
225 int /* request_id */,
226 std::string /* characteristic_instance_id */,
227 std::vector<uint8_t> /* value */)