diff --git a/atom/browser/api/atom_api_notification.cc b/atom/browser/api/atom_api_notification.cc index cfe31bc7c3..48c7487191 100644 --- a/atom/browser/api/atom_api_notification.cc +++ b/atom/browser/api/atom_api_notification.cc @@ -57,6 +57,7 @@ Notification::Notification(v8::Isolate* isolate, mate::Dictionary opts; if (args->GetNext(&opts)) { opts.Get("title", &title_); + opts.Get("subtitle", &subtitle_); opts.Get("body", &body_); has_icon_ = opts.Get("icon", &icon_); if (has_icon_) { @@ -88,6 +89,10 @@ base::string16 Notification::GetTitle() { return title_; } +base::string16 Notification::GetSubtitle() { + return subtitle_; +} + base::string16 Notification::GetBody() { return body_; } @@ -109,6 +114,10 @@ void Notification::SetTitle(const base::string16& new_title) { title_ = new_title; } +void Notification::SetSubtitle(const base::string16& new_subtitle) { + subtitle_ = new_subtitle; +} + void Notification::SetBody(const base::string16& new_body) { body_ = new_body; } @@ -164,6 +173,7 @@ void Notification::Show() { if (notification_) { brightray::NotificationOptions options; options.title = title_; + options.subtitle = subtitle_; options.msg = body_; options.icon_url = GURL(); options.icon = icon_.AsBitmap(); @@ -188,6 +198,8 @@ void Notification::BuildPrototype(v8::Isolate* isolate, .MakeDestroyable() .SetMethod("show", &Notification::Show) .SetProperty("title", &Notification::GetTitle, &Notification::SetTitle) + .SetProperty("subtitle", &Notification::GetSubtitle, + &Notification::SetSubtitle) .SetProperty("body", &Notification::GetBody, &Notification::SetBody) .SetProperty("silent", &Notification::GetSilent, &Notification::SetSilent) .SetProperty("replyPlaceholder", &Notification::GetReplyPlaceholder, diff --git a/atom/browser/api/atom_api_notification.h b/atom/browser/api/atom_api_notification.h index 3745f4309b..e61cf9f211 100644 --- a/atom/browser/api/atom_api_notification.h +++ b/atom/browser/api/atom_api_notification.h @@ -48,6 +48,7 @@ class Notification : public mate::TrackableObject, // Prop Getters base::string16 GetTitle(); + base::string16 GetSubtitle(); base::string16 GetBody(); bool GetSilent(); base::string16 GetReplyPlaceholder(); @@ -56,6 +57,7 @@ class Notification : public mate::TrackableObject, // Prop Setters void SetTitle(const base::string16& new_title); + void SetSubtitle(const base::string16& new_subtitle); void SetBody(const base::string16& new_body); void SetSilent(bool new_silent); void SetReplyPlaceholder(const base::string16& new_reply_placeholder); @@ -64,6 +66,7 @@ class Notification : public mate::TrackableObject, private: base::string16 title_; + base::string16 subtitle_; base::string16 body_; gfx::Image icon_; base::string16 icon_path_; diff --git a/brightray/browser/mac/cocoa_notification.mm b/brightray/browser/mac/cocoa_notification.mm index 66a80f6f66..a56d2e24c0 100644 --- a/brightray/browser/mac/cocoa_notification.mm +++ b/brightray/browser/mac/cocoa_notification.mm @@ -27,6 +27,7 @@ CocoaNotification::~CocoaNotification() { void CocoaNotification::Show(const NotificationOptions& options) { notification_.reset([[NSUserNotification alloc] init]); [notification_ setTitle:base::SysUTF16ToNSString(options.title)]; + [notification_ setSubtitle:base::SysUTF16ToNSString(options.subtitle)]; [notification_ setInformativeText:base::SysUTF16ToNSString(options.msg)]; if ([notification_ respondsToSelector:@selector(setContentImage:)] && diff --git a/brightray/browser/notification.h b/brightray/browser/notification.h index c9f31e68f5..017fdd8526 100644 --- a/brightray/browser/notification.h +++ b/brightray/browser/notification.h @@ -25,6 +25,7 @@ struct NotificationAction { struct NotificationOptions { base::string16 title; + base::string16 subtitle; base::string16 msg; std::string tag; GURL icon_url; diff --git a/docs/api/notification.md b/docs/api/notification.md index 17b2e94048..64f094ff74 100644 --- a/docs/api/notification.md +++ b/docs/api/notification.md @@ -31,7 +31,8 @@ Returns `Boolean` - Whether or not desktop notifications are supported on the cu * `options` Object * `title` String - A title for the notification, which will be shown at the top of the notification window when it is shown - * `body` String - The body text of the notification, which will be displayed below the title + * `subtitle` String - A subtitle for the notification, which will be displayed below the title. _macOS_ + * `body` String - The body text of the notification, which will be displayed below the title or subtitle * `silent` Boolean - (optional) Whether or not to emit an OS notification noise when showing the notification * `icon` [NativeImage](native-image.md) - (optional) An icon to use in the notification * `hasReply` Boolean - (optional) Whether or not to add an inline reply option to the notification. _macOS_