OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_PAIRING_CHROMEOS_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_PAIRING_BLUEZ_H_ |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_PAIRING_CHROMEOS_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_PAIRING_BLUEZ_H_ |
7 | 7 |
| 8 #include "base/macros.h" |
8 #include "device/bluetooth/bluetooth_device.h" | 9 #include "device/bluetooth/bluetooth_device.h" |
9 #include "device/bluetooth/dbus/bluetooth_agent_service_provider.h" | 10 #include "device/bluetooth/dbus/bluetooth_agent_service_provider.h" |
10 | 11 |
11 namespace chromeos { | 12 namespace bluez { |
12 | 13 |
13 class BluetoothDeviceChromeOS; | 14 class BluetoothDeviceBlueZ; |
14 | 15 |
15 // The BluetoothPairingChromeOS class encapsulates the logic for an individual | 16 // The BluetoothPairingBlueZ class encapsulates the logic for an individual |
16 // device pairing, acting as a bridge between BluetoothAdapterChromeOS which | 17 // device pairing, acting as a bridge between BluetoothAdapterBlueZ which |
17 // communicates with the underlying Controller and Host Subsystem, and | 18 // communicates with the underlying Controller and Host Subsystem, and |
18 // BluetoothDeviceChromeOS which presents the pairing logic to the application. | 19 // BluetoothDeviceBlueZ which presents the pairing logic to the application. |
19 class BluetoothPairingChromeOS { | 20 class BluetoothPairingBlueZ { |
20 public: | 21 public: |
21 BluetoothPairingChromeOS( | 22 BluetoothPairingBlueZ( |
22 BluetoothDeviceChromeOS* device, | 23 BluetoothDeviceBlueZ* device, |
23 device::BluetoothDevice::PairingDelegate* pairing_delegate); | 24 device::BluetoothDevice::PairingDelegate* pairing_delegate); |
24 ~BluetoothPairingChromeOS(); | 25 ~BluetoothPairingBlueZ(); |
25 | 26 |
26 // Indicates whether the device is currently pairing and expecting a | 27 // Indicates whether the device is currently pairing and expecting a |
27 // Passkey to be returned. | 28 // Passkey to be returned. |
28 bool ExpectingPasskey() const; | 29 bool ExpectingPasskey() const; |
29 | 30 |
30 // Indicates whether the device is currently pairing and expecting | 31 // Indicates whether the device is currently pairing and expecting |
31 // confirmation of a displayed passkey. | 32 // confirmation of a displayed passkey. |
32 bool ExpectingConfirmation() const; | 33 bool ExpectingConfirmation() const; |
33 | 34 |
34 // Requests a PIN code for the current device from the current pairing | 35 // Requests a PIN code for the current device from the current pairing |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 private: | 111 private: |
111 // Internal method to reset the current set of callbacks because a new | 112 // Internal method to reset the current set of callbacks because a new |
112 // request has arrived that supersedes them. | 113 // request has arrived that supersedes them. |
113 void ResetCallbacks(); | 114 void ResetCallbacks(); |
114 | 115 |
115 // Internal method to respond to the relevant callback for a RejectPairing | 116 // Internal method to respond to the relevant callback for a RejectPairing |
116 // or CancelPairing call. | 117 // or CancelPairing call. |
117 bool RunPairingCallbacks( | 118 bool RunPairingCallbacks( |
118 bluez::BluetoothAgentServiceProvider::Delegate::Status status); | 119 bluez::BluetoothAgentServiceProvider::Delegate::Status status); |
119 | 120 |
120 // The underlying BluetoothDeviceChromeOS that owns this pairing context. | 121 // The underlying BluetoothDeviceBlueZ that owns this pairing context. |
121 BluetoothDeviceChromeOS* device_; | 122 BluetoothDeviceBlueZ* device_; |
122 | 123 |
123 // UI Pairing Delegate to make method calls on, this must live as long as | 124 // UI Pairing Delegate to make method calls on, this must live as long as |
124 // the object capturing the PairingContext. | 125 // the object capturing the PairingContext. |
125 device::BluetoothDevice::PairingDelegate* pairing_delegate_; | 126 device::BluetoothDevice::PairingDelegate* pairing_delegate_; |
126 | 127 |
127 // Flag to indicate whether any pairing delegate method has been called | 128 // Flag to indicate whether any pairing delegate method has been called |
128 // during pairing. Used to determine whether we need to log the | 129 // during pairing. Used to determine whether we need to log the |
129 // "no pairing interaction" metric. | 130 // "no pairing interaction" metric. |
130 bool pairing_delegate_used_; | 131 bool pairing_delegate_used_; |
131 | 132 |
132 // During pairing these callbacks are set to those provided by method calls | 133 // During pairing these callbacks are set to those provided by method calls |
133 // made on the BluetoothAdapterChromeOS instance by its respective | 134 // made on the BluetoothAdapterBlueZ instance by its respective |
134 // bluez::BluetoothAgentServiceProvider instance, and are called by our own | 135 // bluez::BluetoothAgentServiceProvider instance, and are called by our own |
135 // method calls such as SetPinCode() and SetPasskey(). | 136 // method calls such as SetPinCode() and SetPasskey(). |
136 bluez::BluetoothAgentServiceProvider::Delegate::PinCodeCallback | 137 bluez::BluetoothAgentServiceProvider::Delegate::PinCodeCallback |
137 pincode_callback_; | 138 pincode_callback_; |
138 bluez::BluetoothAgentServiceProvider::Delegate::PasskeyCallback | 139 bluez::BluetoothAgentServiceProvider::Delegate::PasskeyCallback |
139 passkey_callback_; | 140 passkey_callback_; |
140 bluez::BluetoothAgentServiceProvider::Delegate::ConfirmationCallback | 141 bluez::BluetoothAgentServiceProvider::Delegate::ConfirmationCallback |
141 confirmation_callback_; | 142 confirmation_callback_; |
142 | 143 |
143 DISALLOW_COPY_AND_ASSIGN(BluetoothPairingChromeOS); | 144 DISALLOW_COPY_AND_ASSIGN(BluetoothPairingBlueZ); |
144 }; | 145 }; |
145 | 146 |
146 } // namespace chromeos | 147 } // namespace bluez |
147 | 148 |
148 #endif // DEVICE_BLUETOOTH_BLUETOOTH_PAIRING_CHROMEOS_H_ | 149 #endif // DEVICE_BLUETOOTH_BLUETOOTH_PAIRING_BLUEZ_H_ |
OLD | NEW |