summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--chrome/browser/ui/ash/system_tray_delegate_chromeos.cc12
-rw-r--r--chrome/browser/ui/ash/system_tray_delegate_chromeos.h1
-rw-r--r--chrome/browser/ui/ash/system_tray_delegate_win.cc4
7 files changed, 41 insertions, 24 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;
diff --git a/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc b/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc
index f39af56..7dff150 100644
--- a/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc
+++ b/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc
@@ -692,8 +692,7 @@ void SystemTrayDelegateChromeOS::GetAvailableBluetoothDevices(
}
void SystemTrayDelegateChromeOS::BluetoothStartDiscovering() {
- if (bluetooth_discovery_session_.get() &&
- bluetooth_discovery_session_->IsActive()) {
+ if (GetBluetoothDiscovering()) {
LOG(WARNING) << "Already have active Bluetooth device discovery session.";
return;
}
@@ -707,8 +706,7 @@ void SystemTrayDelegateChromeOS::BluetoothStartDiscovering() {
void SystemTrayDelegateChromeOS::BluetoothStopDiscovering() {
should_run_bluetooth_discovery_ = false;
- if (!bluetooth_discovery_session_.get() ||
- !bluetooth_discovery_session_->IsActive()) {
+ if (!GetBluetoothDiscovering()) {
LOG(WARNING) << "No active Bluetooth device discovery session.";
return;
}
@@ -864,6 +862,11 @@ bool SystemTrayDelegateChromeOS::GetBluetoothEnabled() {
return bluetooth_adapter_->IsPowered();
}
+bool SystemTrayDelegateChromeOS::GetBluetoothDiscovering() {
+ return (bluetooth_discovery_session_.get() &&
+ bluetooth_discovery_session_->IsActive());
+}
+
void SystemTrayDelegateChromeOS::ChangeProxySettings() {
CHECK(GetUserLoginStatus() == ash::user::LOGGED_IN_NONE);
LoginDisplayHostImpl::default_host()->OpenProxySettings();
@@ -1343,6 +1346,7 @@ void SystemTrayDelegateChromeOS::OnStartBluetoothDiscoverySession(
return;
VLOG(1) << "Claiming new Bluetooth device discovery session.";
bluetooth_discovery_session_ = discovery_session.Pass();
+ GetSystemTrayNotifier()->NotifyBluetoothDiscoveringChanged();
}
void SystemTrayDelegateChromeOS::UpdateEnterpriseDomain() {
diff --git a/chrome/browser/ui/ash/system_tray_delegate_chromeos.h b/chrome/browser/ui/ash/system_tray_delegate_chromeos.h
index d39f2a5..f7c01e2 100644
--- a/chrome/browser/ui/ash/system_tray_delegate_chromeos.h
+++ b/chrome/browser/ui/ash/system_tray_delegate_chromeos.h
@@ -120,6 +120,7 @@ class SystemTrayDelegateChromeOS
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 ash::VolumeControlDelegate* GetVolumeControlDelegate() const OVERRIDE;
virtual void SetVolumeControlDelegate(
diff --git a/chrome/browser/ui/ash/system_tray_delegate_win.cc b/chrome/browser/ui/ash/system_tray_delegate_win.cc
index 952d9fd..f85b32e 100644
--- a/chrome/browser/ui/ash/system_tray_delegate_win.cc
+++ b/chrome/browser/ui/ash/system_tray_delegate_win.cc
@@ -251,6 +251,10 @@ class SystemTrayDelegateWin : public ash::SystemTrayDelegate,
return false;
}
+ virtual bool GetBluetoothDiscovering() OVERRIDE {
+ return false;
+ }
+
virtual void ChangeProxySettings() OVERRIDE {
}