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_popup_collection.h" | 5 #include "ui/message_center/views/message_popup_collection.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
76 } | 76 } |
77 | 77 |
78 void MessagePopupCollection::ClickOnNotification( | 78 void MessagePopupCollection::ClickOnNotification( |
79 const std::string& notification_id) { | 79 const std::string& notification_id) { |
80 message_center_->ClickOnNotification(notification_id); | 80 message_center_->ClickOnNotification(notification_id); |
81 } | 81 } |
82 | 82 |
83 void MessagePopupCollection::RemoveNotification( | 83 void MessagePopupCollection::RemoveNotification( |
84 const std::string& notification_id, | 84 const std::string& notification_id, |
85 bool by_user) { | 85 bool by_user) { |
86 message_center_->RemoveNotification(notification_id, by_user); | 86 |
87 NotificationList::PopupNotifications notifications = | |
88 message_center_->GetPopupNotifications(); | |
89 for (NotificationList::PopupNotifications::iterator iter = | |
90 notifications.begin(); iter != notifications.end(); ++iter) { | |
91 Notification* notification = *iter; | |
92 DCHECK(notification); | |
93 | |
94 if (notification->id() != notification_id) | |
95 continue; | |
96 | |
97 // Don't remove the notification only when it's not closable. | |
98 if (notification->closable()) | |
dewittj
2016/02/03 19:31:37
Should there be an else clause, something like "Ma
yoshiki
2016/02/07 17:49:41
Good point. Done.
| |
99 message_center_->RemoveNotification(notification_id, by_user); | |
100 | |
101 break; | |
102 } | |
87 } | 103 } |
88 | 104 |
89 scoped_ptr<ui::MenuModel> MessagePopupCollection::CreateMenuModel( | 105 scoped_ptr<ui::MenuModel> MessagePopupCollection::CreateMenuModel( |
90 const NotifierId& notifier_id, | 106 const NotifierId& notifier_id, |
91 const base::string16& display_source) { | 107 const base::string16& display_source) { |
92 return tray_->CreateNotificationMenuModel(notifier_id, display_source); | 108 return tray_->CreateNotificationMenuModel(notifier_id, display_source); |
93 } | 109 } |
94 | 110 |
95 bool MessagePopupCollection::HasClickedListener( | 111 bool MessagePopupCollection::HasClickedListener( |
96 const std::string& notification_id) { | 112 const std::string& notification_id) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 bool top_down = alignment_delegate_->IsTopDown(); | 148 bool top_down = alignment_delegate_->IsTopDown(); |
133 int base = GetBaseLine(toasts_.empty() ? NULL : toasts_.back()); | 149 int base = GetBaseLine(toasts_.empty() ? NULL : toasts_.back()); |
134 | 150 |
135 // Iterate in the reverse order to keep the oldest toasts on screen. Newer | 151 // Iterate in the reverse order to keep the oldest toasts on screen. Newer |
136 // items may be ignored if there are no room to place them. | 152 // items may be ignored if there are no room to place them. |
137 for (NotificationList::PopupNotifications::const_reverse_iterator iter = | 153 for (NotificationList::PopupNotifications::const_reverse_iterator iter = |
138 popups.rbegin(); iter != popups.rend(); ++iter) { | 154 popups.rbegin(); iter != popups.rend(); ++iter) { |
139 if (FindToast((*iter)->id())) | 155 if (FindToast((*iter)->id())) |
140 continue; | 156 continue; |
141 | 157 |
158 Notification notification = *(*iter); | |
159 // Override closable status, since toasts should be closable even when it's | |
160 // non-closable. | |
161 notification.set_closable(true); | |
142 NotificationView* view = | 162 NotificationView* view = |
143 NotificationView::Create(NULL, | 163 NotificationView::Create(NULL, |
144 *(*iter), | 164 notification, |
145 true); // Create top-level notification. | 165 true); // Create top-level notification. |
146 view->set_context_menu_controller(context_menu_controller_.get()); | 166 view->set_context_menu_controller(context_menu_controller_.get()); |
147 int view_height = ToastContentsView::GetToastSizeForView(view).height(); | 167 int view_height = ToastContentsView::GetToastSizeForView(view).height(); |
148 int height_available = | 168 int height_available = |
149 top_down ? alignment_delegate_->GetWorkAreaBottom() - base : base; | 169 top_down ? alignment_delegate_->GetWorkAreaBottom() - base : base; |
150 | 170 |
151 if (height_available - view_height - kToastMarginY < 0) { | 171 if (height_available - view_height - kToastMarginY < 0) { |
152 delete view; | 172 delete view; |
153 break; | 173 break; |
154 } | 174 } |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
509 views::Widget* widget = (*iter)->GetWidget(); | 529 views::Widget* widget = (*iter)->GetWidget(); |
510 if (widget) | 530 if (widget) |
511 return widget->GetWindowBoundsInScreen(); | 531 return widget->GetWindowBoundsInScreen(); |
512 break; | 532 break; |
513 } | 533 } |
514 } | 534 } |
515 return gfx::Rect(); | 535 return gfx::Rect(); |
516 } | 536 } |
517 | 537 |
518 } // namespace message_center | 538 } // namespace message_center |
OLD | NEW |