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

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

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