Move notification-related code into a new NotificationPresenter class
This commit is contained in:
parent
1328c85eef
commit
3c41af84a1
6 changed files with 58 additions and 5 deletions
29
brightray/browser/notification_presenter_mac.mm
Normal file
29
brightray/browser/notification_presenter_mac.mm
Normal file
|
@ -0,0 +1,29 @@
|
|||
#import "browser/notification_presenter.h"
|
||||
|
||||
#import "base/strings/sys_string_conversions.h"
|
||||
#import "content/public/browser/render_view_host.h"
|
||||
#import "content/public/common/show_desktop_notification_params.h"
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
namespace brightray {
|
||||
|
||||
void NotificationPresenter::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);
|
||||
|
||||
[NSUserNotificationCenter.defaultUserNotificationCenter deliverNotification:notification];
|
||||
[notification release];
|
||||
|
||||
auto host = content::RenderViewHost::FromID(render_process_id, render_view_id);
|
||||
if (!host)
|
||||
return;
|
||||
|
||||
host->DesktopNotificationPostDisplay(params.notification_id);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue