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

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

Issue 1986493002: Show message center on lock screen (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 4 years, 7 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_list.h ('k') | ui/message_center/notification_list_unittest.cc » ('j') | 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_style.h" 16 #include "ui/message_center/message_center_style.h"
16 #include "ui/message_center/notification.h" 17 #include "ui/message_center/notification.h"
17 #include "ui/message_center/notification_blocker.h" 18 #include "ui/message_center/notification_blocker.h"
18 #include "ui/message_center/notification_types.h" 19 #include "ui/message_center/notification_types.h"
19 20
20 namespace message_center { 21 namespace message_center {
21 22
22 namespace { 23 namespace {
23 24
24 bool ShouldShowNotificationAsPopup( 25 bool ShouldShowNotificationAsPopup(
(...skipping 22 matching lines...) Expand all
47 return true; 48 return true;
48 if (n1->timestamp() < n2->timestamp()) 49 if (n1->timestamp() < n2->timestamp())
49 return false; 50 return false;
50 if (n1->serial_number() > n2->serial_number()) // Newer come first. 51 if (n1->serial_number() > n2->serial_number()) // Newer come first.
51 return true; 52 return true;
52 if (n1->serial_number() < n2->serial_number()) 53 if (n1->serial_number() < n2->serial_number())
53 return false; 54 return false;
54 return false; 55 return false;
55 } 56 }
56 57
57 NotificationList::NotificationList() 58 NotificationList::NotificationList(MessageCenter* message_center)
58 : message_center_visible_(false), 59 : message_center_(message_center),
59 quiet_mode_(false) { 60 quiet_mode_(false) {
60 } 61 }
61 62
62 NotificationList::~NotificationList() { 63 NotificationList::~NotificationList() {
63 STLDeleteContainerPointers(notifications_.begin(), notifications_.end()); 64 STLDeleteContainerPointers(notifications_.begin(), notifications_.end());
64 } 65 }
65 66
66 void NotificationList::SetMessageCenterVisible( 67 void NotificationList::SetNotificationsShown(
67 bool visible, 68 const NotificationBlockers& blockers,
68 std::set<std::string>* updated_ids) { 69 std::set<std::string>* updated_ids) {
69 if (message_center_visible_ == visible) 70 Notifications notifications = GetVisibleNotifications(blockers);
70 return;
71 71
72 message_center_visible_ = visible; 72 for (auto iter = notifications.begin(); iter != notifications.end(); ++iter) {
73
74 if (!visible)
75 return;
76
77 for (Notifications::iterator iter = notifications_.begin();
78 iter != notifications_.end(); ++iter) {
79 Notification* notification = *iter; 73 Notification* notification = *iter;
80 bool was_popup = notification->shown_as_popup(); 74 bool was_popup = notification->shown_as_popup();
81 bool was_read = notification->IsRead(); 75 bool was_read = notification->IsRead();
82 if (notification->priority() < SYSTEM_PRIORITY) 76 if (notification->priority() < SYSTEM_PRIORITY)
83 notification->set_shown_as_popup(true); 77 notification->set_shown_as_popup(true);
84 notification->set_is_read(true); 78 notification->set_is_read(true);
85 if (updated_ids && !(was_popup && was_read)) 79 if (updated_ids && !(was_popup && was_read))
86 updated_ids->insert(notification->id()); 80 updated_ids->insert(notification->id());
87 } 81 }
88 } 82 }
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 if (iter != notifications_.end()) { 333 if (iter != notifications_.end()) {
340 notification->CopyState(*iter); 334 notification->CopyState(*iter);
341 state_inherited = true; 335 state_inherited = true;
342 EraseNotification(iter); 336 EraseNotification(iter);
343 } 337 }
344 // Add the notification to the the list and mark it unread and unshown. 338 // Add the notification to the the list and mark it unread and unshown.
345 if (!state_inherited) { 339 if (!state_inherited) {
346 // TODO(mukai): needs to distinguish if a notification is dismissed by 340 // TODO(mukai): needs to distinguish if a notification is dismissed by
347 // the quiet mode or user operation. 341 // the quiet mode or user operation.
348 notification->set_is_read(false); 342 notification->set_is_read(false);
349 notification->set_shown_as_popup(message_center_visible_ 343 notification->set_shown_as_popup(message_center_->IsMessageCenterVisible()
dewittj 2016/05/24 17:10:29 This is ok for now, but I'd rather the notificatio
yoshiki 2016/05/25 09:13:59 Got it. Let me consider a good way.
350 || quiet_mode_ 344 || quiet_mode_
351 || notification->shown_as_popup()); 345 || notification->shown_as_popup());
352 } 346 }
353 // Take ownership. The notification can only be removed from the list 347 // Take ownership. The notification can only be removed from the list
354 // in EraseNotification(), which will delete it. 348 // in EraseNotification(), which will delete it.
355 notifications_.insert(notification.release()); 349 notifications_.insert(notification.release());
356 } 350 }
357 351
358 } // namespace message_center 352 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/notification_list.h ('k') | ui/message_center/notification_list_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698