Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "bindings/core/v8/V8Binding.h" | 31 #include "bindings/core/v8/V8Binding.h" |
| 32 | 32 |
| 33 #include "bindings/core/v8/ScriptController.h" | 33 #include "bindings/core/v8/ScriptController.h" |
| 34 #include "bindings/core/v8/V8AbstractEventListener.h" | 34 #include "bindings/core/v8/V8AbstractEventListener.h" |
| 35 #include "bindings/core/v8/V8ArrayBufferView.h" | 35 #include "bindings/core/v8/V8ArrayBufferView.h" |
| 36 #include "bindings/core/v8/V8BindingMacros.h" | 36 #include "bindings/core/v8/V8BindingMacros.h" |
| 37 #include "bindings/core/v8/V8Element.h" | 37 #include "bindings/core/v8/V8Element.h" |
| 38 #include "bindings/core/v8/V8EventTarget.h" | 38 #include "bindings/core/v8/V8EventTarget.h" |
| 39 #include "bindings/core/v8/V8HTMLLinkElement.h" | |
| 39 #include "bindings/core/v8/V8NodeFilter.h" | 40 #include "bindings/core/v8/V8NodeFilter.h" |
| 40 #include "bindings/core/v8/V8NodeFilterCondition.h" | 41 #include "bindings/core/v8/V8NodeFilterCondition.h" |
| 41 #include "bindings/core/v8/V8ObjectConstructor.h" | 42 #include "bindings/core/v8/V8ObjectConstructor.h" |
| 42 #include "bindings/core/v8/V8Window.h" | 43 #include "bindings/core/v8/V8Window.h" |
| 43 #include "bindings/core/v8/V8WorkerGlobalScope.h" | 44 #include "bindings/core/v8/V8WorkerGlobalScope.h" |
| 44 #include "bindings/core/v8/V8WorkletGlobalScope.h" | 45 #include "bindings/core/v8/V8WorkletGlobalScope.h" |
| 45 #include "bindings/core/v8/V8XPathNSResolver.h" | 46 #include "bindings/core/v8/V8XPathNSResolver.h" |
| 46 #include "bindings/core/v8/WindowProxy.h" | 47 #include "bindings/core/v8/WindowProxy.h" |
| 47 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" | 48 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" |
| 48 #include "bindings/core/v8/custom/V8CustomXPathNSResolver.h" | 49 #include "bindings/core/v8/custom/V8CustomXPathNSResolver.h" |
| (...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 802 ASSERT(frame); | 803 ASSERT(frame); |
| 803 return frame->windowProxy(world)->contextIfInitialized(); | 804 return frame->windowProxy(world)->contextIfInitialized(); |
| 804 } | 805 } |
| 805 | 806 |
| 806 void installOriginTrialsCore(ScriptState* scriptState) | 807 void installOriginTrialsCore(ScriptState* scriptState) |
| 807 { | 808 { |
| 808 // TODO(iclelland): Generate all of this logic at compile-time, based on the | 809 // TODO(iclelland): Generate all of this logic at compile-time, based on the |
| 809 // configuration of origin trial enabled attibutes and interfaces in IDL | 810 // configuration of origin trial enabled attibutes and interfaces in IDL |
| 810 // files. (crbug.com/615060) | 811 // files. (crbug.com/615060) |
| 811 | 812 |
| 812 // Initialization code for origin trials for core bindings, if necessary, | 813 v8::Local<v8::Context> context = scriptState->context(); |
| 813 // should go here. | 814 ExecutionContext* executionContext = toExecutionContext(context); |
| 815 OriginTrialContext* originTrialContext = OriginTrialContext::from(executionC ontext, OriginTrialContext::DontCreateIfNotExists); | |
| 816 if (!originTrialContext) | |
| 817 return; | |
| 818 | |
| 819 if (!originTrialContext->featureBindingsInstalled("LinkServiceWorker") && (R untimeEnabledFeatures::linkServiceWorkerEnabled() || originTrialContext->isFeatu reEnabled("ForeignFetch"))) { | |
|
iclelland
2016/07/26 20:32:06
I thing you could replace this with
if (!orig
| |
| 820 if (executionContext->isDocument()) { | |
| 821 V8HTMLLinkElement::installLinkServiceWorker(scriptState); | |
| 822 } | |
| 823 } | |
| 814 } | 824 } |
| 815 | 825 |
| 816 namespace { | 826 namespace { |
| 817 InstallOriginTrialsFunction s_installOriginTrialsFunction = &installOriginTrials Core; | 827 InstallOriginTrialsFunction s_installOriginTrialsFunction = &installOriginTrials Core; |
| 818 } | 828 } |
| 819 | 829 |
| 820 void installOriginTrials(ScriptState* scriptState) | 830 void installOriginTrials(ScriptState* scriptState) |
| 821 { | 831 { |
| 822 v8::Local<v8::Context> context = scriptState->context(); | 832 v8::Local<v8::Context> context = scriptState->context(); |
| 823 ExecutionContext* executionContext = toExecutionContext(context); | 833 ExecutionContext* executionContext = toExecutionContext(context); |
| 824 OriginTrialContext* originTrialContext = OriginTrialContext::from(executionC ontext, OriginTrialContext::DontCreateIfNotExists); | 834 OriginTrialContext* originTrialContext = OriginTrialContext::from(executionC ontext, OriginTrialContext::DontCreateIfNotExists); |
| 825 if (!originTrialContext) | 835 if (!originTrialContext) |
| 826 return; | 836 return; |
| 827 | 837 |
| 828 ScriptState::Scope scope(scriptState); | 838 ScriptState::Scope scope(scriptState); |
| 829 | 839 |
| 830 (*s_installOriginTrialsFunction)(scriptState); | 840 (*s_installOriginTrialsFunction)(scriptState); |
| 831 | 841 |
| 832 // Mark each enabled feature as having been installed. | 842 // Mark each enabled feature as having been installed. |
| 833 if (!originTrialContext->featureBindingsInstalled("DurableStorage") && (Runt imeEnabledFeatures::durableStorageEnabled() || originTrialContext->isFeatureEnab led("DurableStorage"))) { | 843 if (!originTrialContext->featureBindingsInstalled("DurableStorage") && (Runt imeEnabledFeatures::durableStorageEnabled() || originTrialContext->isFeatureEnab led("DurableStorage"))) { |
| 834 originTrialContext->setFeatureBindingsInstalled("DurableStorage"); | 844 originTrialContext->setFeatureBindingsInstalled("DurableStorage"); |
| 835 } | 845 } |
| 836 | 846 |
| 837 if (!originTrialContext->featureBindingsInstalled("WebBluetooth") && (Runtim eEnabledFeatures::webBluetoothEnabled() || originTrialContext->isFeatureEnabled( "WebBluetooth"))) { | 847 if (!originTrialContext->featureBindingsInstalled("WebBluetooth") && (Runtim eEnabledFeatures::webBluetoothEnabled() || originTrialContext->isFeatureEnabled( "WebBluetooth"))) { |
| 838 originTrialContext->setFeatureBindingsInstalled("WebBluetooth"); | 848 originTrialContext->setFeatureBindingsInstalled("WebBluetooth"); |
| 839 } | 849 } |
| 850 | |
| 851 if (!originTrialContext->featureBindingsInstalled("LinkServiceWorker") && (R untimeEnabledFeatures::webBluetoothEnabled() || originTrialContext->isFeatureEna bled("ForeignFetch"))) { | |
| 852 originTrialContext->setFeatureBindingsInstalled("LinkServiceWorker"); | |
| 853 } | |
| 854 | |
| 855 if (!originTrialContext->featureBindingsInstalled("ForeignFetch") && (Runtim eEnabledFeatures::webBluetoothEnabled() || originTrialContext->isFeatureEnabled( "ForeignFetch"))) { | |
| 856 originTrialContext->setFeatureBindingsInstalled("ForeignFetch"); | |
| 857 } | |
| 840 } | 858 } |
| 841 | 859 |
| 842 InstallOriginTrialsFunction setInstallOriginTrialsFunction(InstallOriginTrialsFu nction newInstallOriginTrialsFunction) | 860 InstallOriginTrialsFunction setInstallOriginTrialsFunction(InstallOriginTrialsFu nction newInstallOriginTrialsFunction) |
| 843 { | 861 { |
| 844 InstallOriginTrialsFunction originalFunction = s_installOriginTrialsFunction ; | 862 InstallOriginTrialsFunction originalFunction = s_installOriginTrialsFunction ; |
| 845 s_installOriginTrialsFunction = newInstallOriginTrialsFunction; | 863 s_installOriginTrialsFunction = newInstallOriginTrialsFunction; |
| 846 return originalFunction; | 864 return originalFunction; |
| 847 } | 865 } |
| 848 | 866 |
| 849 void crashIfIsolateIsDead(v8::Isolate* isolate) | 867 void crashIfIsolateIsDead(v8::Isolate* isolate) |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 948 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u nwrap(data))); | 966 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u nwrap(data))); |
| 949 } | 967 } |
| 950 | 968 |
| 951 v8::Local<v8::Value> freezeV8Object(v8::Local<v8::Value> value, v8::Isolate* iso late) | 969 v8::Local<v8::Value> freezeV8Object(v8::Local<v8::Value> value, v8::Isolate* iso late) |
| 952 { | 970 { |
| 953 v8CallOrCrash(value.As<v8::Object>()->SetIntegrityLevel(isolate->GetCurrentC ontext(), v8::IntegrityLevel::kFrozen)); | 971 v8CallOrCrash(value.As<v8::Object>()->SetIntegrityLevel(isolate->GetCurrentC ontext(), v8::IntegrityLevel::kFrozen)); |
| 954 return value; | 972 return value; |
| 955 } | 973 } |
| 956 | 974 |
| 957 } // namespace blink | 975 } // namespace blink |
| OLD | NEW |