Commit 1ec185eb authored by iclelland's avatar iclelland Committed by Commit bot

[Origin Trials] Rename confusing 'global' variable

The name of variable was causing no end of confusion about when it should be
passed into the various install* methods for origin trials, and when a dummy
object should be passed instead. Renamed to the more sensible 'instanceObject',
as a counterpart to 'interfaceObject' and 'prototypeObject', and now only
instantiate it when necessary (in Window and WorkerGlobalScope blocks).

Review-Url: https://codereview.chromium.org/2532213002
Cr-Commit-Position: refs/heads/master@{#434996}
parent 0046294f
...@@ -45,7 +45,6 @@ void installConditionalFeaturesForModules( ...@@ -45,7 +45,6 @@ void installConditionalFeaturesForModules(
return; return;
v8::Isolate* isolate = scriptState->isolate(); v8::Isolate* isolate = scriptState->isolate();
const DOMWrapperWorld& world = scriptState->world(); const DOMWrapperWorld& world = scriptState->world();
v8::Local<v8::Object> global = scriptState->context()->Global();
if (wrapperTypeInfo == &V8Navigator::wrapperTypeInfo) { if (wrapperTypeInfo == &V8Navigator::wrapperTypeInfo) {
if (OriginTrials::webShareEnabled(executionContext)) { if (OriginTrials::webShareEnabled(executionContext)) {
V8NavigatorPartial::installWebShare(isolate, world, V8NavigatorPartial::installWebShare(isolate, world,
...@@ -57,30 +56,32 @@ void installConditionalFeaturesForModules( ...@@ -57,30 +56,32 @@ void installConditionalFeaturesForModules(
prototypeObject, interfaceObject); prototypeObject, interfaceObject);
} }
if (OriginTrials::webVREnabled(executionContext)) { if (OriginTrials::webVREnabled(executionContext)) {
V8NavigatorPartial::installWebVR(isolate, world, global, prototypeObject, V8NavigatorPartial::installWebVR(isolate, world, v8::Local<v8::Object>(),
interfaceObject); prototypeObject, interfaceObject);
} }
} else if (wrapperTypeInfo == &V8Window::wrapperTypeInfo) { } else if (wrapperTypeInfo == &V8Window::wrapperTypeInfo) {
v8::Local<v8::Object> instanceObject = scriptState->context()->Global();
if (OriginTrials::imageCaptureEnabled(executionContext)) { if (OriginTrials::imageCaptureEnabled(executionContext)) {
V8WindowPartial::installImageCapture(isolate, world, global, V8WindowPartial::installImageCapture(isolate, world, instanceObject,
prototypeObject, interfaceObject); prototypeObject, interfaceObject);
} }
if (OriginTrials::webUSBEnabled(executionContext)) { if (OriginTrials::webUSBEnabled(executionContext)) {
V8WindowPartial::installWebUSB(isolate, world, global, prototypeObject, V8WindowPartial::installWebUSB(isolate, world, instanceObject,
interfaceObject); prototypeObject, interfaceObject);
} }
if (OriginTrials::webVREnabled(executionContext)) { if (OriginTrials::webVREnabled(executionContext)) {
V8WindowPartial::installWebVR(isolate, world, global, prototypeObject, V8WindowPartial::installWebVR(isolate, world, instanceObject,
interfaceObject); prototypeObject, interfaceObject);
} }
if (OriginTrials::gamepadExtensionsEnabled(executionContext)) { if (OriginTrials::gamepadExtensionsEnabled(executionContext)) {
V8WindowPartial::installGamepadExtensions( V8WindowPartial::installGamepadExtensions(
isolate, world, global, prototypeObject, interfaceObject); isolate, world, instanceObject, prototypeObject, interfaceObject);
} }
} else if (wrapperTypeInfo == &V8ServiceWorkerGlobalScope::wrapperTypeInfo) { } else if (wrapperTypeInfo == &V8ServiceWorkerGlobalScope::wrapperTypeInfo) {
v8::Local<v8::Object> instanceObject = scriptState->context()->Global();
if (OriginTrials::foreignFetchEnabled(executionContext)) { if (OriginTrials::foreignFetchEnabled(executionContext)) {
V8ServiceWorkerGlobalScope::installForeignFetch( V8ServiceWorkerGlobalScope::installForeignFetch(
isolate, world, global, prototypeObject, interfaceObject); isolate, world, instanceObject, prototypeObject, interfaceObject);
} }
} else if (wrapperTypeInfo == &V8InstallEvent::wrapperTypeInfo) { } else if (wrapperTypeInfo == &V8InstallEvent::wrapperTypeInfo) {
if (OriginTrials::foreignFetchEnabled(executionContext)) { if (OriginTrials::foreignFetchEnabled(executionContext)) {
...@@ -90,13 +91,15 @@ void installConditionalFeaturesForModules( ...@@ -90,13 +91,15 @@ void installConditionalFeaturesForModules(
} }
} else if (wrapperTypeInfo == &V8Gamepad::wrapperTypeInfo) { } else if (wrapperTypeInfo == &V8Gamepad::wrapperTypeInfo) {
if (OriginTrials::gamepadExtensionsEnabled(executionContext)) { if (OriginTrials::gamepadExtensionsEnabled(executionContext)) {
V8Gamepad::installGamepadExtensions(isolate, world, global, V8Gamepad::installGamepadExtensions(isolate, world,
v8::Local<v8::Object>(),
prototypeObject, interfaceObject); prototypeObject, interfaceObject);
} }
} else if (wrapperTypeInfo == &V8GamepadButton::wrapperTypeInfo) { } else if (wrapperTypeInfo == &V8GamepadButton::wrapperTypeInfo) {
if (OriginTrials::gamepadExtensionsEnabled(executionContext)) { if (OriginTrials::gamepadExtensionsEnabled(executionContext)) {
V8GamepadButton::installGamepadExtensions( V8GamepadButton::installGamepadExtensions(
isolate, world, global, prototypeObject, interfaceObject); isolate, world, v8::Local<v8::Object>(), prototypeObject,
interfaceObject);
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment