| 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();
|
| }
|
| }
|
|
|