From 0a5f7171d4bd6aae36d6690b1046a4f16bf5f254 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 28 Oct 2016 10:54:55 -0700 Subject: [PATCH] Add more guards around null notification --- brightray/browser/mac/cocoa_notification.mm | 5 +++-- brightray/browser/platform_notification_service.cc | 11 ++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/brightray/browser/mac/cocoa_notification.mm b/brightray/browser/mac/cocoa_notification.mm index fe21000e376b..4e9ee3238b8f 100644 --- a/brightray/browser/mac/cocoa_notification.mm +++ b/brightray/browser/mac/cocoa_notification.mm @@ -57,8 +57,9 @@ void CocoaNotification::Show(const base::string16& title, } void CocoaNotification::Dismiss() { - [NSUserNotificationCenter.defaultUserNotificationCenter - removeDeliveredNotification:notification_]; + if (notification_) + [NSUserNotificationCenter.defaultUserNotificationCenter + removeDeliveredNotification:notification_]; NotificationDismissed(); } diff --git a/brightray/browser/platform_notification_service.cc b/brightray/browser/platform_notification_service.cc index 5fabac82c346..c9f2e5a1f91d 100644 --- a/brightray/browser/platform_notification_service.cc +++ b/brightray/browser/platform_notification_service.cc @@ -26,12 +26,13 @@ void OnWebNotificationAllowed(base::WeakPtr notification, const content::PlatformNotificationData& data, bool audio_muted, bool allowed) { - if (!allowed) { - notification->Destroy(); + if (!notification) return; - } - notification->Show(data.title, data.body, data.tag, data.icon, icon, - audio_muted ? true : data.silent); + if (allowed) + notification->Show(data.title, data.body, data.tag, data.icon, icon, + audio_muted ? true : data.silent); + else + notification->Destroy(); } } // namespace