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 | |
57 std::set<std::string> dummy_ids; | |
dewittj
2013/04/16 23:59:13
I don't love keeping a dummy data structure around
Jun Mukai
2013/04/17 01:04:43
Done.
| |
58 if (!updated_ids) | |
59 updated_ids = &dummy_ids; | |
60 | |
54 message_center_visible_ = visible; | 61 message_center_visible_ = visible; |
55 // When the center appears, mark all notifications as shown, and | 62 // When the center appears, mark all notifications as shown, and |
56 // when the center is hidden, clear the unread count, and mark all | 63 // when the center is hidden, clear the unread count, and mark all |
57 // notifications as read. | 64 // notifications as read. |
58 if (!visible) | 65 if (!visible) { |
dewittj
2013/04/16 23:59:13
no braces
Jun Mukai
2013/04/17 01:04:43
Done.
| |
59 unread_count_ = 0; | 66 unread_count_ = 0; |
67 } | |
60 | 68 |
61 for (Notifications::iterator iter = notifications_.begin(); | 69 for (Notifications::iterator iter = notifications_.begin(); |
62 iter != notifications_.end(); ++iter) { | 70 iter != notifications_.end(); ++iter) { |
63 if (visible) | 71 if (visible) { |
72 if (!(*iter)->shown_as_popup()) | |
73 updated_ids->insert((*iter)->id()); | |
64 (*iter)->set_shown_as_popup(true); | 74 (*iter)->set_shown_as_popup(true); |
65 else | 75 } else { |
76 if (!(*iter)->is_read()) | |
77 updated_ids->insert((*iter)->id()); | |
66 (*iter)->set_is_read(true); | 78 (*iter)->set_is_read(true); |
79 } | |
67 } | 80 } |
68 } | 81 } |
69 | 82 |
70 void NotificationList::AddNotification( | 83 void NotificationList::AddNotification( |
71 NotificationType type, | 84 NotificationType type, |
72 const std::string& id, | 85 const std::string& id, |
73 const string16& title, | 86 const string16& title, |
74 const string16& message, | 87 const string16& message, |
75 const string16& display_source, | 88 const string16& display_source, |
76 const std::string& extension_id, | 89 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_); | 345 notification->set_shown_as_popup(quiet_mode_); |
333 if (!quiet_mode_ && notification->priority() > MIN_PRIORITY) | 346 if (!quiet_mode_ && notification->priority() > MIN_PRIORITY) |
334 ++unread_count_; | 347 ++unread_count_; |
335 } | 348 } |
336 // Take ownership. The notification can only be removed from the list | 349 // Take ownership. The notification can only be removed from the list |
337 // in EraseNotification(), which will delete it. | 350 // in EraseNotification(), which will delete it. |
338 notifications_.insert(notification.release()); | 351 notifications_.insert(notification.release()); |
339 } | 352 } |
340 | 353 |
341 } // namespace message_center | 354 } // namespace message_center |
OLD | NEW |