Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | |
|
Devlin
2015/10/15 06:26:42
When I patched this in by hand, I saw a few traili
Devlin
2015/10/15 06:26:42
nit: no (c)
stevenjb
2015/10/15 20:48:05
Done.
stevenjb
2015/10/15 20:48:06
Done.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Use the <code>chrome.bluetoothPrivate</code> API to control the Bluetooth | |
| 6 // adapter state and handle device pairing. | |
| 7 // NOTE: This IDL is dependent on bluetooth.idl. | |
| 8 | |
| 9 [implemented_in = "extensions/browser/api/bluetooth/bluetooth_private_api.h"] | |
| 10 | |
| 11 namespace bluetoothPrivate { | |
| 12 // Events that can occur during pairing. The method used for pairing varies | |
| 13 // depending on the capability of the two devices. | |
| 14 enum PairingEventType { | |
| 15 // An alphanumeric PIN code is required to be entered by the user. | |
| 16 requestPincode, | |
| 17 | |
| 18 // Display a PIN code to the user. | |
| 19 displayPincode, | |
| 20 | |
| 21 // A numeric passkey is required to be entered by the user. | |
| 22 requestPasskey, | |
| 23 | |
| 24 // Display a zero padded 6 digit numeric passkey that the user entered on | |
| 25 // the remote device. This event may occur multiple times during pairing to | |
| 26 // update the entered passkey. | |
| 27 displayPasskey, | |
| 28 | |
| 29 // The number of keys inputted by the user on the remote device when | |
| 30 // entering a passkey. This event may be called multiple times during | |
| 31 // pairing to update the number of keys inputted. | |
| 32 keysEntered, | |
| 33 | |
| 34 // Requests that a 6 digit passkey be displayed and the user confirms that | |
| 35 // both devies show the same passkey. | |
| 36 confirmPasskey, | |
| 37 | |
| 38 // Requests authorization for a pairing under the just-works model. It is up | |
| 39 // to the app to ask for user confirmation. | |
| 40 requestAuthorization, | |
| 41 | |
| 42 // Pairing is completed. | |
| 43 complete | |
| 44 }; | |
| 45 | |
| 46 // Valid pairing responses. | |
| 47 enum PairingResponse { | |
| 48 confirm, reject, cancel | |
| 49 }; | |
| 50 | |
| 51 enum TransportType { | |
| 52 le, bredr, dual | |
| 53 }; | |
| 54 | |
| 55 // A pairing event received from a Bluetooth device. | |
| 56 dictionary PairingEvent { | |
| 57 PairingEventType pairing; | |
| 58 bluetooth.Device device; | |
| 59 DOMString? pincode; | |
| 60 long? passkey; | |
| 61 long? enteredKey; | |
| 62 }; | |
| 63 | |
| 64 dictionary NewAdapterState { | |
| 65 // The human-readable name of the adapter. | |
| 66 DOMString? name; | |
| 67 | |
| 68 // Whether or not the adapter has power. | |
| 69 boolean? powered; | |
| 70 | |
| 71 // Whether the adapter is discoverable by other devices. | |
| 72 boolean? discoverable; | |
| 73 }; | |
| 74 | |
| 75 dictionary SetPairingResponseOptions { | |
| 76 // The remote device to send the pairing response. | |
| 77 bluetooth.Device device; | |
| 78 | |
| 79 // The response type. | |
| 80 PairingResponse? response; | |
| 81 | |
| 82 // A 1-16 character alphanumeric set in response to | |
| 83 // <code>requestPincode</code>. | |
| 84 DOMString? pincode; | |
| 85 | |
| 86 // An integer between 0-999999 set in response to | |
| 87 // <code>requestPasskey</code>. | |
| 88 long? passkey; | |
| 89 }; | |
| 90 | |
| 91 dictionary DiscoveryFilter { | |
| 92 // Transport type. | |
| 93 TransportType? transport; | |
| 94 | |
| 95 // uuid of service or array of uuids | |
| 96 (DOMString or DOMString[])? uuids; | |
| 97 | |
| 98 // RSSI ranging value. Only devices with RSSI higher than this value will be | |
| 99 // reported. | |
| 100 long? rssi; | |
| 101 | |
| 102 // Pathloss ranging value. Only devices with pathloss lower than this value | |
| 103 // will be reported. | |
| 104 long? pathloss; | |
| 105 }; | |
| 106 | |
| 107 callback VoidCallback = void(); | |
| 108 | |
| 109 // These functions all report failures via chrome.runtime.lastError. | |
| 110 interface Functions { | |
| 111 // Changes the state of the Bluetooth adapter. | |
| 112 // |adapterState|: | |
| 113 static void setAdapterState(NewAdapterState adapterState, | |
| 114 optional VoidCallback callback); | |
| 115 | |
| 116 static void setPairingResponse(SetPairingResponseOptions options, | |
| 117 optional VoidCallback callback); | |
| 118 | |
| 119 // Tears down all connections to the given device. | |
| 120 static void disconnectAll(DOMString deviceAddress, | |
| 121 optional VoidCallback callback); | |
| 122 | |
| 123 // Set or clear discovery filter. | |
| 124 static void setDiscoveryFilter(DiscoveryFilter discoveryFilter, | |
| 125 optional VoidCallback callback); | |
| 126 | |
| 127 // Pairs the given device. | |
| 128 static void pair(DOMString deviceAddress, optional VoidCallback callback); | |
| 129 }; | |
| 130 | |
| 131 interface Events { | |
| 132 // Fired when a pairing event occurs. | |
| 133 // |pairingEvent|: A pairing event. | |
| 134 [maxListeners=1] static void onPairing(PairingEvent pairingEvent); | |
| 135 }; | |
| 136 }; | |
| OLD | NEW |