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

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

Issue 417163005: Revert of Web Notifications should always reappear as popups when updated. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 const std::string& old_id, 93 const std::string& old_id,
94 scoped_ptr<Notification> new_notification) { 94 scoped_ptr<Notification> new_notification) {
95 Notifications::iterator iter = GetNotification(old_id); 95 Notifications::iterator iter = GetNotification(old_id);
96 if (iter == notifications_.end()) 96 if (iter == notifications_.end())
97 return; 97 return;
98 98
99 new_notification->CopyState(*iter); 99 new_notification->CopyState(*iter);
100 100
101 // Handles priority promotion. If the notification is already dismissed but 101 // Handles priority promotion. If the notification is already dismissed but
102 // the updated notification has higher priority, it should re-appear as a 102 // the updated notification has higher priority, it should re-appear as a
103 // toast. Notifications coming from websites through the Web Notification API 103 // toast.
104 // will always re-appear on update. 104 if ((*iter)->priority() < new_notification->priority()) {
105 if ((*iter)->priority() < new_notification->priority() ||
106 new_notification->notifier_id().type == NotifierId::WEB_PAGE) {
107 new_notification->set_is_read(false); 105 new_notification->set_is_read(false);
108 new_notification->set_shown_as_popup(false); 106 new_notification->set_shown_as_popup(false);
109 } 107 }
110 108
111 // Do not use EraseNotification and PushNotification, since we don't want to 109 // Do not use EraseNotification and PushNotification, since we don't want to
112 // change unread counts nor to update is_read/shown_as_popup states. 110 // change unread counts nor to update is_read/shown_as_popup states.
113 Notification* old = *iter; 111 Notification* old = *iter;
114 notifications_.erase(iter); 112 notifications_.erase(iter);
115 delete old; 113 delete old;
116 114
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 notification->set_shown_as_popup(message_center_visible_ 343 notification->set_shown_as_popup(message_center_visible_
346 || quiet_mode_ 344 || quiet_mode_
347 || notification->shown_as_popup()); 345 || notification->shown_as_popup());
348 } 346 }
349 // Take ownership. The notification can only be removed from the list 347 // Take ownership. The notification can only be removed from the list
350 // in EraseNotification(), which will delete it. 348 // in EraseNotification(), which will delete it.
351 notifications_.insert(notification.release()); 349 notifications_.insert(notification.release());
352 } 350 }
353 351
354 } // namespace message_center 352 } // namespace message_center
OLDNEW
« no previous file with comments | « chrome/browser/notifications/notification_browsertest.cc ('k') | ui/message_center/notification_list_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698