Index: chrome/browser/notifications/notification_ui_manager_mac.mm |
diff --git a/chrome/browser/notifications/notification_ui_manager_mac.mm b/chrome/browser/notifications/notification_ui_manager_mac.mm |
index cd10fd6719aaaa85949cb3da8bfc6cd5c7d3e824..52f7c7551e53f337fafafec65d84b8480714339d 100644 |
--- a/chrome/browser/notifications/notification_ui_manager_mac.mm |
+++ b/chrome/browser/notifications/notification_ui_manager_mac.mm |
@@ -99,8 +99,11 @@ NotificationUIManager* NotificationUIManager::Create( |
} |
NotificationUIManagerMac::ControllerNotification::ControllerNotification( |
- id<CrUserNotification> a_view, Notification* a_model) |
- : view(a_view), |
+ Profile* a_profile, |
+ id<CrUserNotification> a_view, |
+ Notification* a_model) |
+ : profile(a_profile), |
+ view(a_view), |
model(a_model) { |
} |
@@ -150,10 +153,11 @@ void NotificationUIManagerMac::Add(const Notification& notification, |
forKey:kNotificationIDKey]; |
ns_notification.hasActionButton = NO; |
- notification_map_.insert( |
- std::make_pair(notification.notification_id(), |
- new ControllerNotification(ns_notification, |
- new Notification(notification)))); |
+ notification_map_.insert(std::make_pair( |
+ notification.notification_id(), |
+ new ControllerNotification(profile, |
+ ns_notification, |
+ new Notification(notification)))); |
[GetNotificationCenter() deliverNotification:ns_notification]; |
} |
@@ -185,6 +189,23 @@ bool NotificationUIManagerMac::CancelAllBySourceOrigin( |
return success; |
} |
+bool NotificationUIManagerMac::CancelAllByProfile(Profile* profile) { |
+ bool success = builtin_manager_->CancelAllByProfile(profile); |
+ |
+ for (NotificationMap::iterator it = notification_map_.begin(); |
+ it != notification_map_.end();) { |
+ if (it->second->profile == profile) { |
+ // RemoveNotification will erase from the map, invalidating iterator |
+ // references to the removed element. |
+ success |= RemoveNotification((it++)->second->view); |
+ } else { |
+ ++it; |
+ } |
+ } |
+ |
+ return success; |
+} |
+ |
void NotificationUIManagerMac::CancelAll() { |
id<CrUserNotificationCenter> center = GetNotificationCenter(); |