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

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

Issue 2640823004: Allow origin trials to be enabled by script (Closed)
Patch Set: Add tracking of installed features Created 3 years, 11 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/modules/v8/ConditionalFeaturesForModules.cpp
diff --git a/third_party/WebKit/Source/bindings/modules/v8/ConditionalFeaturesForModules.cpp b/third_party/WebKit/Source/bindings/modules/v8/ConditionalFeaturesForModules.cpp
index 05b68ce4422fe2f66c5c1a236da3e879aa34f7ce..7454945574931e3017fc978d8a1e6a0b13585bbc 100644
--- a/third_party/WebKit/Source/bindings/modules/v8/ConditionalFeaturesForModules.cpp
+++ b/third_party/WebKit/Source/bindings/modules/v8/ConditionalFeaturesForModules.cpp
@@ -29,6 +29,10 @@ namespace blink {
namespace {
InstallConditionalFeaturesFunction
s_originalInstallConditionalFeaturesFunction = nullptr;
+InstallConditionalFeaturesIfNeededFunction
+ s_originalInstallConditionalFeaturesIfNeededFunction = nullptr;
+GetAffectedTypesForConditionalFeatureFunction
+ s_originalGetAffectedTypesForConditionalFeatureFunction = nullptr;
}
void installConditionalFeaturesForModules(
@@ -140,10 +144,61 @@ void installConditionalFeaturesForModules(
}
}
+bool installConditionalFeaturesIfNeededForModules(
+ const WrapperTypeInfo* wrapperTypeInfo,
+ const ScriptState* scriptState) {
+ (*s_originalInstallConditionalFeaturesIfNeededFunction)(wrapperTypeInfo,
+ scriptState);
+
+ // Only install features here, if the target type has an existing instance
iclelland 2017/01/20 14:31:19 I think rather than instance, you mean prototype/c
chasej 2017/01/25 19:58:20 This method is gone in the new, simplified approac
+ V8PerContextData* contextData = scriptState->perContextData();
+ if (wrapperTypeInfo == &V8Navigator::wrapperTypeInfo) {
+ v8::Local<v8::Function> interfaceObject =
+ contextData->constructorForTypeFromCache(wrapperTypeInfo);
+ if (interfaceObject.IsEmpty()) {
+ LOG(INFO) << "No existing instance for type: "
+ << wrapperTypeInfo->interfaceName;
+ return true;
+ }
+ LOG(INFO) << "Found existing instance for type: "
+ << wrapperTypeInfo->interfaceName;
+ v8::Local<v8::Object> prototypeObject =
+ contextData->prototypeForType(wrapperTypeInfo);
+
+ installConditionalFeaturesForModules(wrapperTypeInfo, scriptState,
+ prototypeObject, interfaceObject);
+ return true;
+ }
+ return false;
+}
+
+void getAffectedTypesForConditionalFeatureFunctionForModules(
+ const String& feature,
+ HashSet<const WrapperTypeInfo*>* affectedTypes) {
+ (*s_originalGetAffectedTypesForConditionalFeatureFunction)(feature,
+ affectedTypes);
+ if (feature == "ServiceWorkerNavigationPreload") {
iclelland 2017/01/20 14:31:19 Is this method eventually intended to cover all of
chasej 2017/01/25 19:58:20 This method is gone in the new, simplified approac
+ // affectedTypes->add(&V8Navigator::wrapperTypeInfo);
+ affectedTypes->add(&V8Window::wrapperTypeInfo);
+ return;
+ }
+ if (feature == "WebUSB") {
+ affectedTypes->add(&V8Navigator::wrapperTypeInfo);
+ affectedTypes->add(&V8Window::wrapperTypeInfo);
+ return;
+ }
+}
+
void registerInstallConditionalFeaturesForModules() {
s_originalInstallConditionalFeaturesFunction =
setInstallConditionalFeaturesFunction(
&installConditionalFeaturesForModules);
+ s_originalInstallConditionalFeaturesIfNeededFunction =
+ setInstallConditionalFeaturesIfNeededFunction(
+ &installConditionalFeaturesIfNeededForModules);
+ s_originalGetAffectedTypesForConditionalFeatureFunction =
+ setGetAffectedTypesForConditionalFeatureFunction(
+ &getAffectedTypesForConditionalFeatureFunctionForModules);
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698