no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / dom / notification / NotificationEvent.h
blob744c21679883d0fcbe801cea8683b4283e5f7c23
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_workers_notificationevent_h__
8 #define mozilla_dom_workers_notificationevent_h__
10 #include "mozilla/dom/Event.h"
11 #include "mozilla/dom/NotificationEventBinding.h"
12 #include "mozilla/dom/ServiceWorkerEvents.h"
13 #include "mozilla/dom/WorkerCommon.h"
15 namespace mozilla::dom {
17 class ServiceWorker;
18 class ServiceWorkerClient;
20 class NotificationEvent final : public ExtendableEvent {
21 protected:
22 explicit NotificationEvent(EventTarget* aOwner);
23 ~NotificationEvent() = default;
25 public:
26 NS_DECL_ISUPPORTS_INHERITED
27 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(NotificationEvent, ExtendableEvent)
29 virtual JSObject* WrapObjectInternal(
30 JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override {
31 return NotificationEvent_Binding::Wrap(aCx, this, aGivenProto);
34 static already_AddRefed<NotificationEvent> Constructor(
35 mozilla::dom::EventTarget* aOwner, const nsAString& aType,
36 const NotificationEventInit& aOptions) {
37 RefPtr<NotificationEvent> e = new NotificationEvent(aOwner);
38 bool trusted = e->Init(aOwner);
39 e->InitEvent(aType, aOptions.mBubbles, aOptions.mCancelable);
40 e->SetTrusted(trusted);
41 e->SetComposed(aOptions.mComposed);
42 e->mNotification = aOptions.mNotification;
43 e->SetWantsPopupControlCheck(e->IsTrusted());
44 return e.forget();
47 static already_AddRefed<NotificationEvent> Constructor(
48 const GlobalObject& aGlobal, const nsAString& aType,
49 const NotificationEventInit& aOptions) {
50 nsCOMPtr<EventTarget> owner = do_QueryInterface(aGlobal.GetAsSupports());
51 return Constructor(owner, aType, aOptions);
54 already_AddRefed<Notification> Notification_() {
55 RefPtr<Notification> n = mNotification;
56 return n.forget();
59 private:
60 RefPtr<Notification> mNotification;
63 } // namespace mozilla::dom
65 #endif /* mozilla_dom_workers_notificationevent_h__ */