diff options
author | stevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-25 18:11:08 +0000 |
---|---|---|
committer | stevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-25 18:11:08 +0000 |
commit | 42973b953187b9315d6e325ccd58af44118fc5e2 (patch) | |
tree | 9f9ed0b1d7775f4c643e46890ac0cb1517eda959 /ash | |
parent | 795d46a2e7233658b05e8279b391f5d44dd480c0 (diff) | |
download | chromium_src-42973b953187b9315d6e325ccd58af44118fc5e2.zip chromium_src-42973b953187b9315d6e325ccd58af44118fc5e2.tar.gz chromium_src-42973b953187b9315d6e325ccd58af44118fc5e2.tar.bz2 |
Handle lock screen correctly for web notification tray.
BUG=133985
TEST=See issue for repro
Review URL: https://chromiumcodereview.appspot.com/10640024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143952 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/system/status_area_widget.cc | 12 | ||||
-rw-r--r-- | ash/system/status_area_widget.h | 9 | ||||
-rw-r--r-- | ash/system/web_notification/web_notification_tray.cc | 25 | ||||
-rw-r--r-- | ash/system/web_notification/web_notification_tray.h | 5 |
4 files changed, 48 insertions, 3 deletions
diff --git a/ash/system/status_area_widget.cc b/ash/system/status_area_widget.cc index 6d78f47..59d743c 100644 --- a/ash/system/status_area_widget.cc +++ b/ash/system/status_area_widget.cc @@ -278,7 +278,8 @@ namespace internal { StatusAreaWidget::StatusAreaWidget() : widget_delegate_(new internal::StatusAreaWidgetDelegate), system_tray_(NULL), - web_notification_tray_(NULL) { + web_notification_tray_(NULL), + login_status_(user::LOGGED_IN_NONE) { views::Widget::InitParams params( views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); params.delegate = widget_delegate_; @@ -373,5 +374,14 @@ void StatusAreaWidget::HideWebNotificationBubble() { system_tray_->SetHideNotifications(false); } +void StatusAreaWidget::UpdateAfterLoginStatusChange( + user::LoginStatus login_status) { + login_status_ = login_status; + if (system_tray_) + system_tray_->UpdateAfterLoginStatusChange(login_status); + if (web_notification_tray_) + web_notification_tray_->UpdateAfterLoginStatusChange(login_status); +} + } // namespace internal } // namespace ash diff --git a/ash/system/status_area_widget.h b/ash/system/status_area_widget.h index 5b66862..93393da 100644 --- a/ash/system/status_area_widget.h +++ b/ash/system/status_area_widget.h @@ -8,6 +8,7 @@ #include "ash/ash_export.h" #include "ash/launcher/background_animator.h" +#include "ash/system/user/login_status.h" #include "ash/wm/shelf_auto_hide_behavior.h" #include "ui/views/widget/widget.h" @@ -52,6 +53,11 @@ class ASH_EXPORT StatusAreaWidget : public views::Widget { void ShowWebNotificationBubble(UserAction user_action); void HideWebNotificationBubble(); + // Called by the client when the login status changes. Caches login_status + // and calls UpdateAfterLoginStatusChange for the system tray and the web + // notification tray. + void UpdateAfterLoginStatusChange(user::LoginStatus login_status); + SystemTray* system_tray() { return system_tray_; } SystemTrayDelegate* system_tray_delegate() { return system_tray_delegate_.get(); @@ -60,6 +66,8 @@ class ASH_EXPORT StatusAreaWidget : public views::Widget { return web_notification_tray_; } + user::LoginStatus login_status() const { return login_status_; } + private: void AddSystemTray(SystemTray* system_tray, ShellDelegate* shell_delegate); void AddWebNotificationTray(WebNotificationTray* web_notification_tray); @@ -69,6 +77,7 @@ class ASH_EXPORT StatusAreaWidget : public views::Widget { internal::StatusAreaWidgetDelegate* widget_delegate_; SystemTray* system_tray_; WebNotificationTray* web_notification_tray_; + user::LoginStatus login_status_; DISALLOW_COPY_AND_ASSIGN(StatusAreaWidget); }; diff --git a/ash/system/web_notification/web_notification_tray.cc b/ash/system/web_notification/web_notification_tray.cc index 1ebaf4b..608442d 100644 --- a/ash/system/web_notification/web_notification_tray.cc +++ b/ash/system/web_notification/web_notification_tray.cc @@ -660,7 +660,8 @@ WebNotificationTray::WebNotificationTray( notification_list_(new WebNotificationList()), tray_container_(NULL), icon_(NULL), - delegate_(NULL) { + delegate_(NULL), + show_bubble_on_unlock_(false) { tray_container_ = new views::View; tray_container_->set_border(views::Border::CreateEmptyBorder( kTrayBorder, kTrayBorder, kTrayBorder, kTrayBorder)); @@ -756,6 +757,10 @@ void WebNotificationTray::DisableByUrl(const std::string& id) { } void WebNotificationTray::ShowBubble() { + if (status_area_widget_->login_status() == user::LOGGED_IN_LOCKED) { + show_bubble_on_unlock_ = true; + return; + } if (bubble()) return; bubble_.reset(new Bubble(this)); @@ -763,6 +768,21 @@ void WebNotificationTray::ShowBubble() { void WebNotificationTray::HideBubble() { bubble_.reset(); + show_bubble_on_unlock_ = false; +} + +void WebNotificationTray::UpdateAfterLoginStatusChange( + user::LoginStatus login_status) { + if (login_status == user::LOGGED_IN_LOCKED) { + if (bubble()) { + HideBubble(); + show_bubble_on_unlock_ = true; + } + } else if (show_bubble_on_unlock_) { + ShowBubble(); + show_bubble_on_unlock_ = false; + } + UpdateIcon(); } void WebNotificationTray::ShowSettings(const std::string& id) { @@ -799,7 +819,8 @@ int WebNotificationTray::GetNotificationCount() const { void WebNotificationTray::UpdateIcon() { int count = GetNotificationCount(); - if (count == 0) { + if (count == 0 || + status_area_widget_->login_status() == user::LOGGED_IN_LOCKED) { SetVisible(false); } else { icon_->SetImage(gfx::ImageSkia(GetNotificationImage(count))); diff --git a/ash/system/web_notification/web_notification_tray.h b/ash/system/web_notification/web_notification_tray.h index bc0a294..a957e93 100644 --- a/ash/system/web_notification/web_notification_tray.h +++ b/ash/system/web_notification/web_notification_tray.h @@ -8,6 +8,7 @@ #include "ash/ash_export.h" #include "ash/system/tray/tray_background_view.h" +#include "ash/system/user/login_status.h" #include "base/gtest_prod_util.h" #include "ui/aura/event_filter.h" @@ -110,6 +111,9 @@ class ASH_EXPORT WebNotificationTray : public internal::TrayBackgroundView { // Hide the notification bubble. Should only be called by StatusAreaWidget. void HideBubble(); + // Updates tray visibility login status of the system changes. + void UpdateAfterLoginStatusChange(user::LoginStatus login_status); + // Request the Delegate to the settings dialog. void ShowSettings(const std::string& id); @@ -147,6 +151,7 @@ class ASH_EXPORT WebNotificationTray : public internal::TrayBackgroundView { views::View* tray_container_; views::ImageView* icon_; Delegate* delegate_; + bool show_bubble_on_unlock_; DISALLOW_COPY_AND_ASSIGN(WebNotificationTray); }; |