Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(445)

Side by Side Diff: ui/message_center/notification_list.cc

Issue 324583002: The 1st patch to disambiguate message center notifications (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/time.h" 10 #include "base/time/time.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 bool NotificationList::SetNotificationButtonIcon( 153 bool NotificationList::SetNotificationButtonIcon(
154 const std::string& notification_id, int button_index, 154 const std::string& notification_id, int button_index,
155 const gfx::Image& image) { 155 const gfx::Image& image) {
156 Notifications::iterator iter = GetNotification(notification_id); 156 Notifications::iterator iter = GetNotification(notification_id);
157 if (iter == notifications_.end()) 157 if (iter == notifications_.end())
158 return false; 158 return false;
159 (*iter)->SetButtonIcon(button_index, image); 159 (*iter)->SetButtonIcon(button_index, image);
160 return true; 160 return true;
161 } 161 }
162 162
163 bool NotificationList::HasNotification(const std::string& id) {
164 return GetNotification(id) != notifications_.end();
165 }
166
167 bool NotificationList::HasNotificationOfType(const std::string& id, 163 bool NotificationList::HasNotificationOfType(const std::string& id,
168 const NotificationType type) { 164 const NotificationType type) {
169 Notifications::iterator iter = GetNotification(id); 165 Notifications::iterator iter = GetNotification(id);
170 if (iter == notifications_.end()) 166 if (iter == notifications_.end())
171 return false; 167 return false;
172 168
173 return (*iter)->type() == type; 169 return (*iter)->type() == type;
174 } 170 }
175 171
176 bool NotificationList::HasPopupNotifications( 172 bool NotificationList::HasPopupNotifications(
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 quiet_mode_ = quiet_mode; 260 quiet_mode_ = quiet_mode;
265 if (quiet_mode_) { 261 if (quiet_mode_) {
266 for (Notifications::iterator iter = notifications_.begin(); 262 for (Notifications::iterator iter = notifications_.begin();
267 iter != notifications_.end(); 263 iter != notifications_.end();
268 ++iter) { 264 ++iter) {
269 (*iter)->set_shown_as_popup(true); 265 (*iter)->set_shown_as_popup(true);
270 } 266 }
271 } 267 }
272 } 268 }
273 269
270 Notification* NotificationList::GetNotificationById(const std::string& id) {
271 Notifications::iterator iter = GetNotification(id);
272 if (iter != notifications_.end())
273 return *iter;
274 else
dewittj 2014/06/09 19:59:10 nit: no else clause, just return null
juyik 2014/06/09 21:28:08 Done.
275 return NULL;
276 }
277
274 NotificationList::Notifications NotificationList::GetVisibleNotifications( 278 NotificationList::Notifications NotificationList::GetVisibleNotifications(
275 const NotificationBlockers& blockers) const { 279 const NotificationBlockers& blockers) const {
276 Notifications result; 280 Notifications result;
277 for (Notifications::const_iterator iter = notifications_.begin(); 281 for (Notifications::const_iterator iter = notifications_.begin();
278 iter != notifications_.end(); ++iter) { 282 iter != notifications_.end(); ++iter) {
279 bool should_show = true; 283 bool should_show = true;
280 for (size_t i = 0; i < blockers.size(); ++i) { 284 for (size_t i = 0; i < blockers.size(); ++i) {
281 if (!blockers[i]->ShouldShowNotification((*iter)->notifier_id())) { 285 if (!blockers[i]->ShouldShowNotification((*iter)->notifier_id())) {
282 should_show = false; 286 should_show = false;
283 break; 287 break;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 notification->set_shown_as_popup(message_center_visible_ 344 notification->set_shown_as_popup(message_center_visible_
341 || quiet_mode_ 345 || quiet_mode_
342 || notification->shown_as_popup()); 346 || notification->shown_as_popup());
343 } 347 }
344 // Take ownership. The notification can only be removed from the list 348 // Take ownership. The notification can only be removed from the list
345 // in EraseNotification(), which will delete it. 349 // in EraseNotification(), which will delete it.
346 notifications_.insert(notification.release()); 350 notifications_.insert(notification.release());
347 } 351 }
348 352
349 } // namespace message_center 353 } // namespace message_center
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698