summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorarmansito@chromium.org <armansito@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-01 00:37:06 +0000
committerarmansito@chromium.org <armansito@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-01 00:37:06 +0000
commit1d8e61772ad9012127510f968af0f7fad8bc1595 (patch)
tree3883c6f1c8780d91da3affe2263ee19fadf7580a /ash
parent64832fa1aab8a1ac95aebf0d1058fcbe3e66c08d (diff)
downloadchromium_src-1d8e61772ad9012127510f968af0f7fad8bc1595.zip
chromium_src-1d8e61772ad9012127510f968af0f7fad8bc1595.tar.gz
chromium_src-1d8e61772ad9012127510f968af0f7fad8bc1595.tar.bz2
ash::internal::TrayBluetooth: Hide spinner if discovery session stops.
Changed TrayBluetooth to update the spinner not based on whether or not it requested discovery but whether or not system tray delegate has an active discovery session. The code will now automatically try to restart discovery if discovery stops unexpectedly and start or stop the throbber based on that. Also renamed UpdateBlueToothDeviceList to UpdateBluetoothDeviceList and UpdateBluetoothDeviceList to UpdateBluetoothDeviceListHelper. BUG=345494 TEST=1. Hack bluetoothd to allow stopping discovery via command-line regardless of the client who intiated it. Use bluetoothctl and run 'scan off' after running discovery via TrayBluetooth. The spinner should visibly update and discovery should restart (upon which the spinner should re-update). 2. Start discovery outside of TrayBluetooth (e.g chrome://settings). Opening the tray discovery dialog should work as expected (i.e. the spinner should animate and found devices list should be populated. Review URL: https://codereview.chromium.org/216293007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260718 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/system/bluetooth/tray_bluetooth.cc40
-rw-r--r--ash/system/tray/default_system_tray_delegate.cc4
-rw-r--r--ash/system/tray/default_system_tray_delegate.h1
-rw-r--r--ash/system/tray/system_tray_delegate.h3
4 files changed, 28 insertions, 20 deletions
diff --git a/ash/system/bluetooth/tray_bluetooth.cc b/ash/system/bluetooth/tray_bluetooth.cc
index 9114118..eb3177e 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_;
}
diff --git a/ash/system/tray/default_system_tray_delegate.cc b/ash/system/tray/default_system_tray_delegate.cc
index 46c4c3d..694b66b 100644
--- a/ash/system/tray/default_system_tray_delegate.cc
+++ b/ash/system/tray/default_system_tray_delegate.cc
@@ -253,6 +253,10 @@ bool DefaultSystemTrayDelegate::GetBluetoothEnabled() {
return bluetooth_enabled_;
}
+bool DefaultSystemTrayDelegate::GetBluetoothDiscovering() {
+ return false;
+}
+
void DefaultSystemTrayDelegate::ChangeProxySettings() {
}
diff --git a/ash/system/tray/default_system_tray_delegate.h b/ash/system/tray/default_system_tray_delegate.h
index 5499ee4..0f47d16 100644
--- a/ash/system/tray/default_system_tray_delegate.h
+++ b/ash/system/tray/default_system_tray_delegate.h
@@ -80,6 +80,7 @@ class ASH_EXPORT DefaultSystemTrayDelegate : public SystemTrayDelegate {
virtual void ShowOtherNetworkDialog(const std::string& type) OVERRIDE;
virtual bool GetBluetoothAvailable() OVERRIDE;
virtual bool GetBluetoothEnabled() OVERRIDE;
+ virtual bool GetBluetoothDiscovering() OVERRIDE;
virtual void ChangeProxySettings() OVERRIDE;
virtual VolumeControlDelegate* GetVolumeControlDelegate() const OVERRIDE;
virtual void SetVolumeControlDelegate(
diff --git a/ash/system/tray/system_tray_delegate.h b/ash/system/tray/system_tray_delegate.h
index 67d1f8c..fe0863b 100644
--- a/ash/system/tray/system_tray_delegate.h
+++ b/ash/system/tray/system_tray_delegate.h
@@ -300,6 +300,9 @@ class ASH_EXPORT SystemTrayDelegate {
// Returns whether bluetooth is enabled.
virtual bool GetBluetoothEnabled() = 0;
+ // Returns whether the delegate has initiated a bluetooth discovery session.
+ virtual bool GetBluetoothDiscovering() = 0;
+
// Shows UI for changing proxy settings.
virtual void ChangeProxySettings() = 0;