diff --git a/brightray/browser/notification_presenter_mac.mm b/brightray/browser/notification_presenter_mac.mm index dc914bb9352b..a8e07fbfeaf1 100644 --- a/brightray/browser/notification_presenter_mac.mm +++ b/brightray/browser/notification_presenter_mac.mm @@ -11,6 +11,20 @@ namespace brightray { +namespace { + +scoped_nsobject CreateUserNotification( + const content::ShowDesktopNotificationHostMsgParams& params, + int render_process_id, + int render_view_id) { + auto notification = [[NSUserNotification alloc] init]; + notification.title = base::SysUTF16ToNSString(params.title); + notification.informativeText = base::SysUTF16ToNSString(params.body); + return scoped_nsobject(notification); +} + +} + NotificationPresenter* NotificationPresenter::Create() { return new NotificationPresenterMac; } @@ -27,12 +41,8 @@ void NotificationPresenterMac::ShowNotification( const content::ShowDesktopNotificationHostMsgParams& params, int render_process_id, int render_view_id) { - auto notification = [[NSUserNotification alloc] init]; - notification.title = base::SysUTF16ToNSString(params.title); - notification.informativeText = base::SysUTF16ToNSString(params.body); - + auto notification = CreateUserNotification(params, render_process_id, render_view_id); [NSUserNotificationCenter.defaultUserNotificationCenter deliverNotification:notification]; - [notification release]; auto host = content::RenderViewHost::FromID(render_process_id, render_view_id); if (!host)