Chromium Code Reviews| 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 |