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

Unified Diff: chrome/browser/notifications/desktop_notification_service.cc

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/desktop_notification_service.cc
diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc
index 2568fb5727ac8805f7336617e69c1ee740df6275..f2e3b17d47b96ff5e9480295b8bcc804dead2350 100644
--- a/chrome/browser/notifications/desktop_notification_service.cc
+++ b/chrome/browser/notifications/desktop_notification_service.cc
@@ -276,7 +276,8 @@ void DesktopNotificationService::RemoveNotification(
g_browser_process->notification_ui_manager()->CancelById(notification_id);
}
-DesktopNotificationService::DesktopNotificationService(Profile* profile,
+DesktopNotificationService::DesktopNotificationService(
+ Profile* profile,
NotificationUIManager* ui_manager)
: profile_(profile),
ui_manager_(ui_manager) {
@@ -326,10 +327,14 @@ void DesktopNotificationService::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
+ // This may get called during shutdown, so don't use GetUIManager() here,
+ // and don't do anything if ui_manager_ hasn't already been set.
+ if (!ui_manager_)
+ return;
+
if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) {
// Remove all notifications currently shown or queued by the extension
- // which was unloaded. Don't use GetUIManager() here, because this may
- // get called during shutdown.
+ // which was unloaded.
const extensions::Extension* extension =
content::Details<extensions::UnloadedExtensionInfo>(details)->extension;
if (extension &&
@@ -338,6 +343,10 @@ void DesktopNotificationService::Observe(
CancelAllBySourceOrigin(extension->url());
}
} else if (type == chrome::NOTIFICATION_PROFILE_DESTROYED) {
+ if (g_browser_process && g_browser_process->notification_ui_manager()) {
+ g_browser_process->notification_ui_manager()->
+ CancelAllByProfile(profile_);
+ }
StopObserving();
}
}
« no previous file with comments | « chrome/browser/notifications/balloon_collection_impl.cc ('k') | chrome/browser/notifications/notification_ui_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698