Commit 4ba7a33e authored by Tatsuhisa Yamaguchi's avatar Tatsuhisa Yamaguchi Committed by Commit Bot

Update notification icon color when session types change.

Prevents showing the notification icon being invisible, or in a faded
color in certain conditions.

- Faded color after first sign-in (crbug.com/880766)
After OOBE is finished, the icon color should be updated.

- Invisible do-not-disturb icon in OOBE (crbug.com/886561)
Session status is UNKNOWN at the view creation during OOBE.

Bug: 880766,886561
Change-Id: I82d22a5d0967ab9c0fdef3b109ea3157e0244d8c
Reviewed-on: https://chromium-review.googlesource.com/1233101Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Commit-Queue: Tatsuhisa Yamaguchi <yamaguchi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593107}
parent 31aa99eb
......@@ -89,10 +89,13 @@ class NumberIconImageSource : public gfx::CanvasImageSource {
NotificationCounterView::NotificationCounterView() : TrayItemView(nullptr) {
CreateImageView();
Update();
SetVisible(false);
Shell::Get()->session_controller()->AddObserver(this);
}
NotificationCounterView::~NotificationCounterView() = default;
NotificationCounterView::~NotificationCounterView() {
Shell::Get()->session_controller()->RemoveObserver(this);
}
void NotificationCounterView::Update() {
size_t notification_count =
......@@ -111,22 +114,38 @@ void NotificationCounterView::Update() {
SetVisible(true);
}
void NotificationCounterView::OnSessionStateChanged(
session_manager::SessionState state) {
Update();
}
QuietModeView::QuietModeView() : TrayItemView(nullptr) {
CreateImageView();
SetVisible(false);
Shell::Get()->session_controller()->AddObserver(this);
}
QuietModeView::~QuietModeView() {
Shell::Get()->session_controller()->RemoveObserver(this);
}
void QuietModeView::Update() {
// TODO(yamaguchi): Add this check when new style of the system tray is
// implemented, so that icon resizing will not happen here.
// DCHECK_EQ(kTrayIconSize,
// gfx::GetDefaultSizeOfVectorIcon(kSystemTrayDoNotDisturbIcon));
if (message_center::MessageCenter::Get()->IsQuietMode()) {
image_view()->SetImage(gfx::CreateVectorIcon(
kSystemTrayDoNotDisturbIcon,
TrayIconColor(Shell::Get()->session_controller()->GetSessionState())));
Update();
SetVisible(true);
} else {
SetVisible(false);
}
}
QuietModeView::~QuietModeView() = default;
void QuietModeView::Update() {
SetVisible(message_center::MessageCenter::Get()->IsQuietMode());
void QuietModeView::OnSessionStateChanged(session_manager::SessionState state) {
Update();
}
} // namespace ash
......@@ -5,19 +5,23 @@
#ifndef ASH_SYSTEM_UNIFIED_NOTIFICATION_COUNTER_VIEW_H_
#define ASH_SYSTEM_UNIFIED_NOTIFICATION_COUNTER_VIEW_H_
#include "ash/session/session_observer.h"
#include "ash/system/tray/tray_item_view.h"
#include "base/macros.h"
namespace ash {
// A notification counter view in UnifiedSystemTray button.
class NotificationCounterView : public TrayItemView {
class NotificationCounterView : public TrayItemView, public SessionObserver {
public:
NotificationCounterView();
~NotificationCounterView() override;
void Update();
// SessionObserver:
void OnSessionStateChanged(session_manager::SessionState state) override;
private:
// The type / number of the icon that is currently set to the image view.
// 0 indicates no icon is drawn yet.
......@@ -29,13 +33,16 @@ class NotificationCounterView : public TrayItemView {
};
// A do-not-distrub icon view in UnifiedSystemTray button.
class QuietModeView : public TrayItemView {
class QuietModeView : public TrayItemView, public SessionObserver {
public:
QuietModeView();
~QuietModeView() override;
void Update();
// SessionObserver:
void OnSessionStateChanged(session_manager::SessionState state) override;
private:
DISALLOW_COPY_AND_ASSIGN(QuietModeView);
};
......
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