Chromium Code Reviews| 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 V8PerContextData* contextData = scriptState->perContextData(); | |
| 157 if (feature == "ForeignFetch") { | |
|
haraken
2017/01/28 02:25:20
Just help me understand: You're adding installatio
chasej
2017/01/30 19:15:56
See my comment above on ConditionalFeatures.cpp.
| |
| 158 if (contextData->getExistingConstructorAndPrototypeForType( | |
| 159 &V8InstallEvent::wrapperTypeInfo, &prototypeObject, | |
| 160 &interfaceObject)) { | |
| 161 V8InstallEvent::installForeignFetch(isolate, world, | |
| 162 v8::Local<v8::Object>(), | |
| 163 prototypeObject, interfaceObject); | |
| 164 } | |
| 165 return; | |
| 166 } | |
| 167 if (feature == "ImageCapture") { | |
| 168 v8::Local<v8::Object> instanceObject = scriptState->context()->Global(); | |
| 169 V8WindowPartial::installImageCapture(isolate, world, instanceObject, | |
| 170 v8::Local<v8::Object>(), | |
| 171 v8::Local<v8::Function>()); | |
| 172 return; | |
| 173 } | |
| 174 if (feature == "ServiceWorkerNavigationPreload") { | |
| 175 v8::Local<v8::Object> instanceObject = scriptState->context()->Global(); | |
| 176 V8WindowPartial::installServiceWorkerNavigationPreload( | |
| 177 isolate, world, instanceObject, v8::Local<v8::Object>(), | |
| 178 v8::Local<v8::Function>()); | |
| 179 if (contextData->getExistingConstructorAndPrototypeForType( | |
| 180 &V8FetchEvent::wrapperTypeInfo, &prototypeObject, | |
| 181 &interfaceObject)) { | |
| 182 V8FetchEvent::installServiceWorkerNavigationPreload( | |
| 183 isolate, world, v8::Local<v8::Object>(), prototypeObject, | |
| 184 interfaceObject); | |
| 185 } | |
| 186 if (contextData->getExistingConstructorAndPrototypeForType( | |
| 187 &V8ServiceWorkerRegistration::wrapperTypeInfo, &prototypeObject, | |
| 188 &interfaceObject)) { | |
| 189 V8ServiceWorkerRegistration::installServiceWorkerNavigationPreload( | |
| 190 isolate, world, v8::Local<v8::Object>(), prototypeObject, | |
| 191 interfaceObject); | |
| 192 } | |
| 193 return; | |
| 194 } | |
| 195 if (feature == "WebShare") { | |
| 196 if (contextData->getExistingConstructorAndPrototypeForType( | |
| 197 &V8Navigator::wrapperTypeInfo, &prototypeObject, | |
| 198 &interfaceObject)) { | |
| 199 V8NavigatorPartial::installWebShare(isolate, world, | |
| 200 v8::Local<v8::Object>(), | |
| 201 prototypeObject, interfaceObject); | |
| 202 } | |
| 203 return; | |
| 204 } | |
| 205 if (feature == "WebUSB") { | |
| 206 v8::Local<v8::Object> instanceObject = scriptState->context()->Global(); | |
| 207 V8WindowPartial::installWebUSB(isolate, world, instanceObject, | |
| 208 v8::Local<v8::Object>(), | |
| 209 v8::Local<v8::Function>()); | |
| 210 if (contextData->getExistingConstructorAndPrototypeForType( | |
| 211 &V8Navigator::wrapperTypeInfo, &prototypeObject, | |
| 212 &interfaceObject)) { | |
| 213 V8NavigatorPartial::installWebUSB(isolate, world, v8::Local<v8::Object>(), | |
| 214 prototypeObject, interfaceObject); | |
| 215 } | |
| 216 return; | |
| 217 } | |
| 218 if (feature == "WebVR") { | |
| 219 v8::Local<v8::Object> instanceObject = scriptState->context()->Global(); | |
|
haraken
2017/01/28 02:25:20
You can factor out this statement out of the if cl
chasej
2017/01/30 19:15:56
Done.
iclelland
2017/01/30 20:37:39
chasej -- I don't have really strong feelings one
| |
| 220 V8WindowPartial::installGamepadExtensions(isolate, world, instanceObject, | |
| 221 v8::Local<v8::Object>(), | |
| 222 v8::Local<v8::Function>()); | |
| 223 V8WindowPartial::installWebVR(isolate, world, instanceObject, | |
| 224 v8::Local<v8::Object>(), | |
| 225 v8::Local<v8::Function>()); | |
| 226 if (contextData->getExistingConstructorAndPrototypeForType( | |
| 227 &V8Gamepad::wrapperTypeInfo, &prototypeObject, &interfaceObject)) { | |
| 228 V8Gamepad::installGamepadExtensions(isolate, world, | |
| 229 v8::Local<v8::Object>(), | |
| 230 prototypeObject, interfaceObject); | |
| 231 } | |
| 232 if (contextData->getExistingConstructorAndPrototypeForType( | |
| 233 &V8GamepadButton::wrapperTypeInfo, &prototypeObject, | |
| 234 &interfaceObject)) { | |
| 235 V8GamepadButton::installGamepadExtensions( | |
| 236 isolate, world, v8::Local<v8::Object>(), prototypeObject, | |
| 237 interfaceObject); | |
| 238 } | |
| 239 if (contextData->getExistingConstructorAndPrototypeForType( | |
| 240 &V8Navigator::wrapperTypeInfo, &prototypeObject, | |
| 241 &interfaceObject)) { | |
| 242 V8NavigatorPartial::installWebVR(isolate, world, v8::Local<v8::Object>(), | |
| 243 prototypeObject, interfaceObject); | |
| 244 } | |
| 245 return; | |
| 246 } | |
| 247 } | |
| 248 | |
| 143 void registerInstallConditionalFeaturesForModules() { | 249 void registerInstallConditionalFeaturesForModules() { |
| 144 s_originalInstallConditionalFeaturesFunction = | 250 s_originalInstallConditionalFeaturesFunction = |
| 145 setInstallConditionalFeaturesFunction( | 251 setInstallConditionalFeaturesFunction( |
| 146 &installConditionalFeaturesForModules); | 252 &installConditionalFeaturesForModules); |
| 253 s_originalInstallPendingConditionalFeatureFunction = | |
| 254 setInstallPendingConditionalFeatureFunction( | |
| 255 &installPendingConditionalFeatureForModules); | |
| 147 } | 256 } |
| 148 | 257 |
| 149 } // namespace blink | 258 } // namespace blink |
| OLD | NEW |