2017-10-27 01:08:41 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2015-06-26 04:50:25 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_workers_notificationevent_h__
|
|
|
|
#define mozilla_dom_workers_notificationevent_h__
|
|
|
|
|
|
|
|
#include "mozilla/dom/Event.h"
|
|
|
|
#include "mozilla/dom/NotificationEventBinding.h"
|
|
|
|
#include "mozilla/dom/ServiceWorkerEvents.h"
|
2018-01-31 10:24:59 +03:00
|
|
|
#include "mozilla/dom/WorkerCommon.h"
|
2015-06-26 04:50:25 +03:00
|
|
|
|
2018-01-31 10:23:44 +03:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2015-06-26 04:50:25 +03:00
|
|
|
|
|
|
|
class ServiceWorker;
|
|
|
|
class ServiceWorkerClient;
|
|
|
|
|
|
|
|
class NotificationEvent final : public ExtendableEvent {
|
|
|
|
protected:
|
|
|
|
explicit NotificationEvent(EventTarget* aOwner);
|
|
|
|
~NotificationEvent() {}
|
|
|
|
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(NotificationEvent, ExtendableEvent)
|
|
|
|
|
|
|
|
virtual JSObject* WrapObjectInternal(
|
|
|
|
JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override {
|
2018-06-26 00:20:54 +03:00
|
|
|
return NotificationEvent_Binding::Wrap(aCx, this, aGivenProto);
|
2015-06-26 04:50:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static already_AddRefed<NotificationEvent> Constructor(
|
|
|
|
mozilla::dom::EventTarget* aOwner, const nsAString& aType,
|
2019-09-11 17:35:28 +03:00
|
|
|
const NotificationEventInit& aOptions) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<NotificationEvent> e = new NotificationEvent(aOwner);
|
2015-06-26 04:50:25 +03:00
|
|
|
bool trusted = e->Init(aOwner);
|
|
|
|
e->InitEvent(aType, aOptions.mBubbles, aOptions.mCancelable);
|
|
|
|
e->SetTrusted(trusted);
|
2016-08-31 06:16:11 +03:00
|
|
|
e->SetComposed(aOptions.mComposed);
|
2015-06-26 04:50:25 +03:00
|
|
|
e->mNotification = aOptions.mNotification;
|
|
|
|
e->SetWantsPopupControlCheck(e->IsTrusted());
|
|
|
|
return e.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
static already_AddRefed<NotificationEvent> Constructor(
|
|
|
|
const GlobalObject& aGlobal, const nsAString& aType,
|
2019-09-11 17:35:28 +03:00
|
|
|
const NotificationEventInit& aOptions) {
|
2015-06-26 04:50:25 +03:00
|
|
|
nsCOMPtr<EventTarget> owner = do_QueryInterface(aGlobal.GetAsSupports());
|
2019-09-11 17:35:28 +03:00
|
|
|
return Constructor(owner, aType, aOptions);
|
2015-06-26 04:50:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<Notification> Notification_() {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Notification> n = mNotification;
|
2015-06-26 04:50:25 +03:00
|
|
|
return n.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Notification> mNotification;
|
2015-06-26 04:50:25 +03:00
|
|
|
};
|
|
|
|
|
2018-01-31 10:23:44 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2015-06-26 04:50:25 +03:00
|
|
|
|
2018-01-31 10:23:44 +03:00
|
|
|
#endif /* mozilla_dom_workers_notificationevent_h__ */
|