Commit bee7bee6 authored by Tim Song's avatar Tim Song Committed by Commit Bot

Ash Tray: Add skeleton for the privacy screen toast UI.

BUG=1040648

Change-Id: Ifb92fcb180c8b6a504cc2d22165b9b7bf96499bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2072821Reviewed-by: default avatarAhmed Mehfooz <amehfooz@chromium.org>
Commit-Queue: Tim Song <tengs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745215}
parent d60403f4
...@@ -957,6 +957,10 @@ component("ash") { ...@@ -957,6 +957,10 @@ component("ash") {
"system/power/video_activity_notifier.h", "system/power/video_activity_notifier.h",
"system/privacy_screen/privacy_screen_feature_pod_controller.cc", "system/privacy_screen/privacy_screen_feature_pod_controller.cc",
"system/privacy_screen/privacy_screen_feature_pod_controller.h", "system/privacy_screen/privacy_screen_feature_pod_controller.h",
"system/privacy_screen/privacy_screen_toast_controller.cc",
"system/privacy_screen/privacy_screen_toast_controller.h",
"system/privacy_screen/privacy_screen_toast_view.cc",
"system/privacy_screen/privacy_screen_toast_view.h",
"system/rotation/rotation_lock_feature_pod_controller.cc", "system/rotation/rotation_lock_feature_pod_controller.cc",
"system/rotation/rotation_lock_feature_pod_controller.h", "system/rotation/rotation_lock_feature_pod_controller.h",
"system/screen_layout_observer.cc", "system/screen_layout_observer.cc",
......
...@@ -12,14 +12,17 @@ ...@@ -12,14 +12,17 @@
#include "ash/strings/grit/ash_strings.h" #include "ash/strings/grit/ash_strings.h"
#include "ash/system/unified/feature_pod_button.h" #include "ash/system/unified/feature_pod_button.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/views/layout/box_layout.h"
namespace ash { namespace ash {
PrivacyScreenFeaturePodController::PrivacyScreenFeaturePodController() = PrivacyScreenFeaturePodController::PrivacyScreenFeaturePodController() {
default; Shell::Get()->privacy_screen_controller()->AddObserver(this);
}
PrivacyScreenFeaturePodController::~PrivacyScreenFeaturePodController() = PrivacyScreenFeaturePodController::~PrivacyScreenFeaturePodController() {
default; Shell::Get()->privacy_screen_controller()->RemoveObserver(this);
}
FeaturePodButton* PrivacyScreenFeaturePodController::CreateButton() { FeaturePodButton* PrivacyScreenFeaturePodController::CreateButton() {
DCHECK(!button_); DCHECK(!button_);
...@@ -55,12 +58,15 @@ void PrivacyScreenFeaturePodController::UpdateButton() { ...@@ -55,12 +58,15 @@ void PrivacyScreenFeaturePodController::UpdateButton() {
if (!is_supported) if (!is_supported)
return; return;
bool is_enabled = privacy_screen_controller->GetEnabled();
button_->SetVectorIcon(kPrivacyScreenIcon); button_->SetVectorIcon(kPrivacyScreenIcon);
button_->SetToggled(is_enabled);
button_->SetLabel( button_->SetLabel(
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_PRIVACY_SCREEN_LABEL)); l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_PRIVACY_SCREEN_LABEL));
base::string16 tooltip_state; base::string16 tooltip_state;
if (privacy_screen_controller->GetEnabled()) { if (is_enabled) {
button_->SetSubLabel(l10n_util::GetStringUTF16( button_->SetSubLabel(l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_PRIVACY_SCREEN_ON_SUBLABEL)); IDS_ASH_STATUS_TRAY_PRIVACY_SCREEN_ON_SUBLABEL));
tooltip_state = l10n_util::GetStringUTF16( tooltip_state = l10n_util::GetStringUTF16(
...@@ -76,4 +82,9 @@ void PrivacyScreenFeaturePodController::UpdateButton() { ...@@ -76,4 +82,9 @@ void PrivacyScreenFeaturePodController::UpdateButton() {
IDS_ASH_STATUS_TRAY_ROTATION_LOCK_TOOLTIP, tooltip_state)); IDS_ASH_STATUS_TRAY_ROTATION_LOCK_TOOLTIP, tooltip_state));
} }
void PrivacyScreenFeaturePodController::OnPrivacyScreenSettingChanged(
bool enabled) {
UpdateButton();
}
} // namespace ash } // namespace ash
...@@ -5,13 +5,16 @@ ...@@ -5,13 +5,16 @@
#ifndef ASH_SYSTEM_PRIVACY_SCREEN_PRIVACY_SCREEN_FEATURE_POD_CONTROLLER_H_ #ifndef ASH_SYSTEM_PRIVACY_SCREEN_PRIVACY_SCREEN_FEATURE_POD_CONTROLLER_H_
#define ASH_SYSTEM_PRIVACY_SCREEN_PRIVACY_SCREEN_FEATURE_POD_CONTROLLER_H_ #define ASH_SYSTEM_PRIVACY_SCREEN_PRIVACY_SCREEN_FEATURE_POD_CONTROLLER_H_
#include "ash/display/privacy_screen_controller.h"
#include "ash/system/unified/feature_pod_controller_base.h" #include "ash/system/unified/feature_pod_controller_base.h"
#include "base/macros.h" #include "base/macros.h"
namespace ash { namespace ash {
// Controller of a feature pod button for toggling the built-in privacy screen. // Controller of a feature pod button for toggling the built-in privacy screen.
class PrivacyScreenFeaturePodController : public FeaturePodControllerBase { class PrivacyScreenFeaturePodController
: public FeaturePodControllerBase,
public PrivacyScreenController::Observer {
public: public:
PrivacyScreenFeaturePodController(); PrivacyScreenFeaturePodController();
~PrivacyScreenFeaturePodController() override; ~PrivacyScreenFeaturePodController() override;
...@@ -31,6 +34,9 @@ class PrivacyScreenFeaturePodController : public FeaturePodControllerBase { ...@@ -31,6 +34,9 @@ class PrivacyScreenFeaturePodController : public FeaturePodControllerBase {
void TogglePrivacyScreen(); void TogglePrivacyScreen();
void UpdateButton(); void UpdateButton();
// PrivacyScreenController::Observer:
void OnPrivacyScreenSettingChanged(bool enabled) override;
// Unowned. // Unowned.
FeaturePodButton* button_ = nullptr; FeaturePodButton* button_ = nullptr;
}; };
......
// Copyright 2020 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/privacy_screen/privacy_screen_toast_controller.h"
#include "ash/shelf/shelf.h"
#include "ash/shell.h"
#include "ash/system/status_area_widget.h"
#include "ash/system/tray/tray_constants.h"
#include "ash/system/tray/tray_utils.h"
#include "ash/system/unified/unified_system_tray.h"
#include "ash/system/unified/unified_system_tray_bubble.h"
#include "ash/system/unified/unified_system_tray_view.h"
namespace ash {
PrivacyScreenToastController::PrivacyScreenToastController(
UnifiedSystemTray* tray)
: tray_(tray) {
Shell::Get()->privacy_screen_controller()->AddObserver(this);
}
PrivacyScreenToastController::~PrivacyScreenToastController() {
close_timer_.Stop();
if (bubble_widget_)
bubble_widget_->CloseNow();
}
void PrivacyScreenToastController::ShowToast() {
// If the bubble already exists, update the content of the bubble and extend
// the autoclose timer.
if (bubble_widget_) {
UpdateToastView();
if (!mouse_hovered_)
StartAutoCloseTimer();
return;
}
TrayBubbleView::InitParams init_params;
init_params.shelf_alignment = tray_->shelf()->alignment();
init_params.min_width = kPrivacyScreenToastWidth;
init_params.max_width = kPrivacyScreenToastWidth;
init_params.delegate = this;
init_params.parent_window = tray_->GetBubbleWindowContainer();
init_params.anchor_view = nullptr;
init_params.anchor_mode = TrayBubbleView::AnchorMode::kRect;
init_params.anchor_rect = tray_->shelf()->GetSystemTrayAnchorRect();
// Decrease bottom and right insets to compensate for the adjustment of
// the respective edges in Shelf::GetSystemTrayAnchorRect().
init_params.insets = GetTrayBubbleInsets();
init_params.corner_radius = kUnifiedTrayCornerRadius;
init_params.has_shadow = false;
init_params.translucent = true;
bubble_view_ = new TrayBubbleView(init_params);
toast_view_ = new PrivacyScreenToastView(this);
bubble_view_->AddChildView(toast_view_);
bubble_widget_ = views::BubbleDialogDelegateView::CreateBubble(bubble_view_);
TrayBackgroundView::InitializeBubbleAnimations(bubble_widget_);
bubble_view_->InitializeAndShowBubble();
StartAutoCloseTimer();
UpdateToastView();
}
void PrivacyScreenToastController::HideToast() {
close_timer_.Stop();
if (!bubble_widget_ || bubble_widget_->IsClosed())
return;
bubble_widget_->Close();
tray_->SetTrayBubbleHeight(0);
}
void PrivacyScreenToastController::BubbleViewDestroyed() {
close_timer_.Stop();
bubble_view_ = nullptr;
bubble_widget_ = nullptr;
}
void PrivacyScreenToastController::OnMouseEnteredView() {
close_timer_.Stop();
mouse_hovered_ = true;
}
void PrivacyScreenToastController::OnMouseExitedView() {
StartAutoCloseTimer();
mouse_hovered_ = false;
}
void PrivacyScreenToastController::OnPrivacyScreenSettingChanged(bool enabled) {
if (tray_->IsBubbleShown())
return;
ShowToast();
}
void PrivacyScreenToastController::StartAutoCloseTimer() {
close_timer_.Stop();
close_timer_.Start(
FROM_HERE,
base::TimeDelta::FromSeconds(kTrayPopupAutoCloseDelayInSeconds), this,
&PrivacyScreenToastController::HideToast);
}
void PrivacyScreenToastController::UpdateToastView() {
if (toast_view_) {
toast_view_->SetPrivacyScreenEnabled(
Shell::Get()->privacy_screen_controller()->GetEnabled());
}
}
void PrivacyScreenToastController::ButtonPressed(views::Button* sender,
const ui::Event& event) {
auto* privacy_screen_controller = Shell::Get()->privacy_screen_controller();
privacy_screen_controller->SetEnabled(
!privacy_screen_controller->GetEnabled());
}
} // namespace ash
// Copyright 2020 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_PRIVACY_SCREEN_PRIVACY_SCREEN_TOAST_CONTROLLER_H_
#define ASH_SYSTEM_PRIVACY_SCREEN_PRIVACY_SCREEN_TOAST_CONTROLLER_H_
#include "ash/ash_export.h"
#include "ash/display/privacy_screen_controller.h"
#include "ash/system/privacy_screen/privacy_screen_toast_view.h"
#include "ash/system/tray/tray_bubble_view.h"
#include "base/timer/timer.h"
namespace ash {
class UnifiedSystemTray;
// Controller class for the privacy screen toast, which is shown when the
// privacy screen is toggled on/off.
class ASH_EXPORT PrivacyScreenToastController
: public TrayBubbleView::Delegate,
public PrivacyScreenController::Observer,
public views::ButtonListener {
public:
explicit PrivacyScreenToastController(UnifiedSystemTray* tray);
~PrivacyScreenToastController() override;
PrivacyScreenToastController(PrivacyScreenToastController&) = delete;
PrivacyScreenToastController operator=(PrivacyScreenToastController&) =
delete;
// Shows the toast explicitly. Normally, this is done automatically through
// the PrivacyScreenToastController observer in this class.
void ShowToast();
// Hides the toast if it is shown. Normally, it times out and automatically
// closes.
void HideToast();
private:
// Triggers a timer to automatically close the toast.
void StartAutoCloseTimer();
// Updates the toast UI with the current privacy screen state.
void UpdateToastView();
// TrayBubbleView::Delegate:
void BubbleViewDestroyed() override;
void OnMouseEnteredView() override;
void OnMouseExitedView() override;
// PrivacyScreenController::Observer:
void OnPrivacyScreenSettingChanged(bool enabled) override;
// views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
UnifiedSystemTray* const tray_;
TrayBubbleView* bubble_view_ = nullptr;
views::Widget* bubble_widget_ = nullptr;
PrivacyScreenToastView* toast_view_ = nullptr;
bool mouse_hovered_ = false;
base::OneShotTimer close_timer_;
};
} // namespace ash
#endif // ASH_SYSTEM_PRIVACY_SCREEN_PRIVACY_SCREEN_TOAST_CONTROLLER_H_
// Copyright 2020 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/privacy_screen/privacy_screen_toast_view.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/style/ash_color_provider.h"
#include "ash/style/default_color_constants.h"
#include "ash/system/tray/tray_constants.h"
#include "ash/system/unified/feature_pod_button.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/box_layout.h"
namespace ash {
// View containing the various labels in the toast.
class PrivacyScreenToastLabelView : public views::View {
public:
PrivacyScreenToastLabelView() {
auto* layout = SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical, gfx::Insets(), 0));
layout->set_cross_axis_alignment(
views::BoxLayout::CrossAxisAlignment::kStart);
main_label_ = new views::Label();
sub_label_ = new views::Label();
AddChildView(main_label_);
AddChildView(sub_label_);
const AshColorProvider* color_provider = AshColorProvider::Get();
const SkColor primary_text_color = color_provider->GetContentLayerColor(
AshColorProvider::ContentLayerType::kTextPrimary,
AshColorProvider::AshColorMode::kDark);
const SkColor secondary_text_color = color_provider->GetContentLayerColor(
AshColorProvider::ContentLayerType::kTextSecondary,
AshColorProvider::AshColorMode::kDark);
ConfigureLabel(main_label_, primary_text_color,
kPrivacyScreenToastMainLabelFontSize);
ConfigureLabel(sub_label_, secondary_text_color,
kPrivacyScreenToastSubLabelFontSize);
main_label_->SetText(
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_PRIVACY_SCREEN_LABEL));
}
void SetPrivacyScreenEnabled(bool enabled) {
if (enabled) {
sub_label_->SetText(l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_PRIVACY_SCREEN_ON_SUBLABEL));
} else {
sub_label_->SetText(l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_PRIVACY_SCREEN_OFF_SUBLABEL));
}
}
private:
void ConfigureLabel(views::Label* label, SkColor color, int font_size) {
label->SetAutoColorReadabilityEnabled(false);
label->SetSubpixelRenderingEnabled(false);
label->SetEnabledColor(color);
gfx::Font default_font;
gfx::Font label_font =
default_font.Derive(font_size - default_font.GetFontSize(),
gfx::Font::NORMAL, gfx::Font::Weight::NORMAL);
gfx::FontList font_list(label_font);
label->SetFontList(font_list);
}
views::Label* main_label_;
views::Label* sub_label_;
};
PrivacyScreenToastView::PrivacyScreenToastView(
views::ButtonListener* button_listener) {
auto* layout = SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kHorizontal, kPrivacyScreenToastInsets,
kPrivacyScreenToastSpacing));
layout->set_cross_axis_alignment(
views::BoxLayout::CrossAxisAlignment::kCenter);
button_ = new FeaturePodIconButton(button_listener, /*is_togglable=*/true);
button_->SetVectorIcon(kPrivacyScreenIcon);
button_->SetToggled(false);
AddChildView(button_);
label_ = new PrivacyScreenToastLabelView();
AddChildView(label_);
SetPaintToLayer();
layer()->SetFillsBoundsOpaquely(false);
}
PrivacyScreenToastView::~PrivacyScreenToastView() = default;
void PrivacyScreenToastView::SetPrivacyScreenEnabled(bool enabled) {
button_->SetToggled(enabled);
label_->SetPrivacyScreenEnabled(enabled);
Layout();
}
gfx::Size PrivacyScreenToastView::CalculatePreferredSize() const {
return gfx::Size(kPrivacyScreenToastWidth, kPrivacyScreenToastHeight);
}
} // namespace ash
// Copyright 2020 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_PRIVACY_SCREEN_PRIVACY_SCREEN_TOAST_VIEW_H_
#define ASH_SYSTEM_PRIVACY_SCREEN_PRIVACY_SCREEN_TOAST_VIEW_H_
#include "ash/ash_export.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/view.h"
namespace ash {
class FeaturePodIconButton;
class PrivacyScreenToastLabelView;
// The view shown inside the privacy screen toast bubble.
class ASH_EXPORT PrivacyScreenToastView : public views::View {
public:
explicit PrivacyScreenToastView(views::ButtonListener* button_listener);
~PrivacyScreenToastView() override;
PrivacyScreenToastView(PrivacyScreenToastView&) = delete;
PrivacyScreenToastView operator=(PrivacyScreenToastView&) = delete;
// Updates the toast with whether the privacy screen is enabled.
void SetPrivacyScreenEnabled(bool enabled);
private:
// views::View:
gfx::Size CalculatePreferredSize() const override;
FeaturePodIconButton* button_ = nullptr;
PrivacyScreenToastLabelView* label_ = nullptr;
};
} // namespace ash
#endif // ASH_SYSTEM_PRIVACY_SCREEN_PRIVACY_SCREEN_TOAST_VIEW_H_
...@@ -206,6 +206,14 @@ constexpr int kStatusAreaOverflowGradientSize = 24; ...@@ -206,6 +206,14 @@ constexpr int kStatusAreaOverflowGradientSize = 24;
constexpr int kTrayBubbleInsetTabletModeCompensation = 8; constexpr int kTrayBubbleInsetTabletModeCompensation = 8;
constexpr int kTrayBubbleInsetHotseatCompensation = 16; constexpr int kTrayBubbleInsetHotseatCompensation = 16;
// Constants used for the privacy screen toast.
constexpr int kPrivacyScreenToastWidth = 256;
constexpr int kPrivacyScreenToastHeight = 64;
constexpr int kPrivacyScreenToastMainLabelFontSize = 14;
constexpr int kPrivacyScreenToastSubLabelFontSize = 13;
constexpr gfx::Insets kPrivacyScreenToastInsets(10, 16);
constexpr int kPrivacyScreenToastSpacing = 16;
} // namespace ash } // namespace ash
#endif // ASH_SYSTEM_TRAY_TRAY_CONSTANTS_H_ #endif // ASH_SYSTEM_TRAY_TRAY_CONSTANTS_H_
...@@ -81,6 +81,38 @@ void FeaturePodIconButton::SetToggled(bool toggled) { ...@@ -81,6 +81,38 @@ void FeaturePodIconButton::SetToggled(bool toggled) {
views::ToggleImageButton::SetToggled(toggled); views::ToggleImageButton::SetToggled(toggled);
} }
void FeaturePodIconButton::SetVectorIcon(const gfx::VectorIcon& icon) {
const SkColor icon_color = AshColorProvider::Get()->GetContentLayerColor(
ContentLayerType::kIconSystemMenu, AshColorMode::kDark);
const SkColor toggled_color = AshColorProvider::Get()->GetContentLayerColor(
ContentLayerType::kIconSystemMenuToggled, AshColorMode::kDark);
// Skip repainting if the incoming icon is the same as the current icon. If
// the icon has been painted before, |gfx::CreateVectorIcon()| will simply
// grab the ImageSkia from a cache, so it will be cheap. Note that this
// assumes that toggled/disabled images changes at the same time as the normal
// image, which it currently does.
const gfx::ImageSkia new_normal_image =
gfx::CreateVectorIcon(icon, kUnifiedFeaturePodVectorIconSize, icon_color);
const gfx::ImageSkia& old_normal_image =
GetImage(views::Button::STATE_NORMAL);
if (!new_normal_image.isNull() && !old_normal_image.isNull() &&
new_normal_image.BackedBySameObjectAs(old_normal_image)) {
return;
}
SetImage(views::Button::STATE_NORMAL, new_normal_image);
SetToggledImage(views::Button::STATE_NORMAL,
new gfx::ImageSkia(gfx::CreateVectorIcon(
icon, kUnifiedFeaturePodVectorIconSize, toggled_color)));
SetImage(
views::Button::STATE_DISABLED,
gfx::CreateVectorIcon(icon, kUnifiedFeaturePodVectorIconSize,
AshColorProvider::GetDisabledColor(icon_color)));
}
void FeaturePodIconButton::PaintButtonContents(gfx::Canvas* canvas) { void FeaturePodIconButton::PaintButtonContents(gfx::Canvas* canvas) {
gfx::Rect rect(GetContentsBounds()); gfx::Rect rect(GetContentsBounds());
cc::PaintFlags flags; cc::PaintFlags flags;
...@@ -331,36 +363,7 @@ double FeaturePodButton::GetOpacityForExpandedAmount(double expanded_amount) { ...@@ -331,36 +363,7 @@ double FeaturePodButton::GetOpacityForExpandedAmount(double expanded_amount) {
} }
void FeaturePodButton::SetVectorIcon(const gfx::VectorIcon& icon) { void FeaturePodButton::SetVectorIcon(const gfx::VectorIcon& icon) {
const SkColor icon_color = AshColorProvider::Get()->GetContentLayerColor( icon_button_->SetVectorIcon(icon);
ContentLayerType::kIconSystemMenu, AshColorMode::kDark);
const SkColor toggled_color = AshColorProvider::Get()->GetContentLayerColor(
ContentLayerType::kIconSystemMenuToggled, AshColorMode::kDark);
// Skip repainting if the incoming icon is the same as the current icon. If
// the icon has been painted before, |gfx::CreateVectorIcon()| will simply
// grab the ImageSkia from a cache, so it will be cheap. Note that this
// assumes that toggled/disabled images changes at the same time as the normal
// image, which it currently does.
const gfx::ImageSkia new_normal_image =
gfx::CreateVectorIcon(icon, kUnifiedFeaturePodVectorIconSize, icon_color);
const gfx::ImageSkia& old_normal_image =
icon_button_->GetImage(views::Button::STATE_NORMAL);
if (!new_normal_image.isNull() && !old_normal_image.isNull() &&
new_normal_image.BackedBySameObjectAs(old_normal_image)) {
return;
}
icon_button_->SetImage(views::Button::STATE_NORMAL, new_normal_image);
icon_button_->SetToggledImage(
views::Button::STATE_NORMAL,
new gfx::ImageSkia(gfx::CreateVectorIcon(
icon, kUnifiedFeaturePodVectorIconSize, toggled_color)));
icon_button_->SetImage(
views::Button::STATE_DISABLED,
gfx::CreateVectorIcon(icon, kUnifiedFeaturePodVectorIconSize,
AshColorProvider::GetDisabledColor(icon_color)));
} }
void FeaturePodButton::SetLabel(const base::string16& label) { void FeaturePodButton::SetLabel(const base::string16& label) {
......
...@@ -20,7 +20,7 @@ namespace ash { ...@@ -20,7 +20,7 @@ namespace ash {
class FeaturePodControllerBase; class FeaturePodControllerBase;
// ImageButton internally used in FeaturePodButton. Should not be used directly. // A toggle button with an icon used by feature pods and in other places.
class FeaturePodIconButton : public views::ToggleImageButton { class FeaturePodIconButton : public views::ToggleImageButton {
public: public:
FeaturePodIconButton(views::ButtonListener* listener, bool is_togglable); FeaturePodIconButton(views::ButtonListener* listener, bool is_togglable);
...@@ -29,6 +29,9 @@ class FeaturePodIconButton : public views::ToggleImageButton { ...@@ -29,6 +29,9 @@ class FeaturePodIconButton : public views::ToggleImageButton {
// Change the toggle state. See FeaturePodButton::SetToggled. // Change the toggle state. See FeaturePodButton::SetToggled.
void SetToggled(bool toggled); void SetToggled(bool toggled);
// Sets the button's icon.
void SetVectorIcon(const gfx::VectorIcon& icon);
// views::ImageButton: // views::ImageButton:
void PaintButtonContents(gfx::Canvas* canvas) override; void PaintButtonContents(gfx::Canvas* canvas) override;
std::unique_ptr<views::InkDrop> CreateInkDrop() override; std::unique_ptr<views::InkDrop> CreateInkDrop() override;
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "ash/system/model/system_tray_model.h" #include "ash/system/model/system_tray_model.h"
#include "ash/system/network/network_tray_view.h" #include "ash/system/network/network_tray_view.h"
#include "ash/system/power/tray_power.h" #include "ash/system/power/tray_power.h"
#include "ash/system/privacy_screen/privacy_screen_toast_controller.h"
#include "ash/system/status_area_widget.h" #include "ash/system/status_area_widget.h"
#include "ash/system/time/time_tray_item_view.h" #include "ash/system/time/time_tray_item_view.h"
#include "ash/system/time/time_view.h" #include "ash/system/time/time_view.h"
...@@ -125,6 +126,8 @@ UnifiedSystemTray::UnifiedSystemTray(Shelf* shelf) ...@@ -125,6 +126,8 @@ UnifiedSystemTray::UnifiedSystemTray(Shelf* shelf)
shelf->GetStatusAreaWidget()->GetRootView())), shelf->GetStatusAreaWidget()->GetRootView())),
slider_bubble_controller_( slider_bubble_controller_(
std::make_unique<UnifiedSliderBubbleController>(this)), std::make_unique<UnifiedSliderBubbleController>(this)),
privacy_screen_toast_controller_(
std::make_unique<PrivacyScreenToastController>(this)),
current_locale_view_(new CurrentLocaleView(shelf)), current_locale_view_(new CurrentLocaleView(shelf)),
ime_mode_view_(new ImeModeView(shelf)), ime_mode_view_(new ImeModeView(shelf)),
managed_device_view_(new ManagedDeviceTrayItemView(shelf)), managed_device_view_(new ManagedDeviceTrayItemView(shelf)),
...@@ -423,6 +426,9 @@ void UnifiedSystemTray::ShowBubbleInternal(bool show_by_click) { ...@@ -423,6 +426,9 @@ void UnifiedSystemTray::ShowBubbleInternal(bool show_by_click) {
// Hide volume/brightness slider popup. // Hide volume/brightness slider popup.
slider_bubble_controller_->CloseBubble(); slider_bubble_controller_->CloseBubble();
// Hide the privacy screen toast if it is shown.
privacy_screen_toast_controller_->HideToast();
bubble_ = std::make_unique<UnifiedSystemTrayBubble>(this, show_by_click); bubble_ = std::make_unique<UnifiedSystemTrayBubble>(this, show_by_click);
if (features::IsUnifiedMessageCenterRefactorEnabled()) { if (features::IsUnifiedMessageCenterRefactorEnabled()) {
......
...@@ -29,6 +29,7 @@ class ImeModeView; ...@@ -29,6 +29,7 @@ class ImeModeView;
class ManagedDeviceTrayItemView; class ManagedDeviceTrayItemView;
class NotificationCounterView; class NotificationCounterView;
class QuietModeView; class QuietModeView;
class PrivacyScreenToastController;
class UnifiedSliderBubbleController; class UnifiedSliderBubbleController;
class UnifiedSystemTrayBubble; class UnifiedSystemTrayBubble;
class UnifiedSystemTrayModel; class UnifiedSystemTrayModel;
...@@ -176,6 +177,9 @@ class ASH_EXPORT UnifiedSystemTray : public TrayBackgroundView, ...@@ -176,6 +177,9 @@ class ASH_EXPORT UnifiedSystemTray : public TrayBackgroundView,
const std::unique_ptr<UnifiedSliderBubbleController> const std::unique_ptr<UnifiedSliderBubbleController>
slider_bubble_controller_; slider_bubble_controller_;
const std::unique_ptr<PrivacyScreenToastController>
privacy_screen_toast_controller_;
CurrentLocaleView* const current_locale_view_; CurrentLocaleView* const current_locale_view_;
ImeModeView* const ime_mode_view_; ImeModeView* const ime_mode_view_;
ManagedDeviceTrayItemView* const managed_device_view_; ManagedDeviceTrayItemView* const managed_device_view_;
......
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