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

Unified Diff: ash/common/system/chromeos/bluetooth/tray_bluetooth.cc

Issue 2758553002: Keep focused device in Bluetooth device list when the list is refreshed. (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698