diff options
author | stevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-13 22:06:10 +0000 |
---|---|---|
committer | stevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-13 22:06:10 +0000 |
commit | 82a1cc9ed2a25e8ee549e057d0d1720cc1ce0eb4 (patch) | |
tree | 97326638bcf1c22d612b62b5f451fb9ce0e52239 /ash/system/status_area_widget.cc | |
parent | 589c88ea046766f8f0f745d40a2eef2523cd7fe2 (diff) | |
download | chromium_src-82a1cc9ed2a25e8ee549e057d0d1720cc1ce0eb4.zip chromium_src-82a1cc9ed2a25e8ee549e057d0d1720cc1ce0eb4.tar.gz chromium_src-82a1cc9ed2a25e8ee549e057d0d1720cc1ce0eb4.tar.bz2 |
Add WebNotificationTray to the status area
This CL:
* Adds WebNotificationTray and its Delegate class for handling web/app notifications in the status area
* Adds hooks to SystemTray so that StatusAreaWidget can hide system notifications when web notifications are viewed
BUG=124914
TEST=WebNotificationTrayTest unittest passes, system tray functionality is unchanged, web notification tray works in ash_shell.
Review URL: https://chromiumcodereview.appspot.com/10546125
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141985 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/system/status_area_widget.cc')
-rw-r--r-- | ash/system/status_area_widget.cc | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/ash/system/status_area_widget.cc b/ash/system/status_area_widget.cc index 9c0a312..b3eb72f 100644 --- a/ash/system/status_area_widget.cc +++ b/ash/system/status_area_widget.cc @@ -13,6 +13,7 @@ #include "ash/system/status_area_widget_delegate.h" #include "ash/system/tray/system_tray.h" #include "ash/system/tray/system_tray_delegate.h" +#include "ash/system/web_notification/web_notification_tray.h" #include "base/i18n/time_formatting.h" #include "base/utf_string_conversions.h" #include "ui/aura/window.h" @@ -282,7 +283,8 @@ namespace internal { StatusAreaWidget::StatusAreaWidget() : widget_delegate_(new internal::StatusAreaWidgetDelegate), - system_tray_(NULL) { + system_tray_(NULL), + web_notification_tray_(NULL) { views::Widget::InitParams params( views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); params.delegate = widget_delegate_; @@ -300,6 +302,7 @@ StatusAreaWidget::~StatusAreaWidget() { } void StatusAreaWidget::CreateTrayViews(ShellDelegate* shell_delegate) { + AddWebNotificationTray(new WebNotificationTray(this)); AddSystemTray(new SystemTray(), shell_delegate); } @@ -309,6 +312,8 @@ void StatusAreaWidget::Shutdown() { // in the destructor if Shutdown() is not called (e.g. in tests). delete system_tray_; system_tray_ = NULL; + delete web_notification_tray_; + web_notification_tray_ = NULL; } void StatusAreaWidget::AddSystemTray(SystemTray* system_tray, @@ -327,9 +332,51 @@ void StatusAreaWidget::AddSystemTray(SystemTray* system_tray, system_tray->CreateItems(); // Called after delegate is created. } +void StatusAreaWidget::AddWebNotificationTray( + WebNotificationTray* web_notification_tray) { + web_notification_tray_ = web_notification_tray; + widget_delegate_->AddTray(web_notification_tray); +} + void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) { widget_delegate_->set_alignment(alignment); widget_delegate_->UpdateLayout(); + if (system_tray_) + system_tray_->SetShelfAlignment(alignment); + if (web_notification_tray_) + web_notification_tray_->SetShelfAlignment(alignment); +} + +void StatusAreaWidget::SetPaintsBackground( + bool value, + internal::BackgroundAnimator::ChangeType change_type) { + if (system_tray_) + system_tray_->SetPaintsBackground(value, change_type); + if (web_notification_tray_) + web_notification_tray_->SetPaintsBackground(value, change_type); +} + +void StatusAreaWidget::ShowWebNotificationBubble(UserAction user_action) { + if (system_tray_ && system_tray_->IsBubbleVisible()) { + // User actions should always hide the system tray bubble first. + DCHECK(user_action != USER_ACTION); + // Don't immediately show the web notification bubble if the system tray + // bubble is visible. + return; + } + DCHECK(web_notification_tray_); + web_notification_tray_->ShowBubble(); + // Disable showing system notifications while viewing web notifications. + if (system_tray_) + system_tray_->SetHideNotifications(true); +} + +void StatusAreaWidget::HideWebNotificationBubble() { + DCHECK(web_notification_tray_); + web_notification_tray_->HideBubble(); + // Show any hidden or suppressed system notifications. + if (system_tray_) + system_tray_->SetHideNotifications(false); } } // namespace internal |