Chromium Code Reviews| 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 CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/callback.h" | |
| 13 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 15 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 16 #include "base/string16.h" | 15 #include "base/string16.h" |
| 16 #include "chrome/browser/chromeos/bluetooth/bluetooth_device.h" | |
| 17 #include "chromeos/dbus/bluetooth_agent_service_provider.h" | 17 #include "chromeos/dbus/bluetooth_agent_service_provider.h" |
| 18 #include "chromeos/dbus/bluetooth_device_client.h" | 18 #include "chromeos/dbus/bluetooth_device_client.h" |
| 19 #include "chromeos/dbus/bluetooth_out_of_band_client.h" | 19 #include "chromeos/dbus/bluetooth_out_of_band_client.h" |
| 20 #include "dbus/object_path.h" | 20 #include "dbus/object_path.h" |
| 21 | 21 |
| 22 namespace chromeos { | 22 namespace chromeos { |
| 23 | 23 |
| 24 class BluetoothAdapter; | 24 class BluetoothAdapterChromeOs; |
| 25 class BluetoothServiceRecord; | 25 class BluetoothServiceRecord; |
| 26 class BluetoothSocket; | |
| 27 | 26 |
| 28 // The BluetoothDevice class represents a remote Bluetooth device, both | 27 struct BluetoothOutOfBandPairingData; |
| 29 // its properties and capabilities as discovered by a local adapter and | 28 |
| 30 // actions that may be performed on the remove device such as pairing, | 29 // The BluetoothDeviceChromeOs class is an implementation of BluetoothDevice |
| 31 // connection and disconnection. | 30 // for ChromeOS platform. |
| 32 // | 31 class BluetoothDeviceChromeOs : public BluetoothDevice, |
| 33 // The class is instantiated and managed by the BluetoothAdapter class | 32 public BluetoothDeviceClient::Observer, |
| 34 // and pointers should only be obtained from that class and not cached, | 33 public BluetoothAgentServiceProvider::Delegate { |
| 35 // instead use the address() method as a unique key for a device. | |
| 36 // | |
| 37 // Since the lifecycle of BluetoothDevice instances is managed by | |
| 38 // BluetoothAdapter, that class rather than this provides observer methods | |
| 39 // for devices coming and going, as well as properties being updated. | |
| 40 class BluetoothDevice : public BluetoothDeviceClient::Observer, | |
| 41 public BluetoothAgentServiceProvider::Delegate { | |
| 42 public: | 34 public: |
| 43 // Possible values that may be returned by GetDeviceType(), representing | 35 virtual ~BluetoothDeviceChromeOs(); |
| 44 // different types of bluetooth device that we support or are aware of | |
| 45 // decoded from the bluetooth class information. | |
| 46 enum DeviceType { | |
| 47 DEVICE_UNKNOWN, | |
| 48 DEVICE_COMPUTER, | |
| 49 DEVICE_PHONE, | |
| 50 DEVICE_MODEM, | |
| 51 DEVICE_PERIPHERAL, | |
| 52 DEVICE_JOYSTICK, | |
| 53 DEVICE_GAMEPAD, | |
| 54 DEVICE_KEYBOARD, | |
| 55 DEVICE_MOUSE, | |
| 56 DEVICE_TABLET, | |
| 57 DEVICE_KEYBOARD_MOUSE_COMBO | |
| 58 }; | |
| 59 | 36 |
| 60 // Interface for observing changes from bluetooth devices. | 37 // BluetoothDevice override |
| 61 class Observer { | 38 virtual const std::string& address() const OVERRIDE; |
| 62 public: | |
| 63 virtual ~Observer() {} | |
| 64 | 39 |
| 65 // TODO(keybuk): add observers for pairing and connection. | 40 // BluetoothDevice override |
| 66 }; | 41 virtual string16 GetName() const OVERRIDE; |
| 67 | |
| 68 // Interface for negotiating pairing of bluetooth devices. | |
| 69 class PairingDelegate { | |
| 70 public: | |
| 71 virtual ~PairingDelegate() {} | |
| 72 | |
| 73 // This method will be called when the Bluetooth daemon requires a | |
| 74 // PIN Code for authentication of the device |device|, the delegate should | |
| 75 // obtain the code from the user and call SetPinCode() on the device to | |
| 76 // provide it, or RejectPairing() or CancelPairing() to reject or cancel | |
| 77 // the request. | |
| 78 // | |
| 79 // PIN Codes are generally required for Bluetooth 2.0 and earlier devices | |
| 80 // for which there is no automatic pairing or special handling. | |
| 81 virtual void RequestPinCode(BluetoothDevice* device) = 0; | |
| 82 | |
| 83 // This method will be called when the Bluetooth daemon requires a | |
| 84 // Passkey for authentication of the device |device|, the delegate should | |
| 85 // obtain the passkey from the user (a numeric in the range 0-999999) and | |
| 86 // call SetPasskey() on the device to provide it, or RejectPairing() or | |
| 87 // CancelPairing() to reject or cancel the request. | |
| 88 // | |
| 89 // Passkeys are generally required for Bluetooth 2.1 and later devices | |
| 90 // which cannot provide input or display on their own, and don't accept | |
| 91 // passkey-less pairing. | |
| 92 virtual void RequestPasskey(BluetoothDevice* device) = 0; | |
| 93 | |
| 94 // This method will be called when the Bluetooth daemon requires that the | |
| 95 // user enter the PIN code |pincode| into the device |device| so that it | |
| 96 // may be authenticated. The DismissDisplayOrConfirm() method | |
| 97 // will be called to dismiss the display once pairing is complete or | |
| 98 // cancelled. | |
| 99 // | |
| 100 // This is used for Bluetooth 2.0 and earlier keyboard devices, the | |
| 101 // |pincode| will always be a six-digit numeric in the range 000000-999999 | |
| 102 // for compatibilty with later specifications. | |
| 103 virtual void DisplayPinCode(BluetoothDevice* device, | |
| 104 const std::string& pincode) = 0; | |
| 105 | |
| 106 // This method will be called when the Bluetooth daemon requires that the | |
| 107 // user enter the Passkey |passkey| into the device |device| so that it | |
| 108 // may be authenticated. The DismissDisplayOrConfirm() method will be | |
| 109 // called to dismiss the display once pairing is complete or cancelled. | |
| 110 // | |
| 111 // This is used for Bluetooth 2.1 and later devices that support input | |
| 112 // but not display, such as keyboards. The Passkey is a numeric in the | |
| 113 // range 0-999999 and should be always presented zero-padded to six | |
| 114 // digits. | |
| 115 virtual void DisplayPasskey(BluetoothDevice* device, | |
| 116 uint32 passkey) = 0; | |
| 117 | |
| 118 // This method will be called when the Bluetooth daemon requires that the | |
| 119 // user confirm that the Passkey |passkey| is displayed on the screen | |
| 120 // of the device |device| so that it may be authenticated. The delegate | |
| 121 // should display to the user and ask for confirmation, then call | |
| 122 // ConfirmPairing() on the device to confirm, RejectPairing() on the device | |
| 123 // to reject or CancelPairing() on the device to cancel authentication | |
| 124 // for any other reason. | |
| 125 // | |
| 126 // This is used for Bluetooth 2.1 and later devices that support display, | |
| 127 // such as other computers or phones. The Passkey is a numeric in the | |
| 128 // range 0-999999 and should be always present zero-padded to six | |
| 129 // digits. | |
| 130 virtual void ConfirmPasskey(BluetoothDevice* device, | |
| 131 uint32 passkey) = 0; | |
| 132 | |
| 133 // This method will be called when any previous DisplayPinCode(), | |
| 134 // DisplayPasskey() or ConfirmPasskey() request should be concluded | |
| 135 // and removed from the user. | |
| 136 virtual void DismissDisplayOrConfirm() = 0; | |
| 137 }; | |
| 138 | |
| 139 virtual ~BluetoothDevice(); | |
| 140 | |
| 141 // Returns the Bluetooth of address the device. This should be used as | |
| 142 // a unique key to identify the device and copied where needed. | |
| 143 virtual const std::string& address() const; | |
| 144 | |
| 145 // Returns the name of the device suitable for displaying, this may | |
| 146 // be a synthesied string containing the address and localized type name | |
| 147 // if the device has no obtained name. | |
| 148 virtual string16 GetName() const; | |
| 149 | |
| 150 // Returns the type of the device, limited to those we support or are | |
| 151 // aware of, by decoding the bluetooth class information. The returned | |
| 152 // values are unique, and do not overlap, so DEVICE_KEYBOARD is not also | |
| 153 // DEVICE_PERIPHERAL. | |
| 154 DeviceType GetDeviceType() const; | |
| 155 | 42 |
| 156 // Returns a localized string containing the device's bluetooth address and | 43 // Returns a localized string containing the device's bluetooth address and |
| 157 // a device type for display when |name_| is empty. | 44 // a device type for display when |name_| is empty. |
| 158 string16 GetAddressWithLocalizedDeviceTypeName() const; | 45 string16 GetAddressWithLocalizedDeviceTypeName() const; |
| 159 | 46 |
| 160 // Indicates whether the class of this device is supported by Chrome OS. | 47 // Indicates whether the class of this device is supported by Chrome OS. |
| 161 bool IsSupported() const; | 48 bool IsSupported() const; |
| 162 | 49 |
| 163 // Indicates whether the device is paired to the adapter, whether or not | 50 // BluetoothDevice override |
| 164 // that pairing is permanent or temporary. | 51 virtual bool IsPaired() const OVERRIDE; |
| 165 virtual bool IsPaired() const; | |
| 166 | 52 |
| 167 // Indicates whether the device is visible to the adapter, this is not | 53 // Indicates whether the device is visible to the adapter, this is not |
| 168 // mutually exclusive to being paired. | 54 // mutually exclusive to being paired. |
| 169 bool IsVisible() const { return visible_; } | 55 bool IsVisible() const { return visible_; } |
|
keybuk
2012/09/17 22:19:43
should be an override?
youngki
2012/09/18 18:19:56
Done.
| |
| 170 | 56 |
| 171 // Indicates whether the device is bonded to the adapter, bonding is | 57 // BluetoothDevice override |
| 172 // formed by pairing and exchanging high-security link keys so that | 58 virtual bool IsBonded() const OVERRIDE; |
| 173 // connections may be encrypted. | |
| 174 virtual bool IsBonded() const; | |
| 175 | 59 |
| 176 // Indicates whether the device is currently connected to the adapter | 60 // BluetoothDevice override |
| 177 // and at least one service available for use. | 61 virtual bool IsConnected() const OVERRIDE; |
| 178 virtual bool IsConnected() const; | |
| 179 | 62 |
| 180 // Returns the services (as UUID strings) that this device provides. | 63 // Returns the services (as UUID strings) that this device provides. |
| 181 typedef std::vector<std::string> ServiceList; | 64 typedef std::vector<std::string> ServiceList; |
| 182 const ServiceList& GetServices() const { return service_uuids_; } | 65 const ServiceList& GetServices() const { return service_uuids_; } |
|
keybuk
2012/09/17 22:19:43
should be an override?
youngki
2012/09/18 18:19:56
Done.
| |
| 183 | 66 |
| 184 // The ErrorCallback is used for methods that can fail in which case it | 67 // BluetoothDevice override |
| 185 // is called, in the success case the callback is simply not called. | 68 virtual void GetServiceRecords(const ServiceRecordsCallback& callback, |
| 186 typedef base::Callback<void()> ErrorCallback; | 69 const ErrorCallback& error_callback) OVERRIDE; |
| 187 | 70 |
| 188 // Returns the services (as BluetoothServiceRecord objects) that this device | 71 // BluetoothDevice override |
| 189 // provides. | 72 virtual bool ProvidesServiceWithUUID(const std::string& uuid) const OVERRIDE; |
| 190 typedef ScopedVector<BluetoothServiceRecord> ServiceRecordList; | |
| 191 typedef base::Callback<void(const ServiceRecordList&)> ServiceRecordsCallback; | |
| 192 void GetServiceRecords(const ServiceRecordsCallback& callback, | |
| 193 const ErrorCallback& error_callback); | |
| 194 | 73 |
| 195 // Indicates whether this device provides the given service. |uuid| should | 74 // BluetoothDevice override |
| 196 // be in canonical form (see bluetooth_utils::CanonicalUuid). | 75 virtual void ProvidesServiceWithName(const std::string& name, |
| 197 virtual bool ProvidesServiceWithUUID(const std::string& uuid) const; | 76 const ProvidesServiceCallback& callback) |
| 77 OVERRIDE; | |
| 198 | 78 |
| 199 // The ProvidesServiceCallback is used by ProvidesServiceWithName to indicate | 79 // BluetoothDevice override |
| 200 // whether or not a matching service was found. | 80 virtual bool ExpectingPinCode() const OVERRIDE; |
| 201 typedef base::Callback<void(bool)> ProvidesServiceCallback; | |
| 202 | 81 |
| 203 // Indicates whether this device provides the given service. | 82 // BluetoothDevice override |
| 204 virtual void ProvidesServiceWithName(const std::string& name, | 83 virtual bool ExpectingPasskey() const OVERRIDE; |
| 205 const ProvidesServiceCallback& callback); | |
| 206 | |
| 207 // Indicates whether the device is currently pairing and expecting a | |
| 208 // PIN Code to be returned. | |
| 209 bool ExpectingPinCode() const { return !pincode_callback_.is_null(); } | |
| 210 | |
| 211 // Indicates whether the device is currently pairing and expecting a | |
| 212 // Passkey to be returned. | |
| 213 bool ExpectingPasskey() const { return !passkey_callback_.is_null(); } | |
| 214 | 84 |
| 215 // Indicates whether the device is currently pairing and expecting | 85 // Indicates whether the device is currently pairing and expecting |
| 216 // confirmation of a displayed passkey. | 86 // confirmation of a displayed passkey. |
| 217 bool ExpectingConfirmation() const { | 87 bool ExpectingConfirmation() const { |
| 218 return !confirmation_callback_.is_null(); | 88 return !confirmation_callback_.is_null(); |
| 219 } | 89 } |
|
keybuk
2012/09/17 22:19:43
should be an override?
youngki
2012/09/18 18:19:56
Done.
| |
| 220 | 90 |
| 221 // Initiates a connection to the device, pairing first if necessary. | 91 // BluetoothDevice override |
| 222 // | 92 virtual void Connect(BluetoothDevice::PairingDelegate* pairing_delegate, |
| 223 // Method calls will be made on the supplied object |pairing_delegate| | 93 const base::Closure& callback, |
| 224 // to indicate what display, and in response should make method calls | 94 const ErrorCallback& error_callback) OVERRIDE; |
| 225 // back to the device object. Not all devices require user responses | |
| 226 // during pairing, so it is normal for |pairing_delegate| to receive no | |
| 227 // calls. To explicitly force a low-security connection without bonding, | |
| 228 // pass NULL, though this is ignored if the device is already paired. | |
| 229 // | |
| 230 // If the request fails, |error_callback| will be called; otherwise, | |
| 231 // |callback| is called when the request is complete. | |
| 232 void Connect(PairingDelegate* pairing_delegate, | |
| 233 const base::Closure& callback, | |
| 234 const ErrorCallback& error_callback); | |
| 235 | 95 |
| 236 // Sends the PIN code |pincode| to the remote device during pairing. | 96 // BluetoothDevice override |
| 237 // | 97 virtual void SetPinCode(const std::string& pincode) OVERRIDE; |
| 238 // PIN Codes are generally required for Bluetooth 2.0 and earlier devices | |
| 239 // for which there is no automatic pairing or special handling. | |
| 240 void SetPinCode(const std::string& pincode); | |
| 241 | 98 |
| 242 // Sends the Passkey |passkey| to the remote device during pairing. | 99 // BluetoothDevice override |
| 243 // | 100 virtual void SetPasskey(uint32 passkey) OVERRIDE; |
| 244 // Passkeys are generally required for Bluetooth 2.1 and later devices | |
| 245 // which cannot provide input or display on their own, and don't accept | |
| 246 // passkey-less pairing, and are a numeric in the range 0-999999. | |
| 247 void SetPasskey(uint32 passkey); | |
| 248 | 101 |
| 249 // Confirms to the remote device during pairing that a passkey provided by | 102 // BluetoothDevice override |
| 250 // the ConfirmPasskey() delegate call is displayed on both devices. | 103 virtual void ConfirmPairing() OVERRIDE; |
| 251 void ConfirmPairing(); | |
| 252 | 104 |
| 253 // Rejects a pairing or connection request from a remote device. | 105 // BluetoothDevice override |
| 254 void RejectPairing(); | 106 virtual void RejectPairing() OVERRIDE; |
| 255 | 107 |
| 256 // Cancels a pairing or connection attempt to a remote device. | 108 // BluetoothDevice override |
| 257 void CancelPairing(); | 109 virtual void CancelPairing() OVERRIDE; |
| 258 | 110 |
| 259 // Disconnects the device, terminating the low-level ACL connection | 111 // BluetoothDevice override |
| 260 // and any application connections using it. Link keys and other pairing | 112 virtual void Disconnect(const base::Closure& callback, |
| 261 // information are not discarded, and the device object is not deleted. | 113 const ErrorCallback& error_callback) OVERRIDE; |
| 262 // If the request fails, |error_callback| will be called; otherwise, | |
| 263 // |callback| is called when the request is complete. | |
| 264 void Disconnect(const base::Closure& callback, | |
| 265 const ErrorCallback& error_callback); | |
| 266 | 114 |
| 267 // Disconnects the device, terminating the low-level ACL connection | 115 // BluetoothDevice override |
| 268 // and any application connections using it, and then discards link keys | 116 virtual void Forget(const ErrorCallback& error_callback) OVERRIDE; |
| 269 // and other pairing information. The device object remainds valid until | |
| 270 // returing from the calling function, after which it should be assumed to | |
| 271 // have been deleted. If the request fails, |error_callback| will be called. | |
| 272 // There is no callback for success beause this object is often deleted | |
| 273 // before that callback would be called. | |
| 274 void Forget(const ErrorCallback& error_callback); | |
| 275 | 117 |
| 276 // SocketCallback is used by ConnectToService to return a BluetoothSocket | 118 // BluetoothDevice override |
| 277 // to the caller, or NULL if there was an error. The socket will remain open | 119 virtual void ConnectToService(const std::string& service_uuid, |
| 278 // until the last reference to the returned BluetoothSocket is released. | 120 const SocketCallback& callback) OVERRIDE; |
| 279 typedef base::Callback<void(scoped_refptr<BluetoothSocket>)> SocketCallback; | |
| 280 | 121 |
| 281 // Attempts to open a socket to a service matching |uuid| on this device. If | 122 // BluetoothDevice override |
| 282 // the connection is successful, |callback| is called with a BluetoothSocket. | |
| 283 // Otherwise |callback| is called with NULL. The socket is closed as soon as | |
| 284 // all references to the BluetoothSocket are released. Note that the | |
| 285 // BluetoothSocket object can outlive both this BluetoothDevice and the | |
| 286 // BluetoothAdapter for this device. | |
| 287 void ConnectToService(const std::string& service_uuid, | |
| 288 const SocketCallback& callback); | |
| 289 | |
| 290 // Sets the Out Of Band pairing data for this device to |data|. Exactly one | |
| 291 // of |callback| or |error_callback| will be run. | |
| 292 virtual void SetOutOfBandPairingData( | 123 virtual void SetOutOfBandPairingData( |
| 293 const chromeos::BluetoothOutOfBandPairingData& data, | 124 const chromeos::BluetoothOutOfBandPairingData& data, |
| 294 const base::Closure& callback, | 125 const base::Closure& callback, |
| 295 const ErrorCallback& error_callback); | 126 const ErrorCallback& error_callback) OVERRIDE; |
| 296 | 127 |
| 297 // Clears the Out Of Band pairing data for this device. Exactly one of | 128 // BluetoothDevice override |
| 298 // |callback| or |error_callback| will be run. | |
| 299 virtual void ClearOutOfBandPairingData( | 129 virtual void ClearOutOfBandPairingData( |
| 300 const base::Closure& callback, | 130 const base::Closure& callback, |
| 301 const ErrorCallback& error_callback); | 131 const ErrorCallback& error_callback) OVERRIDE; |
| 302 | 132 |
| 303 private: | 133 private: |
| 304 friend class BluetoothAdapter; | 134 friend class BluetoothAdapterChromeOs; |
| 305 friend class MockBluetoothDevice; | 135 friend class MockBluetoothDevice; |
| 306 | 136 |
| 307 explicit BluetoothDevice(BluetoothAdapter* adapter); | 137 explicit BluetoothDeviceChromeOs(BluetoothAdapterChromeOs* adapter); |
| 308 | 138 |
| 309 // Sets the dbus object path for the device to |object_path|, indicating | 139 // Sets the dbus object path for the device to |object_path|, indicating |
| 310 // that the device has gone from being discovered to paired or bonded. | 140 // that the device has gone from being discovered to paired or bonded. |
| 311 void SetObjectPath(const dbus::ObjectPath& object_path); | 141 void SetObjectPath(const dbus::ObjectPath& object_path); |
| 312 | 142 |
| 313 // Removes the dbus object path from the device, indicating that the | 143 // Removes the dbus object path from the device, indicating that the |
| 314 // device is no longer paired or bonded, but perhaps still visible. | 144 // device is no longer paired or bonded, but perhaps still visible. |
| 315 void RemoveObjectPath(); | 145 void RemoveObjectPath(); |
| 316 | 146 |
| 317 // Sets whether the device is visible to the owning adapter to |visible|. | 147 // Sets whether the device is visible to the owning adapter to |visible|. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 395 const std::string& error_message); | 225 const std::string& error_message); |
| 396 | 226 |
| 397 // Called by BluetoothDeviceClient when a call to Disconnect() completes, | 227 // Called by BluetoothDeviceClient when a call to Disconnect() completes, |
| 398 // |success| indicates whether or not the request succeeded, |callback| and | 228 // |success| indicates whether or not the request succeeded, |callback| and |
| 399 // |error_callback| are the callbacks provided to Disconnect() and | 229 // |error_callback| are the callbacks provided to Disconnect() and |
| 400 // |device_path| is the device disconnected. | 230 // |device_path| is the device disconnected. |
| 401 void DisconnectCallback(const base::Closure& callback, | 231 void DisconnectCallback(const base::Closure& callback, |
| 402 const ErrorCallback& error_callback, | 232 const ErrorCallback& error_callback, |
| 403 const dbus::ObjectPath& device_path, bool success); | 233 const dbus::ObjectPath& device_path, bool success); |
| 404 | 234 |
| 405 // Called by BluetoothAdapterClient when a call to RemoveDevice() completes, | 235 // Called by BluetoothAdapterClient when a call to RemoveDevice() |
| 406 // |success| indicates whether or not the request succeeded, |error_callback| | 236 // completes, |success| indicates whether or not the request succeeded, |
| 407 // is the callback provided to Forget() and |adapter_path| is the d-bus | 237 // |error_callback| is the callback provided to Forget() and |adapter_path| is |
| 408 // object path of the adapter that performed the removal. | 238 // the d-bus object path of the adapter that performed the removal. |
| 409 void ForgetCallback(const ErrorCallback& error_callback, | 239 void ForgetCallback(const ErrorCallback& error_callback, |
| 410 const dbus::ObjectPath& adapter_path, bool success); | 240 const dbus::ObjectPath& adapter_path, bool success); |
| 411 | 241 |
| 412 // Called if the call to GetServiceRecords from ProvidesServiceWithName fails. | 242 // Called if the call to GetServiceRecords from ProvidesServiceWithName fails. |
| 413 void SearchServicesForNameErrorCallback( | 243 void SearchServicesForNameErrorCallback( |
| 414 const ProvidesServiceCallback& callback); | 244 const ProvidesServiceCallback& callback); |
| 415 | 245 |
| 416 // Called by GetServiceRecords with the list of BluetoothServiceRecords to | 246 // Called by GetServiceRecords with the list of BluetoothServiceRecords to |
| 417 // search for |name|. |callback| is the callback from | 247 // search for |name|. |callback| is the callback from |
| 418 // ProvidesServiceWithName. | 248 // ProvidesServiceWithName. |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 547 // their response (success, rejected or cancelled). | 377 // their response (success, rejected or cancelled). |
| 548 virtual void ConfirmModeChange(Mode mode, | 378 virtual void ConfirmModeChange(Mode mode, |
| 549 const ConfirmationCallback& callback) OVERRIDE; | 379 const ConfirmationCallback& callback) OVERRIDE; |
| 550 | 380 |
| 551 // BluetoothAgentServiceProvider::Delegate override. | 381 // BluetoothAgentServiceProvider::Delegate override. |
| 552 // | 382 // |
| 553 // This method will be called by the Bluetooth daemon to indicate that | 383 // This method will be called by the Bluetooth daemon to indicate that |
| 554 // the request failed before a reply was returned from the device. | 384 // the request failed before a reply was returned from the device. |
| 555 virtual void Cancel() OVERRIDE; | 385 virtual void Cancel() OVERRIDE; |
| 556 | 386 |
| 557 // Creates a new BluetoothDevice object bound to the adapter |adapter|. | 387 // Creates a new BluetoothDeviceChromeOs object bound to the adapter |
| 558 static BluetoothDevice* Create(BluetoothAdapter* adapter); | 388 // |adapter|. |
| 389 static BluetoothDeviceChromeOs* Create(BluetoothAdapterChromeOs* adapter); | |
| 559 | 390 |
| 560 // The adapter that owns this device instance. | 391 // The adapter that owns this device instance. |
| 561 BluetoothAdapter* adapter_; | 392 BluetoothAdapterChromeOs* adapter_; |
| 562 | 393 |
| 563 // The dbus object path of the device, will be empty if the device has only | 394 // The dbus object path of the device, will be empty if the device has only |
| 564 // been discovered and not yet paired with. | 395 // been discovered and not yet paired with. |
| 565 dbus::ObjectPath object_path_; | 396 dbus::ObjectPath object_path_; |
| 566 | 397 |
| 567 // The Bluetooth address of the device. | 398 // The Bluetooth address of the device. |
| 568 std::string address_; | 399 std::string address_; |
| 569 | 400 |
| 570 // The name of the device, as supplied by the remote device. | 401 // The name of the device, as supplied by the remote device. |
| 571 std::string name_; | 402 std::string name_; |
| 572 | 403 |
| 573 // The Bluetooth class of the device, a bitmask that may be decoded using | |
| 574 // https://www.bluetooth.org/Technical/AssignedNumbers/baseband.htm | |
| 575 uint32 bluetooth_class_; | |
| 576 | |
| 577 // Tracked device state, updated by the adapter managing the lifecyle of | 404 // Tracked device state, updated by the adapter managing the lifecyle of |
| 578 // the device. | 405 // the device. |
| 579 bool visible_; | 406 bool visible_; |
| 580 bool bonded_; | 407 bool bonded_; |
| 581 bool connected_; | 408 bool connected_; |
| 582 | 409 |
| 583 // The services (identified by UUIDs) that this device provides. | 410 // The services (identified by UUIDs) that this device provides. |
| 584 std::vector<std::string> service_uuids_; | 411 std::vector<std::string> service_uuids_; |
| 585 | 412 |
| 586 // During pairing this is set to an object that we don't own, but on which | 413 // During pairing this is set to an object that we don't own, but on which |
| 587 // we can make method calls to request, display or confirm PIN Codes and | 414 // we can make method calls to request, display or confirm PIN Codes and |
| 588 // Passkeys. Generally it is the object that owns this one. | 415 // Passkeys. Generally it is the object that owns this one. |
| 589 PairingDelegate* pairing_delegate_; | 416 BluetoothDevice::PairingDelegate* pairing_delegate_; |
| 590 | 417 |
| 591 // During pairing this is set to an instance of a D-Bus agent object | 418 // During pairing this is set to an instance of a D-Bus agent object |
| 592 // intialized with our own class as its delegate. | 419 // intialized with our own class as its delegate. |
| 593 scoped_ptr<BluetoothAgentServiceProvider> agent_; | 420 scoped_ptr<BluetoothAgentServiceProvider> agent_; |
| 594 | 421 |
| 595 // During pairing these callbacks are set to those provided by method calls | 422 // During pairing these callbacks are set to those provided by method calls |
| 596 // made on us by |agent_| and are called by our own method calls such as | 423 // made on us by |agent_| and are called by our own method calls such as |
| 597 // SetPinCode() and SetPasskey(). | 424 // SetPinCode() and SetPasskey(). |
| 598 PinCodeCallback pincode_callback_; | 425 PinCodeCallback pincode_callback_; |
| 599 PasskeyCallback passkey_callback_; | 426 PasskeyCallback passkey_callback_; |
| 600 ConfirmationCallback confirmation_callback_; | 427 ConfirmationCallback confirmation_callback_; |
| 601 | 428 |
| 602 // Used to keep track of pending application connection requests. | 429 // Used to keep track of pending application connection requests. |
| 603 int connecting_applications_counter_; | 430 int connecting_applications_counter_; |
| 604 | 431 |
| 605 // Note: This should remain the last member so it'll be destroyed and | 432 // Note: This should remain the last member so it'll be destroyed and |
| 606 // invalidate its weak pointers before any other members are destroyed. | 433 // invalidate its weak pointers before any other members are destroyed. |
| 607 base::WeakPtrFactory<BluetoothDevice> weak_ptr_factory_; | 434 base::WeakPtrFactory<BluetoothDeviceChromeOs> weak_ptr_factory_; |
| 608 | 435 |
| 609 DISALLOW_COPY_AND_ASSIGN(BluetoothDevice); | 436 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceChromeOs); |
| 610 }; | 437 }; |
| 611 | 438 |
| 612 } // namespace chromeos | 439 } // namespace chromeos |
| 613 | 440 |
| 614 #endif // CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 441 #endif // CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H_ |
| OLD | NEW |