Chromium Code Reviews| 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/tray/hover_highlight_view.h" | 8 #include "ash/common/system/tray/hover_highlight_view.h" |
| 9 #include "ash/common/system/tray/system_tray.h" | 9 #include "ash/common/system/tray/system_tray.h" |
| 10 #include "ash/common/system/tray/system_tray_delegate.h" | 10 #include "ash/common/system/tray/system_tray_delegate.h" |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 262 } | 262 } |
| 263 | 263 |
| 264 void UpdateHeaderEntry() { | 264 void UpdateHeaderEntry() { |
| 265 bool is_bluetooth_enabled = | 265 bool is_bluetooth_enabled = |
| 266 WmShell::Get()->system_tray_delegate()->GetBluetoothEnabled(); | 266 WmShell::Get()->system_tray_delegate()->GetBluetoothEnabled(); |
| 267 if (toggle_) | 267 if (toggle_) |
| 268 toggle_->SetIsOn(is_bluetooth_enabled, true); | 268 toggle_->SetIsOn(is_bluetooth_enabled, true); |
| 269 } | 269 } |
| 270 | 270 |
| 271 void UpdateDeviceScrollList() { | 271 void UpdateDeviceScrollList() { |
| 272 std::string focused_device_address = GetFocusedDeviceAddress(); | |
| 273 | |
| 272 device_map_.clear(); | 274 device_map_.clear(); |
| 273 scroll_content()->RemoveAllChildViews(true); | 275 scroll_content()->RemoveAllChildViews(true); |
| 274 | 276 |
| 275 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); | 277 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); |
| 276 bool bluetooth_enabled = delegate->GetBluetoothEnabled(); | 278 bool bluetooth_enabled = delegate->GetBluetoothEnabled(); |
| 277 bool bluetooth_available = delegate->GetBluetoothAvailable(); | 279 bool bluetooth_available = delegate->GetBluetoothAvailable(); |
| 278 | 280 |
| 279 // If Bluetooth is disabled, show a panel which only indicates that it is | 281 // If Bluetooth is disabled, show a panel which only indicates that it is |
| 280 // disabled, instead of the scroller with Bluetooth devices. | 282 // disabled, instead of the scroller with Bluetooth devices. |
| 281 if (bluetooth_enabled) { | 283 if (bluetooth_enabled) { |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 311 if (device_map_.size() == 0) { | 313 if (device_map_.size() == 0) { |
| 312 if (bluetooth_available && bluetooth_enabled) { | 314 if (bluetooth_available && bluetooth_enabled) { |
| 313 HoverHighlightView* container = new HoverHighlightView(this); | 315 HoverHighlightView* container = new HoverHighlightView(this); |
| 314 container->AddLabel(l10n_util::GetStringUTF16( | 316 container->AddLabel(l10n_util::GetStringUTF16( |
| 315 IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCOVERING), | 317 IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCOVERING), |
| 316 gfx::ALIGN_LEFT, false); | 318 gfx::ALIGN_LEFT, false); |
| 317 scroll_content()->AddChildView(container); | 319 scroll_content()->AddChildView(container); |
| 318 } | 320 } |
| 319 } | 321 } |
| 320 | 322 |
| 323 // Focus the device which was focused before the device-list update. | |
| 324 if (!focused_device_address.empty()) | |
| 325 FocusDeviceByAddress(focused_device_address); | |
|
fukino
2017/03/16 14:20:15
Here, I restore the focus based on the device addr
tdanderson
2017/03/16 20:40:14
Sounds good to me, I think focusing based on addre
| |
| 326 | |
| 321 scroll_content()->InvalidateLayout(); | 327 scroll_content()->InvalidateLayout(); |
| 322 } | 328 } |
| 323 | 329 |
| 324 void AppendSameTypeDevicesToScrollList(const BluetoothDeviceList& list, | 330 void AppendSameTypeDevicesToScrollList(const BluetoothDeviceList& list, |
| 325 bool highlight, | 331 bool highlight, |
| 326 bool checked, | 332 bool checked, |
| 327 bool enabled) { | 333 bool enabled) { |
| 328 for (size_t i = 0; i < list.size(); ++i) { | 334 for (size_t i = 0; i < list.size(); ++i) { |
| 329 HoverHighlightView* container = nullptr; | 335 HoverHighlightView* container = nullptr; |
| 330 gfx::ImageSkia icon_image = CreateVectorIcon( | 336 gfx::ImageSkia icon_image = CreateVectorIcon( |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 541 kDisabledPanelLabelBaselineY - label->GetBaseline(), 0, 0, 0)); | 547 kDisabledPanelLabelBaselineY - label->GetBaseline(), 0, 0, 0)); |
| 542 container->AddChildView(label); | 548 container->AddChildView(label); |
| 543 | 549 |
| 544 // Make top padding of the icon equal to the height of the label so that the | 550 // Make top padding of the icon equal to the height of the label so that the |
| 545 // icon is vertically aligned to center of the container. | 551 // icon is vertically aligned to center of the container. |
| 546 image_view->SetBorder( | 552 image_view->SetBorder( |
| 547 views::CreateEmptyBorder(label->GetPreferredSize().height(), 0, 0, 0)); | 553 views::CreateEmptyBorder(label->GetPreferredSize().height(), 0, 0, 0)); |
| 548 return container; | 554 return container; |
| 549 } | 555 } |
| 550 | 556 |
| 557 std::string GetFocusedDeviceAddress() { | |
| 558 for (auto& view_and_address : device_map_) { | |
| 559 if (view_and_address.first->HasFocus()) | |
| 560 return view_and_address.second; | |
| 561 } | |
| 562 return std::string(); | |
| 563 } | |
| 564 | |
| 565 void FocusDeviceByAddress(const std::string& address) { | |
| 566 for (auto& view_and_address : device_map_) { | |
| 567 if (view_and_address.second == address) { | |
| 568 view_and_address.first->RequestFocus(); | |
| 569 return; | |
| 570 } | |
| 571 } | |
| 572 } | |
| 573 | |
| 551 LoginStatus login_; | 574 LoginStatus login_; |
| 552 | 575 |
| 553 std::map<views::View*, std::string> device_map_; | 576 std::map<views::View*, std::string> device_map_; |
| 554 | 577 |
| 555 BluetoothDeviceList connected_devices_; | 578 BluetoothDeviceList connected_devices_; |
| 556 BluetoothDeviceList connecting_devices_; | 579 BluetoothDeviceList connecting_devices_; |
| 557 BluetoothDeviceList paired_not_connected_devices_; | 580 BluetoothDeviceList paired_not_connected_devices_; |
| 558 BluetoothDeviceList discovered_not_paired_devices_; | 581 BluetoothDeviceList discovered_not_paired_devices_; |
| 559 | 582 |
| 560 views::ToggleButton* toggle_; | 583 views::ToggleButton* toggle_; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 622 detailed_->Update(); | 645 detailed_->Update(); |
| 623 } | 646 } |
| 624 | 647 |
| 625 void TrayBluetooth::OnBluetoothDiscoveringChanged() { | 648 void TrayBluetooth::OnBluetoothDiscoveringChanged() { |
| 626 if (!detailed_) | 649 if (!detailed_) |
| 627 return; | 650 return; |
| 628 detailed_->Update(); | 651 detailed_->Update(); |
| 629 } | 652 } |
| 630 | 653 |
| 631 } // namespace ash | 654 } // namespace ash |
| OLD | NEW |