From 76aca1e99edcfeadb8061ac15dbefee31c89ab7c Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 27 Oct 2015 12:38:36 -0700 Subject: NULL check the UI manager when getting displayed notifications We can end up with a NULL notification UI manager here when the browser process is being shut down and another feature, in their shut down code, ends up creating a new storage partition. BUG=546745 Review URL: https://codereview.chromium.org/1409293004 Cr-Commit-Position: refs/heads/master@{#356370} --- .../browser/notifications/platform_notification_service_impl.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/chrome/browser/notifications/platform_notification_service_impl.cc b/chrome/browser/notifications/platform_notification_service_impl.cc index d6a4e2c..04734d1 100644 --- a/chrome/browser/notifications/platform_notification_service_impl.cc +++ b/chrome/browser/notifications/platform_notification_service_impl.cc @@ -338,8 +338,15 @@ bool PlatformNotificationServiceImpl::GetDisplayedPersistentNotifications( if (!profile || profile->AsTestingProfile()) return false; // Tests will not have a message center. + // There may not be a notification ui manager when another feature erroneously + // instantiates a storage partition when the browser process is shutting down. + // TODO(peter): Remove in favor of a DCHECK when crbug.com/546745 is fixed. + NotificationUIManager* ui_manager = GetNotificationUIManager(); + if (!ui_manager) + return false; + // TODO(peter): Filter for persistent notifications only. - *displayed_notifications = GetNotificationUIManager()->GetAllIdsByProfile( + *displayed_notifications = ui_manager->GetAllIdsByProfile( NotificationUIManager::GetProfileID(profile)); return true; -- cgit v1.1