| Index: ash/common/system/chromeos/bluetooth/tray_bluetooth.cc
|
| diff --git a/ash/common/system/chromeos/bluetooth/tray_bluetooth.cc b/ash/common/system/chromeos/bluetooth/tray_bluetooth.cc
|
| index 559b56328120e9d41f916e699ad701fe62128960..80a3cbc0d90f16c0049e4867636536e62a3cd3db 100644
|
| --- a/ash/common/system/chromeos/bluetooth/tray_bluetooth.cc
|
| +++ b/ash/common/system/chromeos/bluetooth/tray_bluetooth.cc
|
| @@ -4,7 +4,6 @@
|
|
|
| #include "ash/common/system/chromeos/bluetooth/tray_bluetooth.h"
|
|
|
| -#include "ash/common/material_design/material_design_controller.h"
|
| #include "ash/common/session/session_state_delegate.h"
|
| #include "ash/common/system/tray/hover_highlight_view.h"
|
| #include "ash/common/system/tray/system_tray.h"
|
| @@ -14,7 +13,6 @@
|
| #include "ash/common/system/tray/tray_constants.h"
|
| #include "ash/common/system/tray/tray_details_view.h"
|
| #include "ash/common/system/tray/tray_item_more.h"
|
| -#include "ash/common/system/tray/tray_popup_header_button.h"
|
| #include "ash/common/system/tray/tray_popup_item_style.h"
|
| #include "ash/common/system/tray/tray_popup_utils.h"
|
| #include "ash/common/system/tray/tri_view.h"
|
| @@ -41,10 +39,6 @@ namespace ash {
|
| namespace tray {
|
| namespace {
|
|
|
| -bool UseMd() {
|
| - return MaterialDesignController::IsSystemTrayMenuMaterial();
|
| -}
|
| -
|
| // 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|.
|
| @@ -119,14 +113,7 @@ const int kDisabledPanelLabelBaselineY = 20;
|
| class BluetoothDefaultView : public TrayItemMore {
|
| public:
|
| BluetoothDefaultView(SystemTrayItem* owner, bool show_more)
|
| - : TrayItemMore(owner, show_more) {
|
| - if (!UseMd()) {
|
| - // The icon doesn't change in non-md.
|
| - ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
|
| - SetImage(
|
| - *bundle.GetImageNamed(IDR_AURA_UBER_TRAY_BLUETOOTH).ToImageSkia());
|
| - }
|
| - }
|
| + : TrayItemMore(owner, show_more) {}
|
|
|
| ~BluetoothDefaultView() override {}
|
|
|
| @@ -164,10 +151,6 @@ class BluetoothDefaultView : public TrayItemMore {
|
|
|
| void UpdateStyle() override {
|
| TrayItemMore::UpdateStyle();
|
| -
|
| - if (!UseMd())
|
| - return;
|
| -
|
| std::unique_ptr<TrayPopupItemStyle> style = CreateStyle();
|
| SetImage(gfx::CreateVectorIcon(GetCurrentIcon(), style->GetIconColor()));
|
| }
|
| @@ -199,10 +182,6 @@ class BluetoothDetailedView : public TrayDetailsView {
|
| BluetoothDetailedView(SystemTrayItem* owner, LoginStatus login)
|
| : TrayDetailsView(owner),
|
| login_(login),
|
| - manage_devices_(nullptr),
|
| - throbber_(nullptr),
|
| - toggle_bluetooth_(nullptr),
|
| - enable_bluetooth_(nullptr),
|
| toggle_(nullptr),
|
| settings_(nullptr),
|
| disabled_panel_(nullptr) {
|
| @@ -227,7 +206,6 @@ class BluetoothDetailedView : public TrayDetailsView {
|
| private:
|
| void CreateItems() {
|
| CreateScrollableList();
|
| - AppendSettingsEntries();
|
| CreateTitleRow(IDS_ASH_STATUS_TRAY_BLUETOOTH);
|
| }
|
|
|
| @@ -260,10 +238,6 @@ class BluetoothDetailedView : public TrayDetailsView {
|
| WmShell::Get()->system_tray_delegate()->GetAvailableBluetoothDevices(&list);
|
| for (size_t i = 0; i < list.size(); ++i) {
|
| if (list[i].connecting) {
|
| - if (!UseMd()) {
|
| - list[i].display_name = l10n_util::GetStringFUTF16(
|
| - IDS_ASH_STATUS_TRAY_BLUETOOTH_CONNECTING, list[i].display_name);
|
| - }
|
| new_connecting_devices.insert(list[i].address);
|
| UpdateBluetoothDeviceListHelper(&connecting_devices_, list[i]);
|
| } else if (list[i].connected && list[i].paired) {
|
| @@ -294,33 +268,23 @@ class BluetoothDetailedView : public TrayDetailsView {
|
| WmShell::Get()->system_tray_delegate()->GetBluetoothEnabled();
|
| if (toggle_)
|
| toggle_->SetIsOn(is_bluetooth_enabled, false);
|
| - else if (toggle_bluetooth_)
|
| - toggle_bluetooth_->SetToggled(!is_bluetooth_enabled);
|
| }
|
|
|
| void UpdateDeviceScrollList() {
|
| device_map_.clear();
|
| scroll_content()->RemoveAllChildViews(true);
|
| - enable_bluetooth_ = nullptr;
|
|
|
| SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate();
|
| bool bluetooth_enabled = delegate->GetBluetoothEnabled();
|
| bool bluetooth_available = delegate->GetBluetoothAvailable();
|
| - if (bluetooth_available && !bluetooth_enabled && toggle_bluetooth_) {
|
| - enable_bluetooth_ = AddScrollListItem(
|
| - l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ENABLE_BLUETOOTH),
|
| - false /* highlight */, false /* checked */, true /* enabled */);
|
| - }
|
|
|
| // If Bluetooth is disabled, show a panel which only indicates that it is
|
| // disabled, instead of the scroller with Bluetooth devices.
|
| - if (UseMd()) {
|
| - if (bluetooth_enabled) {
|
| - HideDisabledPanel();
|
| - } else {
|
| - ShowDisabledPanel();
|
| - return;
|
| - }
|
| + if (bluetooth_enabled) {
|
| + HideDisabledPanel();
|
| + } else {
|
| + ShowDisabledPanel();
|
| + return;
|
| }
|
|
|
| // Add paired devices (and their section header in MD) in the list.
|
| @@ -328,8 +292,7 @@ class BluetoothDetailedView : public TrayDetailsView {
|
| connecting_devices_.size() +
|
| paired_not_connected_devices_.size();
|
| if (num_paired_devices > 0) {
|
| - if (UseMd())
|
| - AddSubHeader(IDS_ASH_STATUS_TRAY_BLUETOOTH_PAIRED_DEVICES);
|
| + AddSubHeader(IDS_ASH_STATUS_TRAY_BLUETOOTH_PAIRED_DEVICES);
|
| AppendSameTypeDevicesToScrollList(connected_devices_, true, true,
|
| bluetooth_enabled);
|
| AppendSameTypeDevicesToScrollList(connecting_devices_, true, false,
|
| @@ -340,12 +303,8 @@ class BluetoothDetailedView : public TrayDetailsView {
|
|
|
| // Add paired devices (and their section header in MD) in the list.
|
| if (discovered_not_paired_devices_.size() > 0) {
|
| - if (UseMd()) {
|
| - if (num_paired_devices > 0)
|
| - AddSubHeader(IDS_ASH_STATUS_TRAY_BLUETOOTH_UNPAIRED_DEVICES);
|
| - } else {
|
| - AddScrollSeparator();
|
| - }
|
| + if (num_paired_devices > 0)
|
| + AddSubHeader(IDS_ASH_STATUS_TRAY_BLUETOOTH_UNPAIRED_DEVICES);
|
| AppendSameTypeDevicesToScrollList(discovered_not_paired_devices_, false,
|
| false, bluetooth_enabled);
|
| }
|
| @@ -353,10 +312,11 @@ class BluetoothDetailedView : public TrayDetailsView {
|
| // Show user Bluetooth state if there is no bluetooth devices in list.
|
| if (device_map_.size() == 0) {
|
| if (bluetooth_available && bluetooth_enabled) {
|
| - AddScrollListItem(l10n_util::GetStringUTF16(
|
| - IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCOVERING),
|
| - false /* highlight */, false /* checked */,
|
| - true /* enabled */);
|
| + HoverHighlightView* container = new HoverHighlightView(this);
|
| + container->AddLabel(l10n_util::GetStringUTF16(
|
| + IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCOVERING),
|
| + gfx::ALIGN_LEFT, false);
|
| + scroll_content()->AddChildView(container);
|
| }
|
| }
|
|
|
| @@ -369,45 +329,24 @@ class BluetoothDetailedView : public TrayDetailsView {
|
| bool enabled) {
|
| for (size_t i = 0; i < list.size(); ++i) {
|
| HoverHighlightView* container = nullptr;
|
| - if (UseMd()) {
|
| - gfx::ImageSkia icon_image = CreateVectorIcon(
|
| - GetBluetoothDeviceIcon(list[i].device_type, list[i].connected),
|
| - kMenuIconColor);
|
| - container = AddScrollListItemMd(list[i].display_name, icon_image,
|
| - list[i].connected, list[i].connecting);
|
| - } else {
|
| - container = AddScrollListItem(list[i].display_name, highlight, checked,
|
| - enabled);
|
| - }
|
| + gfx::ImageSkia icon_image = CreateVectorIcon(
|
| + GetBluetoothDeviceIcon(list[i].device_type, list[i].connected),
|
| + kMenuIconColor);
|
| + container = AddScrollListItem(list[i].display_name, icon_image,
|
| + list[i].connected, list[i].connecting);
|
| device_map_[container] = list[i].address;
|
| }
|
| }
|
|
|
| - // TODO(fukino): Remove this code when material design is enabled by default,
|
| - // since AddScrollListItem should be used only in the old design.
|
| - // See crbug.com/614453".
|
| HoverHighlightView* AddScrollListItem(const base::string16& text,
|
| - bool highlight,
|
| - bool checked,
|
| - bool enabled) {
|
| - HoverHighlightView* container = new HoverHighlightView(this);
|
| - views::Label* label =
|
| - container->AddCheckableLabel(text, highlight, checked);
|
| - label->SetEnabled(enabled);
|
| - scroll_content()->AddChildView(container);
|
| - return container;
|
| - }
|
| -
|
| - HoverHighlightView* AddScrollListItemMd(const base::string16& text,
|
| - const gfx::ImageSkia& image,
|
| - bool connected,
|
| - bool connecting) {
|
| - DCHECK(UseMd());
|
| + const gfx::ImageSkia& image,
|
| + bool connected,
|
| + bool connecting) {
|
| HoverHighlightView* container = new HoverHighlightView(this);
|
| if (connected) {
|
| - SetupConnectedItemMd(container, text, image);
|
| + SetupConnectedItem(container, text, image);
|
| } else if (connecting) {
|
| - SetupConnectingItemMd(container, text, image);
|
| + SetupConnectingItem(container, text, image);
|
| } else {
|
| container->AddIconAndLabel(image, text, false);
|
| }
|
| @@ -428,9 +367,9 @@ class BluetoothDetailedView : public TrayDetailsView {
|
| scroll_content()->AddChildView(header);
|
| }
|
|
|
| - void SetupConnectedItemMd(HoverHighlightView* container,
|
| - const base::string16& text,
|
| - const gfx::ImageSkia& image) {
|
| + void SetupConnectedItem(HoverHighlightView* container,
|
| + const base::string16& text,
|
| + const gfx::ImageSkia& image) {
|
| container->AddIconAndLabels(
|
| image, text, l10n_util::GetStringUTF16(
|
| IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CONNECTED));
|
| @@ -439,9 +378,9 @@ class BluetoothDetailedView : public TrayDetailsView {
|
| style.SetupLabel(container->sub_text_label());
|
| }
|
|
|
| - void SetupConnectingItemMd(HoverHighlightView* container,
|
| - const base::string16& text,
|
| - const gfx::ImageSkia& image) {
|
| + void SetupConnectingItem(HoverHighlightView* container,
|
| + const base::string16& text,
|
| + const gfx::ImageSkia& image) {
|
| container->AddIconAndLabels(
|
| image, text, l10n_util::GetStringUTF16(
|
| IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CONNECTING));
|
| @@ -450,32 +389,6 @@ class BluetoothDetailedView : public TrayDetailsView {
|
| container->AddRightView(throbber);
|
| }
|
|
|
| - // Add settings entries.
|
| - void AppendSettingsEntries() {
|
| - // Do not append the bottom button row in material design; this is replaced
|
| - // by the settings button in the header row.
|
| - if (UseMd())
|
| - return;
|
| -
|
| - if (!WmShell::Get()->system_tray_delegate()->ShouldShowSettings())
|
| - return;
|
| -
|
| - // Add bluetooth device requires a browser window, hide it for non logged in
|
| - // user.
|
| - if (!TrayPopupUtils::CanOpenWebUISettings(login_))
|
| - return;
|
| -
|
| - SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate();
|
| - ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
|
| - HoverHighlightView* container = new HoverHighlightView(this);
|
| - container->AddLabel(
|
| - rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_BLUETOOTH_MANAGE_DEVICES),
|
| - gfx::ALIGN_LEFT, false /* highlight */);
|
| - container->SetEnabled(delegate->GetBluetoothAvailable());
|
| - AddChildView(container);
|
| - manage_devices_ = container;
|
| - }
|
| -
|
| // Returns true if the device with |device_id| is found in |device_list|,
|
| // and the display_name of the device will be returned in |display_name| if
|
| // it's not NULL.
|
| @@ -506,17 +419,11 @@ class BluetoothDetailedView : public TrayDetailsView {
|
| item_container->RemoveAllChildViews(true);
|
| HoverHighlightView* container =
|
| static_cast<HoverHighlightView*>(item_container);
|
| - if (UseMd()) {
|
| - TrayPopupItemStyle style(
|
| - TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL);
|
| - gfx::ImageSkia icon_image = CreateVectorIcon(
|
| - GetBluetoothDeviceIcon(device_type, false), style.GetIconColor());
|
| - SetupConnectingItemMd(container, display_name, icon_image);
|
| - } else {
|
| - display_name = l10n_util::GetStringFUTF16(
|
| - IDS_ASH_STATUS_TRAY_BLUETOOTH_CONNECTING, display_name);
|
| - container->AddCheckableLabel(display_name, true /* highlight */, false);
|
| - }
|
| + TrayPopupItemStyle style(
|
| + TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL);
|
| + gfx::ImageSkia icon_image = CreateVectorIcon(
|
| + GetBluetoothDeviceIcon(device_type, false), style.GetIconColor());
|
| + SetupConnectingItem(container, display_name, icon_image);
|
| scroll_content()->SizeToPreferredSize();
|
| scroller()->Layout();
|
| }
|
| @@ -524,20 +431,7 @@ class BluetoothDetailedView : public TrayDetailsView {
|
|
|
| // TrayDetailsView:
|
| void HandleViewClicked(views::View* view) override {
|
| - if (view == manage_devices_) {
|
| - ShowSettings();
|
| - return;
|
| - }
|
| -
|
| SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate();
|
| - if (view == enable_bluetooth_) {
|
| - WmShell::Get()->RecordUserMetricsAction(
|
| - delegate->GetBluetoothEnabled() ? UMA_STATUS_AREA_BLUETOOTH_DISABLED
|
| - : UMA_STATUS_AREA_BLUETOOTH_ENABLED);
|
| - delegate->ToggleBluetooth();
|
| - return;
|
| - }
|
| -
|
| if (!delegate->GetBluetoothEnabled())
|
| return;
|
|
|
| @@ -556,62 +450,29 @@ class BluetoothDetailedView : public TrayDetailsView {
|
|
|
| void HandleButtonPressed(views::Button* sender,
|
| const ui::Event& event) override {
|
| - if (UseMd()) {
|
| - if (sender == toggle_)
|
| - WmShell::Get()->system_tray_delegate()->ToggleBluetooth();
|
| - else if (sender == settings_)
|
| - ShowSettings();
|
| - else
|
| - NOTREACHED();
|
| - return;
|
| - }
|
| + if (sender == toggle_)
|
| + WmShell::Get()->system_tray_delegate()->ToggleBluetooth();
|
| + else if (sender == settings_)
|
| + ShowSettings();
|
|
|
| - SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate();
|
| - if (sender == toggle_bluetooth_)
|
| - delegate->ToggleBluetooth();
|
| - else
|
| - NOTREACHED();
|
| + NOTREACHED();
|
| }
|
|
|
| void CreateExtraTitleRowButtons() override {
|
| if (login_ == LoginStatus::LOCKED)
|
| return;
|
|
|
| - if (UseMd()) {
|
| - DCHECK(!toggle_);
|
| - DCHECK(!settings_);
|
| -
|
| - tri_view()->SetContainerVisible(TriView::Container::END, true);
|
| + DCHECK(!toggle_);
|
| + DCHECK(!settings_);
|
|
|
| - toggle_ = TrayPopupUtils::CreateToggleButton(
|
| - this, IDS_ASH_STATUS_TRAY_BLUETOOTH);
|
| - tri_view()->AddView(TriView::Container::END, toggle_);
|
| -
|
| - settings_ = CreateSettingsButton(login_);
|
| - tri_view()->AddView(TriView::Container::END, settings_);
|
| - return;
|
| - }
|
| + tri_view()->SetContainerVisible(TriView::Container::END, true);
|
|
|
| - throbber_ = new ThrobberView;
|
| - throbber_->SetTooltipText(
|
| - l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCOVERING));
|
| - title_row()->AddViewToRowNonMd(throbber_, false);
|
| + toggle_ =
|
| + TrayPopupUtils::CreateToggleButton(this, IDS_ASH_STATUS_TRAY_BLUETOOTH);
|
| + tri_view()->AddView(TriView::Container::END, toggle_);
|
|
|
| - // Do not allow toggling bluetooth in the lock screen.
|
| - SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate();
|
| - toggle_bluetooth_ =
|
| - new TrayPopupHeaderButton(this, IDR_AURA_UBER_TRAY_BLUETOOTH_ENABLED,
|
| - IDR_AURA_UBER_TRAY_BLUETOOTH_DISABLED,
|
| - IDR_AURA_UBER_TRAY_BLUETOOTH_ENABLED_HOVER,
|
| - IDR_AURA_UBER_TRAY_BLUETOOTH_DISABLED_HOVER,
|
| - IDS_ASH_STATUS_TRAY_BLUETOOTH);
|
| - toggle_bluetooth_->SetToggled(!delegate->GetBluetoothEnabled());
|
| - toggle_bluetooth_->SetTooltipText(
|
| - l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISABLE_BLUETOOTH));
|
| - toggle_bluetooth_->SetToggledTooltipText(
|
| - l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ENABLE_BLUETOOTH));
|
| - toggle_bluetooth_->EnableCanvasFlippingForRTLUI(false);
|
| - title_row()->AddViewToRowNonMd(toggle_bluetooth_, true);
|
| + settings_ = CreateSettingsButton(login_);
|
| + tri_view()->AddView(TriView::Container::END, settings_);
|
| }
|
|
|
| void ShowSettings() {
|
| @@ -622,23 +483,13 @@ class BluetoothDetailedView : public TrayDetailsView {
|
| }
|
|
|
| void ShowLoadingIndicator() {
|
| - if (throbber_) {
|
| - throbber_->Start();
|
| - } else if (UseMd()) {
|
| - // Setting a value of -1 gives progress_bar an infinite-loading behavior.
|
| - ShowProgress(-1, true);
|
| - }
|
| + // Setting a value of -1 gives progress_bar an infinite-loading behavior.
|
| + ShowProgress(-1, true);
|
| }
|
|
|
| - void HideLoadingIndicator() {
|
| - if (throbber_)
|
| - throbber_->Stop();
|
| - else if (UseMd())
|
| - ShowProgress(0, false);
|
| - }
|
| + void HideLoadingIndicator() { ShowProgress(0, false); }
|
|
|
| void ShowDisabledPanel() {
|
| - DCHECK(UseMd());
|
| DCHECK(scroller());
|
| if (!disabled_panel_) {
|
| disabled_panel_ = CreateDisabledPanel();
|
| @@ -654,7 +505,6 @@ class BluetoothDetailedView : public TrayDetailsView {
|
| }
|
|
|
| void HideDisabledPanel() {
|
| - DCHECK(UseMd());
|
| DCHECK(scroller());
|
| if (disabled_panel_)
|
| disabled_panel_->SetVisible(false);
|
| @@ -698,28 +548,14 @@ class BluetoothDetailedView : public TrayDetailsView {
|
|
|
| std::map<views::View*, std::string> device_map_;
|
|
|
| - // Not used in material design.
|
| - views::View* manage_devices_;
|
| -
|
| - // Not used in material design.
|
| - ThrobberView* throbber_;
|
| -
|
| - // Not used in material design.
|
| - TrayPopupHeaderButton* toggle_bluetooth_;
|
| -
|
| - HoverHighlightView* enable_bluetooth_;
|
| BluetoothDeviceList connected_devices_;
|
| BluetoothDeviceList connecting_devices_;
|
| BluetoothDeviceList paired_not_connected_devices_;
|
| BluetoothDeviceList discovered_not_paired_devices_;
|
|
|
| - // The on/off toggle button used in material design.
|
| views::ToggleButton* toggle_;
|
| -
|
| - // Only used in material design.
|
| views::Button* settings_;
|
|
|
| - // Only used in material design.
|
| // The container of the message "Bluetooth is disabled" and an icon. It should
|
| // be shown instead of Bluetooth device list when Bluetooth is disabled.
|
| views::View* disabled_panel_;
|
|
|