| 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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 MessageCenterImpl::NotificationCache::~NotificationCache() {} | 336 MessageCenterImpl::NotificationCache::~NotificationCache() {} |
| 337 | 337 |
| 338 void MessageCenterImpl::NotificationCache::Rebuild( | 338 void MessageCenterImpl::NotificationCache::Rebuild( |
| 339 const NotificationList::Notifications& notifications) { | 339 const NotificationList::Notifications& notifications) { |
| 340 visible_notifications = notifications; | 340 visible_notifications = notifications; |
| 341 RecountUnread(); | 341 RecountUnread(); |
| 342 } | 342 } |
| 343 | 343 |
| 344 void MessageCenterImpl::NotificationCache::RecountUnread() { | 344 void MessageCenterImpl::NotificationCache::RecountUnread() { |
| 345 unread_count = 0; | 345 unread_count = 0; |
| 346 for (const auto& notification : visible_notifications) { | 346 for (auto* notification : visible_notifications) { |
| 347 if (!notification->IsRead()) | 347 if (!notification->IsRead()) |
| 348 ++unread_count; | 348 ++unread_count; |
| 349 } | 349 } |
| 350 } | 350 } |
| 351 | 351 |
| 352 //////////////////////////////////////////////////////////////////////////////// | 352 //////////////////////////////////////////////////////////////////////////////// |
| 353 // MessageCenterImpl | 353 // MessageCenterImpl |
| 354 | 354 |
| 355 MessageCenterImpl::MessageCenterImpl() | 355 MessageCenterImpl::MessageCenterImpl() |
| 356 : MessageCenter(), | 356 : MessageCenter(), |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 notification_list_->GetVisibleNotifications(blockers_)); | 634 notification_list_->GetVisibleNotifications(blockers_)); |
| 635 FOR_EACH_OBSERVER(MessageCenterObserver, | 635 FOR_EACH_OBSERVER(MessageCenterObserver, |
| 636 observer_list_, | 636 observer_list_, |
| 637 OnNotificationRemoved(copied_id, by_user)); | 637 OnNotificationRemoved(copied_id, by_user)); |
| 638 } | 638 } |
| 639 | 639 |
| 640 void MessageCenterImpl::RemoveNotificationsForNotifierId( | 640 void MessageCenterImpl::RemoveNotificationsForNotifierId( |
| 641 const NotifierId& notifier_id) { | 641 const NotifierId& notifier_id) { |
| 642 NotificationList::Notifications notifications = | 642 NotificationList::Notifications notifications = |
| 643 notification_list_->GetNotificationsByNotifierId(notifier_id); | 643 notification_list_->GetNotificationsByNotifierId(notifier_id); |
| 644 for (const auto& notification : notifications) | 644 for (auto* notification : notifications) |
| 645 RemoveNotification(notification->id(), false); | 645 RemoveNotification(notification->id(), false); |
| 646 if (!notifications.empty()) { | 646 if (!notifications.empty()) { |
| 647 notification_cache_.Rebuild( | 647 notification_cache_.Rebuild( |
| 648 notification_list_->GetVisibleNotifications(blockers_)); | 648 notification_list_->GetVisibleNotifications(blockers_)); |
| 649 } | 649 } |
| 650 } | 650 } |
| 651 | 651 |
| 652 void MessageCenterImpl::RemoveAllNotifications(bool by_user, RemoveType type) { | 652 void MessageCenterImpl::RemoveAllNotifications(bool by_user, RemoveType type) { |
| 653 bool remove_pinned = (type == RemoveType::NON_PINNED); | 653 bool remove_pinned = (type == RemoveType::NON_PINNED); |
| 654 | 654 |
| 655 const NotificationBlockers& blockers = | 655 const NotificationBlockers& blockers = |
| 656 (type == RemoveType::ALL ? NotificationBlockers() /* empty blockers */ | 656 (type == RemoveType::ALL ? NotificationBlockers() /* empty blockers */ |
| 657 : blockers_ /* use default blockers */); | 657 : blockers_ /* use default blockers */); |
| 658 | 658 |
| 659 const NotificationList::Notifications notifications = | 659 const NotificationList::Notifications notifications = |
| 660 notification_list_->GetVisibleNotifications(blockers); | 660 notification_list_->GetVisibleNotifications(blockers); |
| 661 std::set<std::string> ids; | 661 std::set<std::string> ids; |
| 662 for (const auto& notification : notifications) { | 662 for (auto* notification : notifications) { |
| 663 if (!remove_pinned && notification->pinned()) | 663 if (!remove_pinned && notification->pinned()) |
| 664 continue; | 664 continue; |
| 665 | 665 |
| 666 ids.insert(notification->id()); | 666 ids.insert(notification->id()); |
| 667 scoped_refptr<NotificationDelegate> delegate = notification->delegate(); | 667 scoped_refptr<NotificationDelegate> delegate = notification->delegate(); |
| 668 if (delegate.get()) | 668 if (delegate.get()) |
| 669 delegate->Close(by_user); | 669 delegate->Close(by_user); |
| 670 notification_list_->RemoveNotification(notification->id()); | 670 notification_list_->RemoveNotification(notification->id()); |
| 671 } | 671 } |
| 672 | 672 |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 } | 901 } |
| 902 | 902 |
| 903 void MessageCenterImpl::EnableChangeQueueForTest(bool enable) { | 903 void MessageCenterImpl::EnableChangeQueueForTest(bool enable) { |
| 904 if (enable) | 904 if (enable) |
| 905 notification_queue_.reset(new internal::ChangeQueue()); | 905 notification_queue_.reset(new internal::ChangeQueue()); |
| 906 else | 906 else |
| 907 notification_queue_.reset(); | 907 notification_queue_.reset(); |
| 908 } | 908 } |
| 909 | 909 |
| 910 } // namespace message_center | 910 } // namespace message_center |
| OLD | NEW |