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/core/v8/ConditionalFeatures.h" | 5 #include "bindings/core/v8/ConditionalFeatures.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptState.h" | 7 #include "bindings/core/v8/ScriptState.h" |
8 #include "bindings/core/v8/V8Document.h" | 8 #include "bindings/core/v8/V8Document.h" |
9 #include "bindings/core/v8/V8HTMLLinkElement.h" | 9 #include "bindings/core/v8/V8HTMLLinkElement.h" |
10 #include "bindings/core/v8/V8Navigator.h" | 10 #include "bindings/core/v8/V8Navigator.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 if (!executionContext) | 26 if (!executionContext) |
27 return; | 27 return; |
28 v8::Isolate* isolate = scriptState->isolate(); | 28 v8::Isolate* isolate = scriptState->isolate(); |
29 const DOMWrapperWorld& world = scriptState->world(); | 29 const DOMWrapperWorld& world = scriptState->world(); |
30 if (wrapperTypeInfo == &V8HTMLLinkElement::wrapperTypeInfo) { | 30 if (wrapperTypeInfo == &V8HTMLLinkElement::wrapperTypeInfo) { |
31 if (OriginTrials::linkServiceWorkerEnabled(executionContext)) { | 31 if (OriginTrials::linkServiceWorkerEnabled(executionContext)) { |
32 V8HTMLLinkElement::installLinkServiceWorker( | 32 V8HTMLLinkElement::installLinkServiceWorker( |
33 isolate, world, v8::Local<v8::Object>(), prototypeObject, | 33 isolate, world, v8::Local<v8::Object>(), prototypeObject, |
34 interfaceObject); | 34 interfaceObject); |
35 } | 35 } |
36 } else if (wrapperTypeInfo == &V8Window::wrapperTypeInfo) { | |
37 v8::Local<v8::Object> instanceObject = scriptState->context()->Global(); | |
38 if (OriginTrials::longTaskObserverEnabled(executionContext)) { | |
39 V8Window::installLongTaskObserver(isolate, world, instanceObject, | |
40 prototypeObject, interfaceObject); | |
41 } | |
42 } else if (wrapperTypeInfo == &V8Document::wrapperTypeInfo) { | 36 } else if (wrapperTypeInfo == &V8Document::wrapperTypeInfo) { |
43 if (OriginTrials::setRootScrollerEnabled(executionContext)) { | 37 if (OriginTrials::setRootScrollerEnabled(executionContext)) { |
44 V8Document::installRootScroller(isolate, world, v8::Local<v8::Object>(), | 38 V8Document::installRootScroller(isolate, world, v8::Local<v8::Object>(), |
45 prototypeObject, interfaceObject); | 39 prototypeObject, interfaceObject); |
46 } | 40 } |
47 } | 41 } |
48 } | 42 } |
49 | 43 |
50 void installPendingConditionalFeatureCore(const String& feature, | 44 void installPendingConditionalFeatureCore(const String& feature, |
51 const ScriptState* scriptState) { | 45 const ScriptState* scriptState) { |
52 // TODO(iclelland): Generate all of this logic at compile-time, based on the | 46 // TODO(iclelland): Generate all of this logic at compile-time, based on the |
53 // configuration of origin trial enabled attributes and interfaces in IDL | 47 // configuration of origin trial enabled attributes and interfaces in IDL |
54 // files. (crbug.com/615060) | 48 // files. (crbug.com/615060) |
55 v8::Local<v8::Object> prototypeObject; | 49 v8::Local<v8::Object> prototypeObject; |
56 v8::Local<v8::Function> interfaceObject; | 50 v8::Local<v8::Function> interfaceObject; |
57 v8::Isolate* isolate = scriptState->isolate(); | 51 v8::Isolate* isolate = scriptState->isolate(); |
58 const DOMWrapperWorld& world = scriptState->world(); | 52 const DOMWrapperWorld& world = scriptState->world(); |
59 V8PerContextData* contextData = scriptState->perContextData(); | 53 V8PerContextData* contextData = scriptState->perContextData(); |
60 if (feature == "ForeignFetch") { | 54 if (feature == "ForeignFetch") { |
61 if (contextData->getExistingConstructorAndPrototypeForType( | 55 if (contextData->getExistingConstructorAndPrototypeForType( |
62 &V8HTMLLinkElement::wrapperTypeInfo, &prototypeObject, | 56 &V8HTMLLinkElement::wrapperTypeInfo, &prototypeObject, |
63 &interfaceObject)) { | 57 &interfaceObject)) { |
64 V8HTMLLinkElement::installLinkServiceWorker( | 58 V8HTMLLinkElement::installLinkServiceWorker( |
65 isolate, world, v8::Local<v8::Object>(), prototypeObject, | 59 isolate, world, v8::Local<v8::Object>(), prototypeObject, |
66 interfaceObject); | 60 interfaceObject); |
67 } | 61 } |
68 return; | 62 return; |
69 } | 63 } |
70 if (feature == "LongTaskObserver") { | |
71 v8::Local<v8::Object> instanceObject = scriptState->context()->Global(); | |
72 V8Window::installLongTaskObserver(isolate, world, instanceObject, | |
73 v8::Local<v8::Object>(), | |
74 v8::Local<v8::Function>()); | |
75 return; | |
76 } | |
77 if (feature == "RootScroller") { | 64 if (feature == "RootScroller") { |
78 if (contextData->getExistingConstructorAndPrototypeForType( | 65 if (contextData->getExistingConstructorAndPrototypeForType( |
79 &V8Document::wrapperTypeInfo, &prototypeObject, &interfaceObject)) { | 66 &V8Document::wrapperTypeInfo, &prototypeObject, &interfaceObject)) { |
80 V8Document::installRootScroller(isolate, world, v8::Local<v8::Object>(), | 67 V8Document::installRootScroller(isolate, world, v8::Local<v8::Object>(), |
81 prototypeObject, interfaceObject); | 68 prototypeObject, interfaceObject); |
82 } | 69 } |
83 return; | 70 return; |
84 } | 71 } |
85 } | 72 } |
86 | 73 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 FeaturePolicy* featurePolicy = frame->securityContext()->getFeaturePolicy(); | 140 FeaturePolicy* featurePolicy = frame->securityContext()->getFeaturePolicy(); |
154 // The policy should always be initialized before checking it to ensure we | 141 // The policy should always be initialized before checking it to ensure we |
155 // properly inherit the parent policy. | 142 // properly inherit the parent policy. |
156 DCHECK(featurePolicy); | 143 DCHECK(featurePolicy); |
157 | 144 |
158 // Otherwise, check policy. | 145 // Otherwise, check policy. |
159 return featurePolicy->isFeatureEnabled(feature); | 146 return featurePolicy->isFeatureEnabled(feature); |
160 } | 147 } |
161 | 148 |
162 } // namespace blink | 149 } // namespace blink |
OLD | NEW |