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_UI_WEBUI_OPTIONS_CHROMEOS_BLUETOOTH_OPTIONS_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_BLUETOOTH_OPTIONS_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_BLUETOOTH_OPTIONS_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_BLUETOOTH_OPTIONS_HANDLER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "chrome/browser/ui/webui/options/options_ui.h" | 14 #include "chrome/browser/ui/webui/options/options_ui.h" |
15 #include "device/bluetooth/bluetooth_adapter.h" | 15 #include "device/bluetooth/bluetooth_adapter.h" |
16 #include "device/bluetooth/bluetooth_device.h" | 16 #include "device/bluetooth/bluetooth_device.h" |
| 17 #include "device/bluetooth/bluetooth_discovery_session.h" |
17 | 18 |
18 namespace base { | 19 namespace base { |
19 class DictionaryValue; | 20 class DictionaryValue; |
20 } | 21 } |
21 | 22 |
22 namespace chromeos { | 23 namespace chromeos { |
23 namespace options { | 24 namespace options { |
24 | 25 |
25 // Handler for Bluetooth options on the system options page. | 26 // Handler for Bluetooth options on the system options page. |
26 class BluetoothOptionsHandler | 27 class BluetoothOptionsHandler |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 device::BluetoothDevice* device) OVERRIDE; | 148 device::BluetoothDevice* device) OVERRIDE; |
148 | 149 |
149 private: | 150 private: |
150 // Displays in the UI a connecting to the device |device| message. | 151 // Displays in the UI a connecting to the device |device| message. |
151 void DeviceConnecting(device::BluetoothDevice* device); | 152 void DeviceConnecting(device::BluetoothDevice* device); |
152 | 153 |
153 // Called by device::BluetoothAdapter in response to a failure to | 154 // Called by device::BluetoothAdapter in response to a failure to |
154 // change the power status of the adapter. | 155 // change the power status of the adapter. |
155 void EnableChangeError(); | 156 void EnableChangeError(); |
156 | 157 |
| 158 // Called by device::BluetoothAdapter in response to a successful request |
| 159 // to initiate a discovery session. |
| 160 void OnStartDiscoverySession( |
| 161 scoped_ptr<device::BluetoothDiscoverySession> discovery_session); |
| 162 |
157 // Called by device::BluetoothAdapter in response to a failure to | 163 // Called by device::BluetoothAdapter in response to a failure to |
158 // set the adapter into discovery mode. | 164 // initiate a discovery session. |
159 void FindDevicesError(); | 165 void FindDevicesError(); |
160 | 166 |
161 // Called by device::BluetoothAdapter in response to a failure to | 167 // Called by device::BluetoothAdapter in response to a failure to |
162 // remove the adapter from discovery mode. | 168 // terminate a discovery session. |
163 void StopDiscoveryError(); | 169 void StopDiscoveryError(); |
164 | 170 |
165 // Called by device::BluetoothDevice on a successful pairing and connection | 171 // Called by device::BluetoothDevice on a successful pairing and connection |
166 // to a device. | 172 // to a device. |
167 void Connected(); | 173 void Connected(); |
168 | 174 |
169 // Called by device::BluetoothDevice in response to a failure to | 175 // Called by device::BluetoothDevice in response to a failure to |
170 // connect to the device with bluetooth address |address| due to an error | 176 // connect to the device with bluetooth address |address| due to an error |
171 // encoded in |error_code|. | 177 // encoded in |error_code|. |
172 void ConnectError(const std::string& address, | 178 void ConnectError(const std::string& address, |
(...skipping 30 matching lines...) Expand all Loading... |
203 void StopDiscoveryCallback(const base::ListValue* args); | 209 void StopDiscoveryCallback(const base::ListValue* args); |
204 | 210 |
205 // Called when the list of paired devices is initialized in order to | 211 // Called when the list of paired devices is initialized in order to |
206 // populate the list. | 212 // populate the list. |
207 // |args| will be an empty list. | 213 // |args| will be an empty list. |
208 void GetPairedDevicesCallback(const base::ListValue* args); | 214 void GetPairedDevicesCallback(const base::ListValue* args); |
209 | 215 |
210 // Default bluetooth adapter, used for all operations. | 216 // Default bluetooth adapter, used for all operations. |
211 scoped_refptr<device::BluetoothAdapter> adapter_; | 217 scoped_refptr<device::BluetoothAdapter> adapter_; |
212 | 218 |
213 // True while performing device discovery. | 219 // True, if the UI has requested device discovery. False, if either no device |
214 bool discovering_; | 220 // discovery was requested or the dialog responsible for device discovery was |
| 221 // dismissed. |
| 222 bool should_run_device_discovery_; |
| 223 |
| 224 // The current device discovery session. Only one active discovery session is |
| 225 // kept at a time and the instance that |discovery_session_| points to gets |
| 226 // replaced by a new one when a new discovery session is initiated. |
| 227 scoped_ptr<device::BluetoothDiscoverySession> discovery_session_; |
215 | 228 |
216 // Cached information about the current pairing device, if any. | 229 // Cached information about the current pairing device, if any. |
217 std::string pairing_device_address_; | 230 std::string pairing_device_address_; |
218 std::string pairing_device_pairing_; | 231 std::string pairing_device_pairing_; |
219 std::string pairing_device_pincode_; | 232 std::string pairing_device_pincode_; |
220 int pairing_device_passkey_; | 233 int pairing_device_passkey_; |
221 int pairing_device_entered_; | 234 int pairing_device_entered_; |
222 | 235 |
223 // Weak pointer factory for generating 'this' pointers that might live longer | 236 // Weak pointer factory for generating 'this' pointers that might live longer |
224 // than this object does. | 237 // than this object does. |
225 base::WeakPtrFactory<BluetoothOptionsHandler> weak_ptr_factory_; | 238 base::WeakPtrFactory<BluetoothOptionsHandler> weak_ptr_factory_; |
226 | 239 |
227 DISALLOW_COPY_AND_ASSIGN(BluetoothOptionsHandler); | 240 DISALLOW_COPY_AND_ASSIGN(BluetoothOptionsHandler); |
228 }; | 241 }; |
229 | 242 |
230 } // namespace options | 243 } // namespace options |
231 } // namespace chromeos | 244 } // namespace chromeos |
232 | 245 |
233 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_BLUETOOTH_OPTIONS_HANDLER_H_ | 246 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_BLUETOOTH_OPTIONS_HANDLER_H_ |
OLD | NEW |