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

Unified Diff: chrome/browser/notifications/notification_ui_manager_mac.mm

Issue 11414215: Add CloseAllByProfile to NotificationUIManager and call before destroyng a Profile (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix mac Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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();

Powered by Google App Engine
This is Rietveld 408576698