Diff
Modified: trunk/Source/WebKit2/ChangeLog (130620 => 130621)
--- trunk/Source/WebKit2/ChangeLog 2012-10-08 07:40:58 UTC (rev 130620)
+++ trunk/Source/WebKit2/ChangeLog 2012-10-08 08:05:26 UTC (rev 130621)
@@ -1,3 +1,49 @@
+2012-10-08 Carlos Garcia Campos <cgar...@igalia.com>
+
+ [GTK] Don't use the C API internally in WebKitWebContext
+ https://bugs.webkit.org/show_bug.cgi?id=96768
+
+ Reviewed by Martin Robinson.
+
+ Using the C++ classes directly instead of the C API wrappers we
+ avoid a lot of toImpl/toAPI casts, string conversions and
+ allocations. The code is also a lot simpler and easier to read.
+
+ * UIProcess/API/gtk/WebKitDownloadClient.cpp:
+ (didStart):
+ (didReceiveResponse):
+ (didReceiveData):
+ (decideDestinationWithSuggestedFilename):
+ (didCreateDestination):
+ (didFail):
+ (didCancel):
+ (didFinish):
+ (attachDownloadClientToContext):
+ * UIProcess/API/gtk/WebKitRequestManagerClient.cpp:
+ (attachRequestManagerClientToContext):
+ * UIProcess/API/gtk/WebKitSecurityManager.cpp:
+ (registerSecurityPolicyForURIScheme):
+ * UIProcess/API/gtk/WebKitWebContext.cpp:
+ (_WebKitWebContextPrivate):
+ (createDefaultWebContext):
+ (webkit_web_context_set_cache_model):
+ (webkit_web_context_get_cache_model):
+ (webkit_web_context_clear_cache):
+ (webkit_web_context_download_uri):
+ (webkit_web_context_get_cookie_manager):
+ (webkit_web_context_get_favicon_database_directory):
+ (webkit_web_context_get_favicon_database):
+ (webkit_web_context_set_additional_plugins_directory):
+ (webkitWebContextGetPluginThread):
+ (webkit_web_context_register_uri_scheme):
+ (webkitWebContextGetOrCreateDownload):
+ (webkitWebContextRemoveDownload):
+ (webkitWebContextGetContext):
+ (webkitWebContextGetRequestManager):
+ * UIProcess/API/gtk/WebKitWebContextPrivate.h:
+ * UIProcess/API/gtk/WebKitWebView.cpp:
+ (webkitWebViewConstructed):
+
2012-10-07 Kangil Han <kangil....@samsung.com>
[EFL][WK2] Fix unused parameter compile warning.
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitDownloadClient.cpp (130620 => 130621)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitDownloadClient.cpp 2012-10-08 07:40:58 UTC (rev 130620)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitDownloadClient.cpp 2012-10-08 08:05:26 UTC (rev 130621)
@@ -34,13 +34,13 @@
static void didStart(WKContextRef, WKDownloadRef wkDownload, const void* clientInfo)
{
- GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(wkDownload);
+ GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload));
webkitWebContextDownloadStarted(WEBKIT_WEB_CONTEXT(clientInfo), download.get());
}
static void didReceiveResponse(WKContextRef, WKDownloadRef wkDownload, WKURLResponseRef wkResponse, const void* clientInfo)
{
- GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(wkDownload);
+ GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload));
if (webkitDownloadIsCancelled(download.get()))
return;
@@ -50,13 +50,13 @@
static void didReceiveData(WKContextRef, WKDownloadRef wkDownload, uint64_t length, const void* clientInfo)
{
- GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(wkDownload);
+ GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload));
webkitDownloadNotifyProgress(download.get(), length);
}
static WKStringRef decideDestinationWithSuggestedFilename(WKContextRef, WKDownloadRef wkDownload, WKStringRef filename, bool* allowOverwrite, const void* clientInfo)
{
- GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(wkDownload);
+ GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload));
CString destinationURI = webkitDownloadDecideDestinationWithSuggestedFilename(download.get(),
toImpl(filename)->string().utf8());
return WKStringCreateWithUTF8CString(destinationURI.data());
@@ -64,33 +64,33 @@
static void didCreateDestination(WKContextRef, WKDownloadRef wkDownload, WKStringRef path, const void* clientInfo)
{
- GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(wkDownload);
+ GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload));
webkitDownloadDestinationCreated(download.get(), toImpl(path)->string().utf8());
}
static void didFail(WKContextRef, WKDownloadRef wkDownload, WKErrorRef error, const void *clientInfo)
{
- GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(wkDownload);
+ GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload));
if (webkitDownloadIsCancelled(download.get())) {
// Cancellation takes precedence over other errors.
webkitDownloadCancelled(download.get());
} else
webkitDownloadFailed(download.get(), toImpl(error)->platformError());
- webkitWebContextRemoveDownload(wkDownload);
+ webkitWebContextRemoveDownload(toImpl(wkDownload));
}
static void didCancel(WKContextRef, WKDownloadRef wkDownload, const void *clientInfo)
{
- GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(wkDownload);
+ GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload));
webkitDownloadCancelled(download.get());
- webkitWebContextRemoveDownload(wkDownload);
+ webkitWebContextRemoveDownload(toImpl(wkDownload));
}
static void didFinish(WKContextRef wkContext, WKDownloadRef wkDownload, const void *clientInfo)
{
- GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(wkDownload);
+ GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload));
webkitDownloadFinished(download.get());
- webkitWebContextRemoveDownload(wkDownload);
+ webkitWebContextRemoveDownload(toImpl(wkDownload));
}
void attachDownloadClientToContext(WebKitWebContext* webContext)
@@ -110,6 +110,6 @@
didCancel,
0, // processDidCrash
};
- WKContextSetDownloadClient(webkitWebContextGetWKContext(webContext), &wkDownloadClient);
+ WKContextSetDownloadClient(toAPI(webkitWebContextGetContext(webContext)), &wkDownloadClient);
}
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitRequestManagerClient.cpp (130620 => 130621)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitRequestManagerClient.cpp 2012-10-08 07:40:58 UTC (rev 130620)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitRequestManagerClient.cpp 2012-10-08 08:05:26 UTC (rev 130621)
@@ -46,6 +46,6 @@
didReceiveURIRequest,
didFailToLoadURIRequest
};
- WKSoupRequestManagerSetClient(webkitWebContextGetRequestManager(webContext), &wkRequestManagerClient);
+ WKSoupRequestManagerSetClient(toAPI(webkitWebContextGetRequestManager(webContext)), &wkRequestManagerClient);
}
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManager.cpp (130620 => 130621)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManager.cpp 2012-10-08 07:40:58 UTC (rev 130620)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManager.cpp 2012-10-08 08:05:26 UTC (rev 130621)
@@ -74,7 +74,7 @@
static void registerSecurityPolicyForURIScheme(WebKitSecurityManager* manager, const char* scheme, SecurityPolicy policy)
{
String urlScheme = String::fromUTF8(scheme);
- WebContext* webContext = toImpl(webkitWebContextGetWKContext(manager->priv->webContext));
+ WebContext* webContext = webkitWebContextGetContext(manager->priv->webContext);
// We keep the WebCore::SchemeRegistry of the UI process in sync with the
// web process one, so that we can return the SecurityPolicy for
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp (130620 => 130621)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp 2012-10-08 07:40:58 UTC (rev 130620)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp 2012-10-08 08:05:26 UTC (rev 130621)
@@ -20,7 +20,6 @@
#include "config.h"
#include "WebKitWebContext.h"
-#include "WebContext.h"
#include "WebKitCookieManagerPrivate.h"
#include "WebKitDownloadClient.h"
#include "WebKitDownloadPrivate.h"
@@ -33,6 +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>
@@ -44,8 +44,6 @@
#include <wtf/gobject/GRefPtr.h>
#include <wtf/text/CString.h>
-using namespace WebKit;
-
enum {
DOWNLOAD_STARTED,
@@ -95,12 +93,12 @@
typedef HashMap<uint64_t, GRefPtr<WebKitURISchemeRequest> > URISchemeRequestMap;
struct _WebKitWebContextPrivate {
- WKRetainPtr<WKContextRef> context;
+ RefPtr<WebContext> context;
GRefPtr<WebKitCookieManager> cookieManager;
GRefPtr<WebKitFaviconDatabase> faviconDatabase;
GRefPtr<WebKitSecurityManager> securityManager;
- WKRetainPtr<WKSoupRequestManagerRef> requestManager;
+ RefPtr<WebSoupRequestManagerProxy> requestManager;
URISchemeHandlerMap uriSchemeHandlers;
URISchemeRequestMap uriSchemeRequests;
#if ENABLE(GEOLOCATION)
@@ -156,17 +154,20 @@
static gpointer createDefaultWebContext(gpointer)
{
static GRefPtr<WebKitWebContext> webContext = adoptGRef(WEBKIT_WEB_CONTEXT(g_object_new(WEBKIT_TYPE_WEB_CONTEXT, NULL)));
- webContext->priv->context = WKContextCreate();
- webContext->priv->requestManager = WKContextGetSoupRequestManager(webContext->priv->context.get());
- WKContextSetCacheModel(webContext->priv->context.get(), kWKCacheModelPrimaryWebBrowser);
+ WebKitWebContextPrivate* priv = webContext->priv;
+
+ priv->context = WebContext::create(String());
+ priv->requestManager = webContext->priv->context->soupRequestManagerProxy();
+ priv->context->setCacheModel(CacheModelPrimaryWebBrowser);
+
attachDownloadClientToContext(webContext.get());
attachRequestManagerClientToContext(webContext.get());
+
#if ENABLE(GEOLOCATION)
- WKGeolocationManagerRef wkGeolocationManager = WKContextGetGeolocationManager(webContext->priv->context.get());
- webContext->priv->geolocationProvider = WebKitGeolocationProvider::create(wkGeolocationManager);
+ priv->geolocationProvider = WebKitGeolocationProvider::create(toAPI(priv->context->geolocationManagerProxy()));
#endif
#if ENABLE(SPELLCHECK)
- webContext->priv->textChecker = WebKitTextChecker::create();
+ priv->textChecker = WebKitTextChecker::create();
#endif
return webContext.get();
}
@@ -210,26 +211,26 @@
*/
void webkit_web_context_set_cache_model(WebKitWebContext* context, WebKitCacheModel model)
{
- WKCacheModel cacheModel;
+ CacheModel cacheModel;
g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context));
switch (model) {
case WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER:
- cacheModel = kWKCacheModelDocumentViewer;
+ cacheModel = CacheModelDocumentViewer;
break;
case WEBKIT_CACHE_MODEL_WEB_BROWSER:
- cacheModel = kWKCacheModelPrimaryWebBrowser;
+ cacheModel = CacheModelPrimaryWebBrowser;
break;
case WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER:
- cacheModel = kWKCacheModelDocumentBrowser;
+ cacheModel = CacheModelDocumentBrowser;
break;
default:
g_assert_not_reached();
}
- WebKitWebContextPrivate* priv = context->priv;
- if (cacheModel != WKContextGetCacheModel(priv->context.get()))
- WKContextSetCacheModel(priv->context.get(), cacheModel);
+
+ if (cacheModel != context->priv->context->cacheModel())
+ context->priv->context->setCacheModel(cacheModel);
}
/**
@@ -246,13 +247,12 @@
{
g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), WEBKIT_CACHE_MODEL_WEB_BROWSER);
- WebKitWebContextPrivate* priv = context->priv;
- switch (WKContextGetCacheModel(priv->context.get())) {
- case kWKCacheModelDocumentViewer:
+ switch (context->priv->context->cacheModel()) {
+ case CacheModelDocumentViewer:
return WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER;
- case kWKCacheModelPrimaryWebBrowser:
+ case CacheModelPrimaryWebBrowser:
return WEBKIT_CACHE_MODEL_WEB_BROWSER;
- case kWKCacheModelDocumentBrowser:
+ case CacheModelDocumentBrowser:
return WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER;
default:
g_assert_not_reached();
@@ -272,11 +272,10 @@
{
g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context));
- WebKitWebContextPrivate* priv = context->priv;
- WKResourceCacheManagerClearCacheForAllOrigins(WKContextGetResourceCacheManager(priv->context.get()), WKResourceCachesToClearAll);
+ context->priv->context->resourceCacheManagerProxy()->clearCacheForAllOrigins(AllResourceCaches);
}
-typedef HashMap<WKDownloadRef, GRefPtr<WebKitDownload> > DownloadsMap;
+typedef HashMap<DownloadProxy*, GRefPtr<WebKitDownload> > DownloadsMap;
static DownloadsMap& downloadsMap()
{
@@ -299,12 +298,9 @@
g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), 0);
g_return_val_if_fail(uri, 0);
- 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);
+ DownloadProxy* downloadProxy = context->priv->context->download(0, WebCore::ResourceRequest(String::fromUTF8(uri)));
+ WebKitDownload* download = webkitDownloadCreate(toAPI(downloadProxy));
+ downloadsMap().set(downloadProxy, download);
return download;
}
@@ -322,7 +318,7 @@
WebKitWebContextPrivate* priv = context->priv;
if (!priv->cookieManager)
- priv->cookieManager = adoptGRef(webkitCookieManagerCreate(WKContextGetCookieManager(priv->context.get())));
+ priv->cookieManager = adoptGRef(webkitCookieManagerCreate(toAPI(priv->context->cookieManagerProxy())));
return priv->cookieManager.get();
}
@@ -377,7 +373,7 @@
WebKitWebContextPrivate* priv = context->priv;
// Use default if a different path has not been previously set.
if (priv->faviconDatabasePath.isNull())
- priv->faviconDatabasePath = toImpl(priv->context.get())->iconDatabasePath().utf8();
+ priv->faviconDatabasePath = priv->context->iconDatabasePath().utf8();
return priv->faviconDatabasePath.data();
}
@@ -408,9 +404,8 @@
NULL));
// Calling the setter in WebContext will cause the icon database to be opened.
- WebContext* webContext = toImpl(priv->context.get());
- webContext->setIconDatabasePath(WebCore::filenameToString(faviconDatabasePath.get()));
- priv->faviconDatabase = adoptGRef(webkitFaviconDatabaseCreate(webContext->iconDatabase()));
+ priv->context->setIconDatabasePath(WebCore::filenameToString(faviconDatabasePath.get()));
+ priv->faviconDatabase = adoptGRef(webkitFaviconDatabaseCreate(priv->context->iconDatabase()));
return priv->faviconDatabase.get();
}
@@ -446,7 +441,7 @@
g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context));
g_return_if_fail(directory);
- toImpl(context->priv->context.get())->setAdditionalPluginsDirectory(WebCore::filenameToString(directory));
+ context->priv->context->setAdditionalPluginsDirectory(WebCore::filenameToString(directory));
}
struct GetPluginsAsyncData {
@@ -457,7 +452,7 @@
static void webkitWebContextGetPluginThread(GSimpleAsyncResult* result, GObject* object, GCancellable*)
{
GetPluginsAsyncData* data = ""
- data->plugins = toImpl(WEBKIT_WEB_CONTEXT(object)->priv->context.get())->pluginInfoStore().plugins();
+ data->plugins = WEBKIT_WEB_CONTEXT(object)->priv->context->pluginInfoStore().plugins();
}
/**
@@ -564,8 +559,7 @@
RefPtr<WebKitURISchemeHandler> handler = adoptRef(new WebKitURISchemeHandler(callback, userData, destroyNotify));
context->priv->uriSchemeHandlers.set(String::fromUTF8(scheme), handler.get());
- WKRetainPtr<WKStringRef> wkScheme(AdoptWK, WKStringCreateWithUTF8CString(scheme));
- WKSoupRequestManagerRegisterURIScheme(context->priv->requestManager.get(), wkScheme.get());
+ context->priv->requestManager->registerURIScheme(String::fromUTF8(scheme));
}
/**
@@ -679,20 +673,20 @@
WebCore::languageDidChange();
}
-WebKitDownload* webkitWebContextGetOrCreateDownload(WKDownloadRef wkDownload)
+WebKitDownload* webkitWebContextGetOrCreateDownload(DownloadProxy* downloadProxy)
{
- GRefPtr<WebKitDownload> download = downloadsMap().get(wkDownload);
+ GRefPtr<WebKitDownload> download = downloadsMap().get(downloadProxy);
if (download)
return download.get();
- download = adoptGRef(webkitDownloadCreate(wkDownload));
- downloadsMap().set(wkDownload, download.get());
+ download = adoptGRef(webkitDownloadCreate(toAPI(downloadProxy)));
+ downloadsMap().set(downloadProxy, download.get());
return download.get();
}
-void webkitWebContextRemoveDownload(WKDownloadRef wkDownload)
+void webkitWebContextRemoveDownload(DownloadProxy* downloadProxy)
{
- downloadsMap().remove(wkDownload);
+ downloadsMap().remove(downloadProxy);
}
void webkitWebContextDownloadStarted(WebKitWebContext* context, WebKitDownload* download)
@@ -700,14 +694,14 @@
g_signal_emit(context, signals[DOWNLOAD_STARTED], 0, download);
}
-WKContextRef webkitWebContextGetWKContext(WebKitWebContext* context)
+WebContext* webkitWebContextGetContext(WebKitWebContext* context)
{
g_assert(WEBKIT_IS_WEB_CONTEXT(context));
return context->priv->context.get();
}
-WKSoupRequestManagerRef webkitWebContextGetRequestManager(WebKitWebContext* context)
+WebSoupRequestManagerProxy* webkitWebContextGetRequestManager(WebKitWebContext* context)
{
return context->priv->requestManager.get();
}
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContextPrivate.h (130620 => 130621)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContextPrivate.h 2012-10-08 07:40:58 UTC (rev 130620)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContextPrivate.h 2012-10-08 08:05:26 UTC (rev 130621)
@@ -26,15 +26,20 @@
#ifndef WebKitWebContextPrivate_h
#define WebKitWebContextPrivate_h
+#include "DownloadProxy.h"
+#include "WebContext.h"
#include "WebKitPrivate.h"
#include "WebKitURISchemeRequest.h"
#include "WebKitWebContext.h"
+#include "WebSoupRequestManagerProxy.h"
-WKContextRef webkitWebContextGetWKContext(WebKitWebContext*);
-WebKitDownload* webkitWebContextGetOrCreateDownload(WKDownloadRef);
-void webkitWebContextRemoveDownload(WKDownloadRef);
+using namespace WebKit;
+
+WebContext* webkitWebContextGetContext(WebKitWebContext*);
+WebKitDownload* webkitWebContextGetOrCreateDownload(DownloadProxy*);
+void webkitWebContextRemoveDownload(DownloadProxy*);
void webkitWebContextDownloadStarted(WebKitWebContext*, WebKitDownload*);
-WKSoupRequestManagerRef webkitWebContextGetRequestManager(WebKitWebContext*);
+WebSoupRequestManagerProxy* webkitWebContextGetRequestManager(WebKitWebContext*);
void webkitWebContextReceivedURIRequest(WebKitWebContext*, WebKitURISchemeRequest*);
void webkitWebContextDidFailToLoadURIRequest(WebKitWebContext*, uint64_t requestID);
void webkitWebContextDidFinishURIRequest(WebKitWebContext*, uint64_t requestID);
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp (130620 => 130621)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp 2012-10-08 07:40:58 UTC (rev 130620)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp 2012-10-08 08:05:26 UTC (rev 130621)
@@ -398,7 +398,7 @@
WebKitWebViewPrivate* priv = webView->priv;
WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(webView);
- webkitWebViewBaseCreateWebPage(webViewBase, toImpl(webkitWebContextGetWKContext(priv->context)), 0);
+ webkitWebViewBaseCreateWebPage(webViewBase, webkitWebContextGetContext(priv->context), 0);
attachLoaderClientToView(webView);
attachUIClientToView(webView);