| 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_CHROMEOS_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H_ | 6 #define DEVICE_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/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #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" | 16 #include "chromeos/dbus/bluetooth_agent_service_provider.h" |
| 18 #include "chromeos/dbus/bluetooth_device_client.h" | 17 #include "chromeos/dbus/bluetooth_device_client.h" |
| 19 #include "dbus/object_path.h" | 18 #include "dbus/object_path.h" |
| 19 #include "device/bluetooth/bluetooth_device.h" |
| 20 |
| 21 namespace device { |
| 22 |
| 23 class BluetoothServiceRecord; |
| 24 class MockBluetoothDevice; |
| 25 struct BluetoothOutOfBandPairingData; |
| 26 |
| 27 } // namespace device |
| 20 | 28 |
| 21 namespace chromeos { | 29 namespace chromeos { |
| 22 | 30 |
| 23 class BluetoothAdapterChromeOs; | 31 class BluetoothAdapterChromeOs; |
| 24 class BluetoothServiceRecord; | |
| 25 | |
| 26 struct BluetoothOutOfBandPairingData; | |
| 27 | 32 |
| 28 // The BluetoothDeviceChromeOs class is an implementation of BluetoothDevice | 33 // The BluetoothDeviceChromeOs class is an implementation of BluetoothDevice |
| 29 // for Chrome OS platform. | 34 // for Chrome OS platform. |
| 30 class BluetoothDeviceChromeOs : public BluetoothDevice, | 35 class BluetoothDeviceChromeOs |
| 31 public BluetoothDeviceClient::Observer, | 36 : public device::BluetoothDevice, |
| 32 public BluetoothAgentServiceProvider::Delegate { | 37 public BluetoothDeviceClient::Observer, |
| 38 public BluetoothAgentServiceProvider::Delegate { |
| 33 public: | 39 public: |
| 34 virtual ~BluetoothDeviceChromeOs(); | 40 virtual ~BluetoothDeviceChromeOs(); |
| 35 | 41 |
| 36 // BluetoothDevice override | 42 // BluetoothDevice override |
| 37 virtual bool IsPaired() const OVERRIDE; | 43 virtual bool IsPaired() const OVERRIDE; |
| 38 virtual const ServiceList& GetServices() const OVERRIDE; | 44 virtual const ServiceList& GetServices() const OVERRIDE; |
| 39 virtual void GetServiceRecords( | 45 virtual void GetServiceRecords( |
| 40 const ServiceRecordsCallback& callback, | 46 const ServiceRecordsCallback& callback, |
| 41 const ErrorCallback& error_callback) OVERRIDE; | 47 const ErrorCallback& error_callback) OVERRIDE; |
| 42 virtual bool ProvidesServiceWithUUID(const std::string& uuid) const OVERRIDE; | 48 virtual bool ProvidesServiceWithUUID(const std::string& uuid) const OVERRIDE; |
| 43 virtual void ProvidesServiceWithName( | 49 virtual void ProvidesServiceWithName( |
| 44 const std::string& name, | 50 const std::string& name, |
| 45 const ProvidesServiceCallback& callback) OVERRIDE; | 51 const ProvidesServiceCallback& callback) OVERRIDE; |
| 46 virtual bool ExpectingPinCode() const OVERRIDE; | 52 virtual bool ExpectingPinCode() const OVERRIDE; |
| 47 virtual bool ExpectingPasskey() const OVERRIDE; | 53 virtual bool ExpectingPasskey() const OVERRIDE; |
| 48 virtual bool ExpectingConfirmation() const OVERRIDE; | 54 virtual bool ExpectingConfirmation() const OVERRIDE; |
| 49 virtual void Connect( | 55 virtual void Connect( |
| 50 BluetoothDevice::PairingDelegate* pairing_delegate, | 56 device::BluetoothDevice::PairingDelegate* pairing_delegate, |
| 51 const base::Closure& callback, | 57 const base::Closure& callback, |
| 52 const ErrorCallback& error_callback) OVERRIDE; | 58 const ErrorCallback& error_callback) OVERRIDE; |
| 53 virtual void SetPinCode(const std::string& pincode) OVERRIDE; | 59 virtual void SetPinCode(const std::string& pincode) OVERRIDE; |
| 54 virtual void SetPasskey(uint32 passkey) OVERRIDE; | 60 virtual void SetPasskey(uint32 passkey) OVERRIDE; |
| 55 virtual void ConfirmPairing() OVERRIDE; | 61 virtual void ConfirmPairing() OVERRIDE; |
| 56 virtual void RejectPairing() OVERRIDE; | 62 virtual void RejectPairing() OVERRIDE; |
| 57 virtual void CancelPairing() OVERRIDE; | 63 virtual void CancelPairing() OVERRIDE; |
| 58 virtual void Disconnect( | 64 virtual void Disconnect( |
| 59 const base::Closure& callback, | 65 const base::Closure& callback, |
| 60 const ErrorCallback& error_callback) OVERRIDE; | 66 const ErrorCallback& error_callback) OVERRIDE; |
| 61 virtual void Forget(const ErrorCallback& error_callback) OVERRIDE; | 67 virtual void Forget(const ErrorCallback& error_callback) OVERRIDE; |
| 62 virtual void ConnectToService( | 68 virtual void ConnectToService( |
| 63 const std::string& service_uuid, | 69 const std::string& service_uuid, |
| 64 const SocketCallback& callback) OVERRIDE; | 70 const SocketCallback& callback) OVERRIDE; |
| 65 virtual void SetOutOfBandPairingData( | 71 virtual void SetOutOfBandPairingData( |
| 66 const chromeos::BluetoothOutOfBandPairingData& data, | 72 const device::BluetoothOutOfBandPairingData& data, |
| 67 const base::Closure& callback, | 73 const base::Closure& callback, |
| 68 const ErrorCallback& error_callback) OVERRIDE; | 74 const ErrorCallback& error_callback) OVERRIDE; |
| 69 virtual void ClearOutOfBandPairingData( | 75 virtual void ClearOutOfBandPairingData( |
| 70 const base::Closure& callback, | 76 const base::Closure& callback, |
| 71 const ErrorCallback& error_callback) OVERRIDE; | 77 const ErrorCallback& error_callback) OVERRIDE; |
| 72 | 78 |
| 73 private: | 79 private: |
| 74 friend class BluetoothAdapterChromeOs; | 80 friend class BluetoothAdapterChromeOs; |
| 75 friend class MockBluetoothDevice; | 81 friend class device::MockBluetoothDevice; |
| 76 | 82 |
| 77 explicit BluetoothDeviceChromeOs(BluetoothAdapterChromeOs* adapter); | 83 explicit BluetoothDeviceChromeOs(BluetoothAdapterChromeOs* adapter); |
| 78 | 84 |
| 79 // Sets the dbus object path for the device to |object_path|, indicating | 85 // Sets the dbus object path for the device to |object_path|, indicating |
| 80 // that the device has gone from being discovered to paired or bonded. | 86 // that the device has gone from being discovered to paired or bonded. |
| 81 void SetObjectPath(const dbus::ObjectPath& object_path); | 87 void SetObjectPath(const dbus::ObjectPath& object_path); |
| 82 | 88 |
| 83 // Removes the dbus object path from the device, indicating that the | 89 // Removes the dbus object path from the device, indicating that the |
| 84 // device is no longer paired or bonded, but perhaps still visible. | 90 // device is no longer paired or bonded, but perhaps still visible. |
| 85 void RemoveObjectPath(); | 91 void RemoveObjectPath(); |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 // The dbus object path of the device, will be empty if the device has only | 340 // The dbus object path of the device, will be empty if the device has only |
| 335 // been discovered and not yet paired with. | 341 // been discovered and not yet paired with. |
| 336 dbus::ObjectPath object_path_; | 342 dbus::ObjectPath object_path_; |
| 337 | 343 |
| 338 // The services (identified by UUIDs) that this device provides. | 344 // The services (identified by UUIDs) that this device provides. |
| 339 std::vector<std::string> service_uuids_; | 345 std::vector<std::string> service_uuids_; |
| 340 | 346 |
| 341 // During pairing this is set to an object that we don't own, but on which | 347 // During pairing this is set to an object that we don't own, but on which |
| 342 // we can make method calls to request, display or confirm PIN Codes and | 348 // we can make method calls to request, display or confirm PIN Codes and |
| 343 // Passkeys. Generally it is the object that owns this one. | 349 // Passkeys. Generally it is the object that owns this one. |
| 344 BluetoothDevice::PairingDelegate* pairing_delegate_; | 350 device::BluetoothDevice::PairingDelegate* pairing_delegate_; |
| 345 | 351 |
| 346 // During pairing this is set to an instance of a D-Bus agent object | 352 // During pairing this is set to an instance of a D-Bus agent object |
| 347 // intialized with our own class as its delegate. | 353 // intialized with our own class as its delegate. |
| 348 scoped_ptr<BluetoothAgentServiceProvider> agent_; | 354 scoped_ptr<BluetoothAgentServiceProvider> agent_; |
| 349 | 355 |
| 350 // During pairing these callbacks are set to those provided by method calls | 356 // During pairing these callbacks are set to those provided by method calls |
| 351 // made on us by |agent_| and are called by our own method calls such as | 357 // made on us by |agent_| and are called by our own method calls such as |
| 352 // SetPinCode() and SetPasskey(). | 358 // SetPinCode() and SetPasskey(). |
| 353 PinCodeCallback pincode_callback_; | 359 PinCodeCallback pincode_callback_; |
| 354 PasskeyCallback passkey_callback_; | 360 PasskeyCallback passkey_callback_; |
| 355 ConfirmationCallback confirmation_callback_; | 361 ConfirmationCallback confirmation_callback_; |
| 356 | 362 |
| 357 // Used to keep track of pending application connection requests. | 363 // Used to keep track of pending application connection requests. |
| 358 int connecting_applications_counter_; | 364 int connecting_applications_counter_; |
| 359 | 365 |
| 360 // Note: This should remain the last member so it'll be destroyed and | 366 // Note: This should remain the last member so it'll be destroyed and |
| 361 // invalidate its weak pointers before any other members are destroyed. | 367 // invalidate its weak pointers before any other members are destroyed. |
| 362 base::WeakPtrFactory<BluetoothDeviceChromeOs> weak_ptr_factory_; | 368 base::WeakPtrFactory<BluetoothDeviceChromeOs> weak_ptr_factory_; |
| 363 | 369 |
| 364 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceChromeOs); | 370 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceChromeOs); |
| 365 }; | 371 }; |
| 366 | 372 |
| 367 } // namespace chromeos | 373 } // namespace chromeos |
| 368 | 374 |
| 369 #endif // CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H_ | 375 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H_ |
| OLD | NEW |