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

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

Issue 2198363002: Pass Notification into NotificationBlocker ShouldShow* methods (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ash build errors Created 4 years, 4 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
« no previous file with comments | « ui/message_center/notification_blocker.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "ui/gfx/image/image.h" 14 #include "ui/gfx/image/image.h"
15 #include "ui/message_center/message_center.h" 15 #include "ui/message_center/message_center.h"
16 #include "ui/message_center/message_center_style.h" 16 #include "ui/message_center/message_center_style.h"
17 #include "ui/message_center/notification.h" 17 #include "ui/message_center/notification.h"
18 #include "ui/message_center/notification_blocker.h" 18 #include "ui/message_center/notification_blocker.h"
19 #include "ui/message_center/notification_types.h" 19 #include "ui/message_center/notification_types.h"
20 20
21 namespace message_center { 21 namespace message_center {
22 22
23 namespace { 23 namespace {
24 24
25 bool ShouldShowNotificationAsPopup( 25 bool ShouldShowNotificationAsPopup(
26 const Notification& notification, 26 const Notification& notification,
27 const NotificationBlockers& blockers) { 27 const NotificationBlockers& blockers) {
28 for (size_t i = 0; i < blockers.size(); ++i) { 28 for (size_t i = 0; i < blockers.size(); ++i) {
29 if (!blockers[i]->ShouldShowNotificationAsPopup(notification.notifier_id())) 29 if (!blockers[i]->ShouldShowNotificationAsPopup(notification))
30 return false; 30 return false;
31 } 31 }
32 return true; 32 return true;
33 } 33 }
34 34
35 } // namespace 35 } // namespace
36 36
37 bool ComparePriorityTimestampSerial::operator()(Notification* n1, 37 bool ComparePriorityTimestampSerial::operator()(Notification* n1,
38 Notification* n2) { 38 Notification* n2) {
39 if (n1->priority() > n2->priority()) // Higher pri go first. 39 if (n1->priority() > n2->priority()) // Higher pri go first.
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 return NULL; 273 return NULL;
274 } 274 }
275 275
276 NotificationList::Notifications NotificationList::GetVisibleNotifications( 276 NotificationList::Notifications NotificationList::GetVisibleNotifications(
277 const NotificationBlockers& blockers) const { 277 const NotificationBlockers& blockers) const {
278 Notifications result; 278 Notifications result;
279 for (Notifications::const_iterator iter = notifications_.begin(); 279 for (Notifications::const_iterator iter = notifications_.begin();
280 iter != notifications_.end(); ++iter) { 280 iter != notifications_.end(); ++iter) {
281 bool should_show = true; 281 bool should_show = true;
282 for (size_t i = 0; i < blockers.size(); ++i) { 282 for (size_t i = 0; i < blockers.size(); ++i) {
283 if (!blockers[i]->ShouldShowNotification((*iter)->notifier_id())) { 283 if (!blockers[i]->ShouldShowNotification(**iter)) {
284 should_show = false; 284 should_show = false;
285 break; 285 break;
286 } 286 }
287 } 287 }
288 if (should_show) 288 if (should_show)
289 result.insert(*iter); 289 result.insert(*iter);
290 } 290 }
291 291
292 return result; 292 return result;
293 } 293 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 notification->set_shown_as_popup(message_center_->IsMessageCenterVisible() 343 notification->set_shown_as_popup(message_center_->IsMessageCenterVisible()
344 || quiet_mode_ 344 || quiet_mode_
345 || notification->shown_as_popup()); 345 || notification->shown_as_popup());
346 } 346 }
347 // Take ownership. The notification can only be removed from the list 347 // Take ownership. The notification can only be removed from the list
348 // in EraseNotification(), which will delete it. 348 // in EraseNotification(), which will delete it.
349 notifications_.insert(notification.release()); 349 notifications_.insert(notification.release());
350 } 350 }
351 351
352 } // namespace message_center 352 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/notification_blocker.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698