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
|
||||
void Notification::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
|
@ -166,6 +170,8 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
mate::Dictionary dict(isolate, exports);
|
||||
dict.Set("Notification",
|
||||
Notification::GetConstructor(isolate)->GetFunction());
|
||||
|
||||
dict.SetMethod("isSupported", &Notification::IsSupported);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -25,8 +25,7 @@ class Notification : public mate::TrackableObject<Notification>,
|
|||
public brightray::NotificationDelegate {
|
||||
public:
|
||||
static mate::WrappableBase* New(mate::Arguments* args);
|
||||
static bool HasID(int id);
|
||||
static Notification* FromID(int id);
|
||||
static bool IsSupported();
|
||||
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
|
|
|
@ -27,8 +27,8 @@ class CocoaNotification : public Notification {
|
|||
const GURL& icon_url,
|
||||
const SkBitmap& icon,
|
||||
bool silent,
|
||||
const bool hasReply,
|
||||
const base::string16 replyPlaceholder) override;
|
||||
const bool has_reply,
|
||||
const base::string16 reply_placeholder) override;
|
||||
void Dismiss() override;
|
||||
|
||||
void NotificationDisplayed();
|
||||
|
|
|
@ -27,7 +27,7 @@ class Notification {
|
|||
const GURL& icon_url,
|
||||
const SkBitmap& icon,
|
||||
bool silent,
|
||||
bool hasReply,
|
||||
bool has_reply,
|
||||
const base::string16& reply_placeholder) = 0;
|
||||
// Closes the notification, this instance will be destroyed after the
|
||||
// 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`.
|
||||
|
||||
### 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_
|
||||
|
||||
* `options` Object
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
const {EventEmitter} = require('events')
|
||||
const {Notification} = process.atomBinding('notification')
|
||||
const {Notification, isSupported} = process.atomBinding('notification')
|
||||
|
||||
Object.setPrototypeOf(Notification.prototype, EventEmitter.prototype)
|
||||
|
||||
Notification.isSupported = isSupported
|
||||
|
||||
module.exports = Notification
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue