Add CreateUserNotification helper function
This commit is contained in:
parent
08f393437e
commit
e592f3ffa1
1 changed files with 15 additions and 5 deletions
|
@ -11,6 +11,20 @@
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
scoped_nsobject<NSUserNotification> 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<NSUserNotification>(notification);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
NotificationPresenter* NotificationPresenter::Create() {
|
NotificationPresenter* NotificationPresenter::Create() {
|
||||||
return new NotificationPresenterMac;
|
return new NotificationPresenterMac;
|
||||||
}
|
}
|
||||||
|
@ -27,12 +41,8 @@ void NotificationPresenterMac::ShowNotification(
|
||||||
const content::ShowDesktopNotificationHostMsgParams& params,
|
const content::ShowDesktopNotificationHostMsgParams& params,
|
||||||
int render_process_id,
|
int render_process_id,
|
||||||
int render_view_id) {
|
int render_view_id) {
|
||||||
auto notification = [[NSUserNotification alloc] init];
|
auto notification = CreateUserNotification(params, render_process_id, render_view_id);
|
||||||
notification.title = base::SysUTF16ToNSString(params.title);
|
|
||||||
notification.informativeText = base::SysUTF16ToNSString(params.body);
|
|
||||||
|
|
||||||
[NSUserNotificationCenter.defaultUserNotificationCenter deliverNotification:notification];
|
[NSUserNotificationCenter.defaultUserNotificationCenter deliverNotification:notification];
|
||||||
[notification release];
|
|
||||||
|
|
||||||
auto host = content::RenderViewHost::FromID(render_process_id, render_view_id);
|
auto host = content::RenderViewHost::FromID(render_process_id, render_view_id);
|
||||||
if (!host)
|
if (!host)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue