Index: ash/system/web_notification/web_notification_tray.cc |
diff --git a/ash/system/web_notification/web_notification_tray.cc b/ash/system/web_notification/web_notification_tray.cc |
index 11f1773897a3dc11a3a9409d1b1b34d4884ca041..0ee3744b2ba589295e50670ce961ad40254189a6 100644 |
--- a/ash/system/web_notification/web_notification_tray.cc |
+++ b/ash/system/web_notification/web_notification_tray.cc |
@@ -21,6 +21,7 @@ |
#include "ui/base/models/simple_menu_model.h" |
#include "ui/base/resource/resource_bundle.h" |
#include "ui/gfx/image/image_skia_operations.h" |
+#include "ui/gfx/screen.h" |
#include "ui/views/controls/button/button.h" |
#include "ui/views/controls/button/menu_button.h" |
#include "ui/views/controls/button/menu_button_listener.h" |
@@ -713,6 +714,7 @@ class WebNotificationTray::Bubble : public TrayBubbleView::Host, |
init_params.bubble_width = kWebNotificationWidth; |
if (bubble_type == BUBBLE_TYPE_MESAGE_CENTER) { |
init_params.max_height = kWebNotificationBubbleMaxHeight; |
+ init_params.can_activate = true; |
} else { |
init_params.arrow_color = kBackgroundColor; |
init_params.close_on_deactivate = false; |
@@ -758,7 +760,12 @@ class WebNotificationTray::Bubble : public TrayBubbleView::Host, |
base::TimeDelta::FromMilliseconds(kUpdateDelayMs)); |
} |
+ bool IsVisible() const { |
+ return bubble_widget_ && bubble_widget_->IsVisible(); |
+ } |
+ |
views::Widget* bubble_widget() const { return bubble_widget_; } |
+ TrayBubbleView* bubble_view() const { return bubble_view_; } |
// Overridden from TrayBubbleView::Host. |
virtual void BubbleViewDestroyed() OVERRIDE { |
@@ -768,10 +775,12 @@ class WebNotificationTray::Bubble : public TrayBubbleView::Host, |
virtual void OnMouseEnteredView() OVERRIDE { |
StopAutoCloseTimer(); |
+ tray_->UpdateShouldShowLauncher(); |
} |
virtual void OnMouseExitedView() OVERRIDE { |
StartAutoCloseTimer(); |
+ tray_->UpdateShouldShowLauncher(); |
} |
virtual void OnClickedOutsideView() OVERRIDE { |
@@ -779,6 +788,10 @@ class WebNotificationTray::Bubble : public TrayBubbleView::Host, |
tray_->HideMessageCenterBubble(); |
} |
+ virtual string16 GetAccessibleName() OVERRIDE { |
+ return tray_->GetAccessibleName(); |
+ } |
+ |
// Overridden from views::WidgetObserver: |
virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE { |
CHECK_EQ(bubble_widget_, widget); |
@@ -903,6 +916,7 @@ void WebNotificationTray::ShowMessageCenterBubble() { |
message_center_bubble_.reset( |
new Bubble(this, Bubble::BUBBLE_TYPE_MESAGE_CENTER)); |
status_area_widget()->SetHideSystemNotifications(true); |
+ UpdateShouldShowLauncher(); |
} |
void WebNotificationTray::HideMessageCenterBubble() { |
@@ -912,6 +926,7 @@ void WebNotificationTray::HideMessageCenterBubble() { |
show_message_center_on_unlock_ = false; |
notification_list_->SetIsVisible(false); |
status_area_widget()->SetHideSystemNotifications(false); |
+ UpdateShouldShowLauncher(); |
} |
void WebNotificationTray::ShowNotificationBubble() { |
@@ -950,6 +965,17 @@ void WebNotificationTray::UpdateAfterLoginStatusChange( |
UpdateTray(); |
} |
+bool WebNotificationTray::IsMessageCenterBubbleVisible() const { |
+ return (message_center_bubble() && message_center_bubble_->IsVisible()); |
+} |
+ |
+bool WebNotificationTray::IsMouseInNotificationBubble() const { |
+ if (!notification_bubble()) |
+ return false; |
+ return notification_bubble_->bubble_view()->GetBoundsInScreen().Contains( |
+ gfx::Screen::GetCursorScreenPoint()); |
+} |
+ |
void WebNotificationTray::SetShelfAlignment(ShelfAlignment alignment) { |
if (alignment == shelf_alignment()) |
return; |
@@ -963,6 +989,21 @@ void WebNotificationTray::SetShelfAlignment(ShelfAlignment alignment) { |
HideNotificationBubble(); |
} |
+void WebNotificationTray::AnchorUpdated() { |
+ if (notification_bubble_.get()) { |
+ notification_bubble_->bubble_view()->UpdateBubble(); |
+ // Ensure that the notification buble is above the launcher/status area. |
+ notification_bubble_->bubble_view()->GetWidget()->StackAtTop(); |
+ } |
+ if (message_center_bubble_.get()) |
+ message_center_bubble_->bubble_view()->UpdateBubble(); |
+} |
+ |
+string16 WebNotificationTray::GetAccessibleName() { |
+ return l10n_util::GetStringUTF16( |
+ IDS_ASH_WEB_NOTIFICATION_TRAY_ACCESSIBLE_NAME); |
+} |
+ |
// Protected methods (invoked only from Bubble and its child classes) |
void WebNotificationTray::SendRemoveNotification(const std::string& id) { |
@@ -1038,7 +1079,10 @@ void WebNotificationTray::UpdateTray() { |
count_label_->SetEnabledColor( |
(notification_list()->notifications().size() == 0) ? |
kMessageCountDimmedColor : kMessageCountColor); |
- SetVisible((status_area_widget()->login_status() != user::LOGGED_IN_NONE)); |
+ bool is_visible = |
+ (status_area_widget()->login_status() != user::LOGGED_IN_NONE) && |
+ (status_area_widget()->login_status() != user::LOGGED_IN_LOCKED); |
+ SetVisible(is_visible); |
Layout(); |
SchedulePaint(); |
} |