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 "core/dom/ExecutionContext.h" | 22 #include "core/dom/ExecutionContext.h" |
| 23 #include "core/origin_trials/OriginTrials.h" | 23 #include "core/origin_trials/OriginTrials.h" |
| 24 | 24 |
| 25 namespace blink { | 25 namespace blink { |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 InstallConditionalFeaturesFunction | 28 InstallConditionalFeaturesFunction |
| 29 s_originalInstallConditionalFeaturesFunction = nullptr; | 29 s_originalInstallConditionalFeaturesFunction = nullptr; |
| 30 } | 30 } |
| 31 | 31 |
| 32 void installConditionalFeaturesForModules( | 32 void installConditionalFeaturesForModules( |
|
Yuki
2016/11/01 11:37:54
Could you add a function header comment in *.h?
Es
| |
| 33 const WrapperTypeInfo* wrapperTypeInfo, | 33 const WrapperTypeInfo* wrapperTypeInfo, |
| 34 const ScriptState* scriptState, | 34 const ScriptState* scriptState, |
| 35 v8::Local<v8::Object> prototypeObject, | 35 v8::Local<v8::Object> prototypeObject, |
| 36 v8::Local<v8::Function> interfaceObject) { | 36 v8::Local<v8::Function> interfaceObject) { |
| 37 // TODO(iclelland): Generate all of this logic at compile-time, based on the | 37 // TODO(iclelland): Generate all of this logic at compile-time, based on the |
| 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(); | |
| 47 const DOMWrapperWorld& world = scriptState->world(); | |
| 48 v8::Local<v8::Object> global = scriptState->context()->Global(); | 46 v8::Local<v8::Object> global = scriptState->context()->Global(); |
| 49 if (wrapperTypeInfo == &V8Navigator::wrapperTypeInfo) { | 47 if (wrapperTypeInfo == &V8Navigator::wrapperTypeInfo) { |
| 50 if (OriginTrials::webShareEnabled(executionContext)) { | 48 if (OriginTrials::webShareEnabled(executionContext)) { |
| 51 V8NavigatorPartial::installWebShare(isolate, world, | 49 V8NavigatorPartial::installWebShare(scriptState, v8::Local<v8::Object>(), |
|
Yuki
2016/11/01 11:37:54
Given that you've already extracted |global|, why
iclelland
2016/11/01 17:06:27
That parameter is supposed to be the object instan
| |
| 52 v8::Local<v8::Object>(), | |
| 53 prototypeObject, interfaceObject); | 50 prototypeObject, interfaceObject); |
| 54 } | 51 } |
| 55 if (OriginTrials::webUSBEnabled(executionContext)) { | 52 if (OriginTrials::webUSBEnabled(executionContext)) { |
| 56 V8NavigatorPartial::installWebUSB(isolate, world, v8::Local<v8::Object>(), | 53 V8NavigatorPartial::installWebUSB(scriptState, v8::Local<v8::Object>(), |
| 57 prototypeObject, interfaceObject); | 54 prototypeObject, interfaceObject); |
| 58 } | 55 } |
| 59 if (OriginTrials::webVREnabled(executionContext)) { | 56 if (OriginTrials::webVREnabled(executionContext)) { |
| 60 V8NavigatorPartial::installWebVR(isolate, world, global, prototypeObject, | 57 V8NavigatorPartial::installWebVR(scriptState, global, prototypeObject, |
| 61 interfaceObject); | 58 interfaceObject); |
| 62 } | 59 } |
| 63 } else if (wrapperTypeInfo == &V8Window::wrapperTypeInfo) { | 60 } else if (wrapperTypeInfo == &V8Window::wrapperTypeInfo) { |
| 64 if (OriginTrials::webUSBEnabled(executionContext)) { | 61 if (OriginTrials::webUSBEnabled(executionContext)) { |
| 65 V8WindowPartial::installWebUSB(isolate, world, global, prototypeObject, | 62 V8WindowPartial::installWebUSB(scriptState, global, prototypeObject, |
| 66 interfaceObject); | 63 interfaceObject); |
| 67 } | 64 } |
| 68 if (OriginTrials::webVREnabled(executionContext)) { | 65 if (OriginTrials::webVREnabled(executionContext)) { |
| 69 V8WindowPartial::installWebVR(isolate, world, global, prototypeObject, | 66 V8WindowPartial::installWebVR(scriptState, global, prototypeObject, |
| 70 interfaceObject); | 67 interfaceObject); |
| 71 } | 68 } |
| 72 if (OriginTrials::gamepadExtensionsEnabled(executionContext)) { | 69 if (OriginTrials::gamepadExtensionsEnabled(executionContext)) { |
| 73 V8WindowPartial::installGamepadExtensions( | 70 V8WindowPartial::installGamepadExtensions( |
| 74 isolate, world, global, prototypeObject, interfaceObject); | 71 scriptState, global, prototypeObject, interfaceObject); |
| 75 } | 72 } |
| 76 } else if (wrapperTypeInfo == &V8ServiceWorkerGlobalScope::wrapperTypeInfo) { | 73 } else if (wrapperTypeInfo == &V8ServiceWorkerGlobalScope::wrapperTypeInfo) { |
| 77 if (OriginTrials::foreignFetchEnabled(executionContext)) { | 74 if (OriginTrials::foreignFetchEnabled(executionContext)) { |
| 78 V8ServiceWorkerGlobalScope::installForeignFetch( | 75 V8ServiceWorkerGlobalScope::installForeignFetch( |
| 79 isolate, world, global, prototypeObject, interfaceObject); | 76 scriptState, global, prototypeObject, interfaceObject); |
| 80 } | 77 } |
| 81 } else if (wrapperTypeInfo == &V8InstallEvent::wrapperTypeInfo) { | 78 } else if (wrapperTypeInfo == &V8InstallEvent::wrapperTypeInfo) { |
| 82 if (OriginTrials::foreignFetchEnabled(executionContext)) { | 79 if (OriginTrials::foreignFetchEnabled(executionContext)) { |
| 83 V8InstallEvent::installForeignFetch(isolate, world, | 80 V8InstallEvent::installForeignFetch(scriptState, v8::Local<v8::Object>(), |
| 84 v8::Local<v8::Object>(), | |
| 85 prototypeObject, interfaceObject); | 81 prototypeObject, interfaceObject); |
| 86 } | 82 } |
| 87 } else if (wrapperTypeInfo == &V8Gamepad::wrapperTypeInfo) { | 83 } else if (wrapperTypeInfo == &V8Gamepad::wrapperTypeInfo) { |
| 88 if (OriginTrials::gamepadExtensionsEnabled(executionContext)) { | 84 if (OriginTrials::gamepadExtensionsEnabled(executionContext)) { |
| 89 V8Gamepad::installGamepadExtensions(isolate, world, global, | 85 V8Gamepad::installGamepadExtensions(scriptState, global, prototypeObject, |
| 90 prototypeObject, interfaceObject); | 86 interfaceObject); |
| 91 } | 87 } |
| 92 } else if (wrapperTypeInfo == &V8GamepadButton::wrapperTypeInfo) { | 88 } else if (wrapperTypeInfo == &V8GamepadButton::wrapperTypeInfo) { |
| 93 if (OriginTrials::gamepadExtensionsEnabled(executionContext)) { | 89 if (OriginTrials::gamepadExtensionsEnabled(executionContext)) { |
| 94 V8GamepadButton::installGamepadExtensions( | 90 V8GamepadButton::installGamepadExtensions( |
| 95 isolate, world, global, prototypeObject, interfaceObject); | 91 scriptState, global, prototypeObject, interfaceObject); |
| 96 } | 92 } |
| 97 } | 93 } |
| 98 } | 94 } |
| 99 | 95 |
| 100 void registerInstallConditionalFeaturesForModules() { | 96 void registerInstallConditionalFeaturesForModules() { |
| 101 s_originalInstallConditionalFeaturesFunction = | 97 s_originalInstallConditionalFeaturesFunction = |
| 102 setInstallConditionalFeaturesFunction( | 98 setInstallConditionalFeaturesFunction( |
| 103 &installConditionalFeaturesForModules); | 99 &installConditionalFeaturesForModules); |
| 104 } | 100 } |
| 105 | 101 |
| 106 } // namespace blink | 102 } // namespace blink |
| OLD | NEW |