diff options
Diffstat (limited to 'Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp')
-rw-r--r-- | Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp | 394 |
1 files changed, 167 insertions, 227 deletions
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp index c23ce4bc7..863834c27 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010, 2013 Apple Inc. All rights reserved. + * Copyright (C) 2010-2016 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,35 +27,41 @@ #include "InjectedBundle.h" #include "APIArray.h" -#include "Arguments.h" +#include "APIData.h" #include "InjectedBundleScriptWorld.h" -#include "InjectedBundleUserMessageCoders.h" -#include "LayerTreeHost.h" #include "NotificationPermissionRequestManager.h" #include "SessionTracker.h" +#include "UserData.h" #include "WKAPICast.h" #include "WKBundleAPICast.h" -#include "WebApplicationCacheManager.h" #include "WebConnectionToUIProcess.h" -#include "WebContextMessageKinds.h" #include "WebCookieManager.h" #include "WebCoreArgumentCoders.h" -#include "WebDatabaseManager.h" #include "WebFrame.h" #include "WebFrameNetworkingContext.h" #include "WebPage.h" +#include "WebPageGroupProxy.h" +#include "WebPreferencesKeys.h" #include "WebPreferencesStore.h" #include "WebProcess.h" +#include "WebProcessCreationParameters.h" +#include "WebProcessMessages.h" +#include "WebProcessPoolMessages.h" +#include "WebUserContentController.h" #include <JavaScriptCore/APICast.h> +#include <JavaScriptCore/Exception.h> #include <JavaScriptCore/JSLock.h> #include <WebCore/ApplicationCache.h> #include <WebCore/ApplicationCacheStorage.h> +#include <WebCore/CommonVM.h> #include <WebCore/FrameLoader.h> #include <WebCore/FrameView.h> #include <WebCore/GCController.h> #include <WebCore/GeolocationClient.h> #include <WebCore/GeolocationController.h> #include <WebCore/GeolocationPosition.h> +#include <WebCore/JSDOMConvertBufferSource.h> +#include <WebCore/JSDOMExceptionHandling.h> #include <WebCore/JSDOMWindow.h> #include <WebCore/JSNotification.h> #include <WebCore/MainFrame.h> @@ -63,16 +69,16 @@ #include <WebCore/PageGroup.h> #include <WebCore/PrintContext.h> #include <WebCore/ResourceHandle.h> -#include <WebCore/ResourceLoadScheduler.h> +#include <WebCore/RuntimeEnabledFeatures.h> #include <WebCore/ScriptController.h> #include <WebCore/SecurityOrigin.h> #include <WebCore/SecurityPolicy.h> +#include <WebCore/SessionID.h> #include <WebCore/Settings.h> #include <WebCore/UserGestureIndicator.h> +#include <WebCore/UserScript.h> +#include <WebCore/UserStyleSheet.h> -#if ENABLE(SHADOW_DOM) || ENABLE(CSS_REGIONS) || ENABLE(IFRAME_SEAMLESS) || ENABLE(CSS_COMPOSITING) -#include <WebCore/RuntimeEnabledFeatures.h> -#endif #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) #include "WebNotificationManager.h" @@ -83,11 +89,21 @@ using namespace JSC; namespace WebKit { -InjectedBundle::InjectedBundle(const String& path) - : m_path(path) +PassRefPtr<InjectedBundle> InjectedBundle::create(const WebProcessCreationParameters& parameters, API::Object* initializationUserData) +{ + auto bundle = adoptRef(*new InjectedBundle(parameters)); + + bundle->m_sandboxExtension = SandboxExtension::create(parameters.injectedBundlePathExtensionHandle); + if (!bundle->initialize(parameters, initializationUserData)) + return nullptr; + + return WTFMove(bundle); +} + +InjectedBundle::InjectedBundle(const WebProcessCreationParameters& parameters) + : m_path(parameters.injectedBundlePath) , m_platformBundle(0) { - initializeClient(0); } InjectedBundle::~InjectedBundle() @@ -101,52 +117,24 @@ void InjectedBundle::initializeClient(const WKBundleClientBase* client) void InjectedBundle::postMessage(const String& messageName, API::Object* messageBody) { - auto encoder = std::make_unique<IPC::MessageEncoder>(WebContextLegacyMessages::messageReceiverName(), WebContextLegacyMessages::postMessageMessageName(), 0); - encoder->encode(messageName); - encoder->encode(InjectedBundleUserMessageEncoder(messageBody)); - - WebProcess::shared().parentProcessConnection()->sendMessage(std::move(encoder)); + auto& webProcess = WebProcess::singleton(); + webProcess.parentProcessConnection()->send(Messages::WebProcessPool::HandleMessage(messageName, UserData(webProcess.transformObjectsToHandles(messageBody))), 0); } void InjectedBundle::postSynchronousMessage(const String& messageName, API::Object* messageBody, RefPtr<API::Object>& returnData) { - InjectedBundleUserMessageDecoder messageDecoder(returnData); - - uint64_t syncRequestID; - std::unique_ptr<IPC::MessageEncoder> encoder = WebProcess::shared().parentProcessConnection()->createSyncMessageEncoder(WebContextLegacyMessages::messageReceiverName(), WebContextLegacyMessages::postSynchronousMessageMessageName(), 0, syncRequestID); - encoder->encode(messageName); - encoder->encode(InjectedBundleUserMessageEncoder(messageBody)); + UserData returnUserData; - std::unique_ptr<IPC::MessageDecoder> replyDecoder = WebProcess::shared().parentProcessConnection()->sendSyncMessage(syncRequestID, std::move(encoder), std::chrono::milliseconds::max()); - if (!replyDecoder || !replyDecoder->decode(messageDecoder)) { + auto& webProcess = WebProcess::singleton(); + if (!webProcess.parentProcessConnection()->sendSync(Messages::WebProcessPool::HandleSynchronousMessage(messageName, UserData(webProcess.transformObjectsToHandles(messageBody))), Messages::WebProcessPool::HandleSynchronousMessage::Reply(returnUserData), 0)) returnData = nullptr; - return; - } + else + returnData = webProcess.transformHandlesToObjects(returnUserData.object()); } WebConnection* InjectedBundle::webConnectionToUIProcess() const { - return WebProcess::shared().webConnectionToUIProcess(); -} - -void InjectedBundle::setShouldTrackVisitedLinks(bool shouldTrackVisitedLinks) -{ - WebProcess::shared().setShouldTrackVisitedLinks(shouldTrackVisitedLinks); -} - -void InjectedBundle::setAlwaysAcceptCookies(bool accept) -{ - WebProcess::shared().supplement<WebCookieManager>()->setHTTPCookieAcceptPolicy(accept ? HTTPCookieAcceptPolicyAlways : HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain); -} - -void InjectedBundle::removeAllVisitedLinks() -{ - PageGroup::removeAllVisitedLinks(); -} - -void InjectedBundle::setCacheModel(uint32_t cacheModel) -{ - WebProcess::shared().setCacheModel(cacheModel); + return WebProcess::singleton().webConnectionToUIProcess(); } void InjectedBundle::overrideBoolPreferenceForTestRunner(WebPageGroupProxy* pageGroup, const String& preference, bool enabled) @@ -155,55 +143,101 @@ void InjectedBundle::overrideBoolPreferenceForTestRunner(WebPageGroupProxy* page if (preference == "WebKitTabToLinksPreferenceKey") { WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::tabsToLinksKey(), enabled); - for (HashSet<Page*>::iterator i = pages.begin(); i != pages.end(); ++i) { - WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient((*i)->mainFrame().loader().client()); - ASSERT(webFrameLoaderClient); - webFrameLoaderClient->webFrame()->page()->setTabToLinksEnabled(enabled); - } + for (auto* page : pages) + WebPage::fromCorePage(page)->setTabToLinksEnabled(enabled); } if (preference == "WebKit2AsynchronousPluginInitializationEnabled") { WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::asynchronousPluginInitializationEnabledKey(), enabled); - for (HashSet<Page*>::iterator i = pages.begin(); i != pages.end(); ++i) { - WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient((*i)->mainFrame().loader().client()); - ASSERT(webFrameLoaderClient); - webFrameLoaderClient->webFrame()->page()->setAsynchronousPluginInitializationEnabled(enabled); - } + for (auto* page : pages) + WebPage::fromCorePage(page)->setAsynchronousPluginInitializationEnabled(enabled); } if (preference == "WebKit2AsynchronousPluginInitializationEnabledForAllPlugins") { WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::asynchronousPluginInitializationEnabledForAllPluginsKey(), enabled); - for (HashSet<Page*>::iterator i = pages.begin(); i != pages.end(); ++i) { - WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient((*i)->mainFrame().loader().client()); - ASSERT(webFrameLoaderClient); - webFrameLoaderClient->webFrame()->page()->setAsynchronousPluginInitializationEnabledForAllPlugins(enabled); - } + for (auto* page : pages) + WebPage::fromCorePage(page)->setAsynchronousPluginInitializationEnabledForAllPlugins(enabled); } if (preference == "WebKit2ArtificialPluginInitializationDelayEnabled") { WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::artificialPluginInitializationDelayEnabledKey(), enabled); - for (HashSet<Page*>::iterator i = pages.begin(); i != pages.end(); ++i) { - WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient((*i)->mainFrame().loader().client()); - ASSERT(webFrameLoaderClient); - webFrameLoaderClient->webFrame()->page()->setArtificialPluginInitializationDelayEnabled(enabled); - } + for (auto* page : pages) + WebPage::fromCorePage(page)->setArtificialPluginInitializationDelayEnabled(enabled); + } + +#if ENABLE(SERVICE_CONTROLS) + if (preference == "WebKitImageControlsEnabled") { + WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::imageControlsEnabledKey(), enabled); + for (auto* page : pages) + page->settings().setImageControlsEnabled(enabled); + return; } +#endif + +#if ENABLE(CSS_ANIMATIONS_LEVEL_2) + if (preference == "WebKitCSSAnimationTriggersEnabled") + RuntimeEnabledFeatures::sharedFeatures().setAnimationTriggersEnabled(enabled); +#endif -#if ENABLE(CSS_REGIONS) - if (preference == "WebKitCSSRegionsEnabled") - RuntimeEnabledFeatures::sharedFeatures().setCSSRegionsEnabled(enabled); +#if ENABLE(WEB_ANIMATIONS) + if (preference == "WebKitWebAnimationsEnabled") + RuntimeEnabledFeatures::sharedFeatures().setWebAnimationsEnabled(enabled); #endif -#if ENABLE(CSS_COMPOSITING) - if (preference == "WebKitCSSCompositingEnabled") - RuntimeEnabledFeatures::sharedFeatures().setCSSCompositingEnabled(enabled); +#if ENABLE(FETCH_API) + if (preference == "WebKitFetchAPIEnabled") + RuntimeEnabledFeatures::sharedFeatures().setFetchAPIEnabled(enabled); +#endif + +#if ENABLE(DOWNLOAD_ATTRIBUTE) + if (preference == "WebKitDownloadAttributeEnabled") + RuntimeEnabledFeatures::sharedFeatures().setDownloadAttributeEnabled(enabled); +#endif + + if (preference == "WebKitShadowDOMEnabled") + RuntimeEnabledFeatures::sharedFeatures().setShadowDOMEnabled(enabled); + + if (preference == "WebKitCSSGridLayoutEnabled") + RuntimeEnabledFeatures::sharedFeatures().setCSSGridLayoutEnabled(enabled); + + if (preference == "WebKitCustomElementsEnabled") + RuntimeEnabledFeatures::sharedFeatures().setCustomElementsEnabled(enabled); + + if (preference == "WebKitInteractiveFormValidationEnabled") + RuntimeEnabledFeatures::sharedFeatures().setInteractiveFormValidationEnabled(enabled); + +#if ENABLE(WEBGL2) + if (preference == "WebKitWebGL2Enabled") + RuntimeEnabledFeatures::sharedFeatures().setWebGL2Enabled(enabled); +#endif + + if (preference == "WebKitModernMediaControlsEnabled") + RuntimeEnabledFeatures::sharedFeatures().setModernMediaControlsEnabled(enabled); + +#if ENABLE(ENCRYPTED_MEDIA) + if (preference == "WebKitEncryptedMediaAPIEnabled") + RuntimeEnabledFeatures::sharedFeatures().setEncryptedMediaAPIEnabled(enabled); +#endif + +#if ENABLE(SUBTLE_CRYPTO) + if (preference == "WebKitSubtleCryptoEnabled") + RuntimeEnabledFeatures::sharedFeatures().setSubtleCryptoEnabled(enabled); +#endif + +#if ENABLE(MEDIA_STREAM) + if (preference == "WebKitMediaStreamEnabled") + RuntimeEnabledFeatures::sharedFeatures().setMediaStreamEnabled(enabled); +#endif + +#if ENABLE(WEB_RTC) + if (preference == "WebKitPeerConnectionEnabled") + RuntimeEnabledFeatures::sharedFeatures().setPeerConnectionEnabled(enabled); #endif // Map the names used in LayoutTests with the names used in WebCore::Settings and WebPreferencesStore. #define FOR_EACH_OVERRIDE_BOOL_PREFERENCE(macro) \ macro(WebKitAcceleratedCompositingEnabled, AcceleratedCompositingEnabled, acceleratedCompositingEnabled) \ macro(WebKitCanvasUsesAcceleratedDrawing, CanvasUsesAcceleratedDrawing, canvasUsesAcceleratedDrawing) \ - macro(WebKitCSSGridLayoutEnabled, CSSGridLayoutEnabled, cssGridLayoutEnabled) \ macro(WebKitFrameFlatteningEnabled, FrameFlatteningEnabled, frameFlatteningEnabled) \ macro(WebKitJavaEnabled, JavaEnabled, javaEnabled) \ macro(WebKitJavaScriptEnabled, ScriptEnabled, javaScriptEnabled) \ @@ -218,10 +252,11 @@ void InjectedBundle::overrideBoolPreferenceForTestRunner(WebPageGroupProxy* page macro(WebKitShouldRespectImageOrientation, ShouldRespectImageOrientation, shouldRespectImageOrientation) \ macro(WebKitEnableCaretBrowsing, CaretBrowsingEnabled, caretBrowsingEnabled) \ macro(WebKitDisplayImagesKey, LoadsImagesAutomatically, loadsImagesAutomatically) \ - macro(WebKitMediaStreamEnabled, MediaStreamEnabled, mediaStreamEnabled) - - if (preference == "WebKitAcceleratedCompositingEnabled") - enabled = enabled && LayerTreeHost::supportsAcceleratedCompositing(); + macro(WebKitHTTPEquivEnabled, HttpEquivEnabled, httpEquivEnabled) \ + macro(WebKitVisualViewportEnabled, VisualViewportEnabled, visualViewportEnabled) \ + macro(WebKitLargeImageAsyncDecodingEnabled, LargeImageAsyncDecodingEnabled, largeImageAsyncDecodingEnabled) \ + macro(WebKitAnimatedImageAsyncDecodingEnabled, AnimatedImageAsyncDecodingEnabled, animatedImageAsyncDecodingEnabled) \ + \ #define OVERRIDE_PREFERENCE_AND_SET_IN_EXISTING_PAGES(TestRunnerName, SettingsName, WebPreferencesName) \ if (preference == #TestRunnerName) { \ @@ -233,25 +268,12 @@ void InjectedBundle::overrideBoolPreferenceForTestRunner(WebPageGroupProxy* page FOR_EACH_OVERRIDE_BOOL_PREFERENCE(OVERRIDE_PREFERENCE_AND_SET_IN_EXISTING_PAGES) -#if ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING) OVERRIDE_PREFERENCE_AND_SET_IN_EXISTING_PAGES(WebKitHiddenPageDOMTimerThrottlingEnabled, HiddenPageDOMTimerThrottlingEnabled, hiddenPageDOMTimerThrottlingEnabled) -#endif #undef OVERRIDE_PREFERENCE_AND_SET_IN_EXISTING_PAGES #undef FOR_EACH_OVERRIDE_BOOL_PREFERENCE } -void InjectedBundle::overrideXSSAuditorEnabledForTestRunner(WebPageGroupProxy* pageGroup, bool enabled) -{ - // Override the preference for all future pages. - WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::xssAuditorEnabledKey(), enabled); - - // Change the setting for existing ones. - const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages(); - for (HashSet<Page*>::iterator iter = pages.begin(); iter != pages.end(); ++iter) - (*iter)->settings().setXSSAuditorEnabled(enabled); -} - void InjectedBundle::setAllowUniversalAccessFromFileURLs(WebPageGroupProxy* pageGroup, bool enabled) { const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages(); @@ -266,6 +288,13 @@ void InjectedBundle::setAllowFileAccessFromFileURLs(WebPageGroupProxy* pageGroup (*iter)->settings().setAllowFileAccessFromFileURLs(enabled); } +void InjectedBundle::setNeedsStorageAccessFromFileURLsQuirk(WebPageGroupProxy* pageGroup, bool needsQuirk) +{ + const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages(); + for (auto page : pages) + page->settings().setNeedsStorageAccessFromFileURLsQuirk(needsQuirk); +} + void InjectedBundle::setMinimumLogicalFontSize(WebPageGroupProxy* pageGroup, int size) { const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages(); @@ -280,32 +309,32 @@ void InjectedBundle::setFrameFlatteningEnabled(WebPageGroupProxy* pageGroup, boo (*iter)->settings().setFrameFlatteningEnabled(enabled); } -void InjectedBundle::setPluginsEnabled(WebPageGroupProxy* pageGroup, bool enabled) +void InjectedBundle::setJavaScriptCanAccessClipboard(WebPageGroupProxy* pageGroup, bool enabled) { const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages(); for (HashSet<Page*>::iterator iter = pages.begin(); iter != pages.end(); ++iter) - (*iter)->settings().setPluginsEnabled(enabled); + (*iter)->settings().setJavaScriptCanAccessClipboard(enabled); } -void InjectedBundle::setJavaScriptCanAccessClipboard(WebPageGroupProxy* pageGroup, bool enabled) +void InjectedBundle::setPrivateBrowsingEnabled(WebPageGroupProxy* pageGroup, bool enabled) { + if (enabled) { + WebProcess::singleton().ensureLegacyPrivateBrowsingSessionInNetworkProcess(); + WebFrameNetworkingContext::ensurePrivateBrowsingSession(SessionID::legacyPrivateSessionID()); + } else + SessionTracker::destroySession(SessionID::legacyPrivateSessionID()); + const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages(); for (HashSet<Page*>::iterator iter = pages.begin(); iter != pages.end(); ++iter) - (*iter)->settings().setJavaScriptCanAccessClipboard(enabled); + (*iter)->enableLegacyPrivateBrowsing(enabled); } -void InjectedBundle::setPrivateBrowsingEnabled(WebPageGroupProxy* pageGroup, bool enabled) +void InjectedBundle::setUseDashboardCompatibilityMode(WebPageGroupProxy* pageGroup, bool enabled) { - // FIXME (NetworkProcess): This test-only function doesn't work with NetworkProcess, <https://bugs.webkit.org/show_bug.cgi?id=115274>. -#if PLATFORM(MAC) || USE(CFNETWORK) || USE(SOUP) - if (enabled) - WebFrameNetworkingContext::ensurePrivateBrowsingSession(SessionTracker::legacyPrivateSessionID); - else - SessionTracker::destroySession(SessionTracker::legacyPrivateSessionID); +#if ENABLE(DASHBOARD_SUPPORT) + for (auto& page : PageGroup::pageGroup(pageGroup->identifier())->pages()) + page->settings().setUsesDashboardBackwardCompatibilityMode(enabled); #endif - const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages(); - for (HashSet<Page*>::iterator iter = pages.begin(); iter != pages.end(); ++iter) - (*iter)->settings().setPrivateBrowsingEnabled(enabled); } void InjectedBundle::setPopupBlockingEnabled(WebPageGroupProxy* pageGroup, bool enabled) @@ -332,12 +361,12 @@ void InjectedBundle::setSpatialNavigationEnabled(WebPageGroupProxy* pageGroup, b void InjectedBundle::addOriginAccessWhitelistEntry(const String& sourceOrigin, const String& destinationProtocol, const String& destinationHost, bool allowDestinationSubdomains) { - SecurityPolicy::addOriginAccessWhitelistEntry(*SecurityOrigin::createFromString(sourceOrigin), destinationProtocol, destinationHost, allowDestinationSubdomains); + SecurityPolicy::addOriginAccessWhitelistEntry(SecurityOrigin::createFromString(sourceOrigin).get(), destinationProtocol, destinationHost, allowDestinationSubdomains); } void InjectedBundle::removeOriginAccessWhitelistEntry(const String& sourceOrigin, const String& destinationProtocol, const String& destinationHost, bool allowDestinationSubdomains) { - SecurityPolicy::removeOriginAccessWhitelistEntry(*SecurityOrigin::createFromString(sourceOrigin), destinationProtocol, destinationHost, allowDestinationSubdomains); + SecurityPolicy::removeOriginAccessWhitelistEntry(SecurityOrigin::createFromString(sourceOrigin).get(), destinationProtocol, destinationHost, allowDestinationSubdomains); } void InjectedBundle::resetOriginAccessWhitelists() @@ -352,72 +381,6 @@ void InjectedBundle::setAsynchronousSpellCheckingEnabled(WebPageGroupProxy* page (*iter)->settings().setAsynchronousSpellCheckingEnabled(enabled); } -void InjectedBundle::clearAllDatabases() -{ -#if ENABLE(SQL_DATABASE) - WebProcess::shared().supplement<WebDatabaseManager>()->deleteAllDatabases(); -#endif -} - -void InjectedBundle::setDatabaseQuota(uint64_t quota) -{ -#if ENABLE(SQL_DATABASE) - // Historically, we've used the following (somewhat non-sensical) string - // for the databaseIdentifier of local files. - WebProcess::shared().supplement<WebDatabaseManager>()->setQuotaForOrigin("file__0", quota); -#else - UNUSED_PARAM(quota); -#endif -} - -void InjectedBundle::clearApplicationCache() -{ - WebProcess::shared().supplement<WebApplicationCacheManager>()->deleteAllEntries(); -} - -void InjectedBundle::clearApplicationCacheForOrigin(const String& originString) -{ - RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromString(originString); - ApplicationCache::deleteCacheForOrigin(origin.get()); -} - -void InjectedBundle::setAppCacheMaximumSize(uint64_t size) -{ - WebProcess::shared().supplement<WebApplicationCacheManager>()->setAppCacheMaximumSize(size); -} - -uint64_t InjectedBundle::appCacheUsageForOrigin(const String& originString) -{ - RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromString(originString); - return ApplicationCache::diskUsageForOrigin(origin.get()); -} - -void InjectedBundle::setApplicationCacheOriginQuota(const String& originString, uint64_t bytes) -{ - RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromString(originString); - cacheStorage().storeUpdatedQuotaForOrigin(origin.get(), bytes); -} - -void InjectedBundle::resetApplicationCacheOriginQuota(const String& originString) -{ - RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromString(originString); - cacheStorage().storeUpdatedQuotaForOrigin(origin.get(), cacheStorage().defaultOriginQuota()); -} - -PassRefPtr<API::Array> InjectedBundle::originsWithApplicationCache() -{ - HashSet<RefPtr<SecurityOrigin>> origins; - cacheStorage().getOriginsWithCache(origins); - - Vector<RefPtr<API::Object>> originIdentifiers; - originIdentifiers.reserveInitialCapacity(origins.size()); - - for (const auto& origin : origins) - originIdentifiers.uncheckedAppend(API::String::create(origin->databaseIdentifier())); - - return API::Array::create(std::move(originIdentifiers)); -} - int InjectedBundle::numberOfPages(WebFrame* frame, double pageWidthInPixels, double pageHeightInPixels) { Frame* coreFrame = frame ? frame->coreFrame() : 0; @@ -428,7 +391,7 @@ int InjectedBundle::numberOfPages(WebFrame* frame, double pageWidthInPixels, dou if (!pageHeightInPixels) pageHeightInPixels = coreFrame->view()->height(); - return PrintContext::numberOfPages(coreFrame, FloatSize(pageWidthInPixels, pageHeightInPixels)); + return PrintContext::numberOfPages(*coreFrame, FloatSize(pageWidthInPixels, pageHeightInPixels)); } int InjectedBundle::pageNumberForElementById(WebFrame* frame, const String& id, double pageWidthInPixels, double pageHeightInPixels) @@ -437,7 +400,7 @@ int InjectedBundle::pageNumberForElementById(WebFrame* frame, const String& id, if (!coreFrame) return -1; - Element* element = coreFrame->document()->getElementById(AtomicString(id)); + Element* element = coreFrame->document()->getElementById(id); if (!element) return -1; @@ -475,56 +438,60 @@ bool InjectedBundle::isProcessingUserGesture() void InjectedBundle::addUserScript(WebPageGroupProxy* pageGroup, InjectedBundleScriptWorld* scriptWorld, const String& source, const String& url, API::Array* whitelist, API::Array* blacklist, WebCore::UserScriptInjectionTime injectionTime, WebCore::UserContentInjectedFrames injectedFrames) { // url is not from URL::string(), i.e. it has not already been parsed by URL, so we have to use the relative URL constructor for URL instead of the ParsedURLStringTag version. - PageGroup::pageGroup(pageGroup->identifier())->addUserScriptToWorld(scriptWorld->coreWorld(), source, URL(URL(), url), whitelist ? whitelist->toStringVector() : Vector<String>(), blacklist ? blacklist->toStringVector() : Vector<String>(), injectionTime, injectedFrames); + UserScript userScript{ source, URL(URL(), url), whitelist ? whitelist->toStringVector() : Vector<String>(), blacklist ? blacklist->toStringVector() : Vector<String>(), injectionTime, injectedFrames }; + + pageGroup->userContentController().addUserScript(*scriptWorld, WTFMove(userScript)); } void InjectedBundle::addUserStyleSheet(WebPageGroupProxy* pageGroup, InjectedBundleScriptWorld* scriptWorld, const String& source, const String& url, API::Array* whitelist, API::Array* blacklist, WebCore::UserContentInjectedFrames injectedFrames) { // url is not from URL::string(), i.e. it has not already been parsed by URL, so we have to use the relative URL constructor for URL instead of the ParsedURLStringTag version. - PageGroup::pageGroup(pageGroup->identifier())->addUserStyleSheetToWorld(scriptWorld->coreWorld(), source, URL(URL(), url), whitelist ? whitelist->toStringVector() : Vector<String>(), blacklist ? blacklist->toStringVector() : Vector<String>(), injectedFrames); + UserStyleSheet userStyleSheet{ source, URL(URL(), url), whitelist ? whitelist->toStringVector() : Vector<String>(), blacklist ? blacklist->toStringVector() : Vector<String>(), injectedFrames, UserStyleUserLevel }; + + pageGroup->userContentController().addUserStyleSheet(*scriptWorld, WTFMove(userStyleSheet)); } void InjectedBundle::removeUserScript(WebPageGroupProxy* pageGroup, InjectedBundleScriptWorld* scriptWorld, const String& url) { // url is not from URL::string(), i.e. it has not already been parsed by URL, so we have to use the relative URL constructor for URL instead of the ParsedURLStringTag version. - PageGroup::pageGroup(pageGroup->identifier())->removeUserScriptFromWorld(scriptWorld->coreWorld(), URL(URL(), url)); + pageGroup->userContentController().removeUserScriptWithURL(*scriptWorld, URL(URL(), url)); } void InjectedBundle::removeUserStyleSheet(WebPageGroupProxy* pageGroup, InjectedBundleScriptWorld* scriptWorld, const String& url) { // url is not from URL::string(), i.e. it has not already been parsed by URL, so we have to use the relative URL constructor for URL instead of the ParsedURLStringTag version. - PageGroup::pageGroup(pageGroup->identifier())->removeUserStyleSheetFromWorld(scriptWorld->coreWorld(), URL(URL(), url)); + pageGroup->userContentController().removeUserStyleSheetWithURL(*scriptWorld, URL(URL(), url)); } void InjectedBundle::removeUserScripts(WebPageGroupProxy* pageGroup, InjectedBundleScriptWorld* scriptWorld) { - PageGroup::pageGroup(pageGroup->identifier())->removeUserScriptsFromWorld(scriptWorld->coreWorld()); + pageGroup->userContentController().removeUserScripts(*scriptWorld); } void InjectedBundle::removeUserStyleSheets(WebPageGroupProxy* pageGroup, InjectedBundleScriptWorld* scriptWorld) { - PageGroup::pageGroup(pageGroup->identifier())->removeUserStyleSheetsFromWorld(scriptWorld->coreWorld()); + pageGroup->userContentController().removeUserStyleSheets(*scriptWorld); } void InjectedBundle::removeAllUserContent(WebPageGroupProxy* pageGroup) { - PageGroup::pageGroup(pageGroup->identifier())->removeAllUserContent(); + pageGroup->userContentController().removeAllUserContent(); } void InjectedBundle::garbageCollectJavaScriptObjects() { - gcController().garbageCollectNow(); + GCController::singleton().garbageCollectNow(); } void InjectedBundle::garbageCollectJavaScriptObjectsOnAlternateThreadForDebugging(bool waitUntilDone) { - gcController().garbageCollectOnAlternateThreadForDebugging(waitUntilDone); + GCController::singleton().garbageCollectOnAlternateThreadForDebugging(waitUntilDone); } size_t InjectedBundle::javaScriptObjectsCount() { - JSLockHolder lock(JSDOMWindow::commonVM()); - return JSDOMWindow::commonVM()->heap.objectCount(); + JSLockHolder lock(commonVM()); + return commonVM().heap.objectCount(); } void InjectedBundle::reportException(JSContextRef context, JSValueRef exception) @@ -536,7 +503,8 @@ void InjectedBundle::reportException(JSContextRef context, JSValueRef exception) JSLockHolder lock(execState); // Make sure the context has a DOMWindow global object, otherwise this context didn't originate from a Page. - if (!toJSDOMWindow(execState->lexicalGlobalObject())) + JSC::JSGlobalObject* globalObject = execState->lexicalGlobalObject(); + if (!toJSDOMWindow(globalObject->vm(), globalObject)) return; WebCore::reportException(execState, toJS(execState, exception)); @@ -597,10 +565,10 @@ void InjectedBundle::removeAllWebNotificationPermissions(WebPage* page) uint64_t InjectedBundle::webNotificationID(JSContextRef jsContext, JSValueRef jsNotification) { #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) - WebCore::Notification* notification = toNotification(toJS(toJS(jsContext), jsNotification)); + WebCore::Notification* notification = JSNotification::toWrapped(toJS(jsContext)->vm(), toJS(toJS(jsContext), jsNotification)); if (!notification) return 0; - return WebProcess::shared().supplement<WebNotificationManager>()->notificationIDForTesting(notification); + return WebProcess::singleton().supplement<WebNotificationManager>()->notificationIDForTesting(notification); #else UNUSED_PARAM(jsContext); UNUSED_PARAM(jsNotification); @@ -612,7 +580,7 @@ uint64_t InjectedBundle::webNotificationID(JSContextRef jsContext, JSValueRef js PassRefPtr<API::Data> InjectedBundle::createWebDataFromUint8Array(JSContextRef context, JSValueRef data) { JSC::ExecState* execState = toJS(context); - RefPtr<Uint8Array> arrayData = WebCore::toUint8Array(toJS(execState, data)); + RefPtr<Uint8Array> arrayData = WebCore::toUnsharedUint8Array(execState->vm(), toJS(execState, data)); return API::Data::create(static_cast<unsigned char*>(arrayData->baseAddress()), arrayData->byteLength()); } @@ -621,50 +589,22 @@ void InjectedBundle::setTabKeyCyclesThroughElements(WebPage* page, bool enabled) page->corePage()->setTabKeyCyclesThroughElements(enabled); } -void InjectedBundle::setSerialLoadingEnabled(bool enabled) -{ - resourceLoadScheduler()->setSerialLoadingEnabled(enabled); -} - -void InjectedBundle::setShadowDOMEnabled(bool enabled) +void InjectedBundle::setCSSAnimationTriggersEnabled(bool enabled) { -#if ENABLE(SHADOW_DOM) - RuntimeEnabledFeatures::sharedFeatures().setShadowDOMEnabled(enabled); +#if ENABLE(CSS_ANIMATIONS_LEVEL_2) + RuntimeEnabledFeatures::sharedFeatures().setAnimationTriggersEnabled(enabled); #else UNUSED_PARAM(enabled); #endif } -void InjectedBundle::setCSSRegionsEnabled(bool enabled) +void InjectedBundle::setWebAnimationsEnabled(bool enabled) { -#if ENABLE(CSS_REGIONS) - RuntimeEnabledFeatures::sharedFeatures().setCSSRegionsEnabled(enabled); +#if ENABLE(WEB_ANIMATIONS) + RuntimeEnabledFeatures::sharedFeatures().setWebAnimationsEnabled(enabled); #else UNUSED_PARAM(enabled); #endif } -void InjectedBundle::setCSSCompositingEnabled(bool enabled) -{ -#if ENABLE(CSS_COMPOSITING) - RuntimeEnabledFeatures::sharedFeatures().setCSSCompositingEnabled(enabled); -#else - UNUSED_PARAM(enabled); -#endif -} - -void InjectedBundle::setSeamlessIFramesEnabled(bool enabled) -{ -#if ENABLE(IFRAME_SEAMLESS) - RuntimeEnabledFeatures::sharedFeatures().setSeamlessIFramesEnabled(enabled); -#else - UNUSED_PARAM(enabled); -#endif -} - -void InjectedBundle::dispatchPendingLoadRequests() -{ - resourceLoadScheduler()->servePendingRequests(); -} - } // namespace WebKit |