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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_MediaKeyNeededEvent_h__
8 #define mozilla_dom_MediaKeyNeededEvent_h__
11 #include "js/RootingAPI.h"
12 #include "mozilla/AlreadyAddRefed.h"
13 #include "mozilla/Assertions.h"
14 #include "mozilla/dom/Event.h"
15 #include "nsCycleCollectionParticipant.h"
16 #include "nsISupports.h"
17 #include "nsStringFwd.h"
20 namespace mozilla::dom
{
21 struct MediaKeyNeededEventInit
;
23 class MediaEncryptedEvent final
: public Event
{
25 NS_DECL_ISUPPORTS_INHERITED
26 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(MediaEncryptedEvent
,
29 virtual ~MediaEncryptedEvent();
30 explicit MediaEncryptedEvent(EventTarget
* aOwner
);
32 nsString mInitDataType
;
33 JS::Heap
<JSObject
*> mInitData
;
36 JSObject
* WrapObjectInternal(JSContext
* aCx
,
37 JS::Handle
<JSObject
*> aGivenProto
) override
;
39 static already_AddRefed
<MediaEncryptedEvent
> Constructor(EventTarget
* aOwner
);
41 static already_AddRefed
<MediaEncryptedEvent
> Constructor(
42 EventTarget
* aOwner
, const nsAString
& aInitDataType
,
43 const nsTArray
<uint8_t>& aInitData
);
45 static already_AddRefed
<MediaEncryptedEvent
> Constructor(
46 const GlobalObject
& aGlobal
, const nsAString
& aType
,
47 const MediaKeyNeededEventInit
& aEventInitDict
, ErrorResult
& aRv
);
49 void GetInitDataType(nsString
& aRetVal
) const;
51 void GetInitData(JSContext
* cx
, JS::MutableHandle
<JSObject
*> aData
,
55 nsTArray
<uint8_t> mRawInitData
;
58 } // namespace mozilla::dom
60 #endif // mozilla_dom_MediaKeyNeededEvent_h__