Commit 4329e5cf authored by Tim Song's avatar Tim Song Committed by Commit Bot

Notifications: No Do-Not-Disturb for critical warning level.

This CL also adds the system notification warning level as a field in
Notification.

BUG=1073726

Change-Id: I7e432f362fc6269e3fe06c671bfca0588850f539
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2200630
Commit-Queue: Tim Song <tengs@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarAhmed Mehfooz <amehfooz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771228}
parent 602bc20d
......@@ -42,10 +42,10 @@ std::unique_ptr<message_center::Notification> CreateSystemNotification(
const message_center::RichNotificationData& optional_fields,
scoped_refptr<message_center::NotificationDelegate> delegate,
const gfx::VectorIcon& small_image,
message_center::SystemNotificationWarningLevel color_type) {
message_center::SystemNotificationWarningLevel warning_level) {
DCHECK_EQ(message_center::NotifierType::SYSTEM_COMPONENT, notifier_id.type);
SkColor color = kSystemNotificationColorNormal;
switch (color_type) {
switch (warning_level) {
case message_center::SystemNotificationWarningLevel::NORMAL:
color = kSystemNotificationColorNormal;
break;
......@@ -60,6 +60,7 @@ std::unique_ptr<message_center::Notification> CreateSystemNotification(
type, id, title, message, gfx::Image(), display_source, origin_url,
notifier_id, optional_fields, delegate);
notification->set_accent_color(color);
notification->set_system_notification_warning_level(warning_level);
if (!small_image.is_empty())
notification->set_vector_small_image(small_image);
return notification;
......
......@@ -68,7 +68,7 @@ CreateSystemNotification(
const message_center::RichNotificationData& optional_fields,
scoped_refptr<message_center::NotificationDelegate> delegate,
const gfx::VectorIcon& small_image,
message_center::SystemNotificationWarningLevel color_type);
message_center::SystemNotificationWarningLevel warning_level);
} // namespace ash
......
......@@ -321,10 +321,18 @@ void NotificationList::PushNotification(
state = iter->second;
EraseNotification(iter);
} else {
// For critical ChromeOS system notifications, we ignore the standard quiet
// mode behaviour and show the notification anyways.
bool effective_quiet_mode = quiet_mode_;
#if defined(OS_CHROMEOS)
effective_quiet_mode &= notification->system_notification_warning_level() !=
SystemNotificationWarningLevel::CRITICAL_WARNING;
#endif
// TODO(mukai): needs to distinguish if a notification is dismissed by
// the quiet mode or user operation.
state.shown_as_popup =
message_center_->IsMessageCenterVisible() || quiet_mode_;
message_center_->IsMessageCenterVisible() || effective_quiet_mode;
}
if (notification->priority() == MIN_PRIORITY)
state.is_read = true;
......
......@@ -433,6 +433,17 @@ class MESSAGE_CENTER_PUBLIC_EXPORT Notification {
// method explicitly, to avoid setting it accidentally.
void SetSystemPriority();
#if defined(OS_CHROMEOS)
void set_system_notification_warning_level(
SystemNotificationWarningLevel warning_level) {
system_notification_warning_level_ = warning_level;
}
SystemNotificationWarningLevel system_notification_warning_level() const {
return system_notification_warning_level_;
}
#endif // defined(OS_CHROMEOS)
const std::string& custom_view_type() const { return custom_view_type_; }
void set_custom_view_type(const std::string& custom_view_type) {
DCHECK_EQ(type(), NotificationType::NOTIFICATION_TYPE_CUSTOM);
......@@ -475,6 +486,12 @@ class MESSAGE_CENTER_PUBLIC_EXPORT Notification {
// creating the view for this notification. The type should match the type
// used to register the factory in MessageViewFactory.
std::string custom_view_type_;
#if defined(OS_CHROMEOS)
// The warning level of a system notification.
SystemNotificationWarningLevel system_notification_warning_level_ =
SystemNotificationWarningLevel::NORMAL;
#endif // defined(OS_CHROMEOS)
};
} // namespace message_center
......
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