/src/mozilla-central/dom/notification/NotificationEvent.h
Line | Count | Source (jump to first uncovered line) |
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/. */ |
6 | | |
7 | | #ifndef mozilla_dom_workers_notificationevent_h__ |
8 | | #define mozilla_dom_workers_notificationevent_h__ |
9 | | |
10 | | #include "mozilla/dom/Event.h" |
11 | | #include "mozilla/dom/NotificationEventBinding.h" |
12 | | #include "mozilla/dom/ServiceWorkerEvents.h" |
13 | | #include "mozilla/dom/WorkerCommon.h" |
14 | | |
15 | | namespace mozilla { |
16 | | namespace dom { |
17 | | |
18 | | class ServiceWorker; |
19 | | class ServiceWorkerClient; |
20 | | |
21 | | class NotificationEvent final : public ExtendableEvent |
22 | | { |
23 | | protected: |
24 | | explicit NotificationEvent(EventTarget* aOwner); |
25 | | ~NotificationEvent() |
26 | 0 | {} |
27 | | |
28 | | public: |
29 | | NS_DECL_ISUPPORTS_INHERITED |
30 | | NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(NotificationEvent, ExtendableEvent) |
31 | | |
32 | | virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override |
33 | 0 | { |
34 | 0 | return NotificationEvent_Binding::Wrap(aCx, this, aGivenProto); |
35 | 0 | } |
36 | | |
37 | | static already_AddRefed<NotificationEvent> |
38 | | Constructor(mozilla::dom::EventTarget* aOwner, |
39 | | const nsAString& aType, |
40 | | const NotificationEventInit& aOptions, |
41 | | ErrorResult& aRv) |
42 | | { |
43 | | RefPtr<NotificationEvent> e = new NotificationEvent(aOwner); |
44 | | bool trusted = e->Init(aOwner); |
45 | | e->InitEvent(aType, aOptions.mBubbles, aOptions.mCancelable); |
46 | | e->SetTrusted(trusted); |
47 | | e->SetComposed(aOptions.mComposed); |
48 | | e->mNotification = aOptions.mNotification; |
49 | | e->SetWantsPopupControlCheck(e->IsTrusted()); |
50 | | return e.forget(); |
51 | | } |
52 | | |
53 | | static already_AddRefed<NotificationEvent> |
54 | | Constructor(const GlobalObject& aGlobal, |
55 | | const nsAString& aType, |
56 | | const NotificationEventInit& aOptions, |
57 | | ErrorResult& aRv) |
58 | | { |
59 | | nsCOMPtr<EventTarget> owner = do_QueryInterface(aGlobal.GetAsSupports()); |
60 | | return Constructor(owner, aType, aOptions, aRv); |
61 | | } |
62 | | |
63 | | already_AddRefed<Notification> |
64 | | Notification_() |
65 | | { |
66 | | RefPtr<Notification> n = mNotification; |
67 | | return n.forget(); |
68 | | } |
69 | | |
70 | | private: |
71 | | RefPtr<Notification> mNotification; |
72 | | }; |
73 | | |
74 | | } // dom namspace |
75 | | } // mozilla namespace |
76 | | |
77 | | #endif /* mozilla_dom_workers_notificationevent_h__ */ |