Add bare-bones HTML notifications support
Calling Notification.show() now works. But Notification.close() does nothing, and none of the notification's events fire.
This commit is contained in:
parent
1a1fecf423
commit
0893253188
3 changed files with 29 additions and 0 deletions
|
@ -18,6 +18,7 @@
|
||||||
'sources': [
|
'sources': [
|
||||||
'browser/browser_client.cc',
|
'browser/browser_client.cc',
|
||||||
'browser/browser_client.h',
|
'browser/browser_client.h',
|
||||||
|
'browser/browser_client_mac.mm',
|
||||||
'browser/browser_context.cc',
|
'browser/browser_context.cc',
|
||||||
'browser/browser_context.h',
|
'browser/browser_context.h',
|
||||||
'browser/browser_main_parts.cc',
|
'browser/browser_main_parts.cc',
|
||||||
|
|
|
@ -28,6 +28,11 @@ protected:
|
||||||
private:
|
private:
|
||||||
virtual content::BrowserMainParts* CreateBrowserMainParts(const content::MainFunctionParams&) OVERRIDE;
|
virtual content::BrowserMainParts* CreateBrowserMainParts(const content::MainFunctionParams&) OVERRIDE;
|
||||||
virtual net::URLRequestContextGetter* CreateRequestContext(content::BrowserContext*, content::ProtocolHandlerMap*) OVERRIDE;
|
virtual net::URLRequestContextGetter* CreateRequestContext(content::BrowserContext*, content::ProtocolHandlerMap*) OVERRIDE;
|
||||||
|
virtual void ShowDesktopNotification(
|
||||||
|
const content::ShowDesktopNotificationHostMsgParams&,
|
||||||
|
int render_process_id,
|
||||||
|
int render_view_id,
|
||||||
|
bool worker) OVERRIDE;
|
||||||
|
|
||||||
BrowserMainParts* browser_main_parts_;
|
BrowserMainParts* browser_main_parts_;
|
||||||
|
|
||||||
|
|
23
brightray/browser/browser_client_mac.mm
Normal file
23
brightray/browser/browser_client_mac.mm
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
#import "browser/browser_client.h"
|
||||||
|
|
||||||
|
#import "base/strings/sys_string_conversions.h"
|
||||||
|
#import "content/public/common/show_desktop_notification_params.h"
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
namespace brightray {
|
||||||
|
|
||||||
|
void BrowserClient::ShowDesktopNotification(
|
||||||
|
const content::ShowDesktopNotificationHostMsgParams& params,
|
||||||
|
int render_process_id,
|
||||||
|
int render_view_id,
|
||||||
|
bool worker) {
|
||||||
|
auto notification = [[NSUserNotification alloc] init];
|
||||||
|
notification.title = base::SysUTF16ToNSString(params.title);
|
||||||
|
notification.informativeText = base::SysUTF16ToNSString(params.body);
|
||||||
|
|
||||||
|
[NSUserNotificationCenter.defaultUserNotificationCenter deliverNotification:notification];
|
||||||
|
[notification release];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue