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