Commit df859669 authored by yoshiki iguchi's avatar yoshiki iguchi Committed by Commit Bot

Create utility methods to retrieve the lock screen notification state

This CL add two methods in ArcMessageCenterLockScreenController.
- IsEnabled() for visibility of lock screen notification
- GetMode() for mode of lock screen notification

Bug: b/111391270
Test: none

Change-Id: Ieb41c6dcc78768cff12932a62f33153d4f3e172b
Reviewed-on: https://chromium-review.googlesource.com/1164872
Commit-Queue: Yoshiki Iguchi <yoshiki@chromium.org>
Reviewed-by: default avatarTetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581224}
parent 64ae3aba
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "ash/login/ui/lock_screen.h" #include "ash/login/ui/lock_screen.h"
#include "ash/login/ui/lock_window.h" #include "ash/login/ui/lock_window.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/session/session_controller.h" #include "ash/session/session_controller.h"
#include "ash/shelf/shelf.h" #include "ash/shelf/shelf.h"
#include "ash/shell.h" #include "ash/shell.h"
...@@ -19,6 +20,20 @@ ...@@ -19,6 +20,20 @@
namespace ash { namespace ash {
// static
bool AshMessageCenterLockScreenController::IsEnabled() {
return GetMode() != Mode::HIDE;
}
// static
AshMessageCenterLockScreenController::Mode
AshMessageCenterLockScreenController::GetMode() {
if (!features::IsLockScreenNotificationsEnabled())
return Mode::HIDE;
return Mode::SHOW;
}
namespace { namespace {
const char kToastId[] = "ash-lock-screen-manager"; const char kToastId[] = "ash-lock-screen-manager";
} // anonymous namespace } // anonymous namespace
......
...@@ -17,6 +17,16 @@ class AshMessageCenterLockScreenController ...@@ -17,6 +17,16 @@ class AshMessageCenterLockScreenController
: public message_center::LockScreenController, : public message_center::LockScreenController,
public SessionObserver { public SessionObserver {
public: public:
// Modes of the lock screen notification.
enum class Mode { HIDE, SHOW, HIDE_SENSITIVE };
// Returns if the message center shows the notifications on the lock screen
// or not. True if it shows, false if doesn't.
static ASH_EXPORT bool IsEnabled();
// Returns the current mode of the lock screen notification.
static Mode GetMode();
AshMessageCenterLockScreenController(); AshMessageCenterLockScreenController();
~AshMessageCenterLockScreenController() override; ~AshMessageCenterLockScreenController() override;
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
#include "ash/message_center/message_center_button_bar.h" #include "ash/message_center/message_center_button_bar.h"
#include "ash/message_center/ash_message_center_lock_screen_controller.h"
#include "ash/message_center/message_center_style.h" #include "ash/message_center/message_center_style.h"
#include "ash/message_center/message_center_view.h" #include "ash/message_center/message_center_view.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/resources/vector_icons/vector_icons.h" #include "ash/resources/vector_icons/vector_icons.h"
#include "ash/strings/grit/ash_strings.h" #include "ash/strings/grit/ash_strings.h"
#include "ash/system/tray/tray_constants.h" #include "ash/system/tray/tray_constants.h"
...@@ -121,7 +121,7 @@ MessageCenterButtonBar::MessageCenterButtonBar( ...@@ -121,7 +121,7 @@ MessageCenterButtonBar::MessageCenterButtonBar(
SetBorder(views::CreateEmptyBorder(kButtonBarBorder)); SetBorder(views::CreateEmptyBorder(kButtonBarBorder));
notification_label_ = new views::Label( notification_label_ = new views::Label(
GetTitle(!locked || features::IsLockScreenNotificationsEnabled())); GetTitle(!locked || AshMessageCenterLockScreenController::IsEnabled()));
notification_label_->SetAutoColorReadabilityEnabled(false); notification_label_->SetAutoColorReadabilityEnabled(false);
notification_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); notification_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
notification_label_->SetEnabledColor(kTextColor); notification_label_->SetEnabledColor(kTextColor);
...@@ -272,7 +272,7 @@ void MessageCenterButtonBar::OnImplicitAnimationsCompleted() { ...@@ -272,7 +272,7 @@ void MessageCenterButtonBar::OnImplicitAnimationsCompleted() {
void MessageCenterButtonBar::SetIsLocked(bool locked) { void MessageCenterButtonBar::SetIsLocked(bool locked) {
SetButtonsVisible(locked); SetButtonsVisible(locked);
UpdateLabel(!locked || features::IsLockScreenNotificationsEnabled()); UpdateLabel(!locked || AshMessageCenterLockScreenController::IsEnabled());
} }
base::string16 MessageCenterButtonBar::GetTitle( base::string16 MessageCenterButtonBar::GetTitle(
...@@ -294,7 +294,7 @@ void MessageCenterButtonBar::UpdateLabel(bool message_center_visible) { ...@@ -294,7 +294,7 @@ void MessageCenterButtonBar::UpdateLabel(bool message_center_visible) {
void MessageCenterButtonBar::SetButtonsVisible(bool locked) { void MessageCenterButtonBar::SetButtonsVisible(bool locked) {
bool message_center_visible = bool message_center_visible =
!locked || features::IsLockScreenNotificationsEnabled(); !locked || AshMessageCenterLockScreenController::IsEnabled();
if (close_all_button_) if (close_all_button_)
close_all_button_->SetVisible(message_center_visible); close_all_button_->SetVisible(message_center_visible);
separator_1_->SetVisible(message_center_visible); separator_1_->SetVisible(message_center_visible);
......
...@@ -7,12 +7,11 @@ ...@@ -7,12 +7,11 @@
#include <list> #include <list>
#include <map> #include <map>
#include "ash/message_center/ash_message_center_lock_screen_controller.h"
#include "ash/message_center/message_center_button_bar.h" #include "ash/message_center/message_center_button_bar.h"
#include "ash/message_center/message_center_scroll_bar.h" #include "ash/message_center/message_center_scroll_bar.h"
#include "ash/message_center/message_center_style.h" #include "ash/message_center/message_center_style.h"
#include "ash/message_center/notifier_settings_view.h" #include "ash/message_center/notifier_settings_view.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/ash_switches.h"
#include "ash/resources/vector_icons/vector_icons.h" #include "ash/resources/vector_icons/vector_icons.h"
#include "ash/session/session_controller.h" #include "ash/session/session_controller.h"
#include "ash/shell.h" #include "ash/shell.h"
...@@ -189,7 +188,7 @@ MessageCenterView::MessageCenterView( ...@@ -189,7 +188,7 @@ MessageCenterView::MessageCenterView(
: message_center_(message_center), : message_center_(message_center),
settings_visible_(initially_settings_visible), settings_visible_(initially_settings_visible),
is_locked_(Shell::Get()->session_controller()->IsScreenLocked()) { is_locked_(Shell::Get()->session_controller()->IsScreenLocked()) {
if (is_locked_ && !features::IsLockScreenNotificationsEnabled()) if (is_locked_ && !AshMessageCenterLockScreenController::IsEnabled())
mode_ = Mode::LOCKED; mode_ = Mode::LOCKED;
else if (initially_settings_visible) else if (initially_settings_visible)
mode_ = Mode::SETTINGS; mode_ = Mode::SETTINGS;
...@@ -577,7 +576,7 @@ void MessageCenterView::AddNotificationAt(const Notification& notification, ...@@ -577,7 +576,7 @@ void MessageCenterView::AddNotificationAt(const Notification& notification,
void MessageCenterView::Update(bool animate) { void MessageCenterView::Update(bool animate) {
bool no_message_views = (message_list_view_->GetNotificationCount() == 0); bool no_message_views = (message_list_view_->GetNotificationCount() == 0);
if (is_locked_ && !features::IsLockScreenNotificationsEnabled()) if (is_locked_ && !AshMessageCenterLockScreenController::IsEnabled())
SetVisibilityMode(Mode::LOCKED, animate); SetVisibilityMode(Mode::LOCKED, animate);
else if (settings_visible_) else if (settings_visible_)
SetVisibilityMode(Mode::SETTINGS, animate); SetVisibilityMode(Mode::SETTINGS, animate);
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <memory> #include <memory>
#include <utility> #include <utility>
#include "ash/message_center/ash_message_center_lock_screen_controller.h"
#include "ash/message_center/message_center_button_bar.h" #include "ash/message_center/message_center_button_bar.h"
#include "ash/message_center/message_center_style.h" #include "ash/message_center/message_center_style.h"
#include "ash/message_center/message_list_view.h" #include "ash/message_center/message_list_view.h"
...@@ -236,8 +237,10 @@ MessageCenterViewTest::~MessageCenterViewTest() = default; ...@@ -236,8 +237,10 @@ MessageCenterViewTest::~MessageCenterViewTest() = default;
void MessageCenterViewTest::SetUp() { void MessageCenterViewTest::SetUp() {
AshTestBase::SetUp(); AshTestBase::SetUp();
if (is_lock_screen_notifications_enabled_) if (is_lock_screen_notifications_enabled_) {
SetLockScreenNotificationsEnabled(); SetLockScreenNotificationsEnabled();
ASSERT_TRUE(AshMessageCenterLockScreenController::IsEnabled());
}
MessageCenterView::disable_animation_for_testing = true; MessageCenterView::disable_animation_for_testing = true;
message_center_.reset(new FakeMessageCenterImpl()); message_center_.reset(new FakeMessageCenterImpl());
...@@ -834,8 +837,9 @@ TEST_P(MessageCenterViewTest, CheckModeWithLockingAndUnlocking) { ...@@ -834,8 +837,9 @@ TEST_P(MessageCenterViewTest, CheckModeWithLockingAndUnlocking) {
// Lock! // Lock!
SetLockedState(true); SetLockedState(true);
EXPECT_EQ(features::IsLockScreenNotificationsEnabled() ? Mode::NOTIFICATIONS EXPECT_EQ(AshMessageCenterLockScreenController::IsEnabled()
: Mode::LOCKED, ? Mode::NOTIFICATIONS
: Mode::LOCKED,
GetMessageCenterViewInternalMode()); GetMessageCenterViewInternalMode());
// Unlock! // Unlock!
...@@ -848,7 +852,7 @@ TEST_P(MessageCenterViewTest, CheckModeWithLockingAndUnlocking) { ...@@ -848,7 +852,7 @@ TEST_P(MessageCenterViewTest, CheckModeWithLockingAndUnlocking) {
// Lock! // Lock!
SetLockedState(true); SetLockedState(true);
EXPECT_EQ(features::IsLockScreenNotificationsEnabled() EXPECT_EQ(AshMessageCenterLockScreenController::IsEnabled()
? Mode::NO_NOTIFICATIONS ? Mode::NO_NOTIFICATIONS
: Mode::LOCKED, : Mode::LOCKED,
GetMessageCenterViewInternalMode()); GetMessageCenterViewInternalMode());
...@@ -864,13 +868,14 @@ TEST_P(MessageCenterViewTest, CheckModeWithRemovingNotificationDuringLock) { ...@@ -864,13 +868,14 @@ TEST_P(MessageCenterViewTest, CheckModeWithRemovingNotificationDuringLock) {
// Lock! // Lock!
SetLockedState(true); SetLockedState(true);
EXPECT_EQ(features::IsLockScreenNotificationsEnabled() ? Mode::NOTIFICATIONS EXPECT_EQ(AshMessageCenterLockScreenController::IsEnabled()
: Mode::LOCKED, ? Mode::NOTIFICATIONS
: Mode::LOCKED,
GetMessageCenterViewInternalMode()); GetMessageCenterViewInternalMode());
// Remove all existing notifications. // Remove all existing notifications.
RemoveDefaultNotifications(); RemoveDefaultNotifications();
EXPECT_EQ(features::IsLockScreenNotificationsEnabled() EXPECT_EQ(AshMessageCenterLockScreenController::IsEnabled()
? Mode::NO_NOTIFICATIONS ? Mode::NO_NOTIFICATIONS
: Mode::LOCKED, : Mode::LOCKED,
GetMessageCenterViewInternalMode()); GetMessageCenterViewInternalMode());
...@@ -902,7 +907,7 @@ TEST_P(MessageCenterViewTest, LockScreen) { ...@@ -902,7 +907,7 @@ TEST_P(MessageCenterViewTest, LockScreen) {
// Lock! // Lock!
SetLockedState(true); SetLockedState(true);
if (features::IsLockScreenNotificationsEnabled()) { if (AshMessageCenterLockScreenController::IsEnabled()) {
EXPECT_TRUE(GetNotificationView(kNotificationId1)->IsDrawn()); EXPECT_TRUE(GetNotificationView(kNotificationId1)->IsDrawn());
EXPECT_TRUE(GetNotificationView(kNotificationId2)->IsDrawn()); EXPECT_TRUE(GetNotificationView(kNotificationId2)->IsDrawn());
} else { } else {
...@@ -911,7 +916,7 @@ TEST_P(MessageCenterViewTest, LockScreen) { ...@@ -911,7 +916,7 @@ TEST_P(MessageCenterViewTest, LockScreen) {
} }
GetMessageCenterView()->SizeToPreferredSize(); GetMessageCenterView()->SizeToPreferredSize();
if (features::IsLockScreenNotificationsEnabled()) { if (AshMessageCenterLockScreenController::IsEnabled()) {
EXPECT_NE(kLockedMessageCenterViewHeight, GetMessageCenterView()->height()); EXPECT_NE(kLockedMessageCenterViewHeight, GetMessageCenterView()->height());
EXPECT_NE(kEmptyMessageCenterViewHeight, GetMessageCenterView()->height()); EXPECT_NE(kEmptyMessageCenterViewHeight, GetMessageCenterView()->height());
} else { } else {
...@@ -921,7 +926,7 @@ TEST_P(MessageCenterViewTest, LockScreen) { ...@@ -921,7 +926,7 @@ TEST_P(MessageCenterViewTest, LockScreen) {
RemoveNotification(kNotificationId1, false); RemoveNotification(kNotificationId1, false);
GetMessageCenterView()->SizeToPreferredSize(); GetMessageCenterView()->SizeToPreferredSize();
if (features::IsLockScreenNotificationsEnabled()) { if (AshMessageCenterLockScreenController::IsEnabled()) {
EXPECT_NE(kLockedMessageCenterViewHeight, GetMessageCenterView()->height()); EXPECT_NE(kLockedMessageCenterViewHeight, GetMessageCenterView()->height());
EXPECT_NE(kEmptyMessageCenterViewHeight, GetMessageCenterView()->height()); EXPECT_NE(kEmptyMessageCenterViewHeight, GetMessageCenterView()->height());
} else { } else {
...@@ -931,7 +936,7 @@ TEST_P(MessageCenterViewTest, LockScreen) { ...@@ -931,7 +936,7 @@ TEST_P(MessageCenterViewTest, LockScreen) {
RemoveNotification(kNotificationId2, false); RemoveNotification(kNotificationId2, false);
GetMessageCenterView()->SizeToPreferredSize(); GetMessageCenterView()->SizeToPreferredSize();
if (features::IsLockScreenNotificationsEnabled()) if (AshMessageCenterLockScreenController::IsEnabled())
EXPECT_EQ(kEmptyMessageCenterViewHeight, GetMessageCenterView()->height()); EXPECT_EQ(kEmptyMessageCenterViewHeight, GetMessageCenterView()->height());
else else
EXPECT_EQ(kLockedMessageCenterViewHeight, GetMessageCenterView()->height()); EXPECT_EQ(kLockedMessageCenterViewHeight, GetMessageCenterView()->height());
...@@ -942,20 +947,20 @@ TEST_P(MessageCenterViewTest, LockScreen) { ...@@ -942,20 +947,20 @@ TEST_P(MessageCenterViewTest, LockScreen) {
base::UTF8ToUTF16("display source"), GURL(), base::UTF8ToUTF16("display source"), GURL(),
NotifierId(NotifierId::APPLICATION, "extension_id"), NotifierId(NotifierId::APPLICATION, "extension_id"),
message_center::RichNotificationData(), nullptr)); message_center::RichNotificationData(), nullptr));
if (features::IsLockScreenNotificationsEnabled()) if (AshMessageCenterLockScreenController::IsEnabled())
EXPECT_TRUE(GetNotificationView(kNotificationId1)->IsDrawn()); EXPECT_TRUE(GetNotificationView(kNotificationId1)->IsDrawn());
else else
EXPECT_FALSE(GetNotificationView(kNotificationId1)->IsDrawn()); EXPECT_FALSE(GetNotificationView(kNotificationId1)->IsDrawn());
GetMessageCenterView()->SizeToPreferredSize(); GetMessageCenterView()->SizeToPreferredSize();
if (features::IsLockScreenNotificationsEnabled()) { if (AshMessageCenterLockScreenController::IsEnabled()) {
EXPECT_NE(kLockedMessageCenterViewHeight, GetMessageCenterView()->height()); EXPECT_NE(kLockedMessageCenterViewHeight, GetMessageCenterView()->height());
EXPECT_NE(kEmptyMessageCenterViewHeight, GetMessageCenterView()->height()); EXPECT_NE(kEmptyMessageCenterViewHeight, GetMessageCenterView()->height());
} else { } else {
EXPECT_EQ(kLockedMessageCenterViewHeight, GetMessageCenterView()->height()); EXPECT_EQ(kLockedMessageCenterViewHeight, GetMessageCenterView()->height());
} }
if (features::IsLockScreenNotificationsEnabled()) { if (AshMessageCenterLockScreenController::IsEnabled()) {
EXPECT_TRUE(close_button->visible()); EXPECT_TRUE(close_button->visible());
EXPECT_TRUE(quiet_mode_button->visible()); EXPECT_TRUE(quiet_mode_button->visible());
} else { } else {
...@@ -981,20 +986,20 @@ TEST_P(MessageCenterViewTest, LockScreen) { ...@@ -981,20 +986,20 @@ TEST_P(MessageCenterViewTest, LockScreen) {
// Lock! // Lock!
SetLockedState(true); SetLockedState(true);
if (features::IsLockScreenNotificationsEnabled()) if (AshMessageCenterLockScreenController::IsEnabled())
EXPECT_TRUE(GetNotificationView(kNotificationId1)->IsDrawn()); EXPECT_TRUE(GetNotificationView(kNotificationId1)->IsDrawn());
else else
EXPECT_FALSE(GetNotificationView(kNotificationId1)->IsDrawn()); EXPECT_FALSE(GetNotificationView(kNotificationId1)->IsDrawn());
GetMessageCenterView()->SizeToPreferredSize(); GetMessageCenterView()->SizeToPreferredSize();
if (features::IsLockScreenNotificationsEnabled()) { if (AshMessageCenterLockScreenController::IsEnabled()) {
EXPECT_NE(kLockedMessageCenterViewHeight, GetMessageCenterView()->height()); EXPECT_NE(kLockedMessageCenterViewHeight, GetMessageCenterView()->height());
EXPECT_NE(kEmptyMessageCenterViewHeight, GetMessageCenterView()->height()); EXPECT_NE(kEmptyMessageCenterViewHeight, GetMessageCenterView()->height());
} else { } else {
EXPECT_EQ(kLockedMessageCenterViewHeight, GetMessageCenterView()->height()); EXPECT_EQ(kLockedMessageCenterViewHeight, GetMessageCenterView()->height());
} }
if (features::IsLockScreenNotificationsEnabled()) { if (AshMessageCenterLockScreenController::IsEnabled()) {
EXPECT_TRUE(close_button->visible()); EXPECT_TRUE(close_button->visible());
EXPECT_TRUE(quiet_mode_button->visible()); EXPECT_TRUE(quiet_mode_button->visible());
} else { } else {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "ash/system/message_center/session_state_notification_blocker.h" #include "ash/system/message_center/session_state_notification_blocker.h"
#include "ash/public/cpp/ash_features.h" #include "ash/message_center/ash_message_center_lock_screen_controller.h"
#include "ash/session/session_controller.h" #include "ash/session/session_controller.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ui/message_center/message_center.h" #include "ui/message_center/message_center.h"
...@@ -21,7 +21,7 @@ bool CalculateShouldShowNotification() { ...@@ -21,7 +21,7 @@ bool CalculateShouldShowNotification() {
return !session_controller->IsRunningInAppMode() && return !session_controller->IsRunningInAppMode() &&
(!session_controller->IsScreenLocked() || (!session_controller->IsScreenLocked() ||
features::IsLockScreenNotificationsEnabled()); AshMessageCenterLockScreenController::IsEnabled());
} }
bool CalculateShouldShowPopup() { bool CalculateShouldShowPopup() {
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "ash/system/unified/unified_system_tray_view.h" #include "ash/system/unified/unified_system_tray_view.h"
#include "ash/message_center/ash_message_center_lock_screen_controller.h"
#include "ash/public/cpp/app_list/app_list_features.h" #include "ash/public/cpp/app_list/app_list_features.h"
#include "ash/public/cpp/ash_features.h" #include "ash/public/cpp/ash_features.h"
#include "ash/session/session_controller.h" #include "ash/session/session_controller.h"
...@@ -281,7 +282,7 @@ UnifiedSystemTrayView::UnifiedSystemTrayView( ...@@ -281,7 +282,7 @@ UnifiedSystemTrayView::UnifiedSystemTrayView(
notification_hidden_view_->SetVisible( notification_hidden_view_->SetVisible(
session_controller->GetUserSession(0) && session_controller->GetUserSession(0) &&
session_controller->IsScreenLocked() && session_controller->IsScreenLocked() &&
!features::IsLockScreenNotificationsEnabled()); !AshMessageCenterLockScreenController::IsEnabled());
AddChildView(notification_hidden_view_); AddChildView(notification_hidden_view_);
AddChildView(system_tray_container_); AddChildView(system_tray_container_);
......
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