Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: ash/system/web_notification/web_notification_tray.cc

Issue 10834338: Move non SystemTray specific code to TrayBackgroundView (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/system/web_notification/web_notification_tray.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 755
756 weak_ptr_factory_.InvalidateWeakPtrs(); // Cancel any pending update. 756 weak_ptr_factory_.InvalidateWeakPtrs(); // Cancel any pending update.
757 MessageLoop::current()->PostDelayedTask( 757 MessageLoop::current()->PostDelayedTask(
758 FROM_HERE, 758 FROM_HERE,
759 base::Bind(&WebNotificationTray::Bubble::UpdateBubbleView, 759 base::Bind(&WebNotificationTray::Bubble::UpdateBubbleView,
760 weak_ptr_factory_.GetWeakPtr()), 760 weak_ptr_factory_.GetWeakPtr()),
761 base::TimeDelta::FromMilliseconds(kUpdateDelayMs)); 761 base::TimeDelta::FromMilliseconds(kUpdateDelayMs));
762 } 762 }
763 763
764 views::Widget* bubble_widget() const { return bubble_widget_; } 764 views::Widget* bubble_widget() const { return bubble_widget_; }
765 TrayBubbleView* bubble_view() const { return bubble_view_; }
765 766
766 // Overridden from TrayBubbleView::Host. 767 // Overridden from TrayBubbleView::Host.
767 virtual void BubbleViewDestroyed() OVERRIDE { 768 virtual void BubbleViewDestroyed() OVERRIDE {
768 bubble_view_ = NULL; 769 bubble_view_ = NULL;
769 contents_view_ = NULL; 770 contents_view_ = NULL;
770 } 771 }
771 772
772 virtual void OnMouseEnteredView() OVERRIDE { 773 virtual void OnMouseEnteredView() OVERRIDE {
773 StopAutoCloseTimer(); 774 StopAutoCloseTimer();
774 } 775 }
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 internal::TrayBackgroundView::SetShelfAlignment(alignment); 960 internal::TrayBackgroundView::SetShelfAlignment(alignment);
960 if (alignment == SHELF_ALIGNMENT_BOTTOM) 961 if (alignment == SHELF_ALIGNMENT_BOTTOM)
961 tray_container()->set_size(gfx::Size(kTrayWidth, kTrayHeight)); 962 tray_container()->set_size(gfx::Size(kTrayWidth, kTrayHeight));
962 else 963 else
963 tray_container()->set_size(gfx::Size(kTraySideWidth, kTraySideHeight)); 964 tray_container()->set_size(gfx::Size(kTraySideWidth, kTraySideHeight));
964 // Destroy any existing bubble so that it will be rebuilt correctly. 965 // Destroy any existing bubble so that it will be rebuilt correctly.
965 HideMessageCenterBubble(); 966 HideMessageCenterBubble();
966 HideNotificationBubble(); 967 HideNotificationBubble();
967 } 968 }
968 969
970 void WebNotificationTray::AnchorUpdated() {
971 if (notification_bubble_.get()) {
972 notification_bubble_->bubble_view()->UpdateBubble();
973 // Ensure that the notification buble is above the launcher/status area.
974 notification_bubble_->bubble_view()->GetWidget()->StackAtTop();
975 }
976 if (message_center_bubble_.get())
977 message_center_bubble_->bubble_view()->UpdateBubble();
978 }
979
969 // Protected methods (invoked only from Bubble and its child classes) 980 // Protected methods (invoked only from Bubble and its child classes)
970 981
971 void WebNotificationTray::SendRemoveNotification(const std::string& id) { 982 void WebNotificationTray::SendRemoveNotification(const std::string& id) {
972 // If this is the only notification in the list, close the bubble. 983 // If this is the only notification in the list, close the bubble.
973 if (notification_list_->notifications().size() == 1 && 984 if (notification_list_->notifications().size() == 1 &&
974 id == notification_list_->GetFirstId()) { 985 id == notification_list_->GetFirstId()) {
975 HideMessageCenterBubble(); 986 HideMessageCenterBubble();
976 } 987 }
977 if (delegate_) 988 if (delegate_)
978 delegate_->NotificationRemoved(id); 989 delegate_->NotificationRemoved(id);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 1045
1035 // Private methods 1046 // Private methods
1036 1047
1037 void WebNotificationTray::UpdateTray() { 1048 void WebNotificationTray::UpdateTray() {
1038 count_label_->SetText(UTF8ToUTF16( 1049 count_label_->SetText(UTF8ToUTF16(
1039 GetNotificationText(notification_list()->unread_count()))); 1050 GetNotificationText(notification_list()->unread_count())));
1040 // Dim the message count text only if the message center is empty. 1051 // Dim the message count text only if the message center is empty.
1041 count_label_->SetEnabledColor( 1052 count_label_->SetEnabledColor(
1042 (notification_list()->notifications().size() == 0) ? 1053 (notification_list()->notifications().size() == 0) ?
1043 kMessageCountDimmedColor : kMessageCountColor); 1054 kMessageCountDimmedColor : kMessageCountColor);
1044 SetVisible((status_area_widget()->login_status() != user::LOGGED_IN_NONE)); 1055 bool is_visible =
1056 (status_area_widget()->login_status() != user::LOGGED_IN_NONE) &&
1057 (status_area_widget()->login_status() != user::LOGGED_IN_LOCKED);
1058 SetVisible(is_visible);
1045 Layout(); 1059 Layout();
1046 SchedulePaint(); 1060 SchedulePaint();
1047 } 1061 }
1048 1062
1049 void WebNotificationTray::UpdateTrayAndBubble() { 1063 void WebNotificationTray::UpdateTrayAndBubble() {
1050 UpdateTray(); 1064 UpdateTray();
1051 1065
1052 if (message_center_bubble()) 1066 if (message_center_bubble())
1053 message_center_bubble()->ScheduleUpdate(); 1067 message_center_bubble()->ScheduleUpdate();
1054 1068
(...skipping 11 matching lines...) Expand all
1066 } else if (bubble == notification_bubble()) { 1080 } else if (bubble == notification_bubble()) {
1067 HideNotificationBubble(); 1081 HideNotificationBubble();
1068 } 1082 }
1069 } 1083 }
1070 1084
1071 bool WebNotificationTray::HasNotificationForTest(const std::string& id) const { 1085 bool WebNotificationTray::HasNotificationForTest(const std::string& id) const {
1072 return notification_list_->HasNotification(id); 1086 return notification_list_->HasNotification(id);
1073 } 1087 }
1074 1088
1075 } // namespace ash 1089 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/web_notification/web_notification_tray.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698