diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2012-10-16 14:56:46 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2012-10-16 14:57:30 +0200 |
commit | b297e0fa5c217c9467033b7c8b46891a52870120 (patch) | |
tree | 43fc14689295e9e64f2719d05aad94e3049f6cd7 /Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp | |
parent | 69d517dbfa69903d8593cc1737f0474b21e3251e (diff) | |
download | qtwebkit-b297e0fa5c217c9467033b7c8b46891a52870120.tar.gz |
Revert "Imported WebKit commit 0dc6cd75e1d4836eaffbb520be96fac4847cc9d2 (http://svn.webkit.org/repository/webkit/trunk@131300)"
This reverts commit 5466563f4b5b6b86523e3f89bb7f77e5b5270c78.
Caused OOM issues on some CI machines :(
Diffstat (limited to 'Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp')
-rw-r--r-- | Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp | 185 |
1 files changed, 45 insertions, 140 deletions
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp index dab18a87d..5b2c26697 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp @@ -20,10 +20,10 @@ #include "config.h" #include "WebKitWebContext.h" +#include "WebContext.h" #include "WebKitCookieManagerPrivate.h" #include "WebKitDownloadClient.h" #include "WebKitDownloadPrivate.h" -#include "WebKitFaviconDatabasePrivate.h" #include "WebKitGeolocationProvider.h" #include "WebKitPluginPrivate.h" #include "WebKitPrivate.h" @@ -32,9 +32,7 @@ #include "WebKitTextChecker.h" #include "WebKitURISchemeRequestPrivate.h" #include "WebKitWebContextPrivate.h" -#include "WebResourceCacheManagerProxy.h" #include <WebCore/FileSystem.h> -#include <WebCore/IconDatabase.h> #include <WebCore/Language.h> #include <wtf/HashMap.h> #include <wtf/OwnPtr.h> @@ -44,6 +42,8 @@ #include <wtf/gobject/GRefPtr.h> #include <wtf/text/CString.h> +using namespace WebKit; + enum { DOWNLOAD_STARTED, @@ -93,12 +93,11 @@ typedef HashMap<String, RefPtr<WebKitURISchemeHandler> > URISchemeHandlerMap; typedef HashMap<uint64_t, GRefPtr<WebKitURISchemeRequest> > URISchemeRequestMap; struct _WebKitWebContextPrivate { - RefPtr<WebContext> context; + WKRetainPtr<WKContextRef> context; GRefPtr<WebKitCookieManager> cookieManager; - GRefPtr<WebKitFaviconDatabase> faviconDatabase; GRefPtr<WebKitSecurityManager> securityManager; - RefPtr<WebSoupRequestManagerProxy> requestManager; + WKRetainPtr<WKSoupRequestManagerRef> requestManager; URISchemeHandlerMap uriSchemeHandlers; URISchemeRequestMap uriSchemeRequests; #if ENABLE(GEOLOCATION) @@ -107,7 +106,6 @@ struct _WebKitWebContextPrivate { #if ENABLE(SPELLCHECK) OwnPtr<WebKitTextChecker> textChecker; #endif - CString faviconDatabaseDirectory; }; static guint signals[LAST_SIGNAL] = { 0, }; @@ -154,20 +152,17 @@ static void webkit_web_context_class_init(WebKitWebContextClass* webContextClass static gpointer createDefaultWebContext(gpointer) { static GRefPtr<WebKitWebContext> webContext = adoptGRef(WEBKIT_WEB_CONTEXT(g_object_new(WEBKIT_TYPE_WEB_CONTEXT, NULL))); - WebKitWebContextPrivate* priv = webContext->priv; - - priv->context = WebContext::create(String()); - priv->requestManager = webContext->priv->context->soupRequestManagerProxy(); - priv->context->setCacheModel(CacheModelPrimaryWebBrowser); - + webContext->priv->context = WKContextCreate(); + webContext->priv->requestManager = WKContextGetSoupRequestManager(webContext->priv->context.get()); + WKContextSetCacheModel(webContext->priv->context.get(), kWKCacheModelPrimaryWebBrowser); attachDownloadClientToContext(webContext.get()); attachRequestManagerClientToContext(webContext.get()); - #if ENABLE(GEOLOCATION) - priv->geolocationProvider = WebKitGeolocationProvider::create(toAPI(priv->context->geolocationManagerProxy())); + WKGeolocationManagerRef wkGeolocationManager = WKContextGetGeolocationManager(webContext->priv->context.get()); + webContext->priv->geolocationProvider = WebKitGeolocationProvider::create(wkGeolocationManager); #endif #if ENABLE(SPELLCHECK) - priv->textChecker = WebKitTextChecker::create(); + webContext->priv->textChecker = WebKitTextChecker::create(); #endif return webContext.get(); } @@ -211,26 +206,26 @@ WebKitWebContext* webkit_web_context_get_default(void) */ void webkit_web_context_set_cache_model(WebKitWebContext* context, WebKitCacheModel model) { - CacheModel cacheModel; + WKCacheModel cacheModel; g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context)); switch (model) { case WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER: - cacheModel = CacheModelDocumentViewer; + cacheModel = kWKCacheModelDocumentViewer; break; case WEBKIT_CACHE_MODEL_WEB_BROWSER: - cacheModel = CacheModelPrimaryWebBrowser; + cacheModel = kWKCacheModelPrimaryWebBrowser; break; case WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER: - cacheModel = CacheModelDocumentBrowser; + cacheModel = kWKCacheModelDocumentBrowser; break; default: g_assert_not_reached(); } - - if (cacheModel != context->priv->context->cacheModel()) - context->priv->context->setCacheModel(cacheModel); + WebKitWebContextPrivate* priv = context->priv; + if (cacheModel != WKContextGetCacheModel(priv->context.get())) + WKContextSetCacheModel(priv->context.get(), cacheModel); } /** @@ -247,12 +242,13 @@ WebKitCacheModel webkit_web_context_get_cache_model(WebKitWebContext* context) { g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), WEBKIT_CACHE_MODEL_WEB_BROWSER); - switch (context->priv->context->cacheModel()) { - case CacheModelDocumentViewer: + WebKitWebContextPrivate* priv = context->priv; + switch (WKContextGetCacheModel(priv->context.get())) { + case kWKCacheModelDocumentViewer: return WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER; - case CacheModelPrimaryWebBrowser: + case kWKCacheModelPrimaryWebBrowser: return WEBKIT_CACHE_MODEL_WEB_BROWSER; - case CacheModelDocumentBrowser: + case kWKCacheModelDocumentBrowser: return WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER; default: g_assert_not_reached(); @@ -272,10 +268,11 @@ void webkit_web_context_clear_cache(WebKitWebContext* context) { g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context)); - context->priv->context->resourceCacheManagerProxy()->clearCacheForAllOrigins(AllResourceCaches); + WebKitWebContextPrivate* priv = context->priv; + WKResourceCacheManagerClearCacheForAllOrigins(WKContextGetResourceCacheManager(priv->context.get()), WKResourceCachesToClearAll); } -typedef HashMap<DownloadProxy*, GRefPtr<WebKitDownload> > DownloadsMap; +typedef HashMap<WKDownloadRef, GRefPtr<WebKitDownload> > DownloadsMap; static DownloadsMap& downloadsMap() { @@ -298,9 +295,12 @@ WebKitDownload* webkit_web_context_download_uri(WebKitWebContext* context, const g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), 0); g_return_val_if_fail(uri, 0); - DownloadProxy* downloadProxy = context->priv->context->download(0, WebCore::ResourceRequest(String::fromUTF8(uri))); - WebKitDownload* download = webkitDownloadCreate(toAPI(downloadProxy)); - downloadsMap().set(downloadProxy, download); + WebKitWebContextPrivate* priv = context->priv; + WKRetainPtr<WKURLRef> wkURL(AdoptWK, WKURLCreateWithUTF8CString(uri)); + WKRetainPtr<WKURLRequestRef> wkRequest(AdoptWK, WKURLRequestCreateWithWKURL(wkURL.get())); + WKRetainPtr<WKDownloadRef> wkDownload = WKContextDownloadURLRequest(priv->context.get(), wkRequest.get()); + WebKitDownload* download = webkitDownloadCreate(wkDownload.get()); + downloadsMap().set(wkDownload.get(), download); return download; } @@ -318,107 +318,11 @@ WebKitCookieManager* webkit_web_context_get_cookie_manager(WebKitWebContext* con WebKitWebContextPrivate* priv = context->priv; if (!priv->cookieManager) - priv->cookieManager = adoptGRef(webkitCookieManagerCreate(toAPI(priv->context->cookieManagerProxy()))); + priv->cookieManager = adoptGRef(webkitCookieManagerCreate(WKContextGetCookieManager(priv->context.get()))); return priv->cookieManager.get(); } -static void ensureFaviconDatabase(WebKitWebContext* context) -{ - WebKitWebContextPrivate* priv = context->priv; - if (priv->faviconDatabase) - return; - - priv->faviconDatabase = adoptGRef(webkitFaviconDatabaseCreate(priv->context->iconDatabase())); -} - -/** - * webkit_web_context_set_favicon_database_directory: - * @context: a #WebKitWebContext - * @path: (allow-none): an absolute path to the icon database - * directory or %NULL to use the defaults - * - * Set the directory path to be used to store the favicons database - * for @context on disk. Passing %NULL as @path means using the - * default directory for the platform (see g_get_user_data_dir()). - * - * Calling this method also means enabling the favicons database for - * its use from the applications, so that's why it's expected to be - * called only once. Further calls for the same instance of - * #WebKitWebContext won't cause any effect. - */ -void webkit_web_context_set_favicon_database_directory(WebKitWebContext* context, const gchar* path) -{ - g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context)); - - WebKitWebContextPrivate* priv = context->priv; - WebIconDatabase* iconDatabase = priv->context->iconDatabase(); - if (iconDatabase->isOpen()) - return; - - ensureFaviconDatabase(context); - - // Use default if 0 is passed as parameter. - String directoryPath = WebCore::filenameToString(path); - priv->faviconDatabaseDirectory = directoryPath.isEmpty() - ? priv->context->iconDatabasePath().utf8() - : directoryPath.utf8(); - - // Build the full path to the icon database file on disk. - GOwnPtr<gchar> faviconDatabasePath(g_build_filename(priv->faviconDatabaseDirectory.data(), - WebCore::IconDatabase::defaultDatabaseFilename().utf8().data(), - NULL)); - - // Setting the path will cause the icon database to be opened. - priv->context->setIconDatabasePath(WebCore::filenameToString(faviconDatabasePath.get())); -} - -/** - * webkit_web_context_get_favicon_database_directory: - * @context: a #WebKitWebContext - * - * Get the directory path being used to store the favicons database - * for @context, or %NULL if - * webkit_web_context_set_favicon_database_directory() hasn't been - * called yet. - * - * This function will always return the same path after having called - * webkit_web_context_set_favicon_database_directory() for the first - * time. - * - * Returns: (transfer none): the path of the directory of the favicons - * database associated with @context, or %NULL. - */ -const gchar* webkit_web_context_get_favicon_database_directory(WebKitWebContext *context) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), 0); - - WebKitWebContextPrivate* priv = context->priv; - if (priv->faviconDatabaseDirectory.isNull()) - return 0; - - return priv->faviconDatabaseDirectory.data(); -} - -/** - * webkit_web_context_get_favicon_database: - * @context: a #WebKitWebContext - * - * Get the #WebKitFaviconDatabase associated with @context. - * - * To initialize the database you need to call - * webkit_web_context_set_favicon_database_directory(). - * - * Returns: (transfer none): the #WebKitFaviconDatabase of @context. - */ -WebKitFaviconDatabase* webkit_web_context_get_favicon_database(WebKitWebContext* context) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), 0); - - ensureFaviconDatabase(context); - return context->priv->faviconDatabase.get(); -} - /** * webkit_web_context_get_security_manager: * @context: a #WebKitWebContext @@ -450,7 +354,7 @@ void webkit_web_context_set_additional_plugins_directory(WebKitWebContext* conte g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context)); g_return_if_fail(directory); - context->priv->context->setAdditionalPluginsDirectory(WebCore::filenameToString(directory)); + toImpl(context->priv->context.get())->setAdditionalPluginsDirectory(WebCore::filenameToString(directory)); } struct GetPluginsAsyncData { @@ -461,7 +365,7 @@ WEBKIT_DEFINE_ASYNC_DATA_STRUCT(GetPluginsAsyncData) static void webkitWebContextGetPluginThread(GSimpleAsyncResult* result, GObject* object, GCancellable*) { GetPluginsAsyncData* data = static_cast<GetPluginsAsyncData*>(g_simple_async_result_get_op_res_gpointer(result)); - data->plugins = WEBKIT_WEB_CONTEXT(object)->priv->context->pluginInfoStore().plugins(); + data->plugins = toImpl(WEBKIT_WEB_CONTEXT(object)->priv->context.get())->pluginInfoStore().plugins(); } /** @@ -568,7 +472,8 @@ void webkit_web_context_register_uri_scheme(WebKitWebContext* context, const cha RefPtr<WebKitURISchemeHandler> handler = adoptRef(new WebKitURISchemeHandler(callback, userData, destroyNotify)); context->priv->uriSchemeHandlers.set(String::fromUTF8(scheme), handler.get()); - context->priv->requestManager->registerURIScheme(String::fromUTF8(scheme)); + WKRetainPtr<WKStringRef> wkScheme(AdoptWK, WKStringCreateWithUTF8CString(scheme)); + WKSoupRequestManagerRegisterURIScheme(context->priv->requestManager.get(), wkScheme.get()); } /** @@ -682,20 +587,20 @@ void webkit_web_context_set_preferred_languages(WebKitWebContext* context, const WebCore::languageDidChange(); } -WebKitDownload* webkitWebContextGetOrCreateDownload(DownloadProxy* downloadProxy) +WebKitDownload* webkitWebContextGetOrCreateDownload(WKDownloadRef wkDownload) { - GRefPtr<WebKitDownload> download = downloadsMap().get(downloadProxy); + GRefPtr<WebKitDownload> download = downloadsMap().get(wkDownload); if (download) return download.get(); - download = adoptGRef(webkitDownloadCreate(toAPI(downloadProxy))); - downloadsMap().set(downloadProxy, download.get()); + download = adoptGRef(webkitDownloadCreate(wkDownload)); + downloadsMap().set(wkDownload, download.get()); return download.get(); } -void webkitWebContextRemoveDownload(DownloadProxy* downloadProxy) +void webkitWebContextRemoveDownload(WKDownloadRef wkDownload) { - downloadsMap().remove(downloadProxy); + downloadsMap().remove(wkDownload); } void webkitWebContextDownloadStarted(WebKitWebContext* context, WebKitDownload* download) @@ -703,14 +608,14 @@ void webkitWebContextDownloadStarted(WebKitWebContext* context, WebKitDownload* g_signal_emit(context, signals[DOWNLOAD_STARTED], 0, download); } -WebContext* webkitWebContextGetContext(WebKitWebContext* context) +WKContextRef webkitWebContextGetWKContext(WebKitWebContext* context) { g_assert(WEBKIT_IS_WEB_CONTEXT(context)); return context->priv->context.get(); } -WebSoupRequestManagerProxy* webkitWebContextGetRequestManager(WebKitWebContext* context) +WKSoupRequestManagerRef webkitWebContextGetRequestManager(WebKitWebContext* context) { return context->priv->requestManager.get(); } |