Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 module blink.mojom; | 5 module blink.mojom; |
| 6 | 6 |
| 7 import "device/bluetooth/public/interfaces/uuid.mojom"; | 7 import "device/bluetooth/public/interfaces/uuid.mojom"; |
| 8 | 8 |
| 9 // Result codes that can occur during Web Bluetooth execution, which are | 9 // Result codes that can occur during Web Bluetooth execution, which are |
| 10 // transformed to a DOMException in Source/modules/bluetooth/BluetoothError.cpp. | 10 // transformed to a DOMException in Source/modules/bluetooth/BluetoothError.cpp. |
| 11 // | 11 // |
| 12 // These errors all produce constant message strings. If a particular message | 12 // These errors all produce constant message strings. If a particular message |
| 13 // needs a dynamic component, we should add a separate enum so type-checking the | 13 // needs a dynamic component, we should add a separate enum so type-checking the |
| 14 // IPC ensures the dynamic component is passed. | 14 // IPC ensures the dynamic component is passed. |
| 15 enum WebBluetoothResult { | 15 enum WebBluetoothResult { |
| 16 SUCCESS, | 16 SUCCESS, |
| 17 // AbortError: | 17 // AbortError: |
| 18 // InvalidModificationError: | 18 // InvalidModificationError: |
| 19 GATT_INVALID_ATTRIBUTE_LENGTH, | 19 GATT_INVALID_ATTRIBUTE_LENGTH, |
| 20 // InvalidStateError: | 20 // InvalidStateError: |
| 21 SERVICE_NO_LONGER_EXISTS, | 21 SERVICE_NO_LONGER_EXISTS, |
| 22 CHARACTERISTIC_NO_LONGER_EXISTS, | 22 CHARACTERISTIC_NO_LONGER_EXISTS, |
| 23 DESCRIPTOR_NO_LONGER_EXISTS, | |
| 23 // NetworkError: | 24 // NetworkError: |
| 24 CONNECT_ALREADY_IN_PROGRESS, | 25 CONNECT_ALREADY_IN_PROGRESS, |
| 25 CONNECT_ATTRIBUTE_LENGTH_INVALID, | 26 CONNECT_ATTRIBUTE_LENGTH_INVALID, |
| 26 CONNECT_AUTH_CANCELED, | 27 CONNECT_AUTH_CANCELED, |
| 27 CONNECT_AUTH_FAILED, | 28 CONNECT_AUTH_FAILED, |
| 28 CONNECT_AUTH_REJECTED, | 29 CONNECT_AUTH_REJECTED, |
| 29 CONNECT_AUTH_TIMEOUT, | 30 CONNECT_AUTH_TIMEOUT, |
| 30 CONNECT_CONNECTION_CONGESTED, | 31 CONNECT_CONNECTION_CONGESTED, |
| 31 CONNECT_INSUFFICIENT_ENCRYPTION, | 32 CONNECT_INSUFFICIENT_ENCRYPTION, |
| 32 CONNECT_OFFSET_INVALID, | 33 CONNECT_OFFSET_INVALID, |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 44 NO_BLUETOOTH_ADAPTER, | 45 NO_BLUETOOTH_ADAPTER, |
| 45 CHOSEN_DEVICE_VANISHED, | 46 CHOSEN_DEVICE_VANISHED, |
| 46 CHOOSER_CANCELLED, | 47 CHOOSER_CANCELLED, |
| 47 CHOOSER_NOT_SHOWN_API_GLOBALLY_DISABLED, | 48 CHOOSER_NOT_SHOWN_API_GLOBALLY_DISABLED, |
| 48 CHOOSER_NOT_SHOWN_API_LOCALLY_DISABLED, | 49 CHOOSER_NOT_SHOWN_API_LOCALLY_DISABLED, |
| 49 CHOOSER_NOT_SHOWN_USER_DENIED_PERMISSION_TO_SCAN, | 50 CHOOSER_NOT_SHOWN_USER_DENIED_PERMISSION_TO_SCAN, |
| 50 SERVICE_NOT_FOUND, | 51 SERVICE_NOT_FOUND, |
| 51 NO_SERVICES_FOUND, | 52 NO_SERVICES_FOUND, |
| 52 CHARACTERISTIC_NOT_FOUND, | 53 CHARACTERISTIC_NOT_FOUND, |
| 53 NO_CHARACTERISTICS_FOUND, | 54 NO_CHARACTERISTICS_FOUND, |
| 55 DESCRIPTOR_NOT_FOUND, | |
| 56 NO_DESCRIPTORS_FOUND, | |
| 54 WEB_BLUETOOTH_NOT_SUPPORTED, | 57 WEB_BLUETOOTH_NOT_SUPPORTED, |
| 55 BLUETOOTH_LOW_ENERGY_NOT_AVAILABLE, | 58 BLUETOOTH_LOW_ENERGY_NOT_AVAILABLE, |
| 56 // NotSupportedError: | 59 // NotSupportedError: |
| 57 GATT_UNKNOWN_ERROR, | 60 GATT_UNKNOWN_ERROR, |
| 58 GATT_UNKNOWN_FAILURE, | 61 GATT_UNKNOWN_FAILURE, |
| 59 GATT_NOT_PERMITTED, | 62 GATT_NOT_PERMITTED, |
| 60 GATT_NOT_SUPPORTED, | 63 GATT_NOT_SUPPORTED, |
| 61 GATT_UNTRANSLATED_ERROR_CODE, | 64 GATT_UNTRANSLATED_ERROR_CODE, |
| 62 // SecurityError: | 65 // SecurityError: |
| 63 GATT_NOT_AUTHORIZED, | 66 GATT_NOT_AUTHORIZED, |
| 67 BLACKLISTED_DESCRIPTOR_UUID, | |
| 64 BLACKLISTED_CHARACTERISTIC_UUID, | 68 BLACKLISTED_CHARACTERISTIC_UUID, |
| 65 BLACKLISTED_READ, | 69 BLACKLISTED_READ, |
| 66 BLACKLISTED_WRITE, | 70 BLACKLISTED_WRITE, |
| 67 NOT_ALLOWED_TO_ACCESS_SERVICE, | 71 NOT_ALLOWED_TO_ACCESS_SERVICE, |
| 68 REQUEST_DEVICE_WITH_BLACKLISTED_UUID, | 72 REQUEST_DEVICE_WITH_BLACKLISTED_UUID, |
| 69 REQUEST_DEVICE_FROM_CROSS_ORIGIN_IFRAME, | 73 REQUEST_DEVICE_FROM_CROSS_ORIGIN_IFRAME, |
| 70 REQUEST_DEVICE_WITHOUT_FRAME, | 74 REQUEST_DEVICE_WITHOUT_FRAME, |
| 71 }; | 75 }; |
| 72 | 76 |
| 73 struct WebBluetoothScanFilter { | 77 struct WebBluetoothScanFilter { |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 101 string instance_id; | 105 string instance_id; |
| 102 string uuid; | 106 string uuid; |
| 103 }; | 107 }; |
| 104 | 108 |
| 105 struct WebBluetoothRemoteGATTCharacteristic { | 109 struct WebBluetoothRemoteGATTCharacteristic { |
| 106 string instance_id; | 110 string instance_id; |
| 107 string uuid; | 111 string uuid; |
| 108 uint32 properties; | 112 uint32 properties; |
| 109 }; | 113 }; |
| 110 | 114 |
| 115 struct WebBluetoothRemoteGATTDescriptor { | |
| 116 string instance_id; | |
| 117 string uuid; | |
| 118 }; | |
| 119 | |
| 111 // Web Bluetooth Interface that Blink can use to perform | 120 // Web Bluetooth Interface that Blink can use to perform |
| 112 // Bluetooth GATT Operations on Bluetooth Devices. | 121 // Bluetooth GATT Operations on Bluetooth Devices. |
| 113 interface WebBluetoothService { | 122 interface WebBluetoothService { |
| 114 // Sets the client for this WebBluetoothService. The service will notify the | 123 // Sets the client for this WebBluetoothService. The service will notify the |
| 115 // client of device events e.g. when a Characteristic's value changes or when | 124 // client of device events e.g. when a Characteristic's value changes or when |
| 116 // a device disconnects. | 125 // a device disconnects. |
| 117 SetClient(associated WebBluetoothServiceClient client); | 126 SetClient(associated WebBluetoothServiceClient client); |
| 118 | 127 |
| 119 RequestDevice(WebBluetoothRequestDeviceOptions options) | 128 RequestDevice(WebBluetoothRequestDeviceOptions options) |
| 120 => (WebBluetoothResult result, WebBluetoothDevice? device); | 129 => (WebBluetoothResult result, WebBluetoothDevice? device); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 | 179 |
| 171 // Starts notifications for the characteristic with | 180 // Starts notifications for the characteristic with |
| 172 // |characteristic_instance_id|. | 181 // |characteristic_instance_id|. |
| 173 RemoteCharacteristicStartNotifications( | 182 RemoteCharacteristicStartNotifications( |
| 174 string characteristic_instance_id) => (WebBluetoothResult result); | 183 string characteristic_instance_id) => (WebBluetoothResult result); |
| 175 | 184 |
| 176 // Stops notifications for the characteristic with | 185 // Stops notifications for the characteristic with |
| 177 // |characteristic_instance_id|. | 186 // |characteristic_instance_id|. |
| 178 RemoteCharacteristicStopNotifications( | 187 RemoteCharacteristicStopNotifications( |
| 179 string characteristic_instance_id) => (); | 188 string characteristic_instance_id) => (); |
| 189 | |
| 190 // Returns the Descriptors of a GATT Characteristics with |service_instance_id |. | |
| 191 // If |quantity| == WebBluetoothGATTQueryQuantity::SINGLE, only one | |
| 192 // descriptor will be returned. | |
| 193 RemoteCharacteristicGetDescriptors( | |
| 194 string characteristics_instance_id, | |
| 195 WebBluetoothGATTQueryQuantity quantity, | |
| 196 bluetooth.mojom.UUID? characteristics_uuid) => ( | |
| 197 WebBluetoothResult result, | |
| 198 array<WebBluetoothRemoteGATTDescriptor>? descriptors); | |
| 199 | |
| 200 // Reads the value for descriptor with | |
| 201 // |descriptor_instance_id|. If the value is successfully read the | |
| 202 // callback will be run with WebBluetoothResult::SUCCESS and the | |
| 203 // descriptor's value. If the value is not successfully read the | |
| 204 // callback with be run with the corresponding error and nullptr for value. | |
| 205 RemoteDescriptorReadValue( | |
| 206 string descriptor_instance_id) => ( | |
| 207 WebBluetoothResult result, | |
| 208 array<uint8>? value); | |
| 209 | |
| 210 // Writes a value to the descriptor with | |
| 211 // |descriptor_instance_id|. The callback is run with | |
| 212 // WebBluetoothResult::SUCCESS if the value was successfully | |
| 213 // written. | |
| 214 RemoteDescriptorWriteValue( | |
| 215 string descriptor_instance_id, | |
| 216 array<uint8> value) => (WebBluetoothResult result); | |
| 180 }; | 217 }; |
| 181 | 218 |
| 182 // Classes should implement this interface and pass an associated pointer | 219 // Classes should implement this interface and pass an associated pointer |
| 183 // bound to them to the WebBluetoothService by using SetClient. Classes | 220 // bound to them to the WebBluetoothService by using SetClient. Classes |
| 184 // that do this will be notified of device events e.g. device disconnection. | 221 // that do this will be notified of device events e.g. device disconnection. |
| 185 interface WebBluetoothServiceClient { | 222 interface WebBluetoothServiceClient { |
| 186 RemoteCharacteristicValueChanged(string characteristic_instance_id, | 223 RemoteCharacteristicValueChanged(string characteristic_instance_id, |
| 187 array<uint8> value); | 224 array<uint8> value); |
| 225 RemoteDescriptorValueChanged(string descriptor_instance_id, | |
|
ortuno
2016/11/21 03:34:09
I don't think we need this. We do it for character
dougt
2016/11/22 01:47:17
Acknowledged.
| |
| 226 array<uint8> value); | |
| 188 GattServerDisconnected(WebBluetoothDeviceId device_id); | 227 GattServerDisconnected(WebBluetoothDeviceId device_id); |
| 189 }; | 228 }; |
| OLD | NEW |