Fix linting errors and add isSupported
This commit is contained in:
parent
686b1388b1
commit
3938373ecb
6 changed files with 21 additions and 6 deletions
|
@ -132,6 +132,10 @@ void Notification::OnInitialProps() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Notification::IsSupported() {
|
||||||
|
return !!brightray::BrowserClient::Get()->GetNotificationPresenter();
|
||||||
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void Notification::BuildPrototype(v8::Isolate* isolate,
|
void Notification::BuildPrototype(v8::Isolate* isolate,
|
||||||
v8::Local<v8::FunctionTemplate> prototype) {
|
v8::Local<v8::FunctionTemplate> prototype) {
|
||||||
|
@ -166,6 +170,8 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||||
mate::Dictionary dict(isolate, exports);
|
mate::Dictionary dict(isolate, exports);
|
||||||
dict.Set("Notification",
|
dict.Set("Notification",
|
||||||
Notification::GetConstructor(isolate)->GetFunction());
|
Notification::GetConstructor(isolate)->GetFunction());
|
||||||
|
|
||||||
|
dict.SetMethod("isSupported", &Notification::IsSupported);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -25,8 +25,7 @@ class Notification : public mate::TrackableObject<Notification>,
|
||||||
public brightray::NotificationDelegate {
|
public brightray::NotificationDelegate {
|
||||||
public:
|
public:
|
||||||
static mate::WrappableBase* New(mate::Arguments* args);
|
static mate::WrappableBase* New(mate::Arguments* args);
|
||||||
static bool HasID(int id);
|
static bool IsSupported();
|
||||||
static Notification* FromID(int id);
|
|
||||||
|
|
||||||
static void BuildPrototype(v8::Isolate* isolate,
|
static void BuildPrototype(v8::Isolate* isolate,
|
||||||
v8::Local<v8::FunctionTemplate> prototype);
|
v8::Local<v8::FunctionTemplate> prototype);
|
||||||
|
|
|
@ -27,8 +27,8 @@ class CocoaNotification : public Notification {
|
||||||
const GURL& icon_url,
|
const GURL& icon_url,
|
||||||
const SkBitmap& icon,
|
const SkBitmap& icon,
|
||||||
bool silent,
|
bool silent,
|
||||||
const bool hasReply,
|
const bool has_reply,
|
||||||
const base::string16 replyPlaceholder) override;
|
const base::string16 reply_placeholder) override;
|
||||||
void Dismiss() override;
|
void Dismiss() override;
|
||||||
|
|
||||||
void NotificationDisplayed();
|
void NotificationDisplayed();
|
||||||
|
|
|
@ -27,7 +27,7 @@ class Notification {
|
||||||
const GURL& icon_url,
|
const GURL& icon_url,
|
||||||
const SkBitmap& icon,
|
const SkBitmap& icon,
|
||||||
bool silent,
|
bool silent,
|
||||||
bool hasReply,
|
bool has_reply,
|
||||||
const base::string16& reply_placeholder) = 0;
|
const base::string16& reply_placeholder) = 0;
|
||||||
// Closes the notification, this instance will be destroyed after the
|
// Closes the notification, this instance will be destroyed after the
|
||||||
// notification gets closed.
|
// notification gets closed.
|
||||||
|
|
|
@ -19,6 +19,14 @@ Process: [Main](../glossary.md#main-process)
|
||||||
|
|
||||||
It creates a new `Notification` with native properties as set by the `options`.
|
It creates a new `Notification` with native properties as set by the `options`.
|
||||||
|
|
||||||
|
### Static Methods
|
||||||
|
|
||||||
|
The `Notification` class has the following static methods:
|
||||||
|
|
||||||
|
#### `BrowserWindow.isSupported()`
|
||||||
|
|
||||||
|
Returns `Boolean` - Whether or not desktop notifications are supported on the current system
|
||||||
|
|
||||||
### `new Notification([options])` _Experimental_
|
### `new Notification([options])` _Experimental_
|
||||||
|
|
||||||
* `options` Object
|
* `options` Object
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
const {EventEmitter} = require('events')
|
const {EventEmitter} = require('events')
|
||||||
const {Notification} = process.atomBinding('notification')
|
const {Notification, isSupported} = process.atomBinding('notification')
|
||||||
|
|
||||||
Object.setPrototypeOf(Notification.prototype, EventEmitter.prototype)
|
Object.setPrototypeOf(Notification.prototype, EventEmitter.prototype)
|
||||||
|
|
||||||
|
Notification.isSupported = isSupported
|
||||||
|
|
||||||
module.exports = Notification
|
module.exports = Notification
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue