From 1cca163c30823ea0531b9a84ddeb5a136c0927ad Mon Sep 17 00:00:00 2001 From: "jennyz@chromium.org" Date: Tue, 23 Oct 2012 00:31:23 +0000 Subject: Improve bluetooth configuration UI in uber tray bubble when it is disabled. BUG=153801 TBR=sky Review URL: https://codereview.chromium.org/11232047 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163458 0039d316-1c4b-4281-b951-d872f2087c98 --- ash/system/bluetooth/bluetooth_observer.h | 1 + ash/system/bluetooth/tray_bluetooth.cc | 46 +++++++++++++++++++++++++++---- ash/system/bluetooth/tray_bluetooth.h | 1 + 3 files changed, 42 insertions(+), 6 deletions(-) (limited to 'ash/system/bluetooth') 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::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_; -- cgit v1.1