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 { ...@@ -89,10 +89,13 @@ class NumberIconImageSource : public gfx::CanvasImageSource {
NotificationCounterView::NotificationCounterView() : TrayItemView(nullptr) { NotificationCounterView::NotificationCounterView() : TrayItemView(nullptr) {
CreateImageView(); CreateImageView();
Update(); SetVisible(false);
Shell::Get()->session_controller()->AddObserver(this);
} }
NotificationCounterView::~NotificationCounterView() = default; NotificationCounterView::~NotificationCounterView() {
Shell::Get()->session_controller()->RemoveObserver(this);
}
void NotificationCounterView::Update() { void NotificationCounterView::Update() {
size_t notification_count = size_t notification_count =
...@@ -111,22 +114,38 @@ void NotificationCounterView::Update() { ...@@ -111,22 +114,38 @@ void NotificationCounterView::Update() {
SetVisible(true); SetVisible(true);
} }
void NotificationCounterView::OnSessionStateChanged(
session_manager::SessionState state) {
Update();
}
QuietModeView::QuietModeView() : TrayItemView(nullptr) { QuietModeView::QuietModeView() : TrayItemView(nullptr) {
CreateImageView(); 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 // TODO(yamaguchi): Add this check when new style of the system tray is
// implemented, so that icon resizing will not happen here. // implemented, so that icon resizing will not happen here.
// DCHECK_EQ(kTrayIconSize, // DCHECK_EQ(kTrayIconSize,
// gfx::GetDefaultSizeOfVectorIcon(kSystemTrayDoNotDisturbIcon)); // gfx::GetDefaultSizeOfVectorIcon(kSystemTrayDoNotDisturbIcon));
image_view()->SetImage(gfx::CreateVectorIcon( if (message_center::MessageCenter::Get()->IsQuietMode()) {
kSystemTrayDoNotDisturbIcon, image_view()->SetImage(gfx::CreateVectorIcon(
TrayIconColor(Shell::Get()->session_controller()->GetSessionState()))); kSystemTrayDoNotDisturbIcon,
Update(); TrayIconColor(Shell::Get()->session_controller()->GetSessionState())));
SetVisible(true);
} else {
SetVisible(false);
}
} }
QuietModeView::~QuietModeView() = default; void QuietModeView::OnSessionStateChanged(session_manager::SessionState state) {
Update();
void QuietModeView::Update() {
SetVisible(message_center::MessageCenter::Get()->IsQuietMode());
} }
} // namespace ash } // namespace ash
...@@ -5,19 +5,23 @@ ...@@ -5,19 +5,23 @@
#ifndef ASH_SYSTEM_UNIFIED_NOTIFICATION_COUNTER_VIEW_H_ #ifndef ASH_SYSTEM_UNIFIED_NOTIFICATION_COUNTER_VIEW_H_
#define 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 "ash/system/tray/tray_item_view.h"
#include "base/macros.h" #include "base/macros.h"
namespace ash { namespace ash {
// A notification counter view in UnifiedSystemTray button. // A notification counter view in UnifiedSystemTray button.
class NotificationCounterView : public TrayItemView { class NotificationCounterView : public TrayItemView, public SessionObserver {
public: public:
NotificationCounterView(); NotificationCounterView();
~NotificationCounterView() override; ~NotificationCounterView() override;
void Update(); void Update();
// SessionObserver:
void OnSessionStateChanged(session_manager::SessionState state) override;
private: private:
// The type / number of the icon that is currently set to the image view. // The type / number of the icon that is currently set to the image view.
// 0 indicates no icon is drawn yet. // 0 indicates no icon is drawn yet.
...@@ -29,13 +33,16 @@ class NotificationCounterView : public TrayItemView { ...@@ -29,13 +33,16 @@ class NotificationCounterView : public TrayItemView {
}; };
// A do-not-distrub icon view in UnifiedSystemTray button. // A do-not-distrub icon view in UnifiedSystemTray button.
class QuietModeView : public TrayItemView { class QuietModeView : public TrayItemView, public SessionObserver {
public: public:
QuietModeView(); QuietModeView();
~QuietModeView() override; ~QuietModeView() override;
void Update(); void Update();
// SessionObserver:
void OnSessionStateChanged(session_manager::SessionState state) override;
private: private:
DISALLOW_COPY_AND_ASSIGN(QuietModeView); 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