OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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/popup_timer.h" | 5 #include "ui/message_center/popup_timer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ui/message_center/message_center_style.h" | 9 #include "ui/message_center/message_center_style.h" |
10 #include "ui/message_center/message_center_types.h" | 10 #include "ui/message_center/message_center_types.h" |
11 #include "ui/message_center/notification.h" | 11 #include "ui/message_center/notification.h" |
12 #include "ui/message_center/notification_list.h" | 12 #include "ui/message_center/notification_list.h" |
13 | 13 |
| 14 namespace message_center { |
| 15 |
14 namespace { | 16 namespace { |
15 | 17 |
16 base::TimeDelta GetTimeoutForPriority(int priority) { | 18 base::TimeDelta GetTimeoutForNotification(Notification* notification) { |
17 if (priority > message_center::DEFAULT_PRIORITY) { | 19 if (notification->priority() > message_center::DEFAULT_PRIORITY) |
18 return base::TimeDelta::FromSeconds( | 20 return base::TimeDelta::FromSeconds(kAutocloseHighPriorityDelaySeconds); |
19 message_center::kAutocloseHighPriorityDelaySeconds); | 21 if (notification->is_web_notification()) |
20 } | 22 return base::TimeDelta::FromSeconds(kAutocloseWebNotificationDelaySeconds); |
21 return base::TimeDelta::FromSeconds( | 23 return base::TimeDelta::FromSeconds(kAutocloseDefaultDelaySeconds); |
22 message_center::kAutocloseDefaultDelaySeconds); | |
23 } | 24 } |
24 | 25 |
25 } // namespace | 26 } // namespace |
26 | 27 |
27 namespace message_center { | |
28 | |
29 //////////////////////////////////////////////////////////////////////////////// | 28 //////////////////////////////////////////////////////////////////////////////// |
30 // PopupTimer | 29 // PopupTimer |
31 | 30 |
32 PopupTimer::PopupTimer(const std::string& id, | 31 PopupTimer::PopupTimer(const std::string& id, |
33 base::TimeDelta timeout, | 32 base::TimeDelta timeout, |
34 base::WeakPtr<PopupTimersController> controller) | 33 base::WeakPtr<PopupTimersController> controller) |
35 : id_(id), | 34 : id_(id), |
36 timeout_(timeout), | 35 timeout_(timeout), |
37 timer_controller_(controller), | 36 timer_controller_(controller), |
38 timer_(new base::OneShotTimer) {} | 37 timer_(new base::OneShotTimer) {} |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 break; | 157 break; |
159 } | 158 } |
160 | 159 |
161 if (iter == popup_notifications.end() || (*iter)->never_timeout()) { | 160 if (iter == popup_notifications.end() || (*iter)->never_timeout()) { |
162 CancelTimer(id); | 161 CancelTimer(id); |
163 return; | 162 return; |
164 } | 163 } |
165 | 164 |
166 // Start the timer if not yet. | 165 // Start the timer if not yet. |
167 if (popup_timers_.find(id) == popup_timers_.end()) | 166 if (popup_timers_.find(id) == popup_timers_.end()) |
168 StartTimer(id, GetTimeoutForPriority((*iter)->priority())); | 167 StartTimer(id, GetTimeoutForNotification(*iter)); |
169 } | 168 } |
170 | 169 |
171 void PopupTimersController::OnNotificationRemoved(const std::string& id, | 170 void PopupTimersController::OnNotificationRemoved(const std::string& id, |
172 bool by_user) { | 171 bool by_user) { |
173 CancelTimer(id); | 172 CancelTimer(id); |
174 } | 173 } |
175 | 174 |
176 } // namespace message_center | 175 } // namespace message_center |
OLD | NEW |