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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 NotificationList::NotificationList() | 41 NotificationList::NotificationList() |
42 : message_center_visible_(false), | 42 : message_center_visible_(false), |
43 unread_count_(0), | 43 unread_count_(0), |
44 quiet_mode_(false) { | 44 quiet_mode_(false) { |
45 } | 45 } |
46 | 46 |
47 NotificationList::~NotificationList() { | 47 NotificationList::~NotificationList() { |
48 STLDeleteContainerPointers(notifications_.begin(), notifications_.end()); | 48 STLDeleteContainerPointers(notifications_.begin(), notifications_.end()); |
49 } | 49 } |
50 | 50 |
51 void NotificationList::SetMessageCenterVisible(bool visible) { | 51 void NotificationList::SetMessageCenterVisible( |
| 52 bool visible, |
| 53 std::set<std::string>* updated_ids) { |
52 if (message_center_visible_ == visible) | 54 if (message_center_visible_ == visible) |
53 return; | 55 return; |
| 56 |
54 message_center_visible_ = visible; | 57 message_center_visible_ = visible; |
55 // When the center appears, mark all notifications as shown, and | 58 // When the center appears, mark all notifications as shown, and |
56 // when the center is hidden, clear the unread count, and mark all | 59 // when the center is hidden, clear the unread count, and mark all |
57 // notifications as read. | 60 // notifications as read. |
58 if (!visible) | 61 if (!visible) |
59 unread_count_ = 0; | 62 unread_count_ = 0; |
60 | 63 |
61 for (Notifications::iterator iter = notifications_.begin(); | 64 for (Notifications::iterator iter = notifications_.begin(); |
62 iter != notifications_.end(); ++iter) { | 65 iter != notifications_.end(); ++iter) { |
63 if (visible) | 66 if (visible) { |
| 67 if (updated_ids && !(*iter)->shown_as_popup()) |
| 68 updated_ids->insert((*iter)->id()); |
64 (*iter)->set_shown_as_popup(true); | 69 (*iter)->set_shown_as_popup(true); |
65 else | 70 } else { |
| 71 if (updated_ids && !(*iter)->is_read()) |
| 72 updated_ids->insert((*iter)->id()); |
66 (*iter)->set_is_read(true); | 73 (*iter)->set_is_read(true); |
| 74 } |
67 } | 75 } |
68 } | 76 } |
69 | 77 |
70 void NotificationList::AddNotification( | 78 void NotificationList::AddNotification( |
71 NotificationType type, | 79 NotificationType type, |
72 const std::string& id, | 80 const std::string& id, |
73 const string16& title, | 81 const string16& title, |
74 const string16& message, | 82 const string16& message, |
75 const string16& display_source, | 83 const string16& display_source, |
76 const std::string& extension_id, | 84 const std::string& extension_id, |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 notification->set_shown_as_popup(quiet_mode_); | 340 notification->set_shown_as_popup(quiet_mode_); |
333 if (!quiet_mode_ && notification->priority() > MIN_PRIORITY) | 341 if (!quiet_mode_ && notification->priority() > MIN_PRIORITY) |
334 ++unread_count_; | 342 ++unread_count_; |
335 } | 343 } |
336 // Take ownership. The notification can only be removed from the list | 344 // Take ownership. The notification can only be removed from the list |
337 // in EraseNotification(), which will delete it. | 345 // in EraseNotification(), which will delete it. |
338 notifications_.insert(notification.release()); | 346 notifications_.insert(notification.release()); |
339 } | 347 } |
340 | 348 |
341 } // namespace message_center | 349 } // namespace message_center |
OLD | NEW |