Line data Source code
1 : /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #ifndef mozilla_dom_workers_notificationevent_h__
7 : #define mozilla_dom_workers_notificationevent_h__
8 :
9 : #include "mozilla/dom/Event.h"
10 : #include "mozilla/dom/NotificationEventBinding.h"
11 : #include "mozilla/dom/ServiceWorkerEvents.h"
12 : #include "mozilla/dom/workers/Workers.h"
13 :
14 : BEGIN_WORKERS_NAMESPACE
15 :
16 : class ServiceWorker;
17 : class ServiceWorkerClient;
18 :
19 : class NotificationEvent final : public ExtendableEvent
20 : {
21 : protected:
22 : explicit NotificationEvent(EventTarget* aOwner);
23 0 : ~NotificationEvent()
24 0 : {}
25 :
26 : public:
27 : NS_DECL_ISUPPORTS_INHERITED
28 0 : NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(NotificationEvent, ExtendableEvent)
29 0 : NS_FORWARD_TO_EVENT
30 :
31 0 : virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
32 : {
33 0 : return NotificationEventBinding::Wrap(aCx, this, aGivenProto);
34 : }
35 :
36 : static already_AddRefed<NotificationEvent>
37 0 : Constructor(mozilla::dom::EventTarget* aOwner,
38 : const nsAString& aType,
39 : const NotificationEventInit& aOptions,
40 : ErrorResult& aRv)
41 : {
42 0 : RefPtr<NotificationEvent> e = new NotificationEvent(aOwner);
43 0 : bool trusted = e->Init(aOwner);
44 0 : e->InitEvent(aType, aOptions.mBubbles, aOptions.mCancelable);
45 0 : e->SetTrusted(trusted);
46 0 : e->SetComposed(aOptions.mComposed);
47 0 : e->mNotification = aOptions.mNotification;
48 0 : e->SetWantsPopupControlCheck(e->IsTrusted());
49 0 : return e.forget();
50 : }
51 :
52 : static already_AddRefed<NotificationEvent>
53 0 : Constructor(const GlobalObject& aGlobal,
54 : const nsAString& aType,
55 : const NotificationEventInit& aOptions,
56 : ErrorResult& aRv)
57 : {
58 0 : nsCOMPtr<EventTarget> owner = do_QueryInterface(aGlobal.GetAsSupports());
59 0 : return Constructor(owner, aType, aOptions, aRv);
60 : }
61 :
62 : already_AddRefed<Notification>
63 0 : Notification_()
64 : {
65 0 : RefPtr<Notification> n = mNotification;
66 0 : return n.forget();
67 : }
68 :
69 : private:
70 : RefPtr<Notification> mNotification;
71 : };
72 :
73 : END_WORKERS_NAMESPACE
74 : #endif /* mozilla_dom_workers_notificationevent_h__ */
75 :
|