1/*
2 This file is part of the WebKit open source project.
3 This file has been generated by generate-bindings.pl. DO NOT MODIFY!
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#include "config.h"
22
23#if ENABLE(ENCRYPTED_MEDIA)
24
25#include "JSMediaKeySystemAccess.h"
26
27#include "JSDOMAttribute.h"
28#include "JSDOMBinding.h"
29#include "JSDOMConstructorNotConstructable.h"
30#include "JSDOMConvertDictionary.h"
31#include "JSDOMConvertStrings.h"
32#include "JSDOMExceptionHandling.h"
33#include "JSDOMGlobalObject.h"
34#include "JSDOMOperation.h"
35#include "JSDOMOperationReturningPromise.h"
36#include "JSDOMWrapperCache.h"
37#include "JSMediaKeySystemConfiguration.h"
38#include "ScriptExecutionContext.h"
39#include <JavaScriptCore/FunctionPrototype.h>
40#include <JavaScriptCore/HeapSnapshotBuilder.h>
41#include <JavaScriptCore/JSCInlines.h>
42#include <wtf/GetPtr.h>
43#include <wtf/PointerPreparations.h>
44#include <wtf/URL.h>
45
46
47namespace WebCore {
48using namespace JSC;
49
50// Functions
51
52JSC::EncodedJSValue JSC_HOST_CALL jsMediaKeySystemAccessPrototypeFunctionGetConfiguration(JSC::ExecState*);
53JSC::EncodedJSValue JSC_HOST_CALL jsMediaKeySystemAccessPrototypeFunctionCreateMediaKeys(JSC::ExecState*);
54
55// Attributes
56
57JSC::EncodedJSValue jsMediaKeySystemAccessConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
58bool setJSMediaKeySystemAccessConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
59JSC::EncodedJSValue jsMediaKeySystemAccessKeySystem(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
60
61class JSMediaKeySystemAccessPrototype : public JSC::JSNonFinalObject {
62public:
63 using Base = JSC::JSNonFinalObject;
64 static JSMediaKeySystemAccessPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
65 {
66 JSMediaKeySystemAccessPrototype* ptr = new (NotNull, JSC::allocateCell<JSMediaKeySystemAccessPrototype>(vm.heap)) JSMediaKeySystemAccessPrototype(vm, globalObject, structure);
67 ptr->finishCreation(vm);
68 return ptr;
69 }
70
71 DECLARE_INFO;
72 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
73 {
74 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
75 }
76
77private:
78 JSMediaKeySystemAccessPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
79 : JSC::JSNonFinalObject(vm, structure)
80 {
81 }
82
83 void finishCreation(JSC::VM&);
84};
85
86using JSMediaKeySystemAccessConstructor = JSDOMConstructorNotConstructable<JSMediaKeySystemAccess>;
87
88template<> JSValue JSMediaKeySystemAccessConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
89{
90 UNUSED_PARAM(vm);
91 return globalObject.functionPrototype();
92}
93
94template<> void JSMediaKeySystemAccessConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
95{
96 putDirect(vm, vm.propertyNames->prototype, JSMediaKeySystemAccess::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
97 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("MediaKeySystemAccess"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
98 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
99}
100
101template<> const ClassInfo JSMediaKeySystemAccessConstructor::s_info = { "MediaKeySystemAccess", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaKeySystemAccessConstructor) };
102
103/* Hash table for prototype */
104
105static const HashTableValue JSMediaKeySystemAccessPrototypeTableValues[] =
106{
107 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaKeySystemAccessConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaKeySystemAccessConstructor) } },
108 { "keySystem", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaKeySystemAccessKeySystem), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
109 { "getConfiguration", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMediaKeySystemAccessPrototypeFunctionGetConfiguration), (intptr_t) (0) } },
110 { "createMediaKeys", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMediaKeySystemAccessPrototypeFunctionCreateMediaKeys), (intptr_t) (0) } },
111};
112
113const ClassInfo JSMediaKeySystemAccessPrototype::s_info = { "MediaKeySystemAccessPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaKeySystemAccessPrototype) };
114
115void JSMediaKeySystemAccessPrototype::finishCreation(VM& vm)
116{
117 Base::finishCreation(vm);
118 reifyStaticProperties(vm, JSMediaKeySystemAccess::info(), JSMediaKeySystemAccessPrototypeTableValues, *this);
119}
120
121const ClassInfo JSMediaKeySystemAccess::s_info = { "MediaKeySystemAccess", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaKeySystemAccess) };
122
123JSMediaKeySystemAccess::JSMediaKeySystemAccess(Structure* structure, JSDOMGlobalObject& globalObject, Ref<MediaKeySystemAccess>&& impl)
124 : JSDOMWrapper<MediaKeySystemAccess>(structure, globalObject, WTFMove(impl))
125{
126}
127
128void JSMediaKeySystemAccess::finishCreation(VM& vm)
129{
130 Base::finishCreation(vm);
131 ASSERT(inherits(vm, info()));
132
133}
134
135JSObject* JSMediaKeySystemAccess::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
136{
137 return JSMediaKeySystemAccessPrototype::create(vm, &globalObject, JSMediaKeySystemAccessPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
138}
139
140JSObject* JSMediaKeySystemAccess::prototype(VM& vm, JSDOMGlobalObject& globalObject)
141{
142 return getDOMPrototype<JSMediaKeySystemAccess>(vm, globalObject);
143}
144
145JSValue JSMediaKeySystemAccess::getConstructor(VM& vm, const JSGlobalObject* globalObject)
146{
147 return getDOMConstructor<JSMediaKeySystemAccessConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
148}
149
150void JSMediaKeySystemAccess::destroy(JSC::JSCell* cell)
151{
152 JSMediaKeySystemAccess* thisObject = static_cast<JSMediaKeySystemAccess*>(cell);
153 thisObject->JSMediaKeySystemAccess::~JSMediaKeySystemAccess();
154}
155
156template<> inline JSMediaKeySystemAccess* IDLAttribute<JSMediaKeySystemAccess>::cast(ExecState& state, EncodedJSValue thisValue)
157{
158 return jsDynamicCast<JSMediaKeySystemAccess*>(state.vm(), JSValue::decode(thisValue));
159}
160
161template<> inline JSMediaKeySystemAccess* IDLOperation<JSMediaKeySystemAccess>::cast(ExecState& state)
162{
163 return jsDynamicCast<JSMediaKeySystemAccess*>(state.vm(), state.thisValue());
164}
165
166EncodedJSValue jsMediaKeySystemAccessConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
167{
168 VM& vm = state->vm();
169 auto throwScope = DECLARE_THROW_SCOPE(vm);
170 auto* prototype = jsDynamicCast<JSMediaKeySystemAccessPrototype*>(vm, JSValue::decode(thisValue));
171 if (UNLIKELY(!prototype))
172 return throwVMTypeError(state, throwScope);
173 return JSValue::encode(JSMediaKeySystemAccess::getConstructor(state->vm(), prototype->globalObject()));
174}
175
176bool setJSMediaKeySystemAccessConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
177{
178 VM& vm = state->vm();
179 auto throwScope = DECLARE_THROW_SCOPE(vm);
180 auto* prototype = jsDynamicCast<JSMediaKeySystemAccessPrototype*>(vm, JSValue::decode(thisValue));
181 if (UNLIKELY(!prototype)) {
182 throwVMTypeError(state, throwScope);
183 return false;
184 }
185 // Shadowing a built-in constructor
186 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
187}
188
189static inline JSValue jsMediaKeySystemAccessKeySystemGetter(ExecState& state, JSMediaKeySystemAccess& thisObject, ThrowScope& throwScope)
190{
191 UNUSED_PARAM(throwScope);
192 UNUSED_PARAM(state);
193 auto& impl = thisObject.wrapped();
194 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.keySystem());
195 return result;
196}
197
198EncodedJSValue jsMediaKeySystemAccessKeySystem(ExecState* state, EncodedJSValue thisValue, PropertyName)
199{
200 return IDLAttribute<JSMediaKeySystemAccess>::get<jsMediaKeySystemAccessKeySystemGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "keySystem");
201}
202
203static inline JSC::EncodedJSValue jsMediaKeySystemAccessPrototypeFunctionGetConfigurationBody(JSC::ExecState* state, typename IDLOperation<JSMediaKeySystemAccess>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
204{
205 UNUSED_PARAM(state);
206 UNUSED_PARAM(throwScope);
207 auto& impl = castedThis->wrapped();
208 return JSValue::encode(toJS<IDLDictionary<MediaKeySystemConfiguration>>(*state, *castedThis->globalObject(), impl.getConfiguration()));
209}
210
211EncodedJSValue JSC_HOST_CALL jsMediaKeySystemAccessPrototypeFunctionGetConfiguration(ExecState* state)
212{
213 return IDLOperation<JSMediaKeySystemAccess>::call<jsMediaKeySystemAccessPrototypeFunctionGetConfigurationBody>(*state, "getConfiguration");
214}
215
216static inline JSC::EncodedJSValue jsMediaKeySystemAccessPrototypeFunctionCreateMediaKeysBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSMediaKeySystemAccess>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope)
217{
218 UNUSED_PARAM(state);
219 UNUSED_PARAM(throwScope);
220 auto& impl = castedThis->wrapped();
221 impl.createMediaKeys(WTFMove(promise));
222 return JSValue::encode(jsUndefined());
223}
224
225EncodedJSValue JSC_HOST_CALL jsMediaKeySystemAccessPrototypeFunctionCreateMediaKeys(ExecState* state)
226{
227 return IDLOperationReturningPromise<JSMediaKeySystemAccess>::call<jsMediaKeySystemAccessPrototypeFunctionCreateMediaKeysBody, PromiseExecutionScope::WindowOnly>(*state, "createMediaKeys");
228}
229
230void JSMediaKeySystemAccess::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
231{
232 auto* thisObject = jsCast<JSMediaKeySystemAccess*>(cell);
233 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
234 if (thisObject->scriptExecutionContext())
235 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
236 Base::heapSnapshot(cell, builder);
237}
238
239bool JSMediaKeySystemAccessOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
240{
241 UNUSED_PARAM(handle);
242 UNUSED_PARAM(visitor);
243 UNUSED_PARAM(reason);
244 return false;
245}
246
247void JSMediaKeySystemAccessOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
248{
249 auto* jsMediaKeySystemAccess = static_cast<JSMediaKeySystemAccess*>(handle.slot()->asCell());
250 auto& world = *static_cast<DOMWrapperWorld*>(context);
251 uncacheWrapper(world, &jsMediaKeySystemAccess->wrapped(), jsMediaKeySystemAccess);
252}
253
254JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<MediaKeySystemAccess>&& impl)
255{
256 // If you hit this failure the interface definition has the ImplementationLacksVTable
257 // attribute. You should remove that attribute. If the class has subclasses
258 // that may be passed through this toJS() function you should use the SkipVTableValidation
259 // attribute to MediaKeySystemAccess.
260 static_assert(!std::is_polymorphic<MediaKeySystemAccess>::value, "MediaKeySystemAccess is polymorphic but the IDL claims it is not");
261 return createWrapper<MediaKeySystemAccess>(globalObject, WTFMove(impl));
262}
263
264JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, MediaKeySystemAccess& impl)
265{
266 return wrap(state, globalObject, impl);
267}
268
269MediaKeySystemAccess* JSMediaKeySystemAccess::toWrapped(JSC::VM& vm, JSC::JSValue value)
270{
271 if (auto* wrapper = jsDynamicCast<JSMediaKeySystemAccess*>(vm, value))
272 return &wrapper->wrapped();
273 return nullptr;
274}
275
276}
277
278#endif // ENABLE(ENCRYPTED_MEDIA)
279