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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 } | 245 } |
| 246 } | 246 } |
| 247 | 247 |
| 248 void NotificationList::MarkPopupsAsShown(int priority) { | 248 void NotificationList::MarkPopupsAsShown(int priority) { |
| 249 Notifications::iterator first, last; | 249 Notifications::iterator first, last; |
| 250 GetPopupIterators(priority, first, last); | 250 GetPopupIterators(priority, first, last); |
| 251 for (Notifications::iterator iter = first; iter != last; ++iter) | 251 for (Notifications::iterator iter = first; iter != last; ++iter) |
| 252 iter->shown_as_popup = true; | 252 iter->shown_as_popup = true; |
| 253 } | 253 } |
| 254 | 254 |
| 255 void NotificationList::MarkSinglePopupAsShown(const std::string& id) { | |
| 256 Notifications::iterator iter; | |
| 257 if (!GetNotification(id, &iter)) | |
| 258 return; | |
| 259 | |
| 260 if (iter->shown_as_popup) | |
| 261 return; | |
| 262 | |
| 263 Notification notification = *iter; | |
| 264 notification.shown_as_popup = true; | |
| 265 // Moves the item at the beginning of the read items. | |
|
miket_OOO
2013/01/07 22:29:07
This comment would make more sense before line 263
Jun Mukai
2013/01/08 02:13:11
Done.
| |
| 266 notifications_[notification.priority].erase(iter); | |
| 267 for (Notifications::iterator iter2 = | |
| 268 notifications_[notification.priority].begin(); | |
| 269 iter2 != notifications_[notification.priority].end(); iter2++) { | |
| 270 if (iter2->shown_as_popup) { | |
| 271 notifications_[notification.priority].insert(iter2, notification); | |
| 272 return; | |
| 273 } | |
| 274 } | |
| 275 | |
| 276 // No notifications are already shown as popup, so just adding at the end of | |
|
miket_OOO
2013/01/07 22:29:07
"re-adding" or "adding back" is a bit clearer than
Jun Mukai
2013/01/08 02:13:11
Done.
| |
| 277 // the list. | |
| 278 notifications_[notification.priority].push_back(notification); | |
| 279 } | |
| 280 | |
| 255 void NotificationList::SetQuietMode(bool quiet_mode) { | 281 void NotificationList::SetQuietMode(bool quiet_mode) { |
| 256 SetQuietModeInternal(quiet_mode); | 282 SetQuietModeInternal(quiet_mode); |
| 257 quiet_mode_timer_.reset(); | 283 quiet_mode_timer_.reset(); |
| 258 } | 284 } |
| 259 | 285 |
| 260 void NotificationList::EnterQuietModeWithExpire( | 286 void NotificationList::EnterQuietModeWithExpire( |
| 261 const base::TimeDelta& expires_in) { | 287 const base::TimeDelta& expires_in) { |
| 262 if (quiet_mode_timer_.get()) { | 288 if (quiet_mode_timer_.get()) { |
| 263 // Note that the capital Reset() is the method to restart the timer, not | 289 // Note that the capital Reset() is the method to restart the timer, not |
| 264 // scoped_ptr::reset(). | 290 // scoped_ptr::reset(). |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 378 popup_count++; | 404 popup_count++; |
| 379 // No limits for HIGH/MAX priority. | 405 // No limits for HIGH/MAX priority. |
| 380 if (priority == ui::notifications::DEFAULT_PRIORITY && | 406 if (priority == ui::notifications::DEFAULT_PRIORITY && |
| 381 popup_count >= kMaxVisiblePopupNotifications) { | 407 popup_count >= kMaxVisiblePopupNotifications) { |
| 382 break; | 408 break; |
| 383 } | 409 } |
| 384 } | 410 } |
| 385 } | 411 } |
| 386 | 412 |
| 387 } // namespace message_center | 413 } // namespace message_center |
| OLD | NEW |