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

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

Issue 216293007: ash::internal::TrayBluetooth: Hide spinner if discovery session stops. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | ash/system/tray/default_system_tray_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/bluetooth/tray_bluetooth.cc
diff --git a/ash/system/bluetooth/tray_bluetooth.cc b/ash/system/bluetooth/tray_bluetooth.cc
index 9114118df83c0a93eae13a64868aa6aa9338e4c0..eb3177e13fe062c8746d2bfa51a4d2fe2a619cfc 100644
--- a/ash/system/bluetooth/tray_bluetooth.cc
+++ b/ash/system/bluetooth/tray_bluetooth.cc
@@ -34,8 +34,8 @@ namespace {
// Updates bluetooth device |device| in the |list|. If it is new, append to the
// end of the |list|; otherwise, keep it at the same place, but update the data
// with new device info provided by |device|.
-void UpdateBluetoothDeviceList(BluetoothDeviceList* list,
- const BluetoothDeviceInfo& device) {
+void UpdateBluetoothDeviceListHelper(BluetoothDeviceList* list,
+ const BluetoothDeviceInfo& device) {
for (BluetoothDeviceList::iterator it = list->begin(); it != list->end();
++it) {
if ((*it).address == device.address) {
@@ -105,10 +105,8 @@ class BluetoothDetailedView : public TrayDetailsView,
login_(login),
manage_devices_(NULL),
toggle_bluetooth_(NULL),
- enable_bluetooth_(NULL),
- bluetooth_discovering_(false) {
+ enable_bluetooth_(NULL) {
CreateItems();
- Update();
}
virtual ~BluetoothDetailedView() {
@@ -118,7 +116,7 @@ class BluetoothDetailedView : public TrayDetailsView,
void Update() {
BluetoothStartDiscovering();
- UpdateBlueToothDeviceList();
+ UpdateBluetoothDeviceList();
// Update UI.
UpdateDeviceScrollList();
@@ -137,27 +135,27 @@ class BluetoothDetailedView : public TrayDetailsView,
ash::SystemTrayDelegate* delegate =
ash::Shell::GetInstance()->system_tray_delegate();
bool bluetooth_enabled = delegate->GetBluetoothEnabled();
- if (!bluetooth_discovering_ && bluetooth_enabled) {
- bluetooth_discovering_ = true;
- delegate->BluetoothStartDiscovering();
+ bool bluetooth_discovering = delegate->GetBluetoothDiscovering();
+ if (bluetooth_discovering) {
throbber_->Start();
- } else if(!bluetooth_enabled) {
- bluetooth_discovering_ = false;
- throbber_->Stop();
+ return;
+ }
+ throbber_->Stop();
+ if (bluetooth_enabled) {
+ delegate->BluetoothStartDiscovering();
}
}
void BluetoothStopDiscovering() {
ash::SystemTrayDelegate* delegate =
ash::Shell::GetInstance()->system_tray_delegate();
- if (delegate && bluetooth_discovering_) {
- bluetooth_discovering_ = false;
+ if (delegate && delegate->GetBluetoothDiscovering()) {
delegate->BluetoothStopDiscovering();
throbber_->Stop();
}
}
- void UpdateBlueToothDeviceList() {
+ void UpdateBluetoothDeviceList() {
std::set<std::string> new_connecting_devices;
std::set<std::string> new_connected_devices;
std::set<std::string> new_paired_not_connected_devices;
@@ -171,16 +169,18 @@ class BluetoothDetailedView : public TrayDetailsView,
list[i].display_name = l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_BLUETOOTH_CONNECTING, list[i].display_name);
new_connecting_devices.insert(list[i].address);
- UpdateBluetoothDeviceList(&connecting_devices_, list[i]);
+ UpdateBluetoothDeviceListHelper(&connecting_devices_, list[i]);
} else if (list[i].connected && list[i].paired) {
new_connected_devices.insert(list[i].address);
- UpdateBluetoothDeviceList(&connected_devices_, list[i]);
+ UpdateBluetoothDeviceListHelper(&connected_devices_, list[i]);
} else if (list[i].paired) {
new_paired_not_connected_devices.insert(list[i].address);
- UpdateBluetoothDeviceList(&paired_not_connected_devices_, list[i]);
+ UpdateBluetoothDeviceListHelper(
+ &paired_not_connected_devices_, list[i]);
} else {
new_discovered_not_paired_devices.insert(list[i].address);
- UpdateBluetoothDeviceList(&discovered_not_paired_devices_, list[i]);
+ UpdateBluetoothDeviceListHelper(
+ &discovered_not_paired_devices_, list[i]);
}
}
RemoveObsoleteBluetoothDevicesFromList(&connecting_devices_,
@@ -399,7 +399,6 @@ class BluetoothDetailedView : public TrayDetailsView,
BluetoothDeviceList connecting_devices_;
BluetoothDeviceList paired_not_connected_devices_;
BluetoothDeviceList discovered_not_paired_devices_;
- bool bluetooth_discovering_;
DISALLOW_COPY_AND_ASSIGN(BluetoothDetailedView);
};
@@ -435,6 +434,7 @@ views::View* TrayBluetooth::CreateDetailedView(user::LoginStatus status) {
ash::UMA_STATUS_AREA_DETAILED_BLUETOOTH_VIEW);
CHECK(detailed_ == NULL);
detailed_ = new tray::BluetoothDetailedView(this, status);
+ detailed_->Update();
return detailed_;
}
« no previous file with comments | « no previous file | ash/system/tray/default_system_tray_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698