diff options
author | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-12 01:52:21 +0000 |
---|---|---|
committer | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-12 01:52:21 +0000 |
commit | b78d79a574bf2171b3d55b0fcb0274b99b6b0518 (patch) | |
tree | 546b6c5e081928295985973e7be2543a2b69437c /ash/system | |
parent | 85ac048edc06d358ae5562aaf91e07a44db924a7 (diff) | |
download | chromium_src-b78d79a574bf2171b3d55b0fcb0274b99b6b0518.zip chromium_src-b78d79a574bf2171b3d55b0fcb0274b99b6b0518.tar.gz chromium_src-b78d79a574bf2171b3d55b0fcb0274b99b6b0518.tar.bz2 |
Introduces NotificationBlocker.
This CL replaces the existing blocking code by the new notification
blocker implementations. The new implementation detects the current
status more precisely, and each platform can implement different
blocking behaviors.
BUG=256404, 260060
TEST=covered by new tests
R=dewittj@chromium.org, stevenjb@chromium.org
Review URL: https://chromiumcodereview.appspot.com/23694021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222698 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/system')
-rw-r--r-- | ash/system/chromeos/managed/tray_locally_managed_user.cc | 3 | ||||
-rw-r--r-- | ash/system/chromeos/network/network_connect.cc | 2 | ||||
-rw-r--r-- | ash/system/chromeos/network/network_state_notifier.cc | 4 | ||||
-rw-r--r-- | ash/system/chromeos/power/tray_power.cc | 2 | ||||
-rw-r--r-- | ash/system/chromeos/screen_security/screen_capture_tray_item.cc | 2 | ||||
-rw-r--r-- | ash/system/chromeos/screen_security/screen_share_tray_item.cc | 2 | ||||
-rw-r--r-- | ash/system/chromeos/tray_display.cc | 2 | ||||
-rw-r--r-- | ash/system/ime/tray_ime.cc | 2 | ||||
-rw-r--r-- | ash/system/locale/locale_notification_controller.cc | 2 | ||||
-rw-r--r-- | ash/system/session_length_limit/tray_session_length_limit.cc | 3 | ||||
-rw-r--r-- | ash/system/status_area_widget.cc | 2 | ||||
-rw-r--r-- | ash/system/system_notifier.cc | 27 | ||||
-rw-r--r-- | ash/system/system_notifier.h | 9 | ||||
-rw-r--r-- | ash/system/web_notification/web_notification_tray.cc | 20 | ||||
-rw-r--r-- | ash/system/web_notification/web_notification_tray.h | 3 |
15 files changed, 49 insertions, 36 deletions
diff --git a/ash/system/chromeos/managed/tray_locally_managed_user.cc b/ash/system/chromeos/managed/tray_locally_managed_user.cc index 4038b323..d1cc459 100644 --- a/ash/system/chromeos/managed/tray_locally_managed_user.cc +++ b/ash/system/chromeos/managed/tray_locally_managed_user.cc @@ -83,7 +83,8 @@ void TrayLocallyManagedUser::CreateOrUpdateNotification( base::string16() /* body is empty */, bundle.GetImageNamed(IDR_AURA_UBER_TRAY_MANAGED_USER), base::string16() /* display_source */, - message_center::NotifierId(NOTIFIER_LOCALLY_MANAGED_USER), + message_center::NotifierId( + system_notifier::NOTIFIER_LOCALLY_MANAGED_USER), message_center::RichNotificationData(), NULL /* no delegate */)); notification->SetSystemPriority(); diff --git a/ash/system/chromeos/network/network_connect.cc b/ash/system/chromeos/network/network_connect.cc index 0f90002..23fd8d9 100644 --- a/ash/system/chromeos/network/network_connect.cc +++ b/ash/system/chromeos/network/network_connect.cc @@ -386,7 +386,7 @@ void ShowMobileSetup(const std::string& service_path) { UTF8ToUTF16(cellular->name())), ui::ResourceBundle::GetSharedInstance().GetImageNamed( IDR_AURA_UBER_TRAY_CELLULAR_NETWORK_FAILED), - ash::NOTIFIER_NETWORK, + ash::system_notifier::NOTIFIER_NETWORK, base::Bind(&ash::network_connect::ShowNetworkSettings, service_path))); return; diff --git a/ash/system/chromeos/network/network_state_notifier.cc b/ash/system/chromeos/network/network_state_notifier.cc index f54c3e7..634aca4 100644 --- a/ash/system/chromeos/network/network_state_notifier.cc +++ b/ash/system/chromeos/network/network_state_notifier.cc @@ -67,7 +67,7 @@ void ShowErrorNotification(const std::string& notification_id, title, message, icon, - ash::NOTIFIER_NETWORK_ERROR, + ash::system_notifier::NOTIFIER_NETWORK_ERROR, callback)); } @@ -189,7 +189,7 @@ void NetworkStateNotifier::UpdateCellularActivating( l10n_util::GetStringFUTF16(IDS_NETWORK_CELLULAR_ACTIVATED, UTF8ToUTF16((cellular->name()))), icon, - NOTIFIER_NETWORK, + system_notifier::NOTIFIER_NETWORK, base::Bind(&ash::network_connect::ShowNetworkSettings, cellular->path()))); } diff --git a/ash/system/chromeos/power/tray_power.cc b/ash/system/chromeos/power/tray_power.cc index 0125d1e..b52f1dd 100644 --- a/ash/system/chromeos/power/tray_power.cc +++ b/ash/system/chromeos/power/tray_power.cc @@ -208,7 +208,7 @@ bool TrayPower::MaybeShowUsbChargerNotification() { rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_LOW_POWER_CHARGER_MESSAGE), rb.GetImageNamed(IDR_AURA_NOTIFICATION_LOW_POWER_CHARGER), base::string16(), - message_center::NotifierId(NOTIFIER_POWER), + message_center::NotifierId(system_notifier::NOTIFIER_POWER), message_center::RichNotificationData(), NULL)); message_center_->AddNotification(notification.Pass()); diff --git a/ash/system/chromeos/screen_security/screen_capture_tray_item.cc b/ash/system/chromeos/screen_security/screen_capture_tray_item.cc index 6d67f5f..2998b3b 100644 --- a/ash/system/chromeos/screen_security/screen_capture_tray_item.cc +++ b/ash/system/chromeos/screen_security/screen_capture_tray_item.cc @@ -63,7 +63,7 @@ void ScreenCaptureTrayItem::CreateOrUpdateNotification() { base::string16() /* body is blank */, resource_bundle.GetImageNamed(IDR_AURA_UBER_TRAY_DISPLAY), base::string16() /* display_source */, - message_center::NotifierId(NOTIFIER_SCREEN_CAPTURE), + message_center::NotifierId(system_notifier::NOTIFIER_SCREEN_CAPTURE), data, new tray::ScreenNotificationDelegate(this))); notification->SetSystemPriority(); diff --git a/ash/system/chromeos/screen_security/screen_share_tray_item.cc b/ash/system/chromeos/screen_security/screen_share_tray_item.cc index 78d99f1..bf70c44 100644 --- a/ash/system/chromeos/screen_security/screen_share_tray_item.cc +++ b/ash/system/chromeos/screen_security/screen_share_tray_item.cc @@ -73,7 +73,7 @@ void ScreenShareTrayItem::CreateOrUpdateNotification() { base::string16() /* body is blank */, resource_bundle.GetImageNamed(IDR_AURA_UBER_TRAY_DISPLAY), base::string16() /* display_source */, - message_center::NotifierId(NOTIFIER_SCREEN_SHARE), + message_center::NotifierId(system_notifier::NOTIFIER_SCREEN_SHARE), data, new tray::ScreenNotificationDelegate(this))); notification->SetSystemPriority(); diff --git a/ash/system/chromeos/tray_display.cc b/ash/system/chromeos/tray_display.cc index 5a23927..15ac17c 100644 --- a/ash/system/chromeos/tray_display.cc +++ b/ash/system/chromeos/tray_display.cc @@ -363,7 +363,7 @@ void TrayDisplay::CreateOrUpdateNotification( additional_message, bundle.GetImageNamed(IDR_AURA_UBER_TRAY_DISPLAY), base::string16(), // display_source - message_center::NotifierId(NOTIFIER_DISPLAY), + message_center::NotifierId(system_notifier::NOTIFIER_DISPLAY), message_center::RichNotificationData(), new message_center::HandleNotificationClickedDelegate( base::Bind(&OpenSettings)))); diff --git a/ash/system/ime/tray_ime.cc b/ash/system/ime/tray_ime.cc index 7fd3b3d..fdbf53b 100644 --- a/ash/system/ime/tray_ime.cc +++ b/ash/system/ime/tray_ime.cc @@ -231,7 +231,7 @@ void TrayIME::UpdateOrCreateNotification() { base::string16(), // message bundle.GetImageNamed(IDR_AURA_UBER_TRAY_IME), base::string16(), // display_source - message_center::NotifierId(NOTIFIER_INPUT_METHOD), + message_center::NotifierId(system_notifier::NOTIFIER_INPUT_METHOD), message_center::RichNotificationData(), new message_center::HandleNotificationClickedDelegate( base::Bind(&TrayIME::PopupDetailedView, diff --git a/ash/system/locale/locale_notification_controller.cc b/ash/system/locale/locale_notification_controller.cc index b23bf6d..ab6f691 100644 --- a/ash/system/locale/locale_notification_controller.cc +++ b/ash/system/locale/locale_notification_controller.cc @@ -117,7 +117,7 @@ void LocaleNotificationController::OnLocaleChanged( base::string16() /* message */, bundle.GetImageNamed(IDR_AURA_UBER_TRAY_LOCALE), base::string16() /* display_source */, - message_center::NotifierId(NOTIFIER_LOCALE), + message_center::NotifierId(system_notifier::NOTIFIER_LOCALE), optional, new LocaleNotificationDelegate(delegate))); message_center::MessageCenter::Get()->AddNotification(notification.Pass()); diff --git a/ash/system/session_length_limit/tray_session_length_limit.cc b/ash/system/session_length_limit/tray_session_length_limit.cc index 4357b7c..6ca887a 100644 --- a/ash/system/session_length_limit/tray_session_length_limit.cc +++ b/ash/system/session_length_limit/tray_session_length_limit.cc @@ -102,7 +102,8 @@ void CreateOrUpdateNotification(const base::TimeDelta& remaining_time, base::string16() /* message */, bundle.GetImageNamed(IDR_AURA_UBER_TRAY_SESSION_LENGTH_LIMIT_TIMER), base::string16() /* display_source */, - message_center::NotifierId(NOTIFIER_SESSION_LENGTH_TIMEOUT), + message_center::NotifierId( + system_notifier::NOTIFIER_SESSION_LENGTH_TIMEOUT), data, NULL /* delegate */)); notification->SetSystemPriority(); diff --git a/ash/system/status_area_widget.cc b/ash/system/status_area_widget.cc index 19649b1..ed7e708 100644 --- a/ash/system/status_area_widget.cc +++ b/ash/system/status_area_widget.cc @@ -142,8 +142,6 @@ void StatusAreaWidget::UpdateAfterLoginStatusChange( login_status_ = login_status; if (system_tray_) system_tray_->UpdateAfterLoginStatusChange(login_status); - if (web_notification_tray_) - web_notification_tray_->UpdateAfterLoginStatusChange(login_status); if (logout_button_tray_) logout_button_tray_->UpdateAfterLoginStatusChange(login_status); } diff --git a/ash/system/system_notifier.cc b/ash/system/system_notifier.cc index a765ee1..554c0f9 100644 --- a/ash/system/system_notifier.cc +++ b/ash/system/system_notifier.cc @@ -7,6 +7,19 @@ #include "base/logging.h" namespace ash { +namespace system_notifier { + +namespace { + +// See http://dev.chromium.org/chromium-os/chromiumos-design-docs/ +// system-notifications for the reasoning. +const AshSystemComponentNotifierType kAlwaysShownNotifierIds[] = { + NOTIFIER_DISPLAY, + NOTIFIER_DISPLAY_ERROR, + NOTIFIER_POWER, +}; + +} // namespace std::string SystemComponentTypeToString(AshSystemComponentNotifierType type) { if (type == NOTIFIER_SCREENSHOT) @@ -17,4 +30,16 @@ std::string SystemComponentTypeToString(AshSystemComponentNotifierType type) { return std::string(); } -} // namespace +bool ShouldAlwaysShowPopups(const message_center::NotifierId& notifier_id) { + if (notifier_id.type != message_center::NotifierId::SYSTEM_COMPONENT) + return false; + + for (size_t i = 0; i < arraysize(kAlwaysShownNotifierIds); ++i) { + if (notifier_id.system_component_type == kAlwaysShownNotifierIds[i]) + return true; + } + return false; +} + +} // namespace system_notifier +} // namespace ash diff --git a/ash/system/system_notifier.h b/ash/system/system_notifier.h index 1680a1b..3d823c8 100644 --- a/ash/system/system_notifier.h +++ b/ash/system/system_notifier.h @@ -8,8 +8,10 @@ #include <string> #include "ash/ash_export.h" +#include "ui/message_center/notifier_settings.h" namespace ash { +namespace system_notifier { enum AshSystemComponentNotifierType { NOTIFIER_NO_SYSTEM_COMPONENT = -1, @@ -33,6 +35,13 @@ enum AshSystemComponentNotifierType { ASH_EXPORT std::string SystemComponentTypeToString( AshSystemComponentNotifierType type); +// Returns true if notifications from |notifier_id| should always appear as +// popups. "Always appear" means the popups should appear even in login screen, +// lock screen, or fullscreen state. +ASH_EXPORT bool ShouldAlwaysShowPopups( + const message_center::NotifierId& notifier_id); + +} // namespace system_notifier } // namespace ash #endif // ASH_SYSTEM_SYSTEM_NOTIFIER_H_ diff --git a/ash/system/web_notification/web_notification_tray.cc b/ash/system/web_notification/web_notification_tray.cc index d592afe..ce8ad98 100644 --- a/ash/system/web_notification/web_notification_tray.cc +++ b/ash/system/web_notification/web_notification_tray.cc @@ -401,10 +401,8 @@ void WebNotificationTray::SetSystemTrayHeight(int height) { } bool WebNotificationTray::ShowPopups() { - if (status_area_widget()->login_status() == user::LOGGED_IN_LOCKED || - message_center_bubble()) { + if (message_center_bubble()) return false; - } popup_collection_.reset(new message_center::MessagePopupCollection( ash::Shell::GetContainer( @@ -431,22 +429,6 @@ bool WebNotificationTray::ShouldShowMessageCenter() { status_area_widget()->system_tray()->HasNotificationBubble()); } -void WebNotificationTray::UpdateAfterLoginStatusChange( - user::LoginStatus login_status) { - if (login_status == user::LOGGED_IN_LOCKED) { - show_message_center_on_unlock_ = - message_center_tray_->HideMessageCenterBubble(); - message_center_tray_->HidePopupBubble(); - } else { - // Only try once to show the message center bubble on login status change, - // so always set |show_message_center_on_unlock_| to false. - if (show_message_center_on_unlock_) - message_center_tray_->ShowMessageCenterBubble(); - show_message_center_on_unlock_ = false; - } - OnMessageCenterTrayChanged(); -} - bool WebNotificationTray::ShouldBlockLauncherAutoHide() const { return should_block_shelf_auto_hide_; } diff --git a/ash/system/web_notification/web_notification_tray.h b/ash/system/web_notification/web_notification_tray.h index be449da..25a236c 100644 --- a/ash/system/web_notification/web_notification_tray.h +++ b/ash/system/web_notification/web_notification_tray.h @@ -62,9 +62,6 @@ class ASH_EXPORT WebNotificationTray // shown in the system tray side. void SetSystemTrayHeight(int height); - // Updates tray visibility login status of the system changes. - void UpdateAfterLoginStatusChange(user::LoginStatus login_status); - // Returns true if it should block the auto hide behavior of the launcher. bool ShouldBlockLauncherAutoHide() const; |