OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "bindings/modules/v8/ConditionalFeaturesForModules.h" | 5 #include "bindings/modules/v8/ConditionalFeaturesForModules.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptState.h" | 7 #include "bindings/core/v8/ScriptState.h" |
8 #include "bindings/core/v8/V8DedicatedWorkerGlobalScope.h" | 8 #include "bindings/core/v8/V8DedicatedWorkerGlobalScope.h" |
9 #include "bindings/core/v8/V8Navigator.h" | 9 #include "bindings/core/v8/V8Navigator.h" |
10 #include "bindings/core/v8/V8SharedWorkerGlobalScope.h" | 10 #include "bindings/core/v8/V8SharedWorkerGlobalScope.h" |
(...skipping 11 matching lines...) Expand all Loading... | |
22 #include "bindings/modules/v8/V8WindowPartial.h" | 22 #include "bindings/modules/v8/V8WindowPartial.h" |
23 #include "bindings/modules/v8/V8WorkerNavigatorPartial.h" | 23 #include "bindings/modules/v8/V8WorkerNavigatorPartial.h" |
24 #include "core/dom/ExecutionContext.h" | 24 #include "core/dom/ExecutionContext.h" |
25 #include "core/origin_trials/OriginTrials.h" | 25 #include "core/origin_trials/OriginTrials.h" |
26 | 26 |
27 namespace blink { | 27 namespace blink { |
28 | 28 |
29 namespace { | 29 namespace { |
30 InstallConditionalFeaturesFunction | 30 InstallConditionalFeaturesFunction |
31 s_originalInstallConditionalFeaturesFunction = nullptr; | 31 s_originalInstallConditionalFeaturesFunction = nullptr; |
32 InstallPendingConditionalFeatureFunction | |
33 s_originalInstallPendingConditionalFeatureFunction = nullptr; | |
32 } | 34 } |
33 | 35 |
34 void installConditionalFeaturesForModules( | 36 void installConditionalFeaturesForModules( |
35 const WrapperTypeInfo* wrapperTypeInfo, | 37 const WrapperTypeInfo* wrapperTypeInfo, |
36 const ScriptState* scriptState, | 38 const ScriptState* scriptState, |
37 v8::Local<v8::Object> prototypeObject, | 39 v8::Local<v8::Object> prototypeObject, |
38 v8::Local<v8::Function> interfaceObject) { | 40 v8::Local<v8::Function> interfaceObject) { |
39 // TODO(iclelland): Generate all of this logic at compile-time, based on the | 41 // TODO(iclelland): Generate all of this logic at compile-time, based on the |
40 // configuration of origin trial enabled attibutes and interfaces in IDL | 42 // configuration of origin trial enabled attibutes and interfaces in IDL |
41 // files. (crbug.com/615060) | 43 // files. (crbug.com/615060) |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 } | 135 } |
134 } else if (wrapperTypeInfo == &V8GamepadButton::wrapperTypeInfo) { | 136 } else if (wrapperTypeInfo == &V8GamepadButton::wrapperTypeInfo) { |
135 if (OriginTrials::gamepadExtensionsEnabled(executionContext)) { | 137 if (OriginTrials::gamepadExtensionsEnabled(executionContext)) { |
136 V8GamepadButton::installGamepadExtensions( | 138 V8GamepadButton::installGamepadExtensions( |
137 isolate, world, v8::Local<v8::Object>(), prototypeObject, | 139 isolate, world, v8::Local<v8::Object>(), prototypeObject, |
138 interfaceObject); | 140 interfaceObject); |
139 } | 141 } |
140 } | 142 } |
141 } | 143 } |
142 | 144 |
145 void installPendingConditionalFeatureForModules( | |
146 const String& feature, | |
147 const ScriptState* scriptState) { | |
148 // TODO(iclelland): Generate all of this logic at compile-time, based on the | |
149 // configuration of origin trial enabled attributes and interfaces in IDL | |
150 // files. (crbug.com/615060) | |
151 (*s_originalInstallPendingConditionalFeatureFunction)(feature, scriptState); | |
152 v8::Local<v8::Object> prototypeObject; | |
153 v8::Local<v8::Function> interfaceObject; | |
154 v8::Isolate* isolate = scriptState->isolate(); | |
155 const DOMWrapperWorld& world = scriptState->world(); | |
156 if (feature == "ForeignFetch") { | |
157 if (getExistingConstructorAndPrototypeForType( | |
158 &V8InstallEvent::wrapperTypeInfo, scriptState, &prototypeObject, | |
159 &interfaceObject)) { | |
160 V8InstallEvent::installForeignFetch(isolate, world, | |
161 v8::Local<v8::Object>(), | |
162 prototypeObject, interfaceObject); | |
163 } | |
164 return; | |
165 } | |
166 if (feature == "ImageCapture") { | |
167 v8::Local<v8::Object> instanceObject = scriptState->context()->Global(); | |
168 V8WindowPartial::installImageCapture(isolate, world, instanceObject, | |
169 v8::Local<v8::Object>(), | |
170 v8::Local<v8::Function>()); | |
171 return; | |
172 } | |
173 if (feature == "ServiceWorkerNavigationPreload") { | |
174 v8::Local<v8::Object> instanceObject = scriptState->context()->Global(); | |
175 V8WindowPartial::installServiceWorkerNavigationPreload( | |
176 isolate, world, instanceObject, prototypeObject, interfaceObject); | |
iclelland
2017/01/26 20:14:11
Can you replace prototypeObject and interfaceObjec
chasej
2017/01/27 17:22:36
Done.
| |
177 if (getExistingConstructorAndPrototypeForType( | |
178 &V8FetchEvent::wrapperTypeInfo, scriptState, &prototypeObject, | |
179 &interfaceObject)) { | |
180 V8FetchEvent::installServiceWorkerNavigationPreload( | |
181 isolate, world, v8::Local<v8::Object>(), prototypeObject, | |
182 interfaceObject); | |
183 } | |
184 if (getExistingConstructorAndPrototypeForType( | |
185 &V8ServiceWorkerRegistration::wrapperTypeInfo, scriptState, | |
186 &prototypeObject, &interfaceObject)) { | |
187 V8ServiceWorkerRegistration::installServiceWorkerNavigationPreload( | |
188 isolate, world, v8::Local<v8::Object>(), prototypeObject, | |
189 interfaceObject); | |
190 } | |
191 return; | |
192 } | |
193 if (feature == "WebShare") { | |
194 if (getExistingConstructorAndPrototypeForType(&V8Navigator::wrapperTypeInfo, | |
195 scriptState, &prototypeObject, | |
196 &interfaceObject)) { | |
197 V8NavigatorPartial::installWebShare(isolate, world, | |
198 v8::Local<v8::Object>(), | |
199 prototypeObject, interfaceObject); | |
200 } | |
201 return; | |
202 } | |
203 if (feature == "WebUSB") { | |
204 v8::Local<v8::Object> instanceObject = scriptState->context()->Global(); | |
205 V8WindowPartial::installWebUSB(isolate, world, instanceObject, | |
206 v8::Local<v8::Object>(), | |
207 v8::Local<v8::Function>()); | |
208 if (getExistingConstructorAndPrototypeForType(&V8Navigator::wrapperTypeInfo, | |
209 scriptState, &prototypeObject, | |
210 &interfaceObject)) { | |
211 V8NavigatorPartial::installWebUSB(isolate, world, v8::Local<v8::Object>(), | |
212 prototypeObject, interfaceObject); | |
213 } | |
214 return; | |
215 } | |
216 if (feature == "WebVR") { | |
217 v8::Local<v8::Object> instanceObject = scriptState->context()->Global(); | |
218 V8WindowPartial::installGamepadExtensions(isolate, world, instanceObject, | |
219 prototypeObject, interfaceObject); | |
iclelland
2017/01/26 20:14:11
ditto here and the next line.
chasej
2017/01/27 17:22:36
Done.
| |
220 V8WindowPartial::installWebVR(isolate, world, instanceObject, | |
221 prototypeObject, interfaceObject); | |
222 if (getExistingConstructorAndPrototypeForType(&V8Gamepad::wrapperTypeInfo, | |
223 scriptState, &prototypeObject, | |
224 &interfaceObject)) { | |
225 V8Gamepad::installGamepadExtensions(isolate, world, | |
226 v8::Local<v8::Object>(), | |
227 prototypeObject, interfaceObject); | |
228 } | |
229 if (getExistingConstructorAndPrototypeForType( | |
230 &V8GamepadButton::wrapperTypeInfo, scriptState, &prototypeObject, | |
231 &interfaceObject)) { | |
232 V8GamepadButton::installGamepadExtensions( | |
233 isolate, world, v8::Local<v8::Object>(), prototypeObject, | |
234 interfaceObject); | |
235 } | |
236 if (getExistingConstructorAndPrototypeForType(&V8Navigator::wrapperTypeInfo, | |
237 scriptState, &prototypeObject, | |
238 &interfaceObject)) { | |
239 V8NavigatorPartial::installWebVR(isolate, world, v8::Local<v8::Object>(), | |
240 prototypeObject, interfaceObject); | |
241 } | |
242 return; | |
243 } | |
244 } | |
245 | |
143 void registerInstallConditionalFeaturesForModules() { | 246 void registerInstallConditionalFeaturesForModules() { |
144 s_originalInstallConditionalFeaturesFunction = | 247 s_originalInstallConditionalFeaturesFunction = |
145 setInstallConditionalFeaturesFunction( | 248 setInstallConditionalFeaturesFunction( |
146 &installConditionalFeaturesForModules); | 249 &installConditionalFeaturesForModules); |
250 s_originalInstallPendingConditionalFeatureFunction = | |
251 setInstallPendingConditionalFeatureFunction( | |
252 &installPendingConditionalFeatureForModules); | |
147 } | 253 } |
148 | 254 |
149 } // namespace blink | 255 } // namespace blink |
OLD | NEW |