Index: third_party/WebKit/Source/bindings/modules/v8/ConditionalFeaturesForModules.cpp |
diff --git a/third_party/WebKit/Source/bindings/modules/v8/ConditionalFeaturesForModules.cpp b/third_party/WebKit/Source/bindings/modules/v8/ConditionalFeaturesForModules.cpp |
index 05b68ce4422fe2f66c5c1a236da3e879aa34f7ce..907b806c2cee844113c1cf128b01f33a12c74c0a 100644 |
--- a/third_party/WebKit/Source/bindings/modules/v8/ConditionalFeaturesForModules.cpp |
+++ b/third_party/WebKit/Source/bindings/modules/v8/ConditionalFeaturesForModules.cpp |
@@ -29,6 +29,8 @@ namespace blink { |
namespace { |
InstallConditionalFeaturesFunction |
s_originalInstallConditionalFeaturesFunction = nullptr; |
+InstallPendingConditionalFeatureFunction |
+ s_originalInstallPendingConditionalFeatureFunction = nullptr; |
} |
void installConditionalFeaturesForModules( |
@@ -140,10 +142,114 @@ void installConditionalFeaturesForModules( |
} |
} |
+void installPendingConditionalFeatureForModules( |
+ const String& feature, |
+ const ScriptState* scriptState) { |
+ // TODO(iclelland): Generate all of this logic at compile-time, based on the |
+ // configuration of origin trial enabled attributes and interfaces in IDL |
+ // files. (crbug.com/615060) |
+ (*s_originalInstallPendingConditionalFeatureFunction)(feature, scriptState); |
+ v8::Local<v8::Object> prototypeObject; |
+ v8::Local<v8::Function> interfaceObject; |
+ v8::Isolate* isolate = scriptState->isolate(); |
+ const DOMWrapperWorld& world = scriptState->world(); |
+ if (feature == "ForeignFetch") { |
+ if (getExistingConstructorAndPrototypeForType( |
+ &V8InstallEvent::wrapperTypeInfo, scriptState, &prototypeObject, |
+ &interfaceObject)) { |
+ V8InstallEvent::installForeignFetch(isolate, world, |
+ v8::Local<v8::Object>(), |
+ prototypeObject, interfaceObject); |
+ } |
+ return; |
+ } |
+ if (feature == "ImageCapture") { |
+ v8::Local<v8::Object> instanceObject = scriptState->context()->Global(); |
+ V8WindowPartial::installImageCapture(isolate, world, instanceObject, |
+ v8::Local<v8::Object>(), |
+ v8::Local<v8::Function>()); |
+ return; |
+ } |
+ if (feature == "ServiceWorkerNavigationPreload") { |
+ v8::Local<v8::Object> instanceObject = scriptState->context()->Global(); |
+ V8WindowPartial::installServiceWorkerNavigationPreload( |
+ 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.
|
+ if (getExistingConstructorAndPrototypeForType( |
+ &V8FetchEvent::wrapperTypeInfo, scriptState, &prototypeObject, |
+ &interfaceObject)) { |
+ V8FetchEvent::installServiceWorkerNavigationPreload( |
+ isolate, world, v8::Local<v8::Object>(), prototypeObject, |
+ interfaceObject); |
+ } |
+ if (getExistingConstructorAndPrototypeForType( |
+ &V8ServiceWorkerRegistration::wrapperTypeInfo, scriptState, |
+ &prototypeObject, &interfaceObject)) { |
+ V8ServiceWorkerRegistration::installServiceWorkerNavigationPreload( |
+ isolate, world, v8::Local<v8::Object>(), prototypeObject, |
+ interfaceObject); |
+ } |
+ return; |
+ } |
+ if (feature == "WebShare") { |
+ if (getExistingConstructorAndPrototypeForType(&V8Navigator::wrapperTypeInfo, |
+ scriptState, &prototypeObject, |
+ &interfaceObject)) { |
+ V8NavigatorPartial::installWebShare(isolate, world, |
+ v8::Local<v8::Object>(), |
+ prototypeObject, interfaceObject); |
+ } |
+ return; |
+ } |
+ if (feature == "WebUSB") { |
+ v8::Local<v8::Object> instanceObject = scriptState->context()->Global(); |
+ V8WindowPartial::installWebUSB(isolate, world, instanceObject, |
+ v8::Local<v8::Object>(), |
+ v8::Local<v8::Function>()); |
+ if (getExistingConstructorAndPrototypeForType(&V8Navigator::wrapperTypeInfo, |
+ scriptState, &prototypeObject, |
+ &interfaceObject)) { |
+ V8NavigatorPartial::installWebUSB(isolate, world, v8::Local<v8::Object>(), |
+ prototypeObject, interfaceObject); |
+ } |
+ return; |
+ } |
+ if (feature == "WebVR") { |
+ v8::Local<v8::Object> instanceObject = scriptState->context()->Global(); |
+ V8WindowPartial::installGamepadExtensions(isolate, world, instanceObject, |
+ prototypeObject, interfaceObject); |
iclelland
2017/01/26 20:14:11
ditto here and the next line.
chasej
2017/01/27 17:22:36
Done.
|
+ V8WindowPartial::installWebVR(isolate, world, instanceObject, |
+ prototypeObject, interfaceObject); |
+ if (getExistingConstructorAndPrototypeForType(&V8Gamepad::wrapperTypeInfo, |
+ scriptState, &prototypeObject, |
+ &interfaceObject)) { |
+ V8Gamepad::installGamepadExtensions(isolate, world, |
+ v8::Local<v8::Object>(), |
+ prototypeObject, interfaceObject); |
+ } |
+ if (getExistingConstructorAndPrototypeForType( |
+ &V8GamepadButton::wrapperTypeInfo, scriptState, &prototypeObject, |
+ &interfaceObject)) { |
+ V8GamepadButton::installGamepadExtensions( |
+ isolate, world, v8::Local<v8::Object>(), prototypeObject, |
+ interfaceObject); |
+ } |
+ if (getExistingConstructorAndPrototypeForType(&V8Navigator::wrapperTypeInfo, |
+ scriptState, &prototypeObject, |
+ &interfaceObject)) { |
+ V8NavigatorPartial::installWebVR(isolate, world, v8::Local<v8::Object>(), |
+ prototypeObject, interfaceObject); |
+ } |
+ return; |
+ } |
+} |
+ |
void registerInstallConditionalFeaturesForModules() { |
s_originalInstallConditionalFeaturesFunction = |
setInstallConditionalFeaturesFunction( |
&installConditionalFeaturesForModules); |
+ s_originalInstallPendingConditionalFeatureFunction = |
+ setInstallPendingConditionalFeatureFunction( |
+ &installPendingConditionalFeatureForModules); |
} |
} // namespace blink |