Merge pull request #10293 from electron/notification-sounds
Add support for soundName in main process notifications
This commit is contained in:
commit
f17bd040ad
5 changed files with 35 additions and 1 deletions
|
@ -67,6 +67,7 @@ Notification::Notification(v8::Isolate* isolate,
|
|||
opts.Get("replyPlaceholder", &reply_placeholder_);
|
||||
opts.Get("hasReply", &has_reply_);
|
||||
opts.Get("actions", &actions_);
|
||||
opts.Get("sound", &sound_);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,6 +114,10 @@ std::vector<brightray::NotificationAction> Notification::GetActions() const {
|
|||
return actions_;
|
||||
}
|
||||
|
||||
base::string16 Notification::GetSound() const {
|
||||
return sound_;
|
||||
}
|
||||
|
||||
// Setters
|
||||
void Notification::SetTitle(const base::string16& new_title) {
|
||||
title_ = new_title;
|
||||
|
@ -143,6 +148,10 @@ void Notification::SetActions(
|
|||
actions_ = actions;
|
||||
}
|
||||
|
||||
void Notification::SetSound(const base::string16& new_sound) {
|
||||
sound_ = new_sound;
|
||||
}
|
||||
|
||||
void Notification::NotificationAction(int index) {
|
||||
Emit("action", index);
|
||||
}
|
||||
|
@ -181,6 +190,7 @@ void Notification::Show() {
|
|||
options.has_reply = has_reply_;
|
||||
options.reply_placeholder = reply_placeholder_;
|
||||
options.actions = actions_;
|
||||
options.sound = sound_;
|
||||
notification_->Show(options);
|
||||
}
|
||||
}
|
||||
|
@ -207,7 +217,9 @@ void Notification::BuildPrototype(v8::Isolate* isolate,
|
|||
.SetProperty("hasReply", &Notification::GetHasReply,
|
||||
&Notification::SetHasReply)
|
||||
.SetProperty("actions", &Notification::GetActions,
|
||||
&Notification::SetActions);
|
||||
&Notification::SetActions)
|
||||
.SetProperty("sound", &Notification::GetSound,
|
||||
&Notification::SetSound);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
|
|
@ -54,6 +54,7 @@ class Notification : public mate::TrackableObject<Notification>,
|
|||
base::string16 GetReplyPlaceholder() const;
|
||||
bool GetHasReply() const;
|
||||
std::vector<brightray::NotificationAction> GetActions() const;
|
||||
base::string16 GetSound() const;
|
||||
|
||||
// Prop Setters
|
||||
void SetTitle(const base::string16& new_title);
|
||||
|
@ -63,6 +64,7 @@ class Notification : public mate::TrackableObject<Notification>,
|
|||
void SetReplyPlaceholder(const base::string16& new_reply_placeholder);
|
||||
void SetHasReply(bool new_has_reply);
|
||||
void SetActions(const std::vector<brightray::NotificationAction>& actions);
|
||||
void SetSound(const base::string16& sound);
|
||||
|
||||
private:
|
||||
base::string16 title_;
|
||||
|
@ -75,6 +77,7 @@ class Notification : public mate::TrackableObject<Notification>,
|
|||
base::string16 reply_placeholder_;
|
||||
bool has_reply_ = false;
|
||||
std::vector<brightray::NotificationAction> actions_;
|
||||
base::string16 sound_;
|
||||
|
||||
brightray::NotificationPresenter* presenter_;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue