| 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 27 matching lines...) Expand all Loading... |
| 38 // configuration of origin trial enabled attibutes and interfaces in IDL | 38 // configuration of origin trial enabled attibutes and interfaces in IDL |
| 39 // files. (crbug.com/615060) | 39 // files. (crbug.com/615060) |
| 40 (*s_originalInstallConditionalFeaturesFunction)( | 40 (*s_originalInstallConditionalFeaturesFunction)( |
| 41 wrapperTypeInfo, scriptState, prototypeObject, interfaceObject); | 41 wrapperTypeInfo, scriptState, prototypeObject, interfaceObject); |
| 42 | 42 |
| 43 ExecutionContext* executionContext = scriptState->getExecutionContext(); | 43 ExecutionContext* executionContext = scriptState->getExecutionContext(); |
| 44 if (!executionContext) | 44 if (!executionContext) |
| 45 return; | 45 return; |
| 46 v8::Isolate* isolate = scriptState->isolate(); | 46 v8::Isolate* isolate = scriptState->isolate(); |
| 47 const DOMWrapperWorld& world = scriptState->world(); | 47 const DOMWrapperWorld& world = scriptState->world(); |
| 48 v8::Local<v8::Object> global = scriptState->context()->Global(); | |
| 49 if (wrapperTypeInfo == &V8Navigator::wrapperTypeInfo) { | 48 if (wrapperTypeInfo == &V8Navigator::wrapperTypeInfo) { |
| 50 if (OriginTrials::webShareEnabled(executionContext)) { | 49 if (OriginTrials::webShareEnabled(executionContext)) { |
| 51 V8NavigatorPartial::installWebShare(isolate, world, | 50 V8NavigatorPartial::installWebShare(isolate, world, |
| 52 v8::Local<v8::Object>(), | 51 v8::Local<v8::Object>(), |
| 53 prototypeObject, interfaceObject); | 52 prototypeObject, interfaceObject); |
| 54 } | 53 } |
| 55 if (OriginTrials::webUSBEnabled(executionContext)) { | 54 if (OriginTrials::webUSBEnabled(executionContext)) { |
| 56 V8NavigatorPartial::installWebUSB(isolate, world, v8::Local<v8::Object>(), | 55 V8NavigatorPartial::installWebUSB(isolate, world, v8::Local<v8::Object>(), |
| 57 prototypeObject, interfaceObject); | 56 prototypeObject, interfaceObject); |
| 58 } | 57 } |
| 59 if (OriginTrials::webVREnabled(executionContext)) { | 58 if (OriginTrials::webVREnabled(executionContext)) { |
| 60 V8NavigatorPartial::installWebVR(isolate, world, global, prototypeObject, | 59 V8NavigatorPartial::installWebVR(isolate, world, v8::Local<v8::Object>(), |
| 61 interfaceObject); | 60 prototypeObject, interfaceObject); |
| 62 } | 61 } |
| 63 } else if (wrapperTypeInfo == &V8Window::wrapperTypeInfo) { | 62 } else if (wrapperTypeInfo == &V8Window::wrapperTypeInfo) { |
| 63 v8::Local<v8::Object> instanceObject = scriptState->context()->Global(); |
| 64 if (OriginTrials::imageCaptureEnabled(executionContext)) { | 64 if (OriginTrials::imageCaptureEnabled(executionContext)) { |
| 65 V8WindowPartial::installImageCapture(isolate, world, global, | 65 V8WindowPartial::installImageCapture(isolate, world, instanceObject, |
| 66 prototypeObject, interfaceObject); | 66 prototypeObject, interfaceObject); |
| 67 } | 67 } |
| 68 if (OriginTrials::webUSBEnabled(executionContext)) { | 68 if (OriginTrials::webUSBEnabled(executionContext)) { |
| 69 V8WindowPartial::installWebUSB(isolate, world, global, prototypeObject, | 69 V8WindowPartial::installWebUSB(isolate, world, instanceObject, |
| 70 interfaceObject); | 70 prototypeObject, interfaceObject); |
| 71 } | 71 } |
| 72 if (OriginTrials::webVREnabled(executionContext)) { | 72 if (OriginTrials::webVREnabled(executionContext)) { |
| 73 V8WindowPartial::installWebVR(isolate, world, global, prototypeObject, | 73 V8WindowPartial::installWebVR(isolate, world, instanceObject, |
| 74 interfaceObject); | 74 prototypeObject, interfaceObject); |
| 75 } | 75 } |
| 76 if (OriginTrials::gamepadExtensionsEnabled(executionContext)) { | 76 if (OriginTrials::gamepadExtensionsEnabled(executionContext)) { |
| 77 V8WindowPartial::installGamepadExtensions( | 77 V8WindowPartial::installGamepadExtensions( |
| 78 isolate, world, global, prototypeObject, interfaceObject); | 78 isolate, world, instanceObject, prototypeObject, interfaceObject); |
| 79 } | 79 } |
| 80 } else if (wrapperTypeInfo == &V8ServiceWorkerGlobalScope::wrapperTypeInfo) { | 80 } else if (wrapperTypeInfo == &V8ServiceWorkerGlobalScope::wrapperTypeInfo) { |
| 81 v8::Local<v8::Object> instanceObject = scriptState->context()->Global(); |
| 81 if (OriginTrials::foreignFetchEnabled(executionContext)) { | 82 if (OriginTrials::foreignFetchEnabled(executionContext)) { |
| 82 V8ServiceWorkerGlobalScope::installForeignFetch( | 83 V8ServiceWorkerGlobalScope::installForeignFetch( |
| 83 isolate, world, global, prototypeObject, interfaceObject); | 84 isolate, world, instanceObject, prototypeObject, interfaceObject); |
| 84 } | 85 } |
| 85 } else if (wrapperTypeInfo == &V8InstallEvent::wrapperTypeInfo) { | 86 } else if (wrapperTypeInfo == &V8InstallEvent::wrapperTypeInfo) { |
| 86 if (OriginTrials::foreignFetchEnabled(executionContext)) { | 87 if (OriginTrials::foreignFetchEnabled(executionContext)) { |
| 87 V8InstallEvent::installForeignFetch(isolate, world, | 88 V8InstallEvent::installForeignFetch(isolate, world, |
| 88 v8::Local<v8::Object>(), | 89 v8::Local<v8::Object>(), |
| 89 prototypeObject, interfaceObject); | 90 prototypeObject, interfaceObject); |
| 90 } | 91 } |
| 91 } else if (wrapperTypeInfo == &V8Gamepad::wrapperTypeInfo) { | 92 } else if (wrapperTypeInfo == &V8Gamepad::wrapperTypeInfo) { |
| 92 if (OriginTrials::gamepadExtensionsEnabled(executionContext)) { | 93 if (OriginTrials::gamepadExtensionsEnabled(executionContext)) { |
| 93 V8Gamepad::installGamepadExtensions(isolate, world, global, | 94 V8Gamepad::installGamepadExtensions(isolate, world, |
| 95 v8::Local<v8::Object>(), |
| 94 prototypeObject, interfaceObject); | 96 prototypeObject, interfaceObject); |
| 95 } | 97 } |
| 96 } else if (wrapperTypeInfo == &V8GamepadButton::wrapperTypeInfo) { | 98 } else if (wrapperTypeInfo == &V8GamepadButton::wrapperTypeInfo) { |
| 97 if (OriginTrials::gamepadExtensionsEnabled(executionContext)) { | 99 if (OriginTrials::gamepadExtensionsEnabled(executionContext)) { |
| 98 V8GamepadButton::installGamepadExtensions( | 100 V8GamepadButton::installGamepadExtensions( |
| 99 isolate, world, global, prototypeObject, interfaceObject); | 101 isolate, world, v8::Local<v8::Object>(), prototypeObject, |
| 102 interfaceObject); |
| 100 } | 103 } |
| 101 } | 104 } |
| 102 } | 105 } |
| 103 | 106 |
| 104 void registerInstallConditionalFeaturesForModules() { | 107 void registerInstallConditionalFeaturesForModules() { |
| 105 s_originalInstallConditionalFeaturesFunction = | 108 s_originalInstallConditionalFeaturesFunction = |
| 106 setInstallConditionalFeaturesFunction( | 109 setInstallConditionalFeaturesFunction( |
| 107 &installConditionalFeaturesForModules); | 110 &installConditionalFeaturesForModules); |
| 108 } | 111 } |
| 109 | 112 |
| 110 } // namespace blink | 113 } // namespace blink |
| OLD | NEW |