Index: chrome/browser/notifications/message_center_notification_manager.cc |
diff --git a/chrome/browser/notifications/message_center_notification_manager.cc b/chrome/browser/notifications/message_center_notification_manager.cc |
index 4c755f0d17b0766e99e09d663424aaa232e3858f..4ab95ec7d64ee775b7868dc4e2ddd417f818ca13 100644 |
--- a/chrome/browser/notifications/message_center_notification_manager.cc |
+++ b/chrome/browser/notifications/message_center_notification_manager.cc |
@@ -237,13 +237,28 @@ MessageCenterNotificationManager::GetAllIdsByProfileAndSourceOrigin( |
// no profile method should be called inside this function. |
std::set<std::string> delegate_ids; |
- for (NotificationMap::iterator iter = profile_notifications_.begin(); |
- iter != profile_notifications_.end(); iter++) { |
- if ((*iter).second->notification().origin_url() == source && |
- profile == (*iter).second->profile()) { |
- delegate_ids.insert(iter->second->notification().delegate_id()); |
+ for (const auto& iter : profile_notifications_) { |
johnme
2015/05/14 15:22:32
s/iter/entry/ or 'pair' or something, ditto below.
Peter Beverloo
2015/05/14 16:03:34
Done.
|
+ const Notification& notification = iter.second->notification(); |
+ if (iter.second->profile() == profile && |
+ notification.origin_url() == source) { |
+ delegate_ids.insert(notification.delegate_id()); |
} |
} |
+ |
+ return delegate_ids; |
+} |
+ |
+std::set<std::string> MessageCenterNotificationManager::GetAllIdsByProfile( |
+ Profile* profile) { |
+ // The profile pointer can be weak, the instance may have been destroyed, so |
johnme
2015/05/14 15:22:32
Eww gross. Since this is a new method, can we just
Peter Beverloo
2015/05/14 16:03:34
As discussed offline, this is a common pattern in
|
+ // no profile method should be called inside this function. |
+ |
+ std::set<std::string> delegate_ids; |
+ for (const auto& iter : profile_notifications_) { |
+ if (iter.second->profile() == profile) |
+ delegate_ids.insert(iter.second->notification().delegate_id()); |
+ } |
+ |
return delegate_ids; |
} |