OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_ASH_TRAY_BLUETOOTH_HELPER_H_ | 5 #ifndef ASH_COMMON_SYSTEM_CHROMEOS_BLUETOOTH_TRAY_BLUETOOTH_HELPER_H_ |
6 #define CHROME_BROWSER_UI_ASH_TRAY_BLUETOOTH_HELPER_H_ | 6 #define ASH_COMMON_SYSTEM_CHROMEOS_BLUETOOTH_TRAY_BLUETOOTH_HELPER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
| 11 #include "ash/ash_export.h" |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
13 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
14 #include "device/bluetooth/bluetooth_adapter.h" | 15 #include "device/bluetooth/bluetooth_adapter.h" |
15 | 16 |
16 namespace ash { | |
17 struct BluetoothDeviceInfo; | |
18 } | |
19 | |
20 namespace device { | 17 namespace device { |
21 class BluetoothDiscoverySession; | 18 class BluetoothDiscoverySession; |
22 } | 19 } |
23 | 20 |
| 21 namespace ash { |
| 22 |
| 23 struct BluetoothDeviceInfo; |
| 24 |
24 // Maps UI concepts from the Bluetooth system tray (e.g. "Bluetooth is on") into | 25 // Maps UI concepts from the Bluetooth system tray (e.g. "Bluetooth is on") into |
25 // device concepts ("Bluetooth adapter enabled"). Note that most Bluetooth | 26 // device concepts ("Bluetooth adapter enabled"). Note that most Bluetooth |
26 // device operations are asynchronous, hence the two step initialization. | 27 // device operations are asynchronous, hence the two step initialization. |
27 // TODO(jamescook): Move into //ash/system next to TrayBluetooth. This isn't | 28 // Exported for test. |
28 // named "delegate" because long-term there should not be any delegation. | 29 class ASH_EXPORT TrayBluetoothHelper |
29 class TrayBluetoothHelper : public device::BluetoothAdapter::Observer { | 30 : public device::BluetoothAdapter::Observer { |
30 public: | 31 public: |
31 TrayBluetoothHelper(); | 32 TrayBluetoothHelper(); |
32 ~TrayBluetoothHelper() override; | 33 ~TrayBluetoothHelper() override; |
33 | 34 |
34 // Called after SystemTray has been instantiated. | 35 // Initializes and gets the adapter asynchronously. |
35 void Initialize(); | 36 void Initialize(); |
36 | 37 |
37 // Completes initialization after the Bluetooth adapter is ready. | 38 // Completes initialization after the Bluetooth adapter is ready. |
38 void InitializeOnAdapterReady( | 39 void InitializeOnAdapterReady( |
39 scoped_refptr<device::BluetoothAdapter> adapter); | 40 scoped_refptr<device::BluetoothAdapter> adapter); |
40 | 41 |
41 // Returns a list of available bluetooth devices. | 42 // Returns a list of available bluetooth devices. |
42 // TODO(jamescook): Just return the list. | 43 // TODO(jamescook): Just return the list. |
43 void GetAvailableDevices(std::vector<ash::BluetoothDeviceInfo>* list); | 44 void GetAvailableDevices(std::vector<BluetoothDeviceInfo>* list); |
44 | 45 |
45 // Requests bluetooth start discovering devices, which happens asynchronously. | 46 // Requests bluetooth start discovering devices, which happens asynchronously. |
46 void StartDiscovering(); | 47 void StartDiscovering(); |
47 | 48 |
48 // Requests bluetooth stop discovering devices. | 49 // Requests bluetooth stop discovering devices. |
49 void StopDiscovering(); | 50 void StopDiscovering(); |
50 | 51 |
51 // Connect to a specific bluetooth device. | 52 // Connect to a specific bluetooth device. |
52 void ConnectToDevice(const std::string& address); | 53 void ConnectToDevice(const std::string& address); |
53 | 54 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 bool should_run_discovery_ = false; | 90 bool should_run_discovery_ = false; |
90 scoped_refptr<device::BluetoothAdapter> adapter_; | 91 scoped_refptr<device::BluetoothAdapter> adapter_; |
91 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session_; | 92 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session_; |
92 | 93 |
93 // Object could be deleted during a prolonged Bluetooth operation. | 94 // Object could be deleted during a prolonged Bluetooth operation. |
94 base::WeakPtrFactory<TrayBluetoothHelper> weak_ptr_factory_; | 95 base::WeakPtrFactory<TrayBluetoothHelper> weak_ptr_factory_; |
95 | 96 |
96 DISALLOW_COPY_AND_ASSIGN(TrayBluetoothHelper); | 97 DISALLOW_COPY_AND_ASSIGN(TrayBluetoothHelper); |
97 }; | 98 }; |
98 | 99 |
99 #endif // CHROME_BROWSER_UI_ASH_TRAY_BLUETOOTH_HELPER_H_ | 100 } // namespace ash |
| 101 |
| 102 #endif // ASH_COMMON_SYSTEM_CHROMEOS_BLUETOOTH_TRAY_BLUETOOTH_HELPER_H_ |
OLD | NEW |