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/message_center_impl.h" | 5 #include "ui/message_center/message_center_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <deque> | 8 #include <deque> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 NotificationList::Notifications notifications = | 636 NotificationList::Notifications notifications = |
637 notification_list_->GetNotificationsByNotifierId(notifier_id); | 637 notification_list_->GetNotificationsByNotifierId(notifier_id); |
638 for (const auto& notification : notifications) | 638 for (const auto& notification : notifications) |
639 RemoveNotification(notification->id(), false); | 639 RemoveNotification(notification->id(), false); |
640 if (!notifications.empty()) { | 640 if (!notifications.empty()) { |
641 notification_cache_.Rebuild( | 641 notification_cache_.Rebuild( |
642 notification_list_->GetVisibleNotifications(blockers_)); | 642 notification_list_->GetVisibleNotifications(blockers_)); |
643 } | 643 } |
644 } | 644 } |
645 | 645 |
646 void MessageCenterImpl::RemoveAllNotifications(bool by_user) { | 646 void MessageCenterImpl::RemoveAllNotifications(bool by_user, RemoveType type) { |
647 // Using not |blockers_| but an empty list since it wants to remove literally | 647 bool remove_pinned = (type == RemoveType::NON_PINNED); |
648 // all notifications. | |
649 RemoveNotifications(by_user, NotificationBlockers()); | |
650 } | |
651 | 648 |
652 void MessageCenterImpl::RemoveAllVisibleNotifications(bool by_user) { | 649 const NotificationBlockers& blockers = |
653 RemoveNotifications(by_user, blockers_); | 650 (type == RemoveType::ALL ? NotificationBlockers() /* empty blockers */ |
654 } | 651 : blockers_ /* use default blockers */); |
655 | 652 |
656 void MessageCenterImpl::RemoveNotifications( | |
657 bool by_user, | |
658 const NotificationBlockers& blockers) { | |
659 const NotificationList::Notifications notifications = | 653 const NotificationList::Notifications notifications = |
660 notification_list_->GetVisibleNotifications(blockers); | 654 notification_list_->GetVisibleNotifications(blockers); |
661 std::set<std::string> ids; | 655 std::set<std::string> ids; |
662 for (const auto& notification : notifications) { | 656 for (const auto& notification : notifications) { |
| 657 if (!remove_pinned && notification->pinned()) |
| 658 continue; |
| 659 |
663 ids.insert(notification->id()); | 660 ids.insert(notification->id()); |
664 scoped_refptr<NotificationDelegate> delegate = notification->delegate(); | 661 scoped_refptr<NotificationDelegate> delegate = notification->delegate(); |
665 if (delegate.get()) | 662 if (delegate.get()) |
666 delegate->Close(by_user); | 663 delegate->Close(by_user); |
667 notification_list_->RemoveNotification(notification->id()); | 664 notification_list_->RemoveNotification(notification->id()); |
668 } | 665 } |
669 | 666 |
670 if (!ids.empty()) { | 667 if (!ids.empty()) { |
671 notification_cache_.Rebuild( | 668 notification_cache_.Rebuild( |
672 notification_list_->GetVisibleNotifications(blockers_)); | 669 notification_list_->GetVisibleNotifications(blockers_)); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 } | 887 } |
891 | 888 |
892 void MessageCenterImpl::EnableChangeQueueForTest(bool enable) { | 889 void MessageCenterImpl::EnableChangeQueueForTest(bool enable) { |
893 if (enable) | 890 if (enable) |
894 notification_queue_.reset(new internal::ChangeQueue()); | 891 notification_queue_.reset(new internal::ChangeQueue()); |
895 else | 892 else |
896 notification_queue_.reset(); | 893 notification_queue_.reset(); |
897 } | 894 } |
898 | 895 |
899 } // namespace message_center | 896 } // namespace message_center |
OLD | NEW |