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

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

Issue 439073002: Web Notifications should always reappear as popups when updated. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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. 103 // toast. Notifications coming from websites through the Web Notification API
104 if ((*iter)->priority() < new_notification->priority()) { 104 // will always re-appear on update.
105 if ((*iter)->priority() < new_notification->priority() ||
106 new_notification->notifier_id().type == NotifierId::WEB_PAGE) {
105 new_notification->set_is_read(false); 107 new_notification->set_is_read(false);
106 new_notification->set_shown_as_popup(false); 108 new_notification->set_shown_as_popup(false);
107 } 109 }
108 110
109 // Do not use EraseNotification and PushNotification, since we don't want to 111 // Do not use EraseNotification and PushNotification, since we don't want to
110 // change unread counts nor to update is_read/shown_as_popup states. 112 // change unread counts nor to update is_read/shown_as_popup states.
111 Notification* old = *iter; 113 Notification* old = *iter;
112 notifications_.erase(iter); 114 notifications_.erase(iter);
113 delete old; 115 delete old;
114 116
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 notification->set_shown_as_popup(message_center_visible_ 345 notification->set_shown_as_popup(message_center_visible_
344 || quiet_mode_ 346 || quiet_mode_
345 || notification->shown_as_popup()); 347 || notification->shown_as_popup());
346 } 348 }
347 // Take ownership. The notification can only be removed from the list 349 // Take ownership. The notification can only be removed from the list
348 // in EraseNotification(), which will delete it. 350 // in EraseNotification(), which will delete it.
349 notifications_.insert(notification.release()); 351 notifications_.insert(notification.release());
350 } 352 }
351 353
352 } // namespace message_center 354 } // 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