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

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

Issue 2454513002: Use the generated checks for whether origin trials are enabled. (Closed)
Patch Set: Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "bindings/core/v8/V8Window.h" 11 #include "bindings/core/v8/V8Window.h"
12 #include "bindings/core/v8/V8WorkerNavigator.h" 12 #include "bindings/core/v8/V8WorkerNavigator.h"
13 #include "bindings/modules/v8/V8DedicatedWorkerGlobalScopePartial.h" 13 #include "bindings/modules/v8/V8DedicatedWorkerGlobalScopePartial.h"
14 #include "bindings/modules/v8/V8Gamepad.h" 14 #include "bindings/modules/v8/V8Gamepad.h"
15 #include "bindings/modules/v8/V8GamepadButton.h" 15 #include "bindings/modules/v8/V8GamepadButton.h"
16 #include "bindings/modules/v8/V8InstallEvent.h" 16 #include "bindings/modules/v8/V8InstallEvent.h"
17 #include "bindings/modules/v8/V8NavigatorPartial.h" 17 #include "bindings/modules/v8/V8NavigatorPartial.h"
18 #include "bindings/modules/v8/V8ServiceWorkerGlobalScope.h" 18 #include "bindings/modules/v8/V8ServiceWorkerGlobalScope.h"
19 #include "bindings/modules/v8/V8SharedWorkerGlobalScopePartial.h" 19 #include "bindings/modules/v8/V8SharedWorkerGlobalScopePartial.h"
20 #include "bindings/modules/v8/V8WindowPartial.h" 20 #include "bindings/modules/v8/V8WindowPartial.h"
21 #include "bindings/modules/v8/V8WorkerNavigatorPartial.h" 21 #include "bindings/modules/v8/V8WorkerNavigatorPartial.h"
22 #include "core/dom/ExecutionContext.h" 22 #include "core/dom/ExecutionContext.h"
23 #include "core/origin_trials/OriginTrialContext.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(
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 OriginTrialContext* originTrialContext = OriginTrialContext::from(
47 executionContext, OriginTrialContext::DontCreateIfNotExists);
48 v8::Isolate* isolate = scriptState->isolate(); 46 v8::Isolate* isolate = scriptState->isolate();
49 const DOMWrapperWorld& world = scriptState->world(); 47 const DOMWrapperWorld& world = scriptState->world();
50 v8::Local<v8::Object> global = scriptState->context()->Global(); 48 v8::Local<v8::Object> global = scriptState->context()->Global();
51 if (wrapperTypeInfo == &V8Navigator::wrapperTypeInfo) { 49 if (wrapperTypeInfo == &V8Navigator::wrapperTypeInfo) {
52 if (RuntimeEnabledFeatures::webBluetoothEnabled() || 50 if (OriginTrials::webBluetoothEnabled(executionContext)) {
53 (originTrialContext &&
54 originTrialContext->isTrialEnabled("WebBluetooth"))) {
55 V8NavigatorPartial::installWebBluetooth(isolate, world, 51 V8NavigatorPartial::installWebBluetooth(isolate, world,
56 v8::Local<v8::Object>(), 52 v8::Local<v8::Object>(),
57 prototypeObject, interfaceObject); 53 prototypeObject, interfaceObject);
58 } 54 }
59 if (RuntimeEnabledFeatures::webShareEnabled() || 55 if (OriginTrials::webShareEnabled(executionContext)) {
60 (originTrialContext &&
61 originTrialContext->isTrialEnabled("WebShare"))) {
62 V8NavigatorPartial::installWebShare(isolate, world, 56 V8NavigatorPartial::installWebShare(isolate, world,
63 v8::Local<v8::Object>(), 57 v8::Local<v8::Object>(),
64 prototypeObject, interfaceObject); 58 prototypeObject, interfaceObject);
65 } 59 }
66 if (RuntimeEnabledFeatures::webUSBEnabled() || 60 if (OriginTrials::webUSBEnabled(executionContext)) {
67 (originTrialContext && originTrialContext->isTrialEnabled("WebUSB"))) {
68 V8NavigatorPartial::installWebUSB(isolate, world, v8::Local<v8::Object>(), 61 V8NavigatorPartial::installWebUSB(isolate, world, v8::Local<v8::Object>(),
69 prototypeObject, interfaceObject); 62 prototypeObject, interfaceObject);
70 } 63 }
71 if (RuntimeEnabledFeatures::webVREnabled() || 64 if (OriginTrials::webVREnabled(executionContext)) {
72 (originTrialContext && originTrialContext->isTrialEnabled("WebVR"))) {
73 V8NavigatorPartial::installWebVR(isolate, world, global, prototypeObject, 65 V8NavigatorPartial::installWebVR(isolate, world, global, prototypeObject,
74 interfaceObject); 66 interfaceObject);
75 } 67 }
76 } else if (wrapperTypeInfo == &V8Window::wrapperTypeInfo) { 68 } else if (wrapperTypeInfo == &V8Window::wrapperTypeInfo) {
77 if (RuntimeEnabledFeatures::webBluetoothEnabled() || 69 if (OriginTrials::webBluetoothEnabled(executionContext)) {
78 (originTrialContext &&
79 originTrialContext->isTrialEnabled("WebBluetooth"))) {
80 V8WindowPartial::installWebBluetooth(isolate, world, global, 70 V8WindowPartial::installWebBluetooth(isolate, world, global,
81 prototypeObject, interfaceObject); 71 prototypeObject, interfaceObject);
82 } 72 }
83 if (RuntimeEnabledFeatures::webUSBEnabled() || 73 if (OriginTrials::webUSBEnabled(executionContext)) {
84 (originTrialContext && originTrialContext->isTrialEnabled("WebUSB"))) {
85 V8WindowPartial::installWebUSB(isolate, world, global, prototypeObject, 74 V8WindowPartial::installWebUSB(isolate, world, global, prototypeObject,
86 interfaceObject); 75 interfaceObject);
87 } 76 }
88 if (RuntimeEnabledFeatures::webVREnabled() || 77 if (OriginTrials::webVREnabled(executionContext)) {
89 (originTrialContext && originTrialContext->isTrialEnabled("WebVR"))) {
90 V8WindowPartial::installWebVR(isolate, world, global, prototypeObject, 78 V8WindowPartial::installWebVR(isolate, world, global, prototypeObject,
91 interfaceObject); 79 interfaceObject);
92 } 80 }
93 if (RuntimeEnabledFeatures::gamepadExtensionsEnabled() || 81 if (OriginTrials::gamepadExtensionsEnabled(executionContext)) {
94 (originTrialContext && originTrialContext->isTrialEnabled("WebVR"))) {
95 V8WindowPartial::installGamepadExtensions( 82 V8WindowPartial::installGamepadExtensions(
96 isolate, world, global, prototypeObject, interfaceObject); 83 isolate, world, global, prototypeObject, interfaceObject);
97 } 84 }
98 } else if (wrapperTypeInfo == &V8ServiceWorkerGlobalScope::wrapperTypeInfo) { 85 } else if (wrapperTypeInfo == &V8ServiceWorkerGlobalScope::wrapperTypeInfo) {
99 if (RuntimeEnabledFeatures::foreignFetchEnabled() || 86 if (OriginTrials::foreignFetchEnabled(executionContext)) {
100 (originTrialContext &&
101 originTrialContext->isTrialEnabled("ForeignFetch"))) {
102 V8ServiceWorkerGlobalScope::installForeignFetch( 87 V8ServiceWorkerGlobalScope::installForeignFetch(
103 isolate, world, global, prototypeObject, interfaceObject); 88 isolate, world, global, prototypeObject, interfaceObject);
104 } 89 }
105 } else if (wrapperTypeInfo == &V8InstallEvent::wrapperTypeInfo) { 90 } else if (wrapperTypeInfo == &V8InstallEvent::wrapperTypeInfo) {
106 if (RuntimeEnabledFeatures::foreignFetchEnabled() || 91 if (OriginTrials::foreignFetchEnabled(executionContext)) {
107 (originTrialContext &&
108 originTrialContext->isTrialEnabled("ForeignFetch"))) {
109 V8InstallEvent::installForeignFetch(isolate, world, 92 V8InstallEvent::installForeignFetch(isolate, world,
110 v8::Local<v8::Object>(), 93 v8::Local<v8::Object>(),
111 prototypeObject, interfaceObject); 94 prototypeObject, interfaceObject);
112 } 95 }
113 } else if (wrapperTypeInfo == &V8Gamepad::wrapperTypeInfo) { 96 } else if (wrapperTypeInfo == &V8Gamepad::wrapperTypeInfo) {
114 if (RuntimeEnabledFeatures::gamepadExtensionsEnabled() || 97 if (OriginTrials::gamepadExtensionsEnabled(executionContext)) {
115 (originTrialContext && originTrialContext->isTrialEnabled("WebVR"))) {
116 V8Gamepad::installGamepadExtensions(isolate, world, global, 98 V8Gamepad::installGamepadExtensions(isolate, world, global,
117 prototypeObject, interfaceObject); 99 prototypeObject, interfaceObject);
118 } 100 }
119 } else if (wrapperTypeInfo == &V8GamepadButton::wrapperTypeInfo) { 101 } else if (wrapperTypeInfo == &V8GamepadButton::wrapperTypeInfo) {
120 if (RuntimeEnabledFeatures::gamepadExtensionsEnabled() || 102 if (OriginTrials::gamepadExtensionsEnabled(executionContext)) {
121 (originTrialContext && originTrialContext->isTrialEnabled("WebVR"))) {
122 V8GamepadButton::installGamepadExtensions( 103 V8GamepadButton::installGamepadExtensions(
123 isolate, world, global, prototypeObject, interfaceObject); 104 isolate, world, global, prototypeObject, interfaceObject);
124 } 105 }
125 } 106 }
126 } 107 }
127 108
128 void registerInstallConditionalFeaturesForModules() { 109 void registerInstallConditionalFeaturesForModules() {
129 s_originalInstallConditionalFeaturesFunction = 110 s_originalInstallConditionalFeaturesFunction =
130 setInstallConditionalFeaturesFunction( 111 setInstallConditionalFeaturesFunction(
131 &installConditionalFeaturesForModules); 112 &installConditionalFeaturesForModules);
132 } 113 }
133 114
134 } // namespace blink 115 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698