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" |
11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "ui/message_center/message_center_constants.h" |
12 #include "ui/message_center/notification.h" | 13 #include "ui/message_center/notification.h" |
13 #include "ui/message_center/notification_types.h" | 14 #include "ui/message_center/notification_types.h" |
14 | 15 |
15 namespace message_center { | 16 namespace message_center { |
16 | 17 |
17 bool ComparePriorityTimestampSerial::operator()(Notification* n1, | 18 bool ComparePriorityTimestampSerial::operator()(Notification* n1, |
18 Notification* n2) { | 19 Notification* n2) { |
19 if (n1->priority() > n2->priority()) // Higher pri go first. | 20 if (n1->priority() > n2->priority()) // Higher pri go first. |
20 return true; | 21 return true; |
21 if (n1->priority() < n2->priority()) | 22 if (n1->priority() < n2->priority()) |
22 return false; | 23 return false; |
23 return CompareTimestampSerial()(n1, n2); | 24 return CompareTimestampSerial()(n1, n2); |
24 } | 25 } |
25 | 26 |
26 bool CompareTimestampSerial::operator()(Notification* n1, Notification* n2) { | 27 bool CompareTimestampSerial::operator()(Notification* n1, Notification* n2) { |
27 if (n1->timestamp() > n2->timestamp()) // Newer come first. | 28 if (n1->timestamp() > n2->timestamp()) // Newer come first. |
28 return true; | 29 return true; |
29 if (n1->timestamp() < n2->timestamp()) | 30 if (n1->timestamp() < n2->timestamp()) |
30 return false; | 31 return false; |
31 if (n1->serial_number() > n2->serial_number()) // Newer come first. | 32 if (n1->serial_number() > n2->serial_number()) // Newer come first. |
32 return true; | 33 return true; |
33 if (n1->serial_number() < n2->serial_number()) | 34 if (n1->serial_number() < n2->serial_number()) |
34 return false; | 35 return false; |
35 return false; | 36 return false; |
36 } | 37 } |
37 | 38 |
38 const size_t NotificationList::kMaxVisibleMessageCenterNotifications = 100; | |
39 const size_t NotificationList::kMaxVisiblePopupNotifications = 3; | |
40 | |
41 NotificationList::NotificationList() | 39 NotificationList::NotificationList() |
42 : message_center_visible_(false), | 40 : message_center_visible_(false), |
43 unread_count_(0), | 41 unread_count_(0), |
44 quiet_mode_(false) { | 42 quiet_mode_(false) { |
45 } | 43 } |
46 | 44 |
47 NotificationList::~NotificationList() { | 45 NotificationList::~NotificationList() { |
48 STLDeleteContainerPointers(notifications_.begin(), notifications_.end()); | 46 STLDeleteContainerPointers(notifications_.begin(), notifications_.end()); |
49 } | 47 } |
50 | 48 |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 notification->set_shown_as_popup(message_center_visible_ || quiet_mode_); | 347 notification->set_shown_as_popup(message_center_visible_ || quiet_mode_); |
350 if (!quiet_mode_ && notification->priority() > MIN_PRIORITY) | 348 if (!quiet_mode_ && notification->priority() > MIN_PRIORITY) |
351 ++unread_count_; | 349 ++unread_count_; |
352 } | 350 } |
353 // Take ownership. The notification can only be removed from the list | 351 // Take ownership. The notification can only be removed from the list |
354 // in EraseNotification(), which will delete it. | 352 // in EraseNotification(), which will delete it. |
355 notifications_.insert(notification.release()); | 353 notifications_.insert(notification.release()); |
356 } | 354 } |
357 | 355 |
358 } // namespace message_center | 356 } // namespace message_center |
OLD | NEW |