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

Side by Side Diff: chrome/browser/notifications/message_center_notification_manager.cc

Issue 802753002: Revert of "Call the Close() event on a Notification when it's being replaced." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 | « no previous file | chrome/browser/notifications/message_center_notifications_browsertest.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 "chrome/browser/notifications/message_center_notification_manager.h" 5 #include "chrome/browser/notifications/message_center_notification_manager.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/prefs/pref_registry_simple.h" 9 #include "base/prefs/pref_registry_simple.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 for (NotificationMap::iterator iter = profile_notifications_.begin(); 159 for (NotificationMap::iterator iter = profile_notifications_.begin();
160 iter != profile_notifications_.end(); ++iter) { 160 iter != profile_notifications_.end(); ++iter) {
161 ProfileNotification* old_notification = (*iter).second; 161 ProfileNotification* old_notification = (*iter).second;
162 if (old_notification->notification().replace_id() == replace_id && 162 if (old_notification->notification().replace_id() == replace_id &&
163 old_notification->notification().origin_url() == origin_url && 163 old_notification->notification().origin_url() == origin_url &&
164 old_notification->profile() == profile) { 164 old_notification->profile() == profile) {
165 // Changing the type from non-progress to progress does not count towards 165 // Changing the type from non-progress to progress does not count towards
166 // the immediate update allowed in the message center. 166 // the immediate update allowed in the message center.
167 std::string old_id = old_notification->notification().id(); 167 std::string old_id = old_notification->notification().id();
168 168
169 // The W3C Web Notifications specification states that replacing a
170 // notification should fire the "close" event on the old one. The WHATWG
171 // version does not include the "close" event at all anymore, so this
172 // will eventually become redundant.
173 // TODO(peter): Remove this call when removing the Close() event from
174 // Web Notifications. See http://crbug.com/437286.
175 old_notification->notification().delegate()->Close(false /* by_user */);
176
177 // Add/remove notification in the local list but just update the same 169 // Add/remove notification in the local list but just update the same
178 // one in MessageCenter. 170 // one in MessageCenter.
179 delete old_notification; 171 delete old_notification;
180 profile_notifications_.erase(old_id); 172 profile_notifications_.erase(old_id);
181 ProfileNotification* new_notification = 173 ProfileNotification* new_notification =
182 new ProfileNotification(profile, notification); 174 new ProfileNotification(profile, notification);
183 profile_notifications_[new_notification->notification().id()] = 175 profile_notifications_[new_notification->notification().id()] =
184 new_notification; 176 new_notification;
185 177
186 // TODO(liyanhou): Add routing updated notifications to alternative 178 // TODO(liyanhou): Add routing updated notifications to alternative
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 it != registry->enabled_extensions().end(); 405 it != registry->enabled_extensions().end();
414 ++it) { 406 ++it) {
415 if ((*it->get()).permissions_data()->HasAPIPermission( 407 if ((*it->get()).permissions_data()->HasAPIPermission(
416 extensions::APIPermission::ID::kNotificationProvider)) { 408 extensions::APIPermission::ID::kNotificationProvider)) {
417 extension_id = (*it->get()).id(); 409 extension_id = (*it->get()).id();
418 return extension_id; 410 return extension_id;
419 } 411 }
420 } 412 }
421 return extension_id; 413 return extension_id;
422 } 414 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/notifications/message_center_notifications_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698