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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/ConditionalFeatures.cpp

Issue 2691343010: Split ConditionalFeatures (Closed)
Patch Set: Rebase, code review changes Created 3 years, 10 months 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/core/v8/ConditionalFeatures.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/ConditionalFeatures.cpp b/third_party/WebKit/Source/bindings/core/v8/ConditionalFeatures.cpp
index 2c2762a973f596f93d1302ac527f1701319bed3e..9c56b844d06a4dc83fbac9a52a96745ebb875a99 100644
--- a/third_party/WebKit/Source/bindings/core/v8/ConditionalFeatures.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/ConditionalFeatures.cpp
@@ -4,82 +4,28 @@
#include "bindings/core/v8/ConditionalFeatures.h"
+#include "bindings/core/v8/DOMWrapperWorld.h"
#include "bindings/core/v8/ScriptState.h"
-#include "bindings/core/v8/V8Document.h"
-#include "bindings/core/v8/V8HTMLLinkElement.h"
-#include "bindings/core/v8/V8Navigator.h"
-#include "bindings/core/v8/V8Window.h"
-#include "core/dom/ExecutionContext.h"
-#include "core/frame/LocalFrame.h"
-#include "core/origin_trials/OriginTrials.h"
namespace blink {
-void installConditionalFeaturesCore(const WrapperTypeInfo* wrapperTypeInfo,
- const ScriptState* scriptState,
- v8::Local<v8::Object> prototypeObject,
- v8::Local<v8::Function> interfaceObject) {
- // TODO(iclelland): Generate all of this logic at compile-time, based on the
- // configuration of origin trial enabled attributes and interfaces in IDL
- // files. (crbug.com/615060)
- ExecutionContext* executionContext = scriptState->getExecutionContext();
- if (!executionContext)
- return;
- v8::Isolate* isolate = scriptState->isolate();
- const DOMWrapperWorld& world = scriptState->world();
- if (wrapperTypeInfo == &V8HTMLLinkElement::wrapperTypeInfo) {
- if (OriginTrials::linkServiceWorkerEnabled(executionContext)) {
- V8HTMLLinkElement::installLinkServiceWorker(
- isolate, world, v8::Local<v8::Object>(), prototypeObject,
- interfaceObject);
- }
- } else if (wrapperTypeInfo == &V8Document::wrapperTypeInfo) {
- if (OriginTrials::setRootScrollerEnabled(executionContext)) {
- V8Document::installRootScroller(isolate, world, v8::Local<v8::Object>(),
- prototypeObject, interfaceObject);
- }
- }
-}
+void installConditionalFeaturesDefault(
+ const WrapperTypeInfo* wrapperTypeInfo,
+ const ScriptState* scriptState,
+ v8::Local<v8::Object> prototypeObject,
+ v8::Local<v8::Function> interfaceObject) {}
-void installPendingConditionalFeatureCore(const String& feature,
- const ScriptState* scriptState) {
- // TODO(iclelland): Generate all of this logic at compile-time, based on the
- // configuration of origin trial enabled attributes and interfaces in IDL
- // files. (crbug.com/615060)
- v8::Local<v8::Object> prototypeObject;
- v8::Local<v8::Function> interfaceObject;
- v8::Isolate* isolate = scriptState->isolate();
- const DOMWrapperWorld& world = scriptState->world();
- V8PerContextData* contextData = scriptState->perContextData();
- if (feature == "ForeignFetch") {
- if (contextData->getExistingConstructorAndPrototypeForType(
- &V8HTMLLinkElement::wrapperTypeInfo, &prototypeObject,
- &interfaceObject)) {
- V8HTMLLinkElement::installLinkServiceWorker(
- isolate, world, v8::Local<v8::Object>(), prototypeObject,
- interfaceObject);
- }
- return;
- }
- if (feature == "RootScroller") {
- if (contextData->getExistingConstructorAndPrototypeForType(
- &V8Document::wrapperTypeInfo, &prototypeObject, &interfaceObject)) {
- V8Document::installRootScroller(isolate, world, v8::Local<v8::Object>(),
- prototypeObject, interfaceObject);
- }
- return;
- }
-}
+void installPendingConditionalFeatureDefault(const String& feature,
+ const ScriptState* scriptState) {}
namespace {
-
InstallConditionalFeaturesFunction s_installConditionalFeaturesFunction =
- &installConditionalFeaturesCore;
+ &installConditionalFeaturesDefault;
InstallPendingConditionalFeatureFunction
s_installPendingConditionalFeatureFunction =
- &installPendingConditionalFeatureCore;
-}
+ &installPendingConditionalFeatureDefault;
+} // namespace
InstallConditionalFeaturesFunction setInstallConditionalFeaturesFunction(
InstallConditionalFeaturesFunction newInstallConditionalFeaturesFunction) {
@@ -108,16 +54,6 @@ void installConditionalFeatures(const WrapperTypeInfo* type,
interfaceObject);
}
-void installConditionalFeaturesOnWindow(const ScriptState* scriptState) {
- DCHECK(scriptState);
- DCHECK(scriptState->context() == scriptState->isolate()->GetCurrentContext());
- DCHECK(scriptState->perContextData());
- DCHECK(scriptState->world().isMainWorld());
- (*s_installConditionalFeaturesFunction)(&V8Window::wrapperTypeInfo,
- scriptState, v8::Local<v8::Object>(),
- v8::Local<v8::Function>());
-}
-
void installPendingConditionalFeature(const String& feature,
const ScriptState* scriptState) {
DCHECK(scriptState);
@@ -128,22 +64,4 @@ void installPendingConditionalFeature(const String& feature,
(*s_installPendingConditionalFeatureFunction)(feature, scriptState);
}
-bool isFeatureEnabledInFrame(const FeaturePolicy::Feature& feature,
- const LocalFrame* frame) {
- // If there is no frame, or if feature policy is disabled, use defaults.
- bool enabledByDefault =
- (feature.defaultPolicy == FeaturePolicy::FeatureDefault::EnableForAll ||
- (feature.defaultPolicy == FeaturePolicy::FeatureDefault::EnableForSelf &&
- !frame->isCrossOriginSubframe()));
- if (!RuntimeEnabledFeatures::featurePolicyEnabled() || !frame)
- return enabledByDefault;
- FeaturePolicy* featurePolicy = frame->securityContext()->getFeaturePolicy();
- // The policy should always be initialized before checking it to ensure we
- // properly inherit the parent policy.
- DCHECK(featurePolicy);
-
- // Otherwise, check policy.
- return featurePolicy->isFeatureEnabled(feature);
-}
-
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698