Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Side by Side Diff: ash/common/system/chromeos/bluetooth/tray_bluetooth_helper.h

Issue 2761993002: cros: Eliminate bluetooth methods from SystemTrayDelegate (Closed)
Patch Set: rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 ASH_COMMON_SYSTEM_CHROMEOS_BLUETOOTH_TRAY_BLUETOOTH_HELPER_H_ 5 #ifndef ASH_COMMON_SYSTEM_CHROMEOS_BLUETOOTH_TRAY_BLUETOOTH_HELPER_H_
6 #define ASH_COMMON_SYSTEM_CHROMEOS_BLUETOOTH_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 "ash/ash_export.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "device/bluetooth/bluetooth_adapter.h" 15 #include "device/bluetooth/bluetooth_adapter.h"
16 16
17 namespace device { 17 namespace device {
18 class BluetoothDiscoverySession; 18 class BluetoothDiscoverySession;
19 } 19 }
20 20
21 namespace ash { 21 namespace ash {
22 22
23 struct BluetoothDeviceInfo; 23 // TODO(jamescook): Convert TrayBlueooth to use device::BluetoothDevice and
24 // delete this. http://crbug.com/660043
25 struct ASH_EXPORT BluetoothDeviceInfo {
26 BluetoothDeviceInfo();
27 BluetoothDeviceInfo(const BluetoothDeviceInfo& other);
28 ~BluetoothDeviceInfo();
29
30 std::string address;
31 base::string16 display_name;
32 bool connected;
33 bool connecting;
34 bool paired;
35 device::BluetoothDeviceType device_type;
36 };
37
38 using BluetoothDeviceList = std::vector<BluetoothDeviceInfo>;
24 39
25 // Maps UI concepts from the Bluetooth system tray (e.g. "Bluetooth is on") into 40 // Maps UI concepts from the Bluetooth system tray (e.g. "Bluetooth is on") into
26 // device concepts ("Bluetooth adapter enabled"). Note that most Bluetooth 41 // device concepts ("Bluetooth adapter enabled"). Note that most Bluetooth
27 // device operations are asynchronous, hence the two step initialization. 42 // device operations are asynchronous, hence the two step initialization.
28 // Exported for test. 43 // Exported for test.
29 class ASH_EXPORT TrayBluetoothHelper 44 class ASH_EXPORT TrayBluetoothHelper
30 : public device::BluetoothAdapter::Observer { 45 : public device::BluetoothAdapter::Observer {
31 public: 46 public:
32 TrayBluetoothHelper(); 47 TrayBluetoothHelper();
33 ~TrayBluetoothHelper() override; 48 ~TrayBluetoothHelper() override;
34 49
35 // Initializes and gets the adapter asynchronously. 50 // Initializes and gets the adapter asynchronously.
36 void Initialize(); 51 void Initialize();
37 52
38 // Completes initialization after the Bluetooth adapter is ready. 53 // Completes initialization after the Bluetooth adapter is ready.
39 void InitializeOnAdapterReady( 54 void InitializeOnAdapterReady(
40 scoped_refptr<device::BluetoothAdapter> adapter); 55 scoped_refptr<device::BluetoothAdapter> adapter);
41 56
42 // Returns a list of available bluetooth devices. 57 // Returns a list of available bluetooth devices.
43 // TODO(jamescook): Just return the list. 58 // TODO(jamescook): Just return the list.
44 void GetAvailableDevices(std::vector<BluetoothDeviceInfo>* list); 59 void GetAvailableBluetoothDevices(std::vector<BluetoothDeviceInfo>* list);
James Cook 2017/03/21 00:31:58 I renamed all these to make the code in TrayBlueto
msw 2017/03/21 01:54:43 I think your renaming is fine as-is.
45 60
46 // Requests bluetooth start discovering devices, which happens asynchronously. 61 // Requests bluetooth start discovering devices, which happens asynchronously.
47 void StartDiscovering(); 62 void StartBluetoothDiscovering();
48 63
49 // Requests bluetooth stop discovering devices. 64 // Requests bluetooth stop discovering devices.
50 void StopDiscovering(); 65 void StopBluetoothDiscovering();
51 66
52 // Connect to a specific bluetooth device. 67 // Connect to a specific bluetooth device.
53 void ConnectToDevice(const std::string& address); 68 void ConnectToBluetoothDevice(const std::string& address);
54 69
55 // Returns true if bluetooth adapter is discovering bluetooth devices. 70 // Returns true if bluetooth adapter is discovering bluetooth devices.
56 bool IsDiscovering() const; 71 bool IsBluetoothDiscovering() const;
57 72
58 // Toggles whether bluetooth is enabled. 73 // Toggles whether bluetooth is enabled.
59 void ToggleEnabled(); 74 void ToggleBluetoothEnabled();
60 75
61 // Returns whether bluetooth capability is available (e.g. the device has 76 // Returns whether bluetooth capability is available (e.g. the device has
62 // hardware support). 77 // hardware support).
63 bool GetAvailable(); 78 bool GetBluetoothAvailable();
64 79
65 // Returns whether bluetooth is enabled. 80 // Returns whether bluetooth is enabled.
66 bool GetEnabled(); 81 bool GetBluetoothEnabled();
67 82
68 // Returns whether the delegate has initiated a bluetooth discovery session. 83 // Returns whether the delegate has initiated a bluetooth discovery session.
69 // TODO(jamescook): Why do we need both this and IsDiscovering()? 84 // TODO(jamescook): Why do we need both this and IsDiscovering()?
70 bool HasDiscoverySession(); 85 bool HasBluetoothDiscoverySession();
71 86
72 // BluetoothAdapter::Observer: 87 // BluetoothAdapter::Observer:
73 void AdapterPresentChanged(device::BluetoothAdapter* adapter, 88 void AdapterPresentChanged(device::BluetoothAdapter* adapter,
74 bool present) override; 89 bool present) override;
75 void AdapterPoweredChanged(device::BluetoothAdapter* adapter, 90 void AdapterPoweredChanged(device::BluetoothAdapter* adapter,
76 bool powered) override; 91 bool powered) override;
77 void AdapterDiscoveringChanged(device::BluetoothAdapter* adapter, 92 void AdapterDiscoveringChanged(device::BluetoothAdapter* adapter,
78 bool discovering) override; 93 bool discovering) override;
79 void DeviceAdded(device::BluetoothAdapter* adapter, 94 void DeviceAdded(device::BluetoothAdapter* adapter,
80 device::BluetoothDevice* device) override; 95 device::BluetoothDevice* device) override;
(...skipping 12 matching lines...) Expand all
93 108
94 // Object could be deleted during a prolonged Bluetooth operation. 109 // Object could be deleted during a prolonged Bluetooth operation.
95 base::WeakPtrFactory<TrayBluetoothHelper> weak_ptr_factory_; 110 base::WeakPtrFactory<TrayBluetoothHelper> weak_ptr_factory_;
96 111
97 DISALLOW_COPY_AND_ASSIGN(TrayBluetoothHelper); 112 DISALLOW_COPY_AND_ASSIGN(TrayBluetoothHelper);
98 }; 113 };
99 114
100 } // namespace ash 115 } // namespace ash
101 116
102 #endif // ASH_COMMON_SYSTEM_CHROMEOS_BLUETOOTH_TRAY_BLUETOOTH_HELPER_H_ 117 #endif // ASH_COMMON_SYSTEM_CHROMEOS_BLUETOOTH_TRAY_BLUETOOTH_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698