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