OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // This file has been auto-generated by generate_conditional_features.py. |
| 6 // DO NOT MODIFY! |
| 7 |
| 8 // This file has been generated from the Jinja2 template in |
| 9 // third_party/WebKit/Source/bindings/templates/ConditionalFeaturesForCore.cpp.t
mpl |
| 10 |
| 11 // clang-format off |
| 12 |
5 #include "bindings/core/v8/ConditionalFeaturesForCore.h" | 13 #include "bindings/core/v8/ConditionalFeaturesForCore.h" |
6 | 14 |
7 #include "bindings/core/v8/V8Document.h" | 15 #include "bindings/core/v8/V8TestObject.h" |
8 #include "bindings/core/v8/V8HTMLLinkElement.h" | |
9 #include "bindings/core/v8/V8Navigator.h" | |
10 #include "bindings/core/v8/V8Window.h" | 16 #include "bindings/core/v8/V8Window.h" |
11 #include "core/context_features/ContextFeatureSettings.h" | 17 #include "core/context_features/ContextFeatureSettings.h" |
12 #include "core/dom/ExecutionContext.h" | 18 #include "core/dom/ExecutionContext.h" |
13 #include "core/frame/Frame.h" | 19 #include "core/frame/Frame.h" |
14 #include "core/origin_trials/OriginTrials.h" | 20 #include "core/origin_trials/OriginTrials.h" |
15 #include "platform/bindings/ConditionalFeatures.h" | 21 #include "platform/bindings/ConditionalFeatures.h" |
16 #include "platform/bindings/ScriptState.h" | 22 #include "platform/bindings/ScriptState.h" |
17 | 23 |
18 namespace blink { | 24 namespace blink { |
19 | 25 |
20 namespace { | 26 namespace { |
21 InstallConditionalFeaturesFunction g_old_install_conditional_features_function = | 27 InstallConditionalFeaturesFunction g_old_install_conditional_features_function = |
22 nullptr; | 28 nullptr; |
23 InstallPendingConditionalFeatureFunction | 29 InstallPendingConditionalFeatureFunction |
24 g_old_install_pending_conditional_feature_function = nullptr; | 30 g_old_install_pending_conditional_feature_function = nullptr; |
25 } | 31 } |
26 | 32 |
27 void InstallConditionalFeaturesCore(const WrapperTypeInfo* wrapper_type_info, | 33 void InstallConditionalFeaturesForCore( |
28 const ScriptState* script_state, | 34 const WrapperTypeInfo* wrapper_type_info, |
29 v8::Local<v8::Object> prototype_object, | 35 const ScriptState* script_state, |
30 v8::Local<v8::Function> interface_object) { | 36 v8::Local<v8::Object> prototype_object, |
| 37 v8::Local<v8::Function> interface_object) { |
31 (*g_old_install_conditional_features_function)( | 38 (*g_old_install_conditional_features_function)( |
32 wrapper_type_info, script_state, prototype_object, interface_object); | 39 wrapper_type_info, script_state, prototype_object, interface_object); |
33 | 40 |
34 // TODO(iclelland): Generate all of this logic at compile-time, based on the | |
35 // configuration of origin trial enabled attributes and interfaces in IDL | |
36 // files. (crbug.com/615060) | |
37 ExecutionContext* execution_context = ExecutionContext::From(script_state); | 41 ExecutionContext* execution_context = ExecutionContext::From(script_state); |
38 if (!execution_context) | 42 if (!execution_context) |
39 return; | 43 return; |
40 v8::Isolate* isolate = script_state->GetIsolate(); | 44 v8::Isolate* isolate = script_state->GetIsolate(); |
41 const DOMWrapperWorld& world = script_state->World(); | 45 const DOMWrapperWorld& world = script_state->World(); |
| 46 // TODO(iclelland): Unify ContextFeatureSettings with the rest of the |
| 47 // conditional features. |
42 if (wrapper_type_info == &V8Window::wrapperTypeInfo) { | 48 if (wrapper_type_info == &V8Window::wrapperTypeInfo) { |
43 auto* settings = ContextFeatureSettings::From( | 49 auto* settings = ContextFeatureSettings::From( |
44 execution_context, | 50 execution_context, |
45 ContextFeatureSettings::CreationMode::kDontCreateIfNotExists); | 51 ContextFeatureSettings::CreationMode::kDontCreateIfNotExists); |
46 if (settings && settings->isMojoJSEnabled()) { | 52 if (settings && settings->isMojoJSEnabled()) { |
47 v8::Local<v8::Object> instance_object = | 53 v8::Local<v8::Object> instance_object = |
48 script_state->GetContext()->Global(); | 54 script_state->GetContext()->Global(); |
49 V8Window::installMojoJS(isolate, world, instance_object, prototype_object, | 55 V8Window::installMojoJS(isolate, world, instance_object, prototype_object, |
50 interface_object); | 56 interface_object); |
51 } | 57 } |
52 } else if (wrapper_type_info == &V8HTMLLinkElement::wrapperTypeInfo) { | 58 } |
53 if (OriginTrials::linkServiceWorkerEnabled(execution_context)) { | 59 // TODO(iclelland): Extract this common code out of ConditionalFeaturesForCore |
54 V8HTMLLinkElement::installLinkServiceWorker( | 60 // and ConditionalFeaturesForModules into a block. |
55 isolate, world, v8::Local<v8::Object>(), prototype_object, | 61 if (wrapper_type_info == &V8TestObject::wrapperTypeInfo) { |
56 interface_object); | 62 if (OriginTrials::featureNameEnabled(execution_context)) { |
| 63 V8TestObject::installFeatureName( |
| 64 isolate, world, v8::Local<v8::Object>(), prototype_object, interface_o
bject); |
57 } | 65 } |
58 } | 66 } |
59 } | 67 } |
60 | 68 |
61 void InstallPendingConditionalFeatureCore(const String& feature, | 69 void InstallPendingConditionalFeatureForCore(const String& feature, |
62 const ScriptState* script_state) { | 70 const ScriptState* script_state) { |
63 (*g_old_install_pending_conditional_feature_function)(feature, script_state); | 71 (*g_old_install_pending_conditional_feature_function)(feature, script_state); |
64 | 72 |
65 // TODO(iclelland): Generate all of this logic at compile-time, based on the | 73 // TODO(iclelland): Extract this common code out of ConditionalFeaturesForCore |
66 // configuration of origin trial enabled attributes and interfaces in IDL | 74 // and ConditionalFeaturesForModules into a block. |
67 // files. (crbug.com/615060) | |
68 v8::Local<v8::Object> prototype_object; | 75 v8::Local<v8::Object> prototype_object; |
69 v8::Local<v8::Function> interface_object; | 76 v8::Local<v8::Function> interface_object; |
70 v8::Isolate* isolate = script_state->GetIsolate(); | 77 v8::Isolate* isolate = script_state->GetIsolate(); |
71 const DOMWrapperWorld& world = script_state->World(); | 78 const DOMWrapperWorld& world = script_state->World(); |
72 V8PerContextData* context_data = script_state->PerContextData(); | 79 V8PerContextData* context_data = script_state->PerContextData(); |
73 if (feature == "ForeignFetch") { | 80 if (feature == "FeatureName") { |
74 if (context_data->GetExistingConstructorAndPrototypeForType( | 81 if (context_data->GetExistingConstructorAndPrototypeForType( |
75 &V8HTMLLinkElement::wrapperTypeInfo, &prototype_object, | 82 &V8TestObject::wrapperTypeInfo, &prototype_object, &interface_object
)) { |
76 &interface_object)) { | 83 V8TestObject::installFeatureName( |
77 V8HTMLLinkElement::installLinkServiceWorker( | 84 isolate, world, v8::Local<v8::Object>(), prototype_object, interface_o
bject); |
78 isolate, world, v8::Local<v8::Object>(), prototype_object, | |
79 interface_object); | |
80 } | 85 } |
81 return; | 86 return; |
82 } | 87 } |
83 } | 88 } |
84 | 89 |
85 void InstallConditionalFeaturesOnWindow(const ScriptState* script_state) { | 90 void InstallConditionalFeaturesOnWindow(const ScriptState* script_state) { |
86 DCHECK(script_state); | 91 DCHECK(script_state); |
87 DCHECK(script_state->GetContext() == | 92 DCHECK(script_state->GetContext() == |
88 script_state->GetIsolate()->GetCurrentContext()); | 93 script_state->GetIsolate()->GetCurrentContext()); |
89 DCHECK(script_state->PerContextData()); | 94 DCHECK(script_state->PerContextData()); |
90 DCHECK(script_state->World().IsMainWorld()); | 95 DCHECK(script_state->World().IsMainWorld()); |
91 InstallConditionalFeatures(&V8Window::wrapperTypeInfo, script_state, | 96 InstallConditionalFeatures(&V8Window::wrapperTypeInfo, script_state, |
92 v8::Local<v8::Object>(), | 97 v8::Local<v8::Object>(), |
93 v8::Local<v8::Function>()); | 98 v8::Local<v8::Function>()); |
94 } | 99 } |
95 | 100 |
96 void RegisterInstallConditionalFeaturesForCore() { | 101 void RegisterInstallConditionalFeaturesForCore() { |
97 g_old_install_conditional_features_function = | 102 g_old_install_conditional_features_function = |
98 SetInstallConditionalFeaturesFunction(&InstallConditionalFeaturesCore); | 103 SetInstallConditionalFeaturesFunction(&InstallConditionalFeaturesForCore); |
99 g_old_install_pending_conditional_feature_function = | 104 g_old_install_pending_conditional_feature_function = |
100 SetInstallPendingConditionalFeatureFunction( | 105 SetInstallPendingConditionalFeatureFunction( |
101 &InstallPendingConditionalFeatureCore); | 106 &InstallPendingConditionalFeatureForCore); |
102 } | 107 } |
103 | 108 |
104 } // namespace blink | 109 } // namespace blink |
OLD | NEW |