Chromium Code Reviews| Index: ash/common/system/chromeos/bluetooth/tray_bluetooth.cc |
| diff --git a/ash/common/system/chromeos/bluetooth/tray_bluetooth.cc b/ash/common/system/chromeos/bluetooth/tray_bluetooth.cc |
| index 3eeae17a49fd3062f89367f67ad6fd43e95daebd..08adff62477101a4c49788bc53f443fee6fdb0cc 100644 |
| --- a/ash/common/system/chromeos/bluetooth/tray_bluetooth.cc |
| +++ b/ash/common/system/chromeos/bluetooth/tray_bluetooth.cc |
| @@ -269,6 +269,8 @@ class BluetoothDetailedView : public TrayDetailsView { |
| } |
| void UpdateDeviceScrollList() { |
| + std::string focused_device_address = GetFocusedDeviceAddress(); |
| + |
| device_map_.clear(); |
| scroll_content()->RemoveAllChildViews(true); |
| @@ -318,6 +320,10 @@ class BluetoothDetailedView : public TrayDetailsView { |
| } |
| } |
| + // Focus the device which was focused before the device-list update. |
| + if (!focused_device_address.empty()) |
| + 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
|
| + |
| scroll_content()->InvalidateLayout(); |
| } |
| @@ -548,6 +554,23 @@ class BluetoothDetailedView : public TrayDetailsView { |
| return container; |
| } |
| + std::string GetFocusedDeviceAddress() { |
| + for (auto& view_and_address : device_map_) { |
| + if (view_and_address.first->HasFocus()) |
| + return view_and_address.second; |
| + } |
| + return std::string(); |
| + } |
| + |
| + void FocusDeviceByAddress(const std::string& address) { |
| + for (auto& view_and_address : device_map_) { |
| + if (view_and_address.second == address) { |
| + view_and_address.first->RequestFocus(); |
| + return; |
| + } |
| + } |
| + } |
| + |
| LoginStatus login_; |
| std::map<views::View*, std::string> device_map_; |