| 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 CHROME_BROWSER_UI_ASH_TRAY_BLUETOOTH_HELPER_H_ |
| 6 #define CHROME_BROWSER_UI_ASH_TRAY_BLUETOOTH_HELPER_H_ | 6 #define CHROME_BROWSER_UI_ASH_TRAY_BLUETOOTH_HELPER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "device/bluetooth/bluetooth_adapter.h" | 14 #include "device/bluetooth/bluetooth_adapter.h" |
| 15 | 15 |
| 16 namespace ash { | 16 namespace ash { |
| 17 struct BluetoothDeviceInfo; | 17 struct BluetoothDeviceInfo; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace chromeos { | |
| 21 class SystemTrayDelegateChromeOS; | |
| 22 } | |
| 23 | |
| 24 namespace device { | 20 namespace device { |
| 25 class BluetoothDiscoverySession; | 21 class BluetoothDiscoverySession; |
| 26 } | 22 } |
| 27 | 23 |
| 28 // Maps UI concepts from the Bluetooth system tray (e.g. "Bluetooth is on") into | 24 // Maps UI concepts from the Bluetooth system tray (e.g. "Bluetooth is on") into |
| 29 // device concepts ("Bluetooth adapter enabled"). Note that most Bluetooth | 25 // device concepts ("Bluetooth adapter enabled"). Note that most Bluetooth |
| 30 // device operations are asynchronous, hence the two step initialization. | 26 // device operations are asynchronous, hence the two step initialization. |
| 31 // TODO(jamescook): Move into //ash/system next to TrayBluetooth. This isn't | 27 // TODO(jamescook): Move into //ash/system next to TrayBluetooth. This isn't |
| 32 // named "delegate" because long-term there should not be any delegation. | 28 // named "delegate" because long-term there should not be any delegation. |
| 33 class TrayBluetoothHelper : public device::BluetoothAdapter::Observer { | 29 class TrayBluetoothHelper : public device::BluetoothAdapter::Observer { |
| 34 public: | 30 public: |
| 35 explicit TrayBluetoothHelper( | 31 TrayBluetoothHelper(); |
| 36 chromeos::SystemTrayDelegateChromeOS* system_tray_delegate); | |
| 37 ~TrayBluetoothHelper() override; | 32 ~TrayBluetoothHelper() override; |
| 38 | 33 |
| 39 // Called after SystemTray has been instantiated. | 34 // Called after SystemTray has been instantiated. |
| 40 void Initialize(); | 35 void Initialize(); |
| 41 | 36 |
| 42 // Completes initialization after the Bluetooth adapter is ready. | 37 // Completes initialization after the Bluetooth adapter is ready. |
| 43 void InitializeOnAdapterReady( | 38 void InitializeOnAdapterReady( |
| 44 scoped_refptr<device::BluetoothAdapter> adapter); | 39 scoped_refptr<device::BluetoothAdapter> adapter); |
| 45 | 40 |
| 46 // Returns a list of available bluetooth devices. | 41 // Returns a list of available bluetooth devices. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 device::BluetoothDevice* device) override; | 79 device::BluetoothDevice* device) override; |
| 85 void DeviceChanged(device::BluetoothAdapter* adapter, | 80 void DeviceChanged(device::BluetoothAdapter* adapter, |
| 86 device::BluetoothDevice* device) override; | 81 device::BluetoothDevice* device) override; |
| 87 void DeviceRemoved(device::BluetoothAdapter* adapter, | 82 void DeviceRemoved(device::BluetoothAdapter* adapter, |
| 88 device::BluetoothDevice* device) override; | 83 device::BluetoothDevice* device) override; |
| 89 | 84 |
| 90 private: | 85 private: |
| 91 void OnStartDiscoverySession( | 86 void OnStartDiscoverySession( |
| 92 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session); | 87 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session); |
| 93 | 88 |
| 94 // TODO: Eliminate this after verifying the initialization order of | |
| 95 // SystemTrayDelegateChromeOS can be changed. | |
| 96 chromeos::SystemTrayDelegateChromeOS* const system_tray_delegate_; | |
| 97 | |
| 98 bool should_run_discovery_ = false; | 89 bool should_run_discovery_ = false; |
| 99 scoped_refptr<device::BluetoothAdapter> adapter_; | 90 scoped_refptr<device::BluetoothAdapter> adapter_; |
| 100 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session_; | 91 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session_; |
| 101 | 92 |
| 102 // Object could be deleted during a prolonged Bluetooth operation. | 93 // Object could be deleted during a prolonged Bluetooth operation. |
| 103 base::WeakPtrFactory<TrayBluetoothHelper> weak_ptr_factory_; | 94 base::WeakPtrFactory<TrayBluetoothHelper> weak_ptr_factory_; |
| 104 | 95 |
| 105 DISALLOW_COPY_AND_ASSIGN(TrayBluetoothHelper); | 96 DISALLOW_COPY_AND_ASSIGN(TrayBluetoothHelper); |
| 106 }; | 97 }; |
| 107 | 98 |
| 108 #endif // CHROME_BROWSER_UI_ASH_TRAY_BLUETOOTH_HELPER_H_ | 99 #endif // CHROME_BROWSER_UI_ASH_TRAY_BLUETOOTH_HELPER_H_ |
| OLD | NEW |