mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Add more guards around null notification
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,12 +26,13 @@ void OnWebNotificationAllowed(base::WeakPtr<Notification> 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
|
||||
|
||||
Reference in New Issue
Block a user