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

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

Issue 2454253003: 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/V8InstallEvent.h" 14 #include "bindings/modules/v8/V8InstallEvent.h"
15 #include "bindings/modules/v8/V8NavigatorPartial.h" 15 #include "bindings/modules/v8/V8NavigatorPartial.h"
16 #include "bindings/modules/v8/V8ServiceWorkerGlobalScope.h" 16 #include "bindings/modules/v8/V8ServiceWorkerGlobalScope.h"
17 #include "bindings/modules/v8/V8SharedWorkerGlobalScopePartial.h" 17 #include "bindings/modules/v8/V8SharedWorkerGlobalScopePartial.h"
18 #include "bindings/modules/v8/V8WindowPartial.h" 18 #include "bindings/modules/v8/V8WindowPartial.h"
19 #include "bindings/modules/v8/V8WorkerNavigatorPartial.h" 19 #include "bindings/modules/v8/V8WorkerNavigatorPartial.h"
20 #include "core/dom/ExecutionContext.h" 20 #include "core/dom/ExecutionContext.h"
21 #include "core/origin_trials/OriginTrialContext.h" 21 #include "core/origin_trials/OriginTrials.h"
22 22
23 namespace blink { 23 namespace blink {
24 24
25 namespace { 25 namespace {
26 InstallConditionalFeaturesFunction 26 InstallConditionalFeaturesFunction
27 s_originalInstallConditionalFeaturesFunction = nullptr; 27 s_originalInstallConditionalFeaturesFunction = nullptr;
28 } 28 }
29 29
30 void installConditionalFeaturesForModules( 30 void installConditionalFeaturesForModules(
31 const WrapperTypeInfo* wrapperTypeInfo, 31 const WrapperTypeInfo* wrapperTypeInfo,
32 const ScriptState* scriptState, 32 const ScriptState* scriptState,
33 v8::Local<v8::Object> prototypeObject, 33 v8::Local<v8::Object> prototypeObject,
34 v8::Local<v8::Function> interfaceObject) { 34 v8::Local<v8::Function> interfaceObject) {
35 // TODO(iclelland): Generate all of this logic at compile-time, based on the 35 // TODO(iclelland): Generate all of this logic at compile-time, based on the
36 // configuration of origin trial enabled attibutes and interfaces in IDL 36 // configuration of origin trial enabled attibutes and interfaces in IDL
37 // files. (crbug.com/615060) 37 // files. (crbug.com/615060)
38 (*s_originalInstallConditionalFeaturesFunction)( 38 (*s_originalInstallConditionalFeaturesFunction)(
39 wrapperTypeInfo, scriptState, prototypeObject, interfaceObject); 39 wrapperTypeInfo, scriptState, prototypeObject, interfaceObject);
40 40
41 ExecutionContext* executionContext = scriptState->getExecutionContext(); 41 ExecutionContext* executionContext = scriptState->getExecutionContext();
42 if (!executionContext) 42 if (!executionContext)
43 return; 43 return;
44 OriginTrialContext* originTrialContext = OriginTrialContext::from(
45 executionContext, OriginTrialContext::DontCreateIfNotExists);
46 v8::Isolate* isolate = scriptState->isolate(); 44 v8::Isolate* isolate = scriptState->isolate();
47 const DOMWrapperWorld& world = scriptState->world(); 45 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 (RuntimeEnabledFeatures::webBluetoothEnabled() || 48 if (OriginTrials::webBluetoothEnabled(executionContext)) {
51 (originTrialContext &&
52 originTrialContext->isFeatureEnabled("WebBluetooth"))) {
53 V8NavigatorPartial::installWebBluetooth(isolate, world, 49 V8NavigatorPartial::installWebBluetooth(isolate, world,
54 v8::Local<v8::Object>(), 50 v8::Local<v8::Object>(),
55 prototypeObject, interfaceObject); 51 prototypeObject, interfaceObject);
56 } 52 }
57 if (RuntimeEnabledFeatures::webShareEnabled() || 53 if (OriginTrials::webShareEnabled(executionContext)) {
58 (originTrialContext &&
59 originTrialContext->isFeatureEnabled("WebShare"))) {
60 V8NavigatorPartial::installWebShare(isolate, world, 54 V8NavigatorPartial::installWebShare(isolate, world,
61 v8::Local<v8::Object>(), 55 v8::Local<v8::Object>(),
62 prototypeObject, interfaceObject); 56 prototypeObject, interfaceObject);
63 } 57 }
64 if (RuntimeEnabledFeatures::webUSBEnabled() || 58 if (OriginTrials::webUSBEnabled(executionContext)) {
65 (originTrialContext &&
66 originTrialContext->isFeatureEnabled("WebUSB"))) {
67 V8NavigatorPartial::installWebUSB(isolate, world, v8::Local<v8::Object>(), 59 V8NavigatorPartial::installWebUSB(isolate, world, v8::Local<v8::Object>(),
68 prototypeObject, interfaceObject); 60 prototypeObject, interfaceObject);
69 } 61 }
70 } else if (wrapperTypeInfo == &V8Window::wrapperTypeInfo) { 62 } else if (wrapperTypeInfo == &V8Window::wrapperTypeInfo) {
71 if (RuntimeEnabledFeatures::webBluetoothEnabled() || 63 if (OriginTrials::webBluetoothEnabled(executionContext)) {
72 (originTrialContext &&
73 originTrialContext->isFeatureEnabled("WebBluetooth"))) {
74 V8WindowPartial::installWebBluetooth(isolate, world, global, 64 V8WindowPartial::installWebBluetooth(isolate, world, global,
75 prototypeObject, interfaceObject); 65 prototypeObject, interfaceObject);
76 } 66 }
77 if (RuntimeEnabledFeatures::webUSBEnabled() || 67 if (OriginTrials::webUSBEnabled(executionContext)) {
78 (originTrialContext &&
79 originTrialContext->isFeatureEnabled("WebUSB"))) {
80 V8WindowPartial::installWebUSB(isolate, world, global, prototypeObject, 68 V8WindowPartial::installWebUSB(isolate, world, global, prototypeObject,
81 interfaceObject); 69 interfaceObject);
82 } 70 }
83 } else if (wrapperTypeInfo == &V8ServiceWorkerGlobalScope::wrapperTypeInfo) { 71 } else if (wrapperTypeInfo == &V8ServiceWorkerGlobalScope::wrapperTypeInfo) {
84 if (RuntimeEnabledFeatures::foreignFetchEnabled() || 72 if (OriginTrials::foreignFetchEnabled(executionContext)) {
85 (originTrialContext &&
86 originTrialContext->isFeatureEnabled("ForeignFetch"))) {
87 V8ServiceWorkerGlobalScope::installForeignFetch( 73 V8ServiceWorkerGlobalScope::installForeignFetch(
88 isolate, world, global, prototypeObject, interfaceObject); 74 isolate, world, global, prototypeObject, interfaceObject);
89 } 75 }
90 } else if (wrapperTypeInfo == &V8InstallEvent::wrapperTypeInfo) { 76 } else if (wrapperTypeInfo == &V8InstallEvent::wrapperTypeInfo) {
91 if (RuntimeEnabledFeatures::foreignFetchEnabled() || 77 if (OriginTrials::foreignFetchEnabled(executionContext)) {
92 (originTrialContext &&
93 originTrialContext->isFeatureEnabled("ForeignFetch"))) {
94 V8InstallEvent::installForeignFetch(isolate, world, 78 V8InstallEvent::installForeignFetch(isolate, world,
95 v8::Local<v8::Object>(), 79 v8::Local<v8::Object>(),
96 prototypeObject, interfaceObject); 80 prototypeObject, interfaceObject);
97 } 81 }
98 } 82 }
99 } 83 }
100 84
101 void registerInstallConditionalFeaturesForModules() { 85 void registerInstallConditionalFeaturesForModules() {
102 s_originalInstallConditionalFeaturesFunction = 86 s_originalInstallConditionalFeaturesFunction =
103 setInstallConditionalFeaturesFunction( 87 setInstallConditionalFeaturesFunction(
104 &installConditionalFeaturesForModules); 88 &installConditionalFeaturesForModules);
105 } 89 }
106 90
107 } // namespace blink 91 } // 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