OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 virtual void RequestPasskey(BluetoothDevice* device) = 0; | 101 virtual void RequestPasskey(BluetoothDevice* device) = 0; |
102 | 102 |
103 // This method will be called when the Bluetooth daemon requires that the | 103 // This method will be called when the Bluetooth daemon requires that the |
104 // user enter the PIN code |pincode| into the device |device| so that it | 104 // user enter the PIN code |pincode| into the device |device| so that it |
105 // may be authenticated. The DismissDisplayOrConfirm() method | 105 // may be authenticated. The DismissDisplayOrConfirm() method |
106 // will be called to dismiss the display once pairing is complete or | 106 // will be called to dismiss the display once pairing is complete or |
107 // cancelled. | 107 // cancelled. |
108 // | 108 // |
109 // This is used for Bluetooth 2.0 and earlier keyboard devices, the | 109 // This is used for Bluetooth 2.0 and earlier keyboard devices, the |
110 // |pincode| will always be a six-digit numeric in the range 000000-999999 | 110 // |pincode| will always be a six-digit numeric in the range 000000-999999 |
111 // for compatibilty with later specifications. | 111 // for compatibility with later specifications. |
112 virtual void DisplayPinCode(BluetoothDevice* device, | 112 virtual void DisplayPinCode(BluetoothDevice* device, |
113 const std::string& pincode) = 0; | 113 const std::string& pincode) = 0; |
114 | 114 |
115 // This method will be called when the Bluetooth daemon requires that the | 115 // This method will be called when the Bluetooth daemon requires that the |
116 // user enter the Passkey |passkey| into the device |device| so that it | 116 // user enter the Passkey |passkey| into the device |device| so that it |
117 // may be authenticated. The DismissDisplayOrConfirm() method will be | 117 // may be authenticated. The DismissDisplayOrConfirm() method will be |
118 // called to dismiss the display once pairing is complete or cancelled. | 118 // called to dismiss the display once pairing is complete or cancelled. |
119 // | 119 // |
120 // This is used for Bluetooth 2.1 and later devices that support input | 120 // This is used for Bluetooth 2.1 and later devices that support input |
121 // but not display, such as keyboards. The Passkey is a numeric in the | 121 // but not display, such as keyboards. The Passkey is a numeric in the |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 virtual uint16 GetVendorID() const = 0; | 179 virtual uint16 GetVendorID() const = 0; |
180 | 180 |
181 // Returns the Product ID of the device, where available. | 181 // Returns the Product ID of the device, where available. |
182 virtual uint16 GetProductID() const = 0; | 182 virtual uint16 GetProductID() const = 0; |
183 | 183 |
184 // Returns the Device ID of the device, typically the release or version | 184 // Returns the Device ID of the device, typically the release or version |
185 // number in BCD format, where available. | 185 // number in BCD format, where available. |
186 virtual uint16 GetDeviceID() const = 0; | 186 virtual uint16 GetDeviceID() const = 0; |
187 | 187 |
188 // Returns the name of the device suitable for displaying, this may | 188 // Returns the name of the device suitable for displaying, this may |
189 // be a synthesied string containing the address and localized type name | 189 // be a synthesized string containing the address and localized type name |
190 // if the device has no obtained name. | 190 // if the device has no obtained name. |
191 virtual string16 GetName() const; | 191 virtual string16 GetName() const; |
192 | 192 |
193 // Returns the type of the device, limited to those we support or are | 193 // Returns the type of the device, limited to those we support or are |
194 // aware of, by decoding the bluetooth class information. The returned | 194 // aware of, by decoding the bluetooth class information. The returned |
195 // values are unique, and do not overlap, so DEVICE_KEYBOARD is not also | 195 // values are unique, and do not overlap, so DEVICE_KEYBOARD is not also |
196 // DEVICE_PERIPHERAL. | 196 // DEVICE_PERIPHERAL. |
197 DeviceType GetDeviceType() const; | 197 DeviceType GetDeviceType() const; |
198 | 198 |
199 // Indicates whether the device is known to support pairing based on its | 199 // Indicates whether the device is known to support pairing based on its |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 // Disconnects the device, terminating the low-level ACL connection | 316 // Disconnects the device, terminating the low-level ACL connection |
317 // and any application connections using it. Link keys and other pairing | 317 // and any application connections using it. Link keys and other pairing |
318 // information are not discarded, and the device object is not deleted. | 318 // information are not discarded, and the device object is not deleted. |
319 // If the request fails, |error_callback| will be called; otherwise, | 319 // If the request fails, |error_callback| will be called; otherwise, |
320 // |callback| is called when the request is complete. | 320 // |callback| is called when the request is complete. |
321 virtual void Disconnect(const base::Closure& callback, | 321 virtual void Disconnect(const base::Closure& callback, |
322 const ErrorCallback& error_callback) = 0; | 322 const ErrorCallback& error_callback) = 0; |
323 | 323 |
324 // Disconnects the device, terminating the low-level ACL connection | 324 // Disconnects the device, terminating the low-level ACL connection |
325 // and any application connections using it, and then discards link keys | 325 // and any application connections using it, and then discards link keys |
326 // and other pairing information. The device object remainds valid until | 326 // and other pairing information. The device object remains valid until |
327 // returing from the calling function, after which it should be assumed to | 327 // returning from the calling function, after which it should be assumed to |
328 // have been deleted. If the request fails, |error_callback| will be called. | 328 // have been deleted. If the request fails, |error_callback| will be called. |
329 // There is no callback for success beause this object is often deleted | 329 // There is no callback for success because this object is often deleted |
330 // before that callback would be called. | 330 // before that callback would be called. |
331 virtual void Forget(const ErrorCallback& error_callback) = 0; | 331 virtual void Forget(const ErrorCallback& error_callback) = 0; |
332 | 332 |
333 // Attempts to open a socket to a service matching |uuid| on this device. If | 333 // Attempts to open a socket to a service matching |uuid| on this device. If |
334 // the connection is successful, |callback| is called with a BluetoothSocket. | 334 // the connection is successful, |callback| is called with a BluetoothSocket. |
335 // Otherwise |callback| is called with NULL. The socket is closed as soon as | 335 // Otherwise |callback| is called with NULL. The socket is closed as soon as |
336 // all references to the BluetoothSocket are released. Note that the | 336 // all references to the BluetoothSocket are released. Note that the |
337 // BluetoothSocket object can outlive both this BluetoothDevice and the | 337 // BluetoothSocket object can outlive both this BluetoothDevice and the |
338 // BluetoothAdapter for this device. | 338 // BluetoothAdapter for this device. |
339 virtual void ConnectToService(const std::string& service_uuid, | 339 virtual void ConnectToService(const std::string& service_uuid, |
(...skipping 28 matching lines...) Expand all Loading... |
368 | 368 |
369 private: | 369 private: |
370 // Returns a localized string containing the device's bluetooth address and | 370 // Returns a localized string containing the device's bluetooth address and |
371 // a device type for display when |name_| is empty. | 371 // a device type for display when |name_| is empty. |
372 string16 GetAddressWithLocalizedDeviceTypeName() const; | 372 string16 GetAddressWithLocalizedDeviceTypeName() const; |
373 }; | 373 }; |
374 | 374 |
375 } // namespace device | 375 } // namespace device |
376 | 376 |
377 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 377 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
OLD | NEW |