OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/system/web_notification/web_notification_tray.h" | 5 #include "ash/system/web_notification/web_notification_tray.h" |
6 | 6 |
7 #include "ash/system/status_area_widget.h" | 7 #include "ash/system/status_area_widget.h" |
8 #include "ash/system/tray/system_tray.h" | 8 #include "ash/system/tray/system_tray.h" |
9 #include "ash/system/tray/tray_bubble_view.h" | 9 #include "ash/system/tray/tray_bubble_view.h" |
10 #include "ash/system/tray/tray_constants.h" | 10 #include "ash/system/tray/tray_constants.h" |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 bubble_view_(NULL), | 710 bubble_view_(NULL), |
711 bubble_widget_(NULL), | 711 bubble_widget_(NULL), |
712 contents_view_(NULL), | 712 contents_view_(NULL), |
713 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { | 713 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { |
714 views::View* anchor = tray->tray_container(); | 714 views::View* anchor = tray->tray_container(); |
715 TrayBubbleView::InitParams init_params(TrayBubbleView::ANCHOR_TYPE_TRAY, | 715 TrayBubbleView::InitParams init_params(TrayBubbleView::ANCHOR_TYPE_TRAY, |
716 tray->shelf_alignment()); | 716 tray->shelf_alignment()); |
717 init_params.bubble_width = kWebNotificationWidth; | 717 init_params.bubble_width = kWebNotificationWidth; |
718 if (bubble_type == BUBBLE_TYPE_MESAGE_CENTER) { | 718 if (bubble_type == BUBBLE_TYPE_MESAGE_CENTER) { |
719 init_params.max_height = kWebNotificationBubbleMaxHeight; | 719 init_params.max_height = kWebNotificationBubbleMaxHeight; |
720 init_params.can_activate = true; | |
721 } else { | 720 } else { |
722 init_params.arrow_color = kBackgroundColor; | 721 init_params.arrow_color = kBackgroundColor; |
723 init_params.close_on_deactivate = false; | 722 init_params.close_on_deactivate = false; |
724 } | 723 } |
725 if (tray_->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { | 724 if (tray_->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { |
726 gfx::Point bounds(anchor->width() / 2, 0); | 725 gfx::Point bounds(anchor->width() / 2, 0); |
727 ConvertPointToWidget(anchor, &bounds); | 726 ConvertPointToWidget(anchor, &bounds); |
728 init_params.arrow_offset = bounds.x(); | 727 init_params.arrow_offset = bounds.x(); |
729 } | 728 } |
730 bubble_view_ = TrayBubbleView::Create(anchor, this, init_params); | 729 bubble_view_ = TrayBubbleView::Create(anchor, this, init_params); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 virtual void OnMouseExitedView() OVERRIDE { | 783 virtual void OnMouseExitedView() OVERRIDE { |
785 StartAutoCloseTimer(); | 784 StartAutoCloseTimer(); |
786 tray_->UpdateShouldShowLauncher(); | 785 tray_->UpdateShouldShowLauncher(); |
787 } | 786 } |
788 | 787 |
789 virtual void OnClickedOutsideView() OVERRIDE { | 788 virtual void OnClickedOutsideView() OVERRIDE { |
790 // May delete |this|. | 789 // May delete |this|. |
791 tray_->HideMessageCenterBubble(); | 790 tray_->HideMessageCenterBubble(); |
792 } | 791 } |
793 | 792 |
794 virtual string16 GetAccessibleName() OVERRIDE { | |
795 return tray_->GetAccessibleName(); | |
796 } | |
797 | |
798 // Overridden from views::WidgetObserver: | 793 // Overridden from views::WidgetObserver: |
799 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE { | 794 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE { |
800 CHECK_EQ(bubble_widget_, widget); | 795 CHECK_EQ(bubble_widget_, widget); |
801 bubble_widget_ = NULL; | 796 bubble_widget_ = NULL; |
802 tray_->HideBubble(this); // Will destroy |this|. | 797 tray_->HideBubble(this); // Will destroy |this|. |
803 } | 798 } |
804 | 799 |
805 private: | 800 private: |
806 void UpdateBubbleView() { | 801 void UpdateBubbleView() { |
807 const WebNotificationList::Notifications& notifications = | 802 const WebNotificationList::Notifications& notifications = |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 void WebNotificationTray::AnchorUpdated() { | 990 void WebNotificationTray::AnchorUpdated() { |
996 if (notification_bubble_.get()) { | 991 if (notification_bubble_.get()) { |
997 notification_bubble_->bubble_view()->UpdateBubble(); | 992 notification_bubble_->bubble_view()->UpdateBubble(); |
998 // Ensure that the notification buble is above the launcher/status area. | 993 // Ensure that the notification buble is above the launcher/status area. |
999 notification_bubble_->bubble_view()->GetWidget()->StackAtTop(); | 994 notification_bubble_->bubble_view()->GetWidget()->StackAtTop(); |
1000 } | 995 } |
1001 if (message_center_bubble_.get()) | 996 if (message_center_bubble_.get()) |
1002 message_center_bubble_->bubble_view()->UpdateBubble(); | 997 message_center_bubble_->bubble_view()->UpdateBubble(); |
1003 } | 998 } |
1004 | 999 |
1005 string16 WebNotificationTray::GetAccessibleName() { | |
1006 return l10n_util::GetStringUTF16( | |
1007 IDS_ASH_WEB_NOTIFICATION_TRAY_ACCESSIBLE_NAME); | |
1008 } | |
1009 | |
1010 // Protected methods (invoked only from Bubble and its child classes) | 1000 // Protected methods (invoked only from Bubble and its child classes) |
1011 | 1001 |
1012 void WebNotificationTray::SendRemoveNotification(const std::string& id) { | 1002 void WebNotificationTray::SendRemoveNotification(const std::string& id) { |
1013 // If this is the only notification in the list, close the bubble. | 1003 // If this is the only notification in the list, close the bubble. |
1014 if (notification_list_->notifications().size() == 1 && | 1004 if (notification_list_->notifications().size() == 1 && |
1015 id == notification_list_->GetFirstId()) { | 1005 id == notification_list_->GetFirstId()) { |
1016 HideMessageCenterBubble(); | 1006 HideMessageCenterBubble(); |
1017 } | 1007 } |
1018 if (delegate_) | 1008 if (delegate_) |
1019 delegate_->NotificationRemoved(id); | 1009 delegate_->NotificationRemoved(id); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1110 } else if (bubble == notification_bubble()) { | 1100 } else if (bubble == notification_bubble()) { |
1111 HideNotificationBubble(); | 1101 HideNotificationBubble(); |
1112 } | 1102 } |
1113 } | 1103 } |
1114 | 1104 |
1115 bool WebNotificationTray::HasNotificationForTest(const std::string& id) const { | 1105 bool WebNotificationTray::HasNotificationForTest(const std::string& id) const { |
1116 return notification_list_->HasNotification(id); | 1106 return notification_list_->HasNotification(id); |
1117 } | 1107 } |
1118 | 1108 |
1119 } // namespace ash | 1109 } // namespace ash |
OLD | NEW |