feat: allow Linux/Windows users to set notification timeout (#20153)

* feat: allow Linux users to set notification timeout

* implement on windows
This commit is contained in:
Shelley Vohr 2019-10-09 17:22:21 +02:00 committed by John Kleinschmidt
parent 5e11be6898
commit f80a17c5be
7 changed files with 92 additions and 3 deletions

View file

@ -69,6 +69,7 @@ Notification::Notification(v8::Local<v8::Object> wrapper,
opts.Get("replyPlaceholder", &reply_placeholder_);
opts.Get("urgency", &urgency_);
opts.Get("hasReply", &has_reply_);
opts.Get("timeoutType", &timeout_type_);
opts.Get("actions", &actions_);
opts.Get("sound", &sound_);
opts.Get("closeButtonText", &close_button_text_);
@ -111,6 +112,10 @@ bool Notification::GetHasReply() const {
return has_reply_;
}
base::string16 Notification::GetTimeoutType() const {
return timeout_type_;
}
base::string16 Notification::GetReplyPlaceholder() const {
return reply_placeholder_;
}
@ -152,6 +157,10 @@ void Notification::SetHasReply(bool new_has_reply) {
has_reply_ = new_has_reply;
}
void Notification::SetTimeoutType(const base::string16& new_timeout_type) {
timeout_type_ = new_timeout_type;
}
void Notification::SetReplyPlaceholder(const base::string16& new_placeholder) {
reply_placeholder_ = new_placeholder;
}
@ -216,6 +225,7 @@ void Notification::Show() {
options.icon = icon_.AsBitmap();
options.silent = silent_;
options.has_reply = has_reply_;
options.timeout_type = timeout_type_;
options.reply_placeholder = reply_placeholder_;
options.actions = actions_;
options.sound = sound_;
@ -246,6 +256,8 @@ void Notification::BuildPrototype(v8::Isolate* isolate,
.SetProperty("silent", &Notification::GetSilent, &Notification::SetSilent)
.SetProperty("hasReply", &Notification::GetHasReply,
&Notification::SetHasReply)
.SetProperty("timeoutType", &Notification::GetTimeoutType,
&Notification::SetTimeoutType)
.SetProperty("replyPlaceholder", &Notification::GetReplyPlaceholder,
&Notification::SetReplyPlaceholder)
.SetProperty("urgency", &Notification::GetUrgency,

View file

@ -54,6 +54,7 @@ class Notification : public mate::TrackableObject<Notification>,
base::string16 GetBody() const;
bool GetSilent() const;
bool GetHasReply() const;
base::string16 GetTimeoutType() const;
base::string16 GetReplyPlaceholder() const;
base::string16 GetUrgency() const;
base::string16 GetSound() const;
@ -67,6 +68,7 @@ class Notification : public mate::TrackableObject<Notification>,
void SetSilent(bool new_silent);
void SetHasReply(bool new_has_reply);
void SetUrgency(const base::string16& new_urgency);
void SetTimeoutType(const base::string16& new_timeout_type);
void SetReplyPlaceholder(const base::string16& new_reply_placeholder);
void SetSound(const base::string16& sound);
void SetActions(const std::vector<electron::NotificationAction>& actions);
@ -81,6 +83,7 @@ class Notification : public mate::TrackableObject<Notification>,
bool has_icon_ = false;
bool silent_ = false;
bool has_reply_ = false;
base::string16 timeout_type_;
base::string16 reply_placeholder_;
base::string16 sound_;
base::string16 urgency_;