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

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

Issue 2260113002: Lazily install origin trial features on V8 objects (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase after parent CL landed Created 4 years, 3 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
new file mode 100644
index 0000000000000000000000000000000000000000..3d25eade120a136b2567be9918186753e85a8a43
--- /dev/null
+++ b/third_party/WebKit/Source/bindings/core/v8/ConditionalFeatures.cpp
@@ -0,0 +1,50 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "bindings/core/v8/ConditionalFeatures.h"
+
+#include "bindings/core/v8/ScriptState.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/origin_trials/OriginTrialContext.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 attibutes and interfaces in IDL
+ // files. (crbug.com/615060)
+ ExecutionContext* executionContext = scriptState->getExecutionContext();
+ if (!executionContext)
+ return;
+ OriginTrialContext* originTrialContext = OriginTrialContext::from(executionContext, OriginTrialContext::DontCreateIfNotExists);
+ if (wrapperTypeInfo == &V8HTMLLinkElement::wrapperTypeInfo) {
+ if (RuntimeEnabledFeatures::linkServiceWorkerEnabled() || (originTrialContext && originTrialContext->isFeatureEnabled("ForeignFetch"))) {
+ V8HTMLLinkElement::installLinkServiceWorker(scriptState->isolate(), scriptState->world(), v8::Local<v8::Object>(), prototypeObject, interfaceObject);
+ }
+ }
+}
+
+namespace {
+
+InstallConditionalFeaturesFunction s_installConditionalFeaturesFunction = &installConditionalFeaturesCore;
+
+}
+
+InstallConditionalFeaturesFunction setInstallConditionalFeaturesFunction(InstallConditionalFeaturesFunction newInstallConditionalFeaturesFunction)
+{
+ InstallConditionalFeaturesFunction originalFunction = s_installConditionalFeaturesFunction;
+ s_installConditionalFeaturesFunction = newInstallConditionalFeaturesFunction;
+ return originalFunction;
+}
+
+void installConditionalFeatures(const WrapperTypeInfo* type, const ScriptState* scriptState, v8::Local<v8::Object> prototypeObject, v8::Local<v8::Function> interfaceObject)
+{
+ (*s_installConditionalFeaturesFunction)(type, scriptState, prototypeObject, interfaceObject);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698