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

Unified Diff: ui/message_center/views/message_popup_collection.cc

Issue 1645843003: Implement Non-Closable Notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unnecessary property. Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: ui/message_center/views/message_popup_collection.cc
diff --git a/ui/message_center/views/message_popup_collection.cc b/ui/message_center/views/message_popup_collection.cc
index 1a28ffe591e6e9f7e29b0d9876aa3ac6fcd40cb5..e4280aa787189e21b29d8b4d1b92d172a098fee6 100644
--- a/ui/message_center/views/message_popup_collection.cc
+++ b/ui/message_center/views/message_popup_collection.cc
@@ -83,7 +83,25 @@ void MessagePopupCollection::ClickOnNotification(
void MessagePopupCollection::RemoveNotification(
const std::string& notification_id,
bool by_user) {
- message_center_->RemoveNotification(notification_id, by_user);
+ NotificationList::PopupNotifications notifications =
+ message_center_->GetPopupNotifications();
+ for (NotificationList::PopupNotifications::iterator iter =
+ notifications.begin();
+ iter != notifications.end(); ++iter) {
+ Notification* notification = *iter;
+ DCHECK(notification);
+
+ if (notification->id() != notification_id)
+ continue;
+
+ // Don't remove the notification only when it's not pinned.
+ if (!notification->pinned())
+ message_center_->RemoveNotification(notification_id, by_user);
+ else
+ message_center_->MarkSinglePopupAsShown(notification_id, true /* read */);
+
+ break;
+ }
}
scoped_ptr<ui::MenuModel> MessagePopupCollection::CreateMenuModel(
@@ -139,10 +157,21 @@ void MessagePopupCollection::UpdateWidgets() {
if (FindToast((*iter)->id()))
continue;
- NotificationView* view =
- NotificationView::Create(NULL,
- *(*iter),
- true); // Create top-level notification.
+ NotificationView* view;
+ // Create top-level notification.
+#if defined(OS_CHROMEOS)
+ if ((*iter)->pinned()) {
+ Notification notification = *(*iter);
+ // Override pinned status, since toasts should be closable even when it's
+ // pinned.
+ notification.set_pinned(false);
+ view = NotificationView::Create(NULL, notification, true);
+ } else
+#endif // defined(OS_CHROMEOS)
+ {
+ view = NotificationView::Create(NULL, *(*iter), true);
+ }
+
view->set_context_menu_controller(context_menu_controller_.get());
int view_height = ToastContentsView::GetToastSizeForView(view).height();
int height_available =
« no previous file with comments | « ui/message_center/views/message_list_view.cc ('k') | ui/message_center/views/message_popup_collection_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698