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:
Adam Roben 2013-03-28 17:17:46 -04:00
parent 1a1fecf423
commit 0893253188
3 changed files with 29 additions and 0 deletions

View file

@ -18,6 +18,7 @@
'sources': [
'browser/browser_client.cc',
'browser/browser_client.h',
'browser/browser_client_mac.mm',
'browser/browser_context.cc',
'browser/browser_context.h',
'browser/browser_main_parts.cc',

View file

@ -28,6 +28,11 @@ protected:
private:
virtual content::BrowserMainParts* CreateBrowserMainParts(const content::MainFunctionParams&) 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_;

View 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];
}
}