| 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 #include "ash/common/system/chromeos/bluetooth/tray_bluetooth.h" | 5 #include "ash/common/system/chromeos/bluetooth/tray_bluetooth.h" |
| 6 | 6 |
| 7 #include "ash/common/session/session_state_delegate.h" | 7 #include "ash/common/session/session_state_delegate.h" |
| 8 #include "ash/common/system/chromeos/bluetooth/tray_bluetooth_helper.h" | 8 #include "ash/common/system/chromeos/bluetooth/tray_bluetooth_helper.h" |
| 9 #include "ash/common/system/tray/hover_highlight_view.h" | 9 #include "ash/common/system/tray/hover_highlight_view.h" |
| 10 #include "ash/common/system/tray/system_tray.h" | 10 #include "ash/common/system/tray/system_tray.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 SetImage(gfx::CreateVectorIcon(GetCurrentIcon(), style->GetIconColor())); | 155 SetImage(gfx::CreateVectorIcon(GetCurrentIcon(), style->GetIconColor())); |
| 156 } | 156 } |
| 157 | 157 |
| 158 private: | 158 private: |
| 159 const gfx::VectorIcon& GetCurrentIcon() { | 159 const gfx::VectorIcon& GetCurrentIcon() { |
| 160 TrayBluetoothHelper* helper = Shell::Get()->tray_bluetooth_helper(); | 160 TrayBluetoothHelper* helper = Shell::Get()->tray_bluetooth_helper(); |
| 161 if (!helper->GetBluetoothEnabled()) | 161 if (!helper->GetBluetoothEnabled()) |
| 162 return kSystemMenuBluetoothDisabledIcon; | 162 return kSystemMenuBluetoothDisabledIcon; |
| 163 | 163 |
| 164 bool has_connected_device = false; | 164 bool has_connected_device = false; |
| 165 BluetoothDeviceList list; | 165 BluetoothDeviceList list = helper->GetAvailableBluetoothDevices(); |
| 166 helper->GetAvailableBluetoothDevices(&list); | |
| 167 for (size_t i = 0; i < list.size(); ++i) { | 166 for (size_t i = 0; i < list.size(); ++i) { |
| 168 if (list[i].connected) { | 167 if (list[i].connected) { |
| 169 has_connected_device = true; | 168 has_connected_device = true; |
| 170 break; | 169 break; |
| 171 } | 170 } |
| 172 } | 171 } |
| 173 return has_connected_device ? kSystemMenuBluetoothConnectedIcon | 172 return has_connected_device ? kSystemMenuBluetoothConnectedIcon |
| 174 : kSystemMenuBluetoothIcon; | 173 : kSystemMenuBluetoothIcon; |
| 175 } | 174 } |
| 176 | 175 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 HideLoadingIndicator(); | 226 HideLoadingIndicator(); |
| 228 } | 227 } |
| 229 } | 228 } |
| 230 | 229 |
| 231 void UpdateBluetoothDeviceList() { | 230 void UpdateBluetoothDeviceList() { |
| 232 std::set<std::string> new_connecting_devices; | 231 std::set<std::string> new_connecting_devices; |
| 233 std::set<std::string> new_connected_devices; | 232 std::set<std::string> new_connected_devices; |
| 234 std::set<std::string> new_paired_not_connected_devices; | 233 std::set<std::string> new_paired_not_connected_devices; |
| 235 std::set<std::string> new_discovered_not_paired_devices; | 234 std::set<std::string> new_discovered_not_paired_devices; |
| 236 | 235 |
| 237 BluetoothDeviceList list; | 236 BluetoothDeviceList list = |
| 238 Shell::Get()->tray_bluetooth_helper()->GetAvailableBluetoothDevices(&list); | 237 Shell::Get()->tray_bluetooth_helper()->GetAvailableBluetoothDevices(); |
| 239 for (size_t i = 0; i < list.size(); ++i) { | 238 for (size_t i = 0; i < list.size(); ++i) { |
| 240 if (list[i].connecting) { | 239 if (list[i].connecting) { |
| 241 new_connecting_devices.insert(list[i].address); | 240 new_connecting_devices.insert(list[i].address); |
| 242 UpdateBluetoothDeviceListHelper(&connecting_devices_, list[i]); | 241 UpdateBluetoothDeviceListHelper(&connecting_devices_, list[i]); |
| 243 } else if (list[i].connected && list[i].paired) { | 242 } else if (list[i].connected && list[i].paired) { |
| 244 new_connected_devices.insert(list[i].address); | 243 new_connected_devices.insert(list[i].address); |
| 245 UpdateBluetoothDeviceListHelper(&connected_devices_, list[i]); | 244 UpdateBluetoothDeviceListHelper(&connected_devices_, list[i]); |
| 246 } else if (list[i].paired) { | 245 } else if (list[i].paired) { |
| 247 new_paired_not_connected_devices.insert(list[i].address); | 246 new_paired_not_connected_devices.insert(list[i].address); |
| 248 UpdateBluetoothDeviceListHelper(&paired_not_connected_devices_, | 247 UpdateBluetoothDeviceListHelper(&paired_not_connected_devices_, |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 detailed_->Update(); | 646 detailed_->Update(); |
| 648 } | 647 } |
| 649 | 648 |
| 650 void TrayBluetooth::OnBluetoothDiscoveringChanged() { | 649 void TrayBluetooth::OnBluetoothDiscoveringChanged() { |
| 651 if (!detailed_) | 650 if (!detailed_) |
| 652 return; | 651 return; |
| 653 detailed_->Update(); | 652 detailed_->Update(); |
| 654 } | 653 } |
| 655 | 654 |
| 656 } // namespace ash | 655 } // namespace ash |
| OLD | NEW |