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 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) { |
647 // Using not |blockers_| but an empty list since it wants to remove literally | 647 // Using not |blockers_| but an empty list since it wants to remove literally |
648 // all notifications. | 648 // all notifications. |
649 RemoveNotifications(by_user, NotificationBlockers()); | 649 RemoveNotifications(by_user, |
| 650 false /* closable only */, |
| 651 NotificationBlockers()); |
650 } | 652 } |
651 | 653 |
652 void MessageCenterImpl::RemoveAllVisibleNotifications(bool by_user) { | 654 void MessageCenterImpl::RemoveAllVisibleNotifications(bool by_user) { |
653 RemoveNotifications(by_user, blockers_); | 655 RemoveNotifications(by_user, |
| 656 false /* closable only */, |
| 657 blockers_); |
| 658 } |
| 659 |
| 660 void MessageCenterImpl::RemoveAllClosableNotifications(bool by_user) { |
| 661 RemoveNotifications(by_user, |
| 662 true /* closable only */, |
| 663 blockers_); |
654 } | 664 } |
655 | 665 |
656 void MessageCenterImpl::RemoveNotifications( | 666 void MessageCenterImpl::RemoveNotifications( |
657 bool by_user, | 667 bool by_user, |
| 668 bool only_closable, |
658 const NotificationBlockers& blockers) { | 669 const NotificationBlockers& blockers) { |
659 const NotificationList::Notifications notifications = | 670 const NotificationList::Notifications notifications = |
660 notification_list_->GetVisibleNotifications(blockers); | 671 notification_list_->GetVisibleNotifications(blockers); |
661 std::set<std::string> ids; | 672 std::set<std::string> ids; |
662 for (const auto& notification : notifications) { | 673 for (const auto& notification : notifications) { |
| 674 if (only_closable && !notification->closable()) |
| 675 continue; |
| 676 |
663 ids.insert(notification->id()); | 677 ids.insert(notification->id()); |
664 scoped_refptr<NotificationDelegate> delegate = notification->delegate(); | 678 scoped_refptr<NotificationDelegate> delegate = notification->delegate(); |
665 if (delegate.get()) | 679 if (delegate.get()) |
666 delegate->Close(by_user); | 680 delegate->Close(by_user); |
667 notification_list_->RemoveNotification(notification->id()); | 681 notification_list_->RemoveNotification(notification->id()); |
668 } | 682 } |
669 | 683 |
670 if (!ids.empty()) { | 684 if (!ids.empty()) { |
671 notification_cache_.Rebuild( | 685 notification_cache_.Rebuild( |
672 notification_list_->GetVisibleNotifications(blockers_)); | 686 notification_list_->GetVisibleNotifications(blockers_)); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 } | 904 } |
891 | 905 |
892 void MessageCenterImpl::EnableChangeQueueForTest(bool enable) { | 906 void MessageCenterImpl::EnableChangeQueueForTest(bool enable) { |
893 if (enable) | 907 if (enable) |
894 notification_queue_.reset(new internal::ChangeQueue()); | 908 notification_queue_.reset(new internal::ChangeQueue()); |
895 else | 909 else |
896 notification_queue_.reset(); | 910 notification_queue_.reset(); |
897 } | 911 } |
898 | 912 |
899 } // namespace message_center | 913 } // namespace message_center |
OLD | NEW |