| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 // UI, so technically the removal is indirect. | 150 // UI, so technically the removal is indirect. |
| 151 delegate_->SendRemoveNotification((*curiter)->id(), false); | 151 delegate_->SendRemoveNotification((*curiter)->id(), false); |
| 152 } | 152 } |
| 153 } | 153 } |
| 154 | 154 |
| 155 bool NotificationList::SetNotificationIcon(const std::string& notification_id, | 155 bool NotificationList::SetNotificationIcon(const std::string& notification_id, |
| 156 const gfx::ImageSkia& image) { | 156 const gfx::ImageSkia& image) { |
| 157 Notifications::iterator iter = GetNotification(notification_id); | 157 Notifications::iterator iter = GetNotification(notification_id); |
| 158 if (iter == notifications_.end()) | 158 if (iter == notifications_.end()) |
| 159 return false; | 159 return false; |
| 160 (*iter)->set_primary_icon(image); | 160 (*iter)->set_icon(image); |
| 161 return true; | 161 return true; |
| 162 } | 162 } |
| 163 | 163 |
| 164 bool NotificationList::SetNotificationImage(const std::string& notification_id, | 164 bool NotificationList::SetNotificationImage(const std::string& notification_id, |
| 165 const gfx::ImageSkia& image) { | 165 const gfx::ImageSkia& image) { |
| 166 Notifications::iterator iter = GetNotification(notification_id); | 166 Notifications::iterator iter = GetNotification(notification_id); |
| 167 if (iter == notifications_.end()) | 167 if (iter == notifications_.end()) |
| 168 return false; | 168 return false; |
| 169 (*iter)->set_image(image); | 169 (*iter)->set_image(image); |
| 170 return true; | 170 return true; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 return; | 240 return; |
| 241 | 241 |
| 242 (*iter)->set_shown_as_popup(true); | 242 (*iter)->set_shown_as_popup(true); |
| 243 | 243 |
| 244 if (mark_notification_as_read) { | 244 if (mark_notification_as_read) { |
| 245 --unread_count_; | 245 --unread_count_; |
| 246 (*iter)->set_is_read(true); | 246 (*iter)->set_is_read(true); |
| 247 } | 247 } |
| 248 } | 248 } |
| 249 | 249 |
| 250 void NotificationList::MarkNotificationAsExpanded(const std::string& id) { |
| 251 Notifications::iterator iter = GetNotification(id); |
| 252 if (iter != notifications_.end()) |
| 253 (*iter)->set_is_expanded(true); |
| 254 } |
| 255 |
| 250 void NotificationList::SetQuietMode(bool quiet_mode) { | 256 void NotificationList::SetQuietMode(bool quiet_mode) { |
| 251 SetQuietModeInternal(quiet_mode); | 257 SetQuietModeInternal(quiet_mode); |
| 252 quiet_mode_timer_.reset(); | 258 quiet_mode_timer_.reset(); |
| 253 } | 259 } |
| 254 | 260 |
| 255 void NotificationList::EnterQuietModeWithExpire( | 261 void NotificationList::EnterQuietModeWithExpire( |
| 256 const base::TimeDelta& expires_in) { | 262 const base::TimeDelta& expires_in) { |
| 257 if (quiet_mode_timer_.get()) { | 263 if (quiet_mode_timer_.get()) { |
| 258 // Note that the capital Reset() is the method to restart the timer, not | 264 // Note that the capital Reset() is the method to restart the timer, not |
| 259 // scoped_ptr::reset(). | 265 // scoped_ptr::reset(). |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 notification->set_shown_as_popup(quiet_mode_); | 326 notification->set_shown_as_popup(quiet_mode_); |
| 321 if (!quiet_mode_ && notification->priority() > MIN_PRIORITY) | 327 if (!quiet_mode_ && notification->priority() > MIN_PRIORITY) |
| 322 ++unread_count_; | 328 ++unread_count_; |
| 323 } | 329 } |
| 324 // Take ownership. The notification can only be removed from the list | 330 // Take ownership. The notification can only be removed from the list |
| 325 // in EraseNotification(), which will delete it. | 331 // in EraseNotification(), which will delete it. |
| 326 notifications_.insert(notification.release()); | 332 notifications_.insert(notification.release()); |
| 327 } | 333 } |
| 328 | 334 |
| 329 } // namespace message_center | 335 } // namespace message_center |
| OLD | NEW |