summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
Diffstat (limited to 'ash')
-rw-r--r--ash/ash_strings.grd9
-rw-r--r--ash/system/bluetooth/bluetooth_observer.h1
-rw-r--r--ash/system/bluetooth/tray_bluetooth.cc46
-rw-r--r--ash/system/bluetooth/tray_bluetooth.h1
-rw-r--r--ash/system/status_area_widget.cc4
-rw-r--r--ash/system/tray/system_tray_delegate.h3
6 files changed, 58 insertions, 6 deletions
diff --git a/ash/ash_strings.grd b/ash/ash_strings.grd
index 34e853a..970dd59 100644
--- a/ash/ash_strings.grd
+++ b/ash/ash_strings.grd
@@ -325,6 +325,15 @@ Press Ctrl+Alt+Z to cancel.
<message name="IDS_ASH_STATUS_TRAY_BLUETOOTH_ADD_DEVICE" desc="The label used in the tray popup to add a bluetooth device.">
Add device...
</message>
+ <message name="IDS_ASH_STATUS_TRAY_BLUETOOTH_TURNED_OFF" desc="The label used in the tray popup to show bluetooth is turned off.">
+ Bluetooth is turned off.
+ </message>
+ <message name="IDS_ASH_STATUS_TRAY_BLUETOOTH_NO_DEVICE" desc="The label used in the tray popup to show bluetooth is turned off.">
+ No bluetooth devices available
+ </message>
+ <message name="IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCOVERING" desc="The label used in the tray popup to show bluetooth is discovering devices.">
+ Scanning for devices...
+ </message>
<message name="IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING" desc="The label used in the tray to show that the current status is mirroring.">
Mirroring to <ph name="DISPLAY_NAME">$1</ph>
</message>
diff --git a/ash/system/bluetooth/bluetooth_observer.h b/ash/system/bluetooth/bluetooth_observer.h
index 3955b8d..1c1bf4f 100644
--- a/ash/system/bluetooth/bluetooth_observer.h
+++ b/ash/system/bluetooth/bluetooth_observer.h
@@ -12,6 +12,7 @@ class BluetoothObserver {
virtual ~BluetoothObserver() {}
virtual void OnBluetoothRefresh() = 0;
+ virtual void OnBluetoothDiscoveringChanged() = 0;
};
} // namespace ash
diff --git a/ash/system/bluetooth/tray_bluetooth.cc b/ash/system/bluetooth/tray_bluetooth.cc
index d7be2de..9f46fa3 100644
--- a/ash/system/bluetooth/tray_bluetooth.cc
+++ b/ash/system/bluetooth/tray_bluetooth.cc
@@ -115,13 +115,37 @@ class BluetoothDetailedView : public TrayDetailsView,
CreateScrollableList();
for (size_t i = 0; i < list.size(); i++) {
- HoverHighlightView* container = new HoverHighlightView(this);
- container->set_fixed_height(kTrayPopupItemHeight);
- container->AddLabel(list[i].display_name,
- list[i].connected ? gfx::Font::BOLD : gfx::Font::NORMAL);
- scroll_content()->AddChildView(container);
+ HoverHighlightView* container =
+ AddScrollListItem(list[i].display_name,
+ list[i].connected ? gfx::Font::BOLD : gfx::Font::NORMAL);
device_map_[container] = list[i].address;
}
+
+ // Show user Bluetooth state if there is no bluetooth devices in list.
+ if (list.size() == 0) {
+ ash::SystemTrayDelegate* delegate =
+ ash::Shell::GetInstance()->tray_delegate();
+ int message_id;
+ if (delegate->GetBluetoothAvailable()) {
+ if (!delegate->GetBluetoothEnabled())
+ message_id = IDS_ASH_STATUS_TRAY_BLUETOOTH_TURNED_OFF;
+ else if (delegate->IsBluetoothDiscovering())
+ message_id = IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCOVERING;
+ else
+ message_id = IDS_ASH_STATUS_TRAY_BLUETOOTH_NO_DEVICE;
+ AddScrollListItem(l10n_util::GetStringUTF16(message_id),
+ gfx::Font::NORMAL);
+ }
+ }
+ }
+
+ HoverHighlightView* AddScrollListItem(const string16& text,
+ gfx::Font::FontStyle style) {
+ HoverHighlightView* container = new HoverHighlightView(this);
+ container->set_fixed_height(kTrayPopupItemHeight);
+ container->AddLabel(text, style);
+ scroll_content()->AddChildView(container);
+ return container;
}
// Add settings entries.
@@ -139,7 +163,7 @@ class BluetoothDetailedView : public TrayDetailsView,
container->set_fixed_height(kTrayPopupItemHeight);
container->AddLabel(rb.GetLocalizedString(
IDS_ASH_STATUS_TRAY_BLUETOOTH_ADD_DEVICE), gfx::Font::NORMAL);
- container->SetEnabled(delegate->GetBluetoothEnabled());
+ container->SetEnabled(delegate->GetBluetoothAvailable());
AddChildView(container);
add_device_ = container;
}
@@ -151,6 +175,8 @@ class BluetoothDetailedView : public TrayDetailsView,
if (sender == footer()->content()) {
Shell::GetInstance()->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING);
} else if (sender == add_device_) {
+ if (!delegate->GetBluetoothEnabled())
+ delegate->ToggleBluetooth();
delegate->AddBluetoothDevice();
} else {
std::map<views::View*, std::string>::iterator find;
@@ -234,5 +260,13 @@ void TrayBluetooth::OnBluetoothRefresh() {
detailed_->Update(list);
}
+void TrayBluetooth::OnBluetoothDiscoveringChanged() {
+ if (!detailed_)
+ return;
+ BluetoothDeviceList list;
+ Shell::GetInstance()->tray_delegate()->GetAvailableBluetoothDevices(&list);
+ detailed_->Update(list);
+}
+
} // namespace internal
} // namespace ash
diff --git a/ash/system/bluetooth/tray_bluetooth.h b/ash/system/bluetooth/tray_bluetooth.h
index 469e54a..2ae655b 100644
--- a/ash/system/bluetooth/tray_bluetooth.h
+++ b/ash/system/bluetooth/tray_bluetooth.h
@@ -34,6 +34,7 @@ class TrayBluetooth : public SystemTrayItem,
// Overridden from BluetoothObserver.
virtual void OnBluetoothRefresh() OVERRIDE;
+ virtual void OnBluetoothDiscoveringChanged() OVERRIDE;
tray::BluetoothDefaultView* default_;
tray::BluetoothDetailedView* detailed_;
diff --git a/ash/system/status_area_widget.cc b/ash/system/status_area_widget.cc
index c3b701c..515488c 100644
--- a/ash/system/status_area_widget.cc
+++ b/ash/system/status_area_widget.cc
@@ -210,6 +210,10 @@ class DummySystemTrayDelegate : public SystemTrayDelegate {
bluetooth_enabled_ = !bluetooth_enabled_;
}
+ virtual bool IsBluetoothDiscovering() OVERRIDE {
+ return false;
+ }
+
virtual void ShowOtherWifi() OVERRIDE {
}
diff --git a/ash/system/tray/system_tray_delegate.h b/ash/system/tray/system_tray_delegate.h
index 4beabf8..c5922c4 100644
--- a/ash/system/tray/system_tray_delegate.h
+++ b/ash/system/tray/system_tray_delegate.h
@@ -167,6 +167,9 @@ class SystemTrayDelegate {
// Toggles connection to a specific bluetooth device.
virtual void ToggleBluetoothConnection(const std::string& address) = 0;
+ // Returns true if bluetooth adapter is discovering bluetooth devices.
+ virtual bool IsBluetoothDiscovering() = 0;
+
// Returns the currently selected IME.
virtual void GetCurrentIME(IMEInfo* info) = 0;