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

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

Issue 324583002: The 1st patch to disambiguate message center notifications (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 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
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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 for (NotificationMap::iterator iter = profile_notifications_.begin(); 131 for (NotificationMap::iterator iter = profile_notifications_.begin();
132 iter != profile_notifications_.end(); ++iter) { 132 iter != profile_notifications_.end(); ++iter) {
133 ProfileNotification* old_notification = (*iter).second; 133 ProfileNotification* old_notification = (*iter).second;
134 if (old_notification->notification().replace_id() == replace_id && 134 if (old_notification->notification().replace_id() == replace_id &&
135 old_notification->notification().origin_url() == origin_url && 135 old_notification->notification().origin_url() == origin_url &&
136 old_notification->profile() == profile) { 136 old_notification->profile() == profile) {
137 // Changing the type from non-progress to progress does not count towards 137 // Changing the type from non-progress to progress does not count towards
138 // the immediate update allowed in the message center. 138 // the immediate update allowed in the message center.
139 std::string old_id = 139 std::string old_id =
140 old_notification->notification().notification_id(); 140 old_notification->notification().notification_id();
141 DCHECK(message_center_->HasNotification(old_id)); 141 DCHECK(message_center_->FindVisibleNotificationById(old_id));
142 142
143 // Add/remove notification in the local list but just update the same 143 // Add/remove notification in the local list but just update the same
144 // one in MessageCenter. 144 // one in MessageCenter.
145 delete old_notification; 145 delete old_notification;
146 profile_notifications_.erase(old_id); 146 profile_notifications_.erase(old_id);
147 ProfileNotification* new_notification = 147 ProfileNotification* new_notification =
148 new ProfileNotification(profile, notification, message_center_); 148 new ProfileNotification(profile, notification, message_center_);
149 profile_notifications_[notification.notification_id()] = new_notification; 149 profile_notifications_[notification.notification_id()] = new_notification;
150 150
151 // Now pass a copy to message center. 151 // Now pass a copy to message center.
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 494
495 MessageCenterNotificationManager::ProfileNotification* 495 MessageCenterNotificationManager::ProfileNotification*
496 MessageCenterNotificationManager::FindProfileNotification( 496 MessageCenterNotificationManager::FindProfileNotification(
497 const std::string& id) const { 497 const std::string& id) const {
498 NotificationMap::const_iterator iter = profile_notifications_.find(id); 498 NotificationMap::const_iterator iter = profile_notifications_.find(id);
499 if (iter == profile_notifications_.end()) 499 if (iter == profile_notifications_.end())
500 return NULL; 500 return NULL;
501 501
502 return (*iter).second; 502 return (*iter).second;
503 } 503 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698