Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1567)

Unified Diff: third_party/WebKit/Source/bindings/modules/v8/ConditionalFeaturesForModules.cpp

Issue 2640823004: Allow origin trials to be enabled by script (Closed)
Patch Set: Address comments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..3066e01bfcda137cd59dd37bad6c4f9e1d95c541 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,117 @@ 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();
+ V8PerContextData* contextData = scriptState->perContextData();
+ 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.
+ if (contextData->getExistingConstructorAndPrototypeForType(
+ &V8InstallEvent::wrapperTypeInfo, &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, v8::Local<v8::Object>(),
+ v8::Local<v8::Function>());
+ if (contextData->getExistingConstructorAndPrototypeForType(
+ &V8FetchEvent::wrapperTypeInfo, &prototypeObject,
+ &interfaceObject)) {
+ V8FetchEvent::installServiceWorkerNavigationPreload(
+ isolate, world, v8::Local<v8::Object>(), prototypeObject,
+ interfaceObject);
+ }
+ if (contextData->getExistingConstructorAndPrototypeForType(
+ &V8ServiceWorkerRegistration::wrapperTypeInfo, &prototypeObject,
+ &interfaceObject)) {
+ V8ServiceWorkerRegistration::installServiceWorkerNavigationPreload(
+ isolate, world, v8::Local<v8::Object>(), prototypeObject,
+ interfaceObject);
+ }
+ return;
+ }
+ if (feature == "WebShare") {
+ if (contextData->getExistingConstructorAndPrototypeForType(
+ &V8Navigator::wrapperTypeInfo, &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 (contextData->getExistingConstructorAndPrototypeForType(
+ &V8Navigator::wrapperTypeInfo, &prototypeObject,
+ &interfaceObject)) {
+ V8NavigatorPartial::installWebUSB(isolate, world, v8::Local<v8::Object>(),
+ prototypeObject, interfaceObject);
+ }
+ return;
+ }
+ if (feature == "WebVR") {
+ 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
+ V8WindowPartial::installGamepadExtensions(isolate, world, instanceObject,
+ v8::Local<v8::Object>(),
+ v8::Local<v8::Function>());
+ V8WindowPartial::installWebVR(isolate, world, instanceObject,
+ v8::Local<v8::Object>(),
+ v8::Local<v8::Function>());
+ if (contextData->getExistingConstructorAndPrototypeForType(
+ &V8Gamepad::wrapperTypeInfo, &prototypeObject, &interfaceObject)) {
+ V8Gamepad::installGamepadExtensions(isolate, world,
+ v8::Local<v8::Object>(),
+ prototypeObject, interfaceObject);
+ }
+ if (contextData->getExistingConstructorAndPrototypeForType(
+ &V8GamepadButton::wrapperTypeInfo, &prototypeObject,
+ &interfaceObject)) {
+ V8GamepadButton::installGamepadExtensions(
+ isolate, world, v8::Local<v8::Object>(), prototypeObject,
+ interfaceObject);
+ }
+ if (contextData->getExistingConstructorAndPrototypeForType(
+ &V8Navigator::wrapperTypeInfo, &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

Powered by Google App Engine
This is Rietveld 408576698