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 #include "ash/common/system/chromeos/bluetooth/tray_bluetooth_helper.h" | 5 #include "ash/common/system/chromeos/bluetooth/tray_bluetooth_helper.h" |
6 | 6 |
7 #include "ash/common/system/tray/system_tray_controller.h" | 7 #include "ash/common/system/tray/system_tray_controller.h" |
8 #include "ash/common/system/tray/system_tray_notifier.h" | 8 #include "ash/common/system/tray/system_tray_notifier.h" |
9 #include "ash/common/wm_shell.h" | 9 #include "ash/common/wm_shell.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 weak_ptr_factory_.GetWeakPtr())); | 53 weak_ptr_factory_.GetWeakPtr())); |
54 } | 54 } |
55 | 55 |
56 void TrayBluetoothHelper::InitializeOnAdapterReady( | 56 void TrayBluetoothHelper::InitializeOnAdapterReady( |
57 scoped_refptr<device::BluetoothAdapter> adapter) { | 57 scoped_refptr<device::BluetoothAdapter> adapter) { |
58 adapter_ = adapter; | 58 adapter_ = adapter; |
59 CHECK(adapter_); | 59 CHECK(adapter_); |
60 adapter_->AddObserver(this); | 60 adapter_->AddObserver(this); |
61 } | 61 } |
62 | 62 |
63 void TrayBluetoothHelper::GetAvailableBluetoothDevices( | 63 BluetoothDeviceList TrayBluetoothHelper::GetAvailableBluetoothDevices() const { |
64 std::vector<BluetoothDeviceInfo>* list) { | 64 BluetoothDeviceList list; |
65 device::BluetoothAdapter::DeviceList devices = adapter_->GetDevices(); | 65 for (device::BluetoothDevice* device : adapter_->GetDevices()) { |
66 for (device::BluetoothDevice* device : devices) { | |
67 BluetoothDeviceInfo info; | 66 BluetoothDeviceInfo info; |
68 info.address = device->GetAddress(); | 67 info.address = device->GetAddress(); |
69 info.display_name = device->GetNameForDisplay(); | 68 info.display_name = device->GetNameForDisplay(); |
70 info.connected = device->IsConnected(); | 69 info.connected = device->IsConnected(); |
71 info.connecting = device->IsConnecting(); | 70 info.connecting = device->IsConnecting(); |
72 info.paired = device->IsPaired(); | 71 info.paired = device->IsPaired(); |
73 info.device_type = device->GetDeviceType(); | 72 info.device_type = device->GetDeviceType(); |
74 list->push_back(info); | 73 list.push_back(info); |
75 } | 74 } |
| 75 return list; |
76 } | 76 } |
77 | 77 |
78 void TrayBluetoothHelper::StartBluetoothDiscovering() { | 78 void TrayBluetoothHelper::StartBluetoothDiscovering() { |
79 if (HasBluetoothDiscoverySession()) { | 79 if (HasBluetoothDiscoverySession()) { |
80 LOG(WARNING) << "Already have active Bluetooth device discovery session."; | 80 LOG(WARNING) << "Already have active Bluetooth device discovery session."; |
81 return; | 81 return; |
82 } | 82 } |
83 VLOG(1) << "Requesting new Bluetooth device discovery session."; | 83 VLOG(1) << "Requesting new Bluetooth device discovery session."; |
84 should_run_discovery_ = true; | 84 should_run_discovery_ = true; |
85 adapter_->StartDiscoverySession( | 85 adapter_->StartDiscoverySession( |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 // (e.g. the user dismissed the Bluetooth detailed view before the call | 179 // (e.g. the user dismissed the Bluetooth detailed view before the call |
180 // returned), don't claim the discovery session and let it clean up. | 180 // returned), don't claim the discovery session and let it clean up. |
181 if (!should_run_discovery_) | 181 if (!should_run_discovery_) |
182 return; | 182 return; |
183 VLOG(1) << "Claiming new Bluetooth device discovery session."; | 183 VLOG(1) << "Claiming new Bluetooth device discovery session."; |
184 discovery_session_ = std::move(discovery_session); | 184 discovery_session_ = std::move(discovery_session); |
185 GetSystemTrayNotifier()->NotifyBluetoothDiscoveringChanged(); | 185 GetSystemTrayNotifier()->NotifyBluetoothDiscoveringChanged(); |
186 } | 186 } |
187 | 187 |
188 } // namespace ash | 188 } // namespace ash |
OLD | NEW |