diff options
author | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2013-09-13 12:51:20 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-19 20:50:05 +0200 |
commit | d441d6f39bb846989d95bcf5caf387b42414718d (patch) | |
tree | e367e64a75991c554930278175d403c072de6bb8 /Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp | |
parent | 0060b2994c07842f4c59de64b5e3e430525c4b90 (diff) | |
download | qtwebkit-d441d6f39bb846989d95bcf5caf387b42414718d.tar.gz |
Import Qt5x2 branch of QtWebkit for Qt 5.2
Importing a new snapshot of webkit.
Change-Id: I2d01ad12cdc8af8cb015387641120a9d7ea5f10c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp')
-rw-r--r-- | Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp | 138 |
1 files changed, 91 insertions, 47 deletions
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp index 07ccab7e3..ef4a82f6e 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp @@ -35,9 +35,11 @@ #include "WKAPICast.h" #include "WKBundleAPICast.h" #include "WebApplicationCacheManager.h" +#include "WebConnectionToUIProcess.h" #include "WebContextMessageKinds.h" #include "WebCookieManager.h" #include "WebCoreArgumentCoders.h" +#include "WebData.h" #include "WebDatabaseManager.h" #include "WebFrame.h" #include "WebFrameNetworkingContext.h" @@ -49,6 +51,7 @@ #include <WebCore/ApplicationCache.h> #include <WebCore/ApplicationCacheStorage.h> #include <WebCore/Frame.h> +#include <WebCore/FrameLoader.h> #include <WebCore/FrameView.h> #include <WebCore/GCController.h> #include <WebCore/GeolocationClient.h> @@ -56,6 +59,7 @@ #include <WebCore/GeolocationPosition.h> #include <WebCore/JSDOMWindow.h> #include <WebCore/JSNotification.h> +#include <WebCore/JSUint8Array.h> #include <WebCore/Page.h> #include <WebCore/PageGroup.h> #include <WebCore/PrintContext.h> @@ -66,14 +70,21 @@ #include <WebCore/SecurityPolicy.h> #include <WebCore/Settings.h> #include <WebCore/UserGestureIndicator.h> -#include <WebCore/WorkerThread.h> #include <wtf/OwnArrayPtr.h> #include <wtf/PassOwnArrayPtr.h> -#if ENABLE(SHADOW_DOM) || ENABLE(CSS_REGIONS) +#if ENABLE(SHADOW_DOM) || ENABLE(CSS_REGIONS) || ENABLE(IFRAME_SEAMLESS) || ENABLE(CSS_COMPOSITING) #include <WebCore/RuntimeEnabledFeatures.h> #endif +#if PLATFORM(MAC) +#include "WebSystemInterface.h" +#endif + +#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) +#include "WebNotificationManager.h" +#endif + using namespace WebCore; using namespace JSC; @@ -97,11 +108,11 @@ void InjectedBundle::initializeClient(WKBundleClient* client) void InjectedBundle::postMessage(const String& messageName, APIObject* messageBody) { - OwnPtr<CoreIPC::MessageEncoder> encoder = CoreIPC::MessageEncoder::create(CoreIPC::MessageKindTraits<WebContextLegacyMessage::Kind>::messageReceiverName(), CoreIPC::StringReference("PostMessage"), 0); + OwnPtr<CoreIPC::MessageEncoder> encoder = CoreIPC::MessageEncoder::create(WebContextLegacyMessages::messageReceiverName(), WebContextLegacyMessages::postMessageMessageName(), 0); encoder->encode(messageName); encoder->encode(InjectedBundleUserMessageEncoder(messageBody)); - WebProcess::shared().connection()->sendMessage(CoreIPC::MessageID(WebContextLegacyMessage::PostMessage), encoder.release()); + WebProcess::shared().parentProcessConnection()->sendMessage(encoder.release()); } void InjectedBundle::postSynchronousMessage(const String& messageName, APIObject* messageBody, RefPtr<APIObject>& returnData) @@ -109,11 +120,11 @@ void InjectedBundle::postSynchronousMessage(const String& messageName, APIObject InjectedBundleUserMessageDecoder messageDecoder(returnData); uint64_t syncRequestID; - OwnPtr<CoreIPC::MessageEncoder> encoder = WebProcess::shared().connection()->createSyncMessageEncoder(CoreIPC::MessageKindTraits<WebContextLegacyMessage::Kind>::messageReceiverName(), CoreIPC::StringReference("PostSynchronousMessage"), 0, syncRequestID); + OwnPtr<CoreIPC::MessageEncoder> encoder = WebProcess::shared().parentProcessConnection()->createSyncMessageEncoder(WebContextLegacyMessages::messageReceiverName(), WebContextLegacyMessages::postSynchronousMessageMessageName(), 0, syncRequestID); encoder->encode(messageName); encoder->encode(InjectedBundleUserMessageEncoder(messageBody)); - OwnPtr<CoreIPC::MessageDecoder> replyDecoder = WebProcess::shared().connection()->sendSyncMessage(CoreIPC::MessageID(WebContextLegacyMessage::PostSynchronousMessage), syncRequestID, encoder.release(), CoreIPC::Connection::NoTimeout); + OwnPtr<CoreIPC::MessageDecoder> replyDecoder = WebProcess::shared().parentProcessConnection()->sendSyncMessage(syncRequestID, encoder.release(), CoreIPC::Connection::NoTimeout); if (!replyDecoder || !replyDecoder->decode(messageDecoder)) { returnData = nullptr; return; @@ -132,7 +143,7 @@ void InjectedBundle::setShouldTrackVisitedLinks(bool shouldTrackVisitedLinks) void InjectedBundle::setAlwaysAcceptCookies(bool accept) { - WebCookieManager::shared().setHTTPCookieAcceptPolicy(accept ? HTTPCookieAcceptPolicyAlways : HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain); + WebProcess::shared().supplement<WebCookieManager>()->setHTTPCookieAcceptPolicy(accept ? HTTPCookieAcceptPolicyAlways : HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain); } void InjectedBundle::removeAllVisitedLinks() @@ -150,34 +161,38 @@ void InjectedBundle::overrideBoolPreferenceForTestRunner(WebPageGroupProxy* page const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages(); if (preference == "WebKitTabToLinksPreferenceKey") { - WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::tabsToLinksKey(), enabled); - for (HashSet<Page*>::iterator i = pages.begin(); i != pages.end(); ++i) { - WebPage* webPage = static_cast<WebFrameLoaderClient*>((*i)->mainFrame()->loader()->client())->webFrame()->page(); - webPage->setTabToLinksEnabled(enabled); + 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); } } if (preference == "WebKit2AsynchronousPluginInitializationEnabled") { WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::asynchronousPluginInitializationEnabledKey(), enabled); for (HashSet<Page*>::iterator i = pages.begin(); i != pages.end(); ++i) { - WebPage* webPage = static_cast<WebFrameLoaderClient*>((*i)->mainFrame()->loader()->client())->webFrame()->page(); - webPage->setAsynchronousPluginInitializationEnabled(enabled); + WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient((*i)->mainFrame()->loader()->client()); + ASSERT(webFrameLoaderClient); + webFrameLoaderClient->webFrame()->page()->setAsynchronousPluginInitializationEnabled(enabled); } } if (preference == "WebKit2AsynchronousPluginInitializationEnabledForAllPlugins") { WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::asynchronousPluginInitializationEnabledForAllPluginsKey(), enabled); for (HashSet<Page*>::iterator i = pages.begin(); i != pages.end(); ++i) { - WebPage* webPage = static_cast<WebFrameLoaderClient*>((*i)->mainFrame()->loader()->client())->webFrame()->page(); - webPage->setAsynchronousPluginInitializationEnabledForAllPlugins(enabled); + WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient((*i)->mainFrame()->loader()->client()); + ASSERT(webFrameLoaderClient); + webFrameLoaderClient->webFrame()->page()->setAsynchronousPluginInitializationEnabledForAllPlugins(enabled); } } if (preference == "WebKit2ArtificialPluginInitializationDelayEnabled") { WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::artificialPluginInitializationDelayEnabledKey(), enabled); for (HashSet<Page*>::iterator i = pages.begin(); i != pages.end(); ++i) { - WebPage* webPage = static_cast<WebFrameLoaderClient*>((*i)->mainFrame()->loader()->client())->webFrame()->page(); - webPage->setArtificialPluginInitializationDelayEnabled(enabled); + WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient((*i)->mainFrame()->loader()->client()); + ASSERT(webFrameLoaderClient); + webFrameLoaderClient->webFrame()->page()->setArtificialPluginInitializationDelayEnabled(enabled); } } @@ -186,11 +201,18 @@ void InjectedBundle::overrideBoolPreferenceForTestRunner(WebPageGroupProxy* page RuntimeEnabledFeatures::setCSSRegionsEnabled(enabled); #endif +#if ENABLE(CSS_COMPOSITING) + if (preference == "WebKitCSSCompositingEnabled") + RuntimeEnabledFeatures::setCSSCompositingEnabled(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(WebKitCSSCustomFilterEnabled, CSSCustomFilterEnabled, cssCustomFilterEnabled) \ macro(WebKitCSSGridLayoutEnabled, CSSGridLayoutEnabled, cssGridLayoutEnabled) \ + macro(WebKitFrameFlatteningEnabled, FrameFlatteningEnabled, frameFlatteningEnabled) \ macro(WebKitJavaEnabled, JavaEnabled, javaEnabled) \ macro(WebKitJavaScriptEnabled, ScriptEnabled, javaScriptEnabled) \ macro(WebKitLoadSiteIconsKey, LoadsSiteIconsIgnoringImageLoadingSetting, loadsSiteIconsIgnoringImageLoadingPreference) \ @@ -218,6 +240,10 @@ 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 } @@ -277,7 +303,8 @@ void InjectedBundle::setJavaScriptCanAccessClipboard(WebPageGroupProxy* pageGrou void InjectedBundle::setPrivateBrowsingEnabled(WebPageGroupProxy* pageGroup, bool enabled) { -#if (PLATFORM(MAC) || USE(CFNETWORK)) && !PLATFORM(WIN) + // 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) if (enabled) WebFrameNetworkingContext::ensurePrivateBrowsingSession(); else @@ -298,9 +325,10 @@ void InjectedBundle::setPopupBlockingEnabled(WebPageGroupProxy* pageGroup, bool void InjectedBundle::switchNetworkLoaderToNewTestingSession() { -#if (PLATFORM(MAC) || USE(CFNETWORK)) && !PLATFORM(WIN) +#if PLATFORM(MAC) || USE(CFNETWORK) // FIXME (NetworkProcess): Do this in network process, too. - WebFrameNetworkingContext::switchToNewTestingSession(); + InitWebCoreSystemInterface(); + NetworkStorageSession::switchToNewTestingSession(); #endif } @@ -333,10 +361,17 @@ void InjectedBundle::resetOriginAccessWhitelists() SecurityPolicy::resetOriginAccessWhitelists(); } +void InjectedBundle::setAsynchronousSpellCheckingEnabled(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()->setAsynchronousSpellCheckingEnabled(enabled); +} + void InjectedBundle::clearAllDatabases() { #if ENABLE(SQL_DATABASE) - WebDatabaseManager::shared().deleteAllDatabases(); + WebProcess::shared().supplement<WebDatabaseManager>()->deleteAllDatabases(); #endif } @@ -345,13 +380,13 @@ 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. - WebDatabaseManager::shared().setQuotaForOrigin("file__0", quota); + WebProcess::shared().supplement<WebDatabaseManager>()->setQuotaForOrigin("file__0", quota); #endif } void InjectedBundle::clearApplicationCache() { - WebApplicationCacheManager::shared().deleteAllEntries(); + WebProcess::shared().supplement<WebApplicationCacheManager>()->deleteAllEntries(); } void InjectedBundle::clearApplicationCacheForOrigin(const String& originString) @@ -362,7 +397,7 @@ void InjectedBundle::clearApplicationCacheForOrigin(const String& originString) void InjectedBundle::setAppCacheMaximumSize(uint64_t size) { - WebApplicationCacheManager::shared().setAppCacheMaximumSize(size); + WebProcess::shared().supplement<WebApplicationCacheManager>()->setAppCacheMaximumSize(size); } uint64_t InjectedBundle::appCacheUsageForOrigin(const String& originString) @@ -385,12 +420,12 @@ void InjectedBundle::resetApplicationCacheOriginQuota(const String& originString PassRefPtr<ImmutableArray> InjectedBundle::originsWithApplicationCache() { - HashSet<RefPtr<SecurityOrigin>, SecurityOriginHash> origins; + HashSet<RefPtr<SecurityOrigin>> origins; cacheStorage().getOriginsWithCache(origins); - Vector< RefPtr<APIObject> > originsVector; + Vector< RefPtr<APIObject>> originsVector; - HashSet<RefPtr<SecurityOrigin>, SecurityOriginHash>::iterator it = origins.begin(); - HashSet<RefPtr<SecurityOrigin>, SecurityOriginHash>::iterator end = origins.end(); + HashSet<RefPtr<SecurityOrigin>>::iterator it = origins.begin(); + HashSet<RefPtr<SecurityOrigin>>::iterator end = origins.end(); for ( ; it != end; ++it) originsVector.append(WebString::create((*it)->databaseIdentifier())); @@ -522,8 +557,8 @@ void InjectedBundle::garbageCollectJavaScriptObjectsOnAlternateThreadForDebuggin size_t InjectedBundle::javaScriptObjectsCount() { - JSLockHolder lock(JSDOMWindow::commonJSGlobalData()); - return JSDOMWindow::commonJSGlobalData()->heap.objectCount(); + JSLockHolder lock(JSDOMWindow::commonVM()); + return JSDOMWindow::commonVM()->heap.objectCount(); } void InjectedBundle::reportException(JSContextRef context, JSValueRef exception) @@ -566,15 +601,6 @@ void InjectedBundle::didReceiveMessageToPage(WebPage* page, const String& messag m_client.didReceiveMessageToPage(this, page, messageName, messageBody); } -size_t InjectedBundle::workerThreadCount() -{ -#if ENABLE(WORKERS) - return WebCore::WorkerThread::workerThreadCount(); -#else - return 0; -#endif -} - void InjectedBundle::setUserStyleSheetLocation(WebPageGroupProxy* pageGroup, const String& location) { const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages(); @@ -582,13 +608,6 @@ void InjectedBundle::setUserStyleSheetLocation(WebPageGroupProxy* pageGroup, con (*iter)->settings()->setUserStyleSheetLocation(KURL(KURL(), location)); } -void InjectedBundle::setMinimumTimerInterval(WebPageGroupProxy* pageGroup, double seconds) -{ - const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages(); - for (HashSet<Page*>::iterator iter = pages.begin(); iter != pages.end(); ++iter) - (*iter)->settings()->setMinDOMTimerInterval(seconds); -} - void InjectedBundle::setWebNotificationPermission(WebPage* page, const String& originString, bool allowed) { #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) @@ -615,7 +634,7 @@ uint64_t InjectedBundle::webNotificationID(JSContextRef jsContext, JSValueRef js WebCore::Notification* notification = toNotification(toJS(toJS(jsContext), jsNotification)); if (!notification) return 0; - return WebProcess::shared().notificationManager().notificationIDForTesting(notification); + return WebProcess::shared().supplement<WebNotificationManager>()->notificationIDForTesting(notification); #else UNUSED_PARAM(jsContext); UNUSED_PARAM(jsNotification); @@ -623,6 +642,13 @@ uint64_t InjectedBundle::webNotificationID(JSContextRef jsContext, JSValueRef js #endif } +PassRefPtr<WebData> InjectedBundle::createWebDataFromUint8Array(JSContextRef context, JSValueRef data) +{ + JSC::ExecState* execState = toJS(context); + RefPtr<Uint8Array> arrayData = WebCore::toUint8Array(toJS(execState, data)); + return WebData::create(static_cast<unsigned char*>(arrayData->baseAddress()), arrayData->byteLength()); +} + void InjectedBundle::setTabKeyCyclesThroughElements(WebPage* page, bool enabled) { page->corePage()->setTabKeyCyclesThroughElements(enabled); @@ -651,6 +677,24 @@ void InjectedBundle::setCSSRegionsEnabled(bool enabled) #endif } +void InjectedBundle::setCSSCompositingEnabled(bool enabled) +{ +#if ENABLE(CSS_COMPOSITING) + RuntimeEnabledFeatures::setCSSCompositingEnabled(enabled); +#else + UNUSED_PARAM(enabled); +#endif +} + +void InjectedBundle::setSeamlessIFramesEnabled(bool enabled) +{ +#if ENABLE(IFRAME_SEAMLESS) + RuntimeEnabledFeatures::setSeamlessIFramesEnabled(enabled); +#else + UNUSED_PARAM(enabled); +#endif +} + void InjectedBundle::dispatchPendingLoadRequests() { resourceLoadScheduler()->servePendingRequests(); |