Commit d4e124ec authored by Giovanni Ortuño Urquidi's avatar Giovanni Ortuño Urquidi Committed by Commit Bot

bluetooth: Delete deprecated TrayBluetooth code

Patch to remove the no longer used TrayBluetooth code.

Bug: 898419
Change-Id: I3f2393dc562a91b42345d107f6faf3292124d232
Reviewed-on: https://chromium-review.googlesource.com/c/1312137Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Commit-Queue: Giovanni Ortuño Urquidi <ortuno@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604854}
parent d1fb11bd
...@@ -661,8 +661,6 @@ component("ash") { ...@@ -661,8 +661,6 @@ component("ash") {
"system/bluetooth/bluetooth_observer.h", "system/bluetooth/bluetooth_observer.h",
"system/bluetooth/bluetooth_power_controller.cc", "system/bluetooth/bluetooth_power_controller.cc",
"system/bluetooth/bluetooth_power_controller.h", "system/bluetooth/bluetooth_power_controller.h",
"system/bluetooth/tray_bluetooth.cc",
"system/bluetooth/tray_bluetooth.h",
"system/bluetooth/tray_bluetooth_helper.cc", "system/bluetooth/tray_bluetooth_helper.cc",
"system/bluetooth/tray_bluetooth_helper.h", "system/bluetooth/tray_bluetooth_helper.h",
"system/bluetooth/tray_bluetooth_helper_experimental.cc", "system/bluetooth/tray_bluetooth_helper_experimental.cc",
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/system/bluetooth/tray_bluetooth.h"
#include <map>
#include <memory>
#include <set>
#include <string>
#include "ash/metrics/user_metrics_recorder.h"
#include "ash/public/cpp/ash_view_ids.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/session/session_controller.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/system/bluetooth/bluetooth_detailed_view.h"
#include "ash/system/bluetooth/tray_bluetooth_helper.h"
#include "ash/system/tray/system_tray.h"
#include "ash/system/tray/system_tray_item_detailed_view_delegate.h"
#include "ash/system/tray/system_tray_notifier.h"
#include "ash/system/tray/tray_constants.h"
#include "ash/system/tray/tray_detailed_view.h"
#include "ash/system/tray/tray_item_more.h"
#include "ash/system/tray/tray_popup_item_style.h"
#include "ash/system/tray/tri_view.h"
#include "device/bluetooth/bluetooth_common.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/vector_icon_types.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/progress_bar.h"
#include "ui/views/controls/separator.h"
using device::mojom::BluetoothSystem;
namespace ash {
namespace tray {
class BluetoothDefaultView : public TrayItemMore {
public:
explicit BluetoothDefaultView(SystemTrayItem* owner) : TrayItemMore(owner) {
set_id(VIEW_ID_BLUETOOTH_DEFAULT_VIEW);
}
~BluetoothDefaultView() override = default;
void Update() {
TrayBluetoothHelper* helper = Shell::Get()->tray_bluetooth_helper();
bool powered_on = true;
switch (helper->GetBluetoothState()) {
case BluetoothSystem::State::kUnsupported:
case BluetoothSystem::State::kUnavailable:
SetVisible(false);
break;
case BluetoothSystem::State::kPoweredOff:
powered_on = false;
FALLTHROUGH;
case BluetoothSystem::State::kTransitioning:
case BluetoothSystem::State::kPoweredOn:
const base::string16 label = l10n_util::GetStringUTF16(
powered_on ? IDS_ASH_STATUS_TRAY_BLUETOOTH_ENABLED
: IDS_ASH_STATUS_TRAY_BLUETOOTH_DISABLED);
SetLabel(label);
SetAccessibleName(label);
SetVisible(true);
break;
}
UpdateStyle();
}
protected:
// TrayItemMore:
std::unique_ptr<TrayPopupItemStyle> HandleCreateStyle() const override {
TrayBluetoothHelper* helper = Shell::Get()->tray_bluetooth_helper();
std::unique_ptr<TrayPopupItemStyle> style =
TrayItemMore::HandleCreateStyle();
TrayPopupItemStyle::ColorStyle color_style;
switch (helper->GetBluetoothState()) {
case BluetoothSystem::State::kUnsupported:
case BluetoothSystem::State::kUnavailable:
color_style = TrayPopupItemStyle::ColorStyle::INACTIVE;
break;
case BluetoothSystem::State::kPoweredOff:
case BluetoothSystem::State::kTransitioning:
color_style = TrayPopupItemStyle::ColorStyle::DISABLED;
break;
case BluetoothSystem::State::kPoweredOn:
color_style = TrayPopupItemStyle::ColorStyle::ACTIVE;
break;
}
style->set_color_style(color_style);
return style;
}
void UpdateStyle() override {
TrayItemMore::UpdateStyle();
std::unique_ptr<TrayPopupItemStyle> style = CreateStyle();
SetImage(gfx::CreateVectorIcon(GetCurrentIcon(), style->GetIconColor()));
}
private:
const gfx::VectorIcon& GetCurrentIcon() {
TrayBluetoothHelper* helper = Shell::Get()->tray_bluetooth_helper();
if (helper->GetBluetoothState() != BluetoothSystem::State::kPoweredOn)
return kSystemMenuBluetoothDisabledIcon;
bool has_connected_device = false;
BluetoothDeviceList list = helper->GetAvailableBluetoothDevices();
for (const auto& device : list) {
if (device.connected) {
has_connected_device = true;
break;
}
}
return has_connected_device ? kSystemMenuBluetoothConnectedIcon
: kSystemMenuBluetoothIcon;
}
DISALLOW_COPY_AND_ASSIGN(BluetoothDefaultView);
};
} // namespace tray
TrayBluetooth::TrayBluetooth(SystemTray* system_tray)
: SystemTrayItem(system_tray, SystemTrayItemUmaType::UMA_BLUETOOTH),
default_(nullptr),
detailed_(nullptr),
detailed_view_delegate_(
std::make_unique<SystemTrayItemDetailedViewDelegate>(this)) {
Shell::Get()->system_tray_notifier()->AddBluetoothObserver(this);
}
TrayBluetooth::~TrayBluetooth() {
Shell::Get()->system_tray_notifier()->RemoveBluetoothObserver(this);
}
views::View* TrayBluetooth::CreateDefaultView(LoginStatus status) {
CHECK(default_ == nullptr);
SessionController* session_controller = Shell::Get()->session_controller();
default_ = new tray::BluetoothDefaultView(this);
if (!session_controller->IsActiveUserSessionStarted()) {
// Bluetooth power setting is always mutable in login screen before any
// user logs in. The changes will affect local state preferences.
default_->SetEnabled(true);
} else {
// The bluetooth setting should be mutable only if:
// * the active user is the primary user, and
// * the session is not in lock screen
// The changes will affect the primary user's preferences.
default_->SetEnabled(session_controller->IsUserPrimary() &&
status != LoginStatus::LOCKED);
}
default_->Update();
return default_;
}
views::View* TrayBluetooth::CreateDetailedView(LoginStatus status) {
if (!Shell::Get()->tray_bluetooth_helper()->IsBluetoothStateAvailable())
return nullptr;
Shell::Get()->metrics()->RecordUserMetricsAction(
UMA_STATUS_AREA_DETAILED_BLUETOOTH_VIEW);
CHECK(detailed_ == nullptr);
detailed_ =
new tray::BluetoothDetailedView(detailed_view_delegate_.get(), status);
detailed_->Update();
return detailed_;
}
void TrayBluetooth::OnDefaultViewDestroyed() {
default_ = nullptr;
}
void TrayBluetooth::OnDetailedViewDestroyed() {
detailed_ = nullptr;
}
void TrayBluetooth::UpdateAfterLoginStatusChange(LoginStatus status) {}
void TrayBluetooth::OnBluetoothRefresh() {
if (default_)
default_->Update();
else if (detailed_)
detailed_->Update();
}
void TrayBluetooth::OnBluetoothDiscoveringChanged() {
if (!detailed_)
return;
detailed_->Update();
}
} // namespace ash
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_SYSTEM_BLUETOOTH_TRAY_BLUETOOTH_H_
#define ASH_SYSTEM_BLUETOOTH_TRAY_BLUETOOTH_H_
#include "ash/system/bluetooth/bluetooth_observer.h"
#include "ash/system/tray/system_tray_item.h"
#include "base/macros.h"
namespace ash {
namespace tray {
class BluetoothDefaultView;
class BluetoothDetailedView;
}
class DetailedViewDelegate;
// Bluetooth section in the main system tray menu. Contains:
// * Toggle to turn Bluetooth on and off
// * Gear icon that takes the user to the web ui settings
// * List of paired devices
// * List of unpaired devices
class TrayBluetooth : public SystemTrayItem, public BluetoothObserver {
public:
explicit TrayBluetooth(SystemTray* system_tray);
~TrayBluetooth() override;
private:
// Overridden from SystemTrayItem.
views::View* CreateDefaultView(LoginStatus status) override;
views::View* CreateDetailedView(LoginStatus status) override;
void OnDefaultViewDestroyed() override;
void OnDetailedViewDestroyed() override;
void UpdateAfterLoginStatusChange(LoginStatus status) override;
// Overridden from BluetoothObserver.
void OnBluetoothRefresh() override;
void OnBluetoothDiscoveringChanged() override;
tray::BluetoothDefaultView* default_;
tray::BluetoothDetailedView* detailed_;
const std::unique_ptr<DetailedViewDelegate> detailed_view_delegate_;
DISALLOW_COPY_AND_ASSIGN(TrayBluetooth);
};
} // namespace ash
#endif // ASH_SYSTEM_BLUETOOTH_TRAY_BLUETOOTH_H_
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "ash/strings/grit/ash_strings.h" #include "ash/strings/grit/ash_strings.h"
#include "ash/system/accessibility/tray_accessibility.h" #include "ash/system/accessibility/tray_accessibility.h"
#include "ash/system/audio/tray_audio.h" #include "ash/system/audio/tray_audio.h"
#include "ash/system/bluetooth/tray_bluetooth.h"
#include "ash/system/brightness/tray_brightness.h" #include "ash/system/brightness/tray_brightness.h"
#include "ash/system/cast/tray_cast.h" #include "ash/system/cast/tray_cast.h"
#include "ash/system/date/tray_system_info.h" #include "ash/system/date/tray_system_info.h"
...@@ -221,8 +220,6 @@ void SystemTray::CreateItems() { ...@@ -221,8 +220,6 @@ void SystemTray::CreateItems() {
AddTrayItem(base::WrapUnique(tray_network_)); AddTrayItem(base::WrapUnique(tray_network_));
tray_vpn_ = new TrayVPN(this); tray_vpn_ = new TrayVPN(this);
AddTrayItem(base::WrapUnique(tray_vpn_)); AddTrayItem(base::WrapUnique(tray_vpn_));
tray_bluetooth_ = new TrayBluetooth(this);
AddTrayItem(base::WrapUnique(tray_bluetooth_));
tray_cast_ = new TrayCast(this); tray_cast_ = new TrayCast(this);
AddTrayItem(base::WrapUnique(tray_cast_)); AddTrayItem(base::WrapUnique(tray_cast_));
AddTrayItem(std::make_unique<ScreenCaptureTrayItem>(this)); AddTrayItem(std::make_unique<ScreenCaptureTrayItem>(this));
...@@ -360,10 +357,6 @@ TrayAudio* SystemTray::GetTrayAudio() const { ...@@ -360,10 +357,6 @@ TrayAudio* SystemTray::GetTrayAudio() const {
return tray_audio_; return tray_audio_;
} }
TrayBluetooth* SystemTray::GetTrayBluetooth() const {
return tray_bluetooth_;
}
TrayCast* SystemTray::GetTrayCast() const { TrayCast* SystemTray::GetTrayCast() const {
return tray_cast_; return tray_cast_;
} }
......
...@@ -28,7 +28,6 @@ class SystemBubbleWrapper; ...@@ -28,7 +28,6 @@ class SystemBubbleWrapper;
class SystemTrayItem; class SystemTrayItem;
class TrayAccessibility; class TrayAccessibility;
class TrayAudio; class TrayAudio;
class TrayBluetooth;
class TrayCapsLock; class TrayCapsLock;
class TrayCast; class TrayCast;
class TrayEnterprise; class TrayEnterprise;
...@@ -128,8 +127,6 @@ class ASH_EXPORT SystemTray : public TrayBackgroundView, ...@@ -128,8 +127,6 @@ class ASH_EXPORT SystemTray : public TrayBackgroundView,
// Returns TrayAudio object if present or null otherwise. // Returns TrayAudio object if present or null otherwise.
TrayAudio* GetTrayAudio() const; TrayAudio* GetTrayAudio() const;
// Returns TrayBluetooth object if present or null otherwise.
TrayBluetooth* GetTrayBluetooth() const;
// Returns TrayCast object if present or null otherwise. // Returns TrayCast object if present or null otherwise.
TrayCast* GetTrayCast() const; TrayCast* GetTrayCast() const;
// Returns TrayAccessibility object if present or null otherwise. // Returns TrayAccessibility object if present or null otherwise.
...@@ -231,7 +228,6 @@ class ASH_EXPORT SystemTray : public TrayBackgroundView, ...@@ -231,7 +228,6 @@ class ASH_EXPORT SystemTray : public TrayBackgroundView,
// These objects are not owned by this class. // These objects are not owned by this class.
TrayAccessibility* tray_accessibility_ = nullptr; TrayAccessibility* tray_accessibility_ = nullptr;
TrayAudio* tray_audio_ = nullptr; TrayAudio* tray_audio_ = nullptr;
TrayBluetooth* tray_bluetooth_ = nullptr;
TrayCapsLock* tray_caps_lock_ = nullptr; TrayCapsLock* tray_caps_lock_ = nullptr;
TrayCast* tray_cast_ = nullptr; TrayCast* tray_cast_ = nullptr;
TrayEnterprise* tray_enterprise_ = nullptr; TrayEnterprise* tray_enterprise_ = nullptr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment