Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/notification_list.h" | 5 #include "ui/message_center/notification_list.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 | 56 |
| 57 NotificationList::NotificationList() | 57 NotificationList::NotificationList() |
| 58 : message_center_visible_(false), | 58 : message_center_visible_(false), |
| 59 quiet_mode_(false) { | 59 quiet_mode_(false) { |
| 60 } | 60 } |
| 61 | 61 |
| 62 NotificationList::~NotificationList() { | 62 NotificationList::~NotificationList() { |
| 63 STLDeleteContainerPointers(notifications_.begin(), notifications_.end()); | 63 STLDeleteContainerPointers(notifications_.begin(), notifications_.end()); |
| 64 } | 64 } |
| 65 | 65 |
| 66 void NotificationList::SetMessageCenterVisible( | 66 void NotificationList::SetMessageCenterVisible(bool visible) { |
| 67 bool visible, | 67 message_center_visible_ = visible; |
|
dewittj
2016/05/19 17:34:03
This doesn't seem like the right place to track th
yoshiki
2016/05/24 17:00:14
I moved the flag from NotificationList to MessageC
| |
| 68 } | |
| 69 | |
| 70 void NotificationList::SetNotificationsShown( | |
|
yoshiki
2016/05/16 19:04:46
I splitted this method because I don't want to mak
| |
| 71 const NotificationBlockers& blockers, | |
|
yoshiki
2016/05/16 19:04:46
Adding blockers fixes the bug that this makes bloc
| |
| 68 std::set<std::string>* updated_ids) { | 72 std::set<std::string>* updated_ids) { |
| 69 if (message_center_visible_ == visible) | 73 Notifications notifications = GetVisibleNotifications(blockers); |
| 70 return; | |
| 71 | 74 |
| 72 message_center_visible_ = visible; | 75 for (auto iter = notifications.begin(); iter != notifications.end(); ++iter) { |
| 73 | |
| 74 if (!visible) | |
| 75 return; | |
| 76 | |
| 77 for (Notifications::iterator iter = notifications_.begin(); | |
| 78 iter != notifications_.end(); ++iter) { | |
| 79 Notification* notification = *iter; | 76 Notification* notification = *iter; |
| 80 bool was_popup = notification->shown_as_popup(); | 77 bool was_popup = notification->shown_as_popup(); |
| 81 bool was_read = notification->IsRead(); | 78 bool was_read = notification->IsRead(); |
| 82 if (notification->priority() < SYSTEM_PRIORITY) | 79 if (notification->priority() < SYSTEM_PRIORITY) |
| 83 notification->set_shown_as_popup(true); | 80 notification->set_shown_as_popup(true); |
| 84 notification->set_is_read(true); | 81 notification->set_is_read(true); |
| 85 if (updated_ids && !(was_popup && was_read)) | 82 if (updated_ids && !(was_popup && was_read)) |
| 86 updated_ids->insert(notification->id()); | 83 updated_ids->insert(notification->id()); |
| 87 } | 84 } |
| 88 } | 85 } |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 349 notification->set_shown_as_popup(message_center_visible_ | 346 notification->set_shown_as_popup(message_center_visible_ |
| 350 || quiet_mode_ | 347 || quiet_mode_ |
| 351 || notification->shown_as_popup()); | 348 || notification->shown_as_popup()); |
| 352 } | 349 } |
| 353 // Take ownership. The notification can only be removed from the list | 350 // Take ownership. The notification can only be removed from the list |
| 354 // in EraseNotification(), which will delete it. | 351 // in EraseNotification(), which will delete it. |
| 355 notifications_.insert(notification.release()); | 352 notifications_.insert(notification.release()); |
| 356 } | 353 } |
| 357 | 354 |
| 358 } // namespace message_center | 355 } // namespace message_center |
| OLD | NEW |