OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ui/message_center/views/message_center_view.h" | 5 #include "ui/message_center/views/message_center_view.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "ui/gfx/rect.h" | 21 #include "ui/gfx/rect.h" |
22 #include "ui/gfx/size.h" | 22 #include "ui/gfx/size.h" |
23 #include "ui/message_center/message_center.h" | 23 #include "ui/message_center/message_center.h" |
24 #include "ui/message_center/message_center_style.h" | 24 #include "ui/message_center/message_center_style.h" |
25 #include "ui/message_center/message_center_tray.h" | 25 #include "ui/message_center/message_center_tray.h" |
26 #include "ui/message_center/message_center_types.h" | 26 #include "ui/message_center/message_center_types.h" |
27 #include "ui/message_center/message_center_util.h" | 27 #include "ui/message_center/message_center_util.h" |
28 #include "ui/message_center/views/group_view.h" | 28 #include "ui/message_center/views/group_view.h" |
29 #include "ui/message_center/views/message_center_button_bar.h" | 29 #include "ui/message_center/views/message_center_button_bar.h" |
30 #include "ui/message_center/views/message_view.h" | 30 #include "ui/message_center/views/message_view.h" |
| 31 #include "ui/message_center/views/message_view_context_menu_controller.h" |
31 #include "ui/message_center/views/notification_view.h" | 32 #include "ui/message_center/views/notification_view.h" |
32 #include "ui/message_center/views/notifier_settings_view.h" | 33 #include "ui/message_center/views/notifier_settings_view.h" |
33 #include "ui/views/animation/bounds_animator.h" | 34 #include "ui/views/animation/bounds_animator.h" |
34 #include "ui/views/animation/bounds_animator_observer.h" | 35 #include "ui/views/animation/bounds_animator_observer.h" |
35 #include "ui/views/background.h" | 36 #include "ui/views/background.h" |
36 #include "ui/views/border.h" | 37 #include "ui/views/border.h" |
37 #include "ui/views/controls/button/button.h" | 38 #include "ui/views/controls/button/button.h" |
38 #include "ui/views/controls/label.h" | 39 #include "ui/views/controls/label.h" |
39 #include "ui/views/controls/scroll_view.h" | 40 #include "ui/views/controls/scroll_view.h" |
40 #include "ui/views/controls/scrollbar/overlay_scroll_bar.h" | 41 #include "ui/views/controls/scrollbar/overlay_scroll_bar.h" |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 tray_(tray), | 600 tray_(tray), |
600 scroller_(NULL), | 601 scroller_(NULL), |
601 settings_view_(NULL), | 602 settings_view_(NULL), |
602 button_bar_(NULL), | 603 button_bar_(NULL), |
603 top_down_(top_down), | 604 top_down_(top_down), |
604 settings_visible_(initially_settings_visible), | 605 settings_visible_(initially_settings_visible), |
605 source_view_(NULL), | 606 source_view_(NULL), |
606 source_height_(0), | 607 source_height_(0), |
607 target_view_(NULL), | 608 target_view_(NULL), |
608 target_height_(0), | 609 target_height_(0), |
609 is_closing_(false) { | 610 is_closing_(false), |
| 611 context_menu_controller_(new MessageViewContextMenuController(this)) { |
610 message_center_->AddObserver(this); | 612 message_center_->AddObserver(this); |
611 set_notify_enter_exit_on_child(true); | 613 set_notify_enter_exit_on_child(true); |
612 set_background(views::Background::CreateSolidBackground( | 614 set_background(views::Background::CreateSolidBackground( |
613 kMessageCenterBackgroundColor)); | 615 kMessageCenterBackgroundColor)); |
614 | 616 |
615 NotifierSettingsProvider* notifier_settings_provider = | 617 NotifierSettingsProvider* notifier_settings_provider = |
616 message_center_->GetNotifierSettingsProvider(); | 618 message_center_->GetNotifierSettingsProvider(); |
617 button_bar_ = new MessageCenterButtonBar(this, | 619 button_bar_ = new MessageCenterButtonBar(this, |
618 message_center, | 620 message_center, |
619 notifier_settings_provider, | 621 notifier_settings_provider, |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 if ((*iter)->id() == id) { | 999 if ((*iter)->id() == id) { |
998 bool expanded = true; | 1000 bool expanded = true; |
999 if (IsExperimentalNotificationUIEnabled()) | 1001 if (IsExperimentalNotificationUIEnabled()) |
1000 expanded = (*iter)->is_expanded(); | 1002 expanded = (*iter)->is_expanded(); |
1001 NotificationView* view = | 1003 NotificationView* view = |
1002 NotificationView::Create(this, | 1004 NotificationView::Create(this, |
1003 *(*iter), | 1005 *(*iter), |
1004 expanded, | 1006 expanded, |
1005 false); // Not creating a top-level | 1007 false); // Not creating a top-level |
1006 // notification. | 1008 // notification. |
| 1009 view->set_context_menu_controller(context_menu_controller_.get()); |
1007 view->set_scroller(scroller_); | 1010 view->set_scroller(scroller_); |
1008 message_list_view_->UpdateNotificationAt(view, index); | 1011 message_list_view_->UpdateNotificationAt(view, index); |
1009 notification_views_[id] = view; | 1012 notification_views_[id] = view; |
1010 NotificationsChanged(); | 1013 NotificationsChanged(); |
1011 break; | 1014 break; |
1012 } | 1015 } |
1013 } | 1016 } |
1014 } | 1017 } |
1015 | 1018 |
1016 void MessageCenterView::ClickOnNotification( | 1019 void MessageCenterView::ClickOnNotification( |
1017 const std::string& notification_id) { | 1020 const std::string& notification_id) { |
1018 message_center_->ClickOnNotification(notification_id); | 1021 message_center_->ClickOnNotification(notification_id); |
1019 } | 1022 } |
1020 | 1023 |
1021 void MessageCenterView::RemoveNotification(const std::string& notification_id, | 1024 void MessageCenterView::RemoveNotification(const std::string& notification_id, |
1022 bool by_user) { | 1025 bool by_user) { |
1023 message_center_->RemoveNotification(notification_id, by_user); | 1026 message_center_->RemoveNotification(notification_id, by_user); |
1024 } | 1027 } |
1025 | 1028 |
1026 void MessageCenterView::DisableNotificationsFromThisSource( | 1029 scoped_ptr<ui::MenuModel> MessageCenterView::CreateMenuModel( |
1027 const NotifierId& notifier_id) { | 1030 const NotifierId& notifier_id, |
1028 message_center_->DisableNotificationsByNotifier(notifier_id); | 1031 const base::string16& display_source) { |
1029 } | 1032 return tray_->CreateNotificationMenuModel(notifier_id, display_source); |
1030 | |
1031 void MessageCenterView::ShowNotifierSettingsBubble() { | |
1032 tray_->ShowNotifierSettingsBubble(); | |
1033 } | 1033 } |
1034 | 1034 |
1035 bool MessageCenterView::HasClickedListener(const std::string& notification_id) { | 1035 bool MessageCenterView::HasClickedListener(const std::string& notification_id) { |
1036 return message_center_->HasClickedListener(notification_id); | 1036 return message_center_->HasClickedListener(notification_id); |
1037 } | 1037 } |
1038 | 1038 |
1039 void MessageCenterView::ClickOnNotificationButton( | 1039 void MessageCenterView::ClickOnNotificationButton( |
1040 const std::string& notification_id, | 1040 const std::string& notification_id, |
1041 int button_index) { | 1041 int button_index) { |
1042 message_center_->ClickOnNotificationButton(notification_id, button_index); | 1042 message_center_->ClickOnNotificationButton(notification_id, button_index); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 const NotifierId& group_id, | 1127 const NotifierId& group_id, |
1128 const Notification& last_notification, | 1128 const Notification& last_notification, |
1129 const gfx::ImageSkia& group_icon, | 1129 const gfx::ImageSkia& group_icon, |
1130 int group_size, | 1130 int group_size, |
1131 int index) { | 1131 int index) { |
1132 GroupView* view = new GroupView(this, | 1132 GroupView* view = new GroupView(this, |
1133 group_id, | 1133 group_id, |
1134 last_notification, | 1134 last_notification, |
1135 group_icon, | 1135 group_icon, |
1136 group_size); | 1136 group_size); |
| 1137 view->set_context_menu_controller(context_menu_controller_.get()); |
1137 group_views_.push_back(view); | 1138 group_views_.push_back(view); |
1138 AddMessageViewAt(view, index); | 1139 AddMessageViewAt(view, index); |
1139 } | 1140 } |
1140 | 1141 |
1141 void MessageCenterView::AddNotificationAt(const Notification& notification, | 1142 void MessageCenterView::AddNotificationAt(const Notification& notification, |
1142 int index) { | 1143 int index) { |
1143 // NotificationViews are expanded by default here until | 1144 // NotificationViews are expanded by default here until |
1144 // http://crbug.com/217902 is fixed. TODO(dharcourt): Fix. | 1145 // http://crbug.com/217902 is fixed. TODO(dharcourt): Fix. |
1145 bool expanded = true; | 1146 bool expanded = true; |
1146 if (IsExperimentalNotificationUIEnabled()) | 1147 if (IsExperimentalNotificationUIEnabled()) |
1147 expanded = notification.is_expanded(); | 1148 expanded = notification.is_expanded(); |
1148 NotificationView* view = | 1149 NotificationView* view = |
1149 NotificationView::Create(this, | 1150 NotificationView::Create(this, |
1150 notification, | 1151 notification, |
1151 expanded, | 1152 expanded, |
1152 false); // Not creating a top-level | 1153 false); // Not creating a top-level |
1153 // notification. | 1154 // notification. |
| 1155 view->set_context_menu_controller(context_menu_controller_.get()); |
1154 notification_views_[notification.id()] = view; | 1156 notification_views_[notification.id()] = view; |
1155 AddMessageViewAt(view, index); | 1157 AddMessageViewAt(view, index); |
1156 } | 1158 } |
1157 | 1159 |
1158 void MessageCenterView::NotificationsChanged() { | 1160 void MessageCenterView::NotificationsChanged() { |
1159 bool no_message_views = notification_views_.empty() && group_views_.empty(); | 1161 bool no_message_views = notification_views_.empty() && group_views_.empty(); |
1160 | 1162 |
1161 // When the child view is removed from the hierarchy, its focus is cleared. | 1163 // When the child view is removed from the hierarchy, its focus is cleared. |
1162 // In this case we want to save which view has focus so that the user can | 1164 // In this case we want to save which view has focus so that the user can |
1163 // continue to interact with notifications in the order they were expecting. | 1165 // continue to interact with notifications in the order they were expecting. |
(...skipping 17 matching lines...) Expand all Loading... |
1181 scroller_->InvalidateLayout(); | 1183 scroller_->InvalidateLayout(); |
1182 PreferredSizeChanged(); | 1184 PreferredSizeChanged(); |
1183 Layout(); | 1185 Layout(); |
1184 } | 1186 } |
1185 | 1187 |
1186 void MessageCenterView::SetNotificationViewForTest(MessageView* view) { | 1188 void MessageCenterView::SetNotificationViewForTest(MessageView* view) { |
1187 message_list_view_->AddNotificationAt(view, 0); | 1189 message_list_view_->AddNotificationAt(view, 0); |
1188 } | 1190 } |
1189 | 1191 |
1190 } // namespace message_center | 1192 } // namespace message_center |
OLD | NEW |