[GTK] Implement custom URI schemes with CustomProtocols
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Jan 2014 13:14:49 +0000 (13:14 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Jan 2014 13:14:49 +0000 (13:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=127091

Reviewed by Gustavo Noronha Silva.

Source/WebKit2:

The old classes are no longer built for GTK+ and should be removed once
other ports using soup backend switch to custom protocols implementation.

* GNUmakefile.am: Remove include path.
* GNUmakefile.list.am: Remove files from compilation.
* PlatformGTK.cmake: Ditto.
* UIProcess/API/gtk/WebKitPrivate.h:
* UIProcess/API/gtk/WebKitRequestManagerClient.cpp:
(startLoading):
(stopLoading):
(attachRequestManagerClientToContext):
* UIProcess/API/gtk/WebKitURISchemeRequest.cpp:
(webkitURISchemeRequestCreate):
(webkit_uri_scheme_request_get_web_view):
(webkitURISchemeRequestReadCallback):
(webkit_uri_scheme_request_finish):
(webkit_uri_scheme_request_finish_error):
* UIProcess/API/gtk/WebKitURISchemeRequestPrivate.h:
* UIProcess/API/gtk/WebKitWebContext.cpp:
(createDefaultWebContext):
(webkit_web_context_register_uri_scheme):
(webkitWebContextGetRequestManager):
(webkitWebContextStartLoadingCustomProtocol):
(webkitWebContextStopLoadingCustomProtocol):
(webkitWebContextDidFinishLoadingCustomProtocol):
* UIProcess/API/gtk/WebKitWebContextPrivate.h:
* UIProcess/gtk/WebContextGtk.cpp:
(WebKit::WebContext::platformInitializeWebProcess):
* WebKit2Prefix.h: Enable CustomProtocols unconditionally for the
GTK+ port.

Tools:

Temporarily disable the WebKitWebView check until we figure out
how to implement it with CustomProtocols.

* TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@162835 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/GNUmakefile.am
Source/WebKit2/GNUmakefile.list.am
Source/WebKit2/PlatformGTK.cmake
Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h
Source/WebKit2/UIProcess/API/gtk/WebKitRequestManagerClient.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequestPrivate.h
Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitWebContextPrivate.h
Source/WebKit2/UIProcess/gtk/WebContextGtk.cpp
Source/WebKit2/WebKit2Prefix.h
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp

index f40476e..1f4f313 100644 (file)
@@ -1,5 +1,43 @@
 2014-01-27  Carlos Garcia Campos  <cgarcia@igalia.com>
 
+        [GTK] Implement custom URI schemes with CustomProtocols
+        https://bugs.webkit.org/show_bug.cgi?id=127091
+
+        Reviewed by Gustavo Noronha Silva.
+
+        The old classes are no longer built for GTK+ and should be removed once
+        other ports using soup backend switch to custom protocols implementation.
+
+        * GNUmakefile.am: Remove include path.
+        * GNUmakefile.list.am: Remove files from compilation.
+        * PlatformGTK.cmake: Ditto.
+        * UIProcess/API/gtk/WebKitPrivate.h:
+        * UIProcess/API/gtk/WebKitRequestManagerClient.cpp:
+        (startLoading):
+        (stopLoading):
+        (attachRequestManagerClientToContext):
+        * UIProcess/API/gtk/WebKitURISchemeRequest.cpp:
+        (webkitURISchemeRequestCreate):
+        (webkit_uri_scheme_request_get_web_view):
+        (webkitURISchemeRequestReadCallback):
+        (webkit_uri_scheme_request_finish):
+        (webkit_uri_scheme_request_finish_error):
+        * UIProcess/API/gtk/WebKitURISchemeRequestPrivate.h:
+        * UIProcess/API/gtk/WebKitWebContext.cpp:
+        (createDefaultWebContext):
+        (webkit_web_context_register_uri_scheme):
+        (webkitWebContextGetRequestManager):
+        (webkitWebContextStartLoadingCustomProtocol):
+        (webkitWebContextStopLoadingCustomProtocol):
+        (webkitWebContextDidFinishLoadingCustomProtocol):
+        * UIProcess/API/gtk/WebKitWebContextPrivate.h:
+        * UIProcess/gtk/WebContextGtk.cpp:
+        (WebKit::WebContext::platformInitializeWebProcess):
+        * WebKit2Prefix.h: Enable CustomProtocols unconditionally for the
+        GTK+ port.
+
+2014-01-27  Carlos Garcia Campos  <cgarcia@igalia.com>
+
         [SOUP] WebProcess sometimes crashes when a download is cancelled
         https://bugs.webkit.org/show_bug.cgi?id=127650
 
index 1b453c4..c299b1f 100644 (file)
@@ -428,7 +428,6 @@ vpath %.messages.in = \
        $(WebKit2)/UIProcess/Plugins \
        $(WebKit2)/UIProcess/ResourceCache \
        $(WebKit2)/UIProcess/Storage \
-       $(WebKit2)/UIProcess/soup \
        $(WebKit2)/WebProcess \
        $(WebKit2)/WebProcess/ApplicationCache \
        $(WebKit2)/WebProcess/Battery \
index 042d39f..eccbc4d 100644 (file)
@@ -160,10 +160,6 @@ webkit2_built_sources += \
        DerivedSources/WebKit2/WebResourceCacheManagerProxyMessages.h \
        DerivedSources/WebKit2/WebResourceLoaderMessageReceiver.cpp \
        DerivedSources/WebKit2/WebResourceLoaderMessages.h \
-       DerivedSources/WebKit2/WebSoupRequestManagerMessageReceiver.cpp \
-       DerivedSources/WebKit2/WebSoupRequestManagerMessages.h \
-       DerivedSources/WebKit2/WebSoupRequestManagerProxyMessageReceiver.cpp \
-       DerivedSources/WebKit2/WebSoupRequestManagerProxyMessages.h \
        DerivedSources/WebKit2/WebVibrationProxyMessageReceiver.cpp \
        DerivedSources/WebKit2/WebVibrationProxyMessages.h
 
@@ -521,10 +517,6 @@ webkit2_sources += \
        Source/WebKit2/UIProcess/API/C/gtk/WKView.h \
        Source/WebKit2/UIProcess/API/C/gtk/WKViewPrivate.h \
        Source/WebKit2/UIProcess/API/C/soup/WKAPICastSoup.h \
-       Source/WebKit2/UIProcess/API/C/soup/WKContextSoup.cpp \
-       Source/WebKit2/UIProcess/API/C/soup/WKContextSoup.h \
-       Source/WebKit2/UIProcess/API/C/soup/WKSoupRequestManager.cpp \
-       Source/WebKit2/UIProcess/API/C/soup/WKSoupRequestManager.h \
        Source/WebKit2/UIProcess/API/C/soup/WKSoupCustomProtocolRequestManager.cpp \
        Source/WebKit2/UIProcess/API/C/soup/WKSoupCustomProtocolRequestManager.h \
        Source/WebKit2/UIProcess/API/C/WebKit2_C.h \
@@ -886,10 +878,6 @@ webkit2_sources += \
        Source/WebKit2/UIProcess/Storage/StorageManager.h \
        Source/WebKit2/UIProcess/soup/WebContextSoup.cpp \
        Source/WebKit2/UIProcess/soup/WebCookieManagerProxySoup.cpp \
-       Source/WebKit2/UIProcess/soup/WebSoupRequestManagerClient.cpp \
-       Source/WebKit2/UIProcess/soup/WebSoupRequestManagerClient.h \
-       Source/WebKit2/UIProcess/soup/WebSoupRequestManagerProxy.cpp \
-       Source/WebKit2/UIProcess/soup/WebSoupRequestManagerProxy.h \
        Source/WebKit2/UIProcess/TextChecker.h \
        Source/WebKit2/UIProcess/TextCheckerCompletion.h \
        Source/WebKit2/UIProcess/TextCheckerCompletion.cpp \
@@ -1184,8 +1172,6 @@ webkit2_sources += \
        Source/WebKit2/WebProcess/Storage/StorageAreaMap.h \
        Source/WebKit2/WebProcess/Storage/StorageNamespaceImpl.cpp \
        Source/WebKit2/WebProcess/Storage/StorageNamespaceImpl.h \
-       Source/WebKit2/WebProcess/soup/WebSoupRequestManager.cpp \
-       Source/WebKit2/WebProcess/soup/WebSoupRequestManager.h \
        Source/WebKit2/WebProcess/soup/WebProcessSoup.cpp \
        Source/WebKit2/WebProcess/soup/WebKitSoupRequestGeneric.cpp \
        Source/WebKit2/WebProcess/soup/WebKitSoupRequestGeneric.h \
index bf60f1b..3c7b8dc 100644 (file)
@@ -82,9 +82,7 @@ list(APPEND WebKit2_SOURCES
     UIProcess/API/C/gtk/WKInspectorClientGtk.cpp
     UIProcess/API/C/gtk/WKView.cpp
 
-    UIProcess/API/C/soup/WKContextSoup.cpp
     UIProcess/API/C/soup/WKCookieManagerSoup.cpp
-    UIProcess/API/C/soup/WKSoupRequestManager.cpp
     UIProcess/API/C/soup/WKSoupCustomProtocolRequestManager.cpp
 
     UIProcess/API/gtk/PageClientImpl.cpp
@@ -269,8 +267,6 @@ list(APPEND WebKit2_SOURCES
     UIProcess/Network/soup/NetworkProcessProxySoup.cpp
     UIProcess/soup/WebContextSoup.cpp
     UIProcess/soup/WebCookieManagerProxySoup.cpp
-    UIProcess/soup/WebSoupRequestManagerClient.cpp
-    UIProcess/soup/WebSoupRequestManagerProxy.cpp
 
     WebProcess/Cookies/soup/WebCookieManagerSoup.cpp
     WebProcess/Cookies/soup/WebKitSoupCookieJarSqlite.cpp
@@ -311,7 +307,6 @@ list(APPEND WebKit2_SOURCES
     WebProcess/soup/WebKitSoupRequestGeneric.cpp
     WebProcess/soup/WebKitSoupRequestInputStream.cpp
     WebProcess/soup/WebProcessSoup.cpp
-    WebProcess/soup/WebSoupRequestManager.cpp
 )
 
 set(WebKit2GTK_INSTALLED_HEADERS
index 83904ad..bd060ed 100644 (file)
@@ -27,7 +27,6 @@
 #define WebKitPrivate_h
 
 #include <WebKit2/WKAPICast.h>
-#include <WebKit2/WKContextSoup.h>
 #include <WebKit2/WKDownload.h>
 #include <WebKit2/WKFindOptions.h>
 #include <WebKit2/WKFullScreenClientGtk.h>
@@ -39,7 +38,7 @@
 #include <WebKit2/WKInspectorClientGtk.h>
 #include <WebKit2/WKRetainPtr.h>
 #include <WebKit2/WKSerializedScriptValue.h>
-#include <WebKit2/WKSoupRequestManager.h>
+#include <WebKit2/WKSoupCustomProtocolRequestManager.h>
 #include <WebKit2/WKString.h>
 #include <WebKit2/WKTextChecker.h>
 #include <WebKit2/WebKit2_C.h>
index acc1901..72f91ec 100644 (file)
 #include "config.h"
 #include "WebKitRequestManagerClient.h"
 
-#include "WebKitURISchemeRequestPrivate.h"
 #include "WebKitWebContextPrivate.h"
-#include <wtf/gobject/GRefPtr.h>
 
 using namespace WebKit;
 
-static void didReceiveURIRequest(WKSoupRequestManagerRef soupRequestManagerRef, WKURLRef urlRef, WKPageRef initiatingPageRef, uint64_t requestID, const void* clientInfo)
+static void startLoading(WKSoupCustomProtocolRequestManagerRef soupRequestManagerRef, uint64_t customProtocolID, WKURLRequestRef requestRef, const void* clientInfo)
 {
-    WebKitWebContext* webContext = WEBKIT_WEB_CONTEXT(clientInfo);
-    GRefPtr<WebKitURISchemeRequest> request = adoptGRef(webkitURISchemeRequestCreate(webContext, toImpl(soupRequestManagerRef), toImpl(urlRef), toImpl(initiatingPageRef), requestID));
-    webkitWebContextReceivedURIRequest(webContext, request.get());
+    webkitWebContextStartLoadingCustomProtocol(WEBKIT_WEB_CONTEXT(clientInfo), customProtocolID, toImpl(requestRef));
 }
 
-static void didFailToLoadURIRequest(WKSoupRequestManagerRef, uint64_t requestID, const void* clientInfo)
+static void stopLoading(WKSoupCustomProtocolRequestManagerRef, uint64_t customProtocolID, const void* clientInfo)
 {
-    webkitWebContextDidFailToLoadURIRequest(WEBKIT_WEB_CONTEXT(clientInfo), requestID);
+    webkitWebContextStopLoadingCustomProtocol(WEBKIT_WEB_CONTEXT(clientInfo), customProtocolID);
 }
 
 void attachRequestManagerClientToContext(WebKitWebContext* webContext)
 {
-    WKSoupRequestManagerClientV0 wkRequestManagerClient = {
+    WKSoupCustomProtocolRequestManagerClientV0 wkRequestManagerClient = {
         {
             0, // version
             webContext // clientInfo
         },
-        didReceiveURIRequest,
-        didFailToLoadURIRequest
+        startLoading,
+        stopLoading
     };
-    WKSoupRequestManagerSetClient(toAPI(webkitWebContextGetRequestManager(webContext)), &wkRequestManagerClient.base);
+    WKSoupCustomProtocolRequestManagerSetClient(toAPI(webkitWebContextGetRequestManager(webContext)), &wkRequestManagerClient.base);
 }
 
index e1e4221..ecb9e18 100644 (file)
@@ -25,7 +25,6 @@
 #include "WebKitWebContextPrivate.h"
 #include "WebKitWebView.h"
 #include "WebPageProxy.h"
-#include "WebSoupRequestManagerProxy.h"
 #include <WebCore/GUniquePtrSoup.h>
 #include <WebCore/ResourceError.h>
 #include <libsoup/soup.h>
@@ -55,7 +54,7 @@ static const unsigned int gReadBufferSize = 8192;
 
 struct _WebKitURISchemeRequestPrivate {
     WebKitWebContext* webContext;
-    RefPtr<WebSoupRequestManagerProxy> webRequestManager;
+    RefPtr<WebSoupCustomProtocolRequestManager> webRequestManager;
     RefPtr<WebPageProxy> initiatingPage;
     uint64_t requestID;
     CString uri;
@@ -75,22 +74,17 @@ static void webkit_uri_scheme_request_class_init(WebKitURISchemeRequestClass* re
 {
 }
 
-WebKitURISchemeRequest* webkitURISchemeRequestCreate(WebKitWebContext* webContext, WebSoupRequestManagerProxy* webRequestManager, API::URL* webURL, WebPageProxy* initiatingPage, uint64_t requestID)
+WebKitURISchemeRequest* webkitURISchemeRequestCreate(uint64_t requestID, WebKitWebContext* webContext, API::URLRequest* urlRequest, WebPageProxy* initiatingPage)
 {
     WebKitURISchemeRequest* request = WEBKIT_URI_SCHEME_REQUEST(g_object_new(WEBKIT_TYPE_URI_SCHEME_REQUEST, NULL));
     request->priv->webContext = webContext;
-    request->priv->webRequestManager = webRequestManager;
-    request->priv->uri = webURL->string().utf8();
+    request->priv->webRequestManager = webkitWebContextGetRequestManager(webContext);
+    request->priv->uri = urlRequest->resourceRequest().url().string().utf8();
     request->priv->initiatingPage = initiatingPage;
     request->priv->requestID = requestID;
     return request;
 }
 
-uint64_t webkitURISchemeRequestGetID(WebKitURISchemeRequest* request)
-{
-    return request->priv->requestID;
-}
-
 void webkitURISchemeRequestCancel(WebKitURISchemeRequest* request)
 {
     if (request->priv->cancellable.get())
@@ -158,7 +152,8 @@ WebKitWebView* webkit_uri_scheme_request_get_web_view(WebKitURISchemeRequest* re
 {
     g_return_val_if_fail(WEBKIT_IS_URI_SCHEME_REQUEST(request), 0);
 
-    return WEBKIT_WEB_VIEW(request->priv->initiatingPage->viewWidget());
+    // FIXME: initiatingPage is now always null, we need to re-implement this somehow.
+    return request->priv->initiatingPage ? WEBKIT_WEB_VIEW(request->priv->initiatingPage->viewWidget()) : nullptr;
 }
 
 static void webkitURISchemeRequestReadCallback(GInputStream* inputStream, GAsyncResult* result, WebKitURISchemeRequest* schemeRequest)
@@ -174,21 +169,25 @@ static void webkitURISchemeRequestReadCallback(GInputStream* inputStream, GAsync
     WebKitURISchemeRequestPrivate* priv = request->priv;
     RefPtr<API::Data> webData = API::Data::create(reinterpret_cast<const unsigned char*>(priv->readBuffer), bytesRead);
     if (!priv->bytesRead) {
-        // First chunk read. In case of empty reply an empty API::Data is sent to the WebProcess.
-        priv->webRequestManager->didHandleURIRequest(webData.get(), priv->streamLength, String::fromUTF8(priv->mimeType.data()), priv->requestID);
+        // First chunk read. In case of empty reply an empty API::Data is sent to the networking process.
+        WebCore::ResourceResponse response(WebCore::URL(WebCore::URL(), String::fromUTF8(priv->uri)), String::fromUTF8(priv->mimeType.data()),
+            priv->streamLength, emptyString(), emptyString());
+        priv->webRequestManager->didReceiveResponse(priv->requestID, response);
+        priv->webRequestManager->didLoadData(priv->requestID, webData.get());
     } else if (bytesRead || (!bytesRead && !priv->streamLength)) {
-        // Subsequent chunk read. We only send an empty API::Data to the WebProcess when stream length is unknown.
-        priv->webRequestManager->didReceiveURIRequestData(webData.get(), priv->requestID);
+        // Subsequent chunk read. We only send an empty API::Data to the networking process when stream length is unknown.
+        priv->webRequestManager->didLoadData(priv->requestID, webData.get());
     }
 
     if (!bytesRead) {
-        webkitWebContextDidFinishURIRequest(request->priv->webContext, request->priv->requestID);
+        priv->webRequestManager->didFinishLoading(request->priv->requestID);
+        webkitWebContextDidFinishLoadingCustomProtocol(request->priv->webContext, request->priv->requestID);
         return;
     }
 
     priv->bytesRead += bytesRead;
     g_input_stream_read_async(inputStream, priv->readBuffer, gReadBufferSize, G_PRIORITY_DEFAULT, priv->cancellable.get(),
-                              reinterpret_cast<GAsyncReadyCallback>(webkitURISchemeRequestReadCallback), g_object_ref(request.get()));
+        reinterpret_cast<GAsyncReadyCallback>(webkitURISchemeRequestReadCallback), g_object_ref(request.get()));
 }
 
 /**
@@ -213,7 +212,7 @@ void webkit_uri_scheme_request_finish(WebKitURISchemeRequest* request, GInputStr
     request->priv->bytesRead = 0;
     request->priv->mimeType = mimeType;
     g_input_stream_read_async(inputStream, request->priv->readBuffer, gReadBufferSize, G_PRIORITY_DEFAULT, request->priv->cancellable.get(),
-                              reinterpret_cast<GAsyncReadyCallback>(webkitURISchemeRequestReadCallback), g_object_ref(request));
+        reinterpret_cast<GAsyncReadyCallback>(webkitURISchemeRequestReadCallback), g_object_ref(request));
 }
 
 /**
@@ -233,7 +232,6 @@ void webkit_uri_scheme_request_finish_error(WebKitURISchemeRequest* request, GEr
     WebKitURISchemeRequestPrivate* priv = request->priv;
 
     WebCore::ResourceError resourceError(g_quark_to_string(error->domain), error->code, priv->uri.data(), String::fromUTF8(error->message));
-    priv->webRequestManager->didFailURIRequest(resourceError, priv->requestID);
-
-    webkitWebContextDidFinishURIRequest(priv->webContext, priv->requestID);
+    priv->webRequestManager->didFailWithError(priv->requestID, resourceError);
+    webkitWebContextDidFinishLoadingCustomProtocol(priv->webContext, priv->requestID);
 }
index 3867173..5208993 100644 (file)
@@ -24,8 +24,7 @@
 #include "WebKitURISchemeRequest.h"
 #include "WebKitWebContext.h"
 
-WebKitURISchemeRequest* webkitURISchemeRequestCreate(WebKitWebContext*, WebKit::WebSoupRequestManagerProxy*, API::URL*, WebKit::WebPageProxy*, uint64_t requestID);
-uint64_t webkitURISchemeRequestGetID(WebKitURISchemeRequest*);
+WebKitURISchemeRequest* webkitURISchemeRequestCreate(uint64_t requestID, WebKitWebContext*, API::URLRequest*, WebKit::WebPageProxy*);
 void webkitURISchemeRequestCancel(WebKitURISchemeRequest*);
 
 #endif // WebKitURISchemeRequestPrivate_h
index 0a7aad6..6509dde 100644 (file)
@@ -137,7 +137,7 @@ struct _WebKitWebContextPrivate {
     GRefPtr<WebKitCookieManager> cookieManager;
     GRefPtr<WebKitFaviconDatabase> faviconDatabase;
     GRefPtr<WebKitSecurityManager> securityManager;
-    RefPtr<WebSoupRequestManagerProxy> requestManager;
+    RefPtr<WebSoupCustomProtocolRequestManager> requestManager;
     URISchemeHandlerMap uriSchemeHandlers;
     URISchemeRequestMap uriSchemeRequests;
 #if ENABLE(GEOLOCATION)
@@ -226,7 +226,7 @@ static gpointer createDefaultWebContext(gpointer)
     WebKitWebContextPrivate* priv = webContext->priv;
 
     priv->context = WebContext::create(WebCore::filenameToString(injectedBundleFilename().data()));
-    priv->requestManager = webContext->priv->context->supplement<WebSoupRequestManagerProxy>();
+    priv->requestManager = webContext->priv->context->supplement<WebSoupCustomProtocolRequestManager>();
     priv->context->setCacheModel(CacheModelPrimaryWebBrowser);
 #if ENABLE(NETWORK_PROCESS)
     // FIXME: Temporary use an env var until we have API to set the process model. See https://bugs.webkit.org/show_bug.cgi?id=125463.
@@ -642,7 +642,7 @@ 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));
+    context->priv->requestManager->registerSchemeForCustomProtocol(String::fromUTF8(scheme));
 }
 
 /**
@@ -933,34 +933,36 @@ WebContext* webkitWebContextGetContext(WebKitWebContext* context)
     return context->priv->context.get();
 }
 
-WebSoupRequestManagerProxy* webkitWebContextGetRequestManager(WebKitWebContext* context)
+WebSoupCustomProtocolRequestManager* webkitWebContextGetRequestManager(WebKitWebContext* context)
 {
     return context->priv->requestManager.get();
 }
 
-void webkitWebContextReceivedURIRequest(WebKitWebContext* context, WebKitURISchemeRequest* request)
+void webkitWebContextStartLoadingCustomProtocol(WebKitWebContext* context, uint64_t customProtocolID, API::URLRequest* urlRequest)
 {
-    String scheme(String::fromUTF8(webkit_uri_scheme_request_get_scheme(request)));
+    // FIXME: We need to figure out how to get the initiating page.
+    GRefPtr<WebKitURISchemeRequest> request = adoptGRef(webkitURISchemeRequestCreate(customProtocolID, context, urlRequest, nullptr));
+    String scheme(String::fromUTF8(webkit_uri_scheme_request_get_scheme(request.get())));
     RefPtr<WebKitURISchemeHandler> handler = context->priv->uriSchemeHandlers.get(scheme);
     ASSERT(handler.get());
     if (!handler->hasCallback())
         return;
 
-    context->priv->uriSchemeRequests.set(webkitURISchemeRequestGetID(request), request);
-    handler->performCallback(request);
+    context->priv->uriSchemeRequests.set(customProtocolID, request.get());
+    handler->performCallback(request.get());
 }
 
-void webkitWebContextDidFailToLoadURIRequest(WebKitWebContext* context, uint64_t requestID)
+void webkitWebContextStopLoadingCustomProtocol(WebKitWebContext* context, uint64_t customProtocolID)
 {
-    GRefPtr<WebKitURISchemeRequest> request = context->priv->uriSchemeRequests.get(requestID);
+    GRefPtr<WebKitURISchemeRequest> request = context->priv->uriSchemeRequests.get(customProtocolID);
     if (!request.get())
         return;
     webkitURISchemeRequestCancel(request.get());
 }
 
-void webkitWebContextDidFinishURIRequest(WebKitWebContext* context, uint64_t requestID)
+void webkitWebContextDidFinishLoadingCustomProtocol(WebKitWebContext* context, uint64_t customProtocolID)
 {
-    context->priv->uriSchemeRequests.remove(requestID);
+    context->priv->uriSchemeRequests.remove(customProtocolID);
 }
 
 void webkitWebContextCreatePageForWebView(WebKitWebContext* context, WebKitWebView* webView, WebKitWebViewGroup* webViewGroup)
index 980eb79..09c522e 100644 (file)
 #include "DownloadProxy.h"
 #include "WebContext.h"
 #include "WebKitPrivate.h"
-#include "WebKitURISchemeRequest.h"
 #include "WebKitWebContext.h"
 #include "WebKitWebViewGroup.h"
-#include "WebSoupRequestManagerProxy.h"
+#include "WebSoupCustomProtocolRequestManager.h"
 
 WebKit::WebContext* webkitWebContextGetContext(WebKitWebContext*);
 WebKitDownload* webkitWebContextGetOrCreateDownload(WebKit::DownloadProxy*);
 WebKitDownload* webkitWebContextStartDownload(WebKitWebContext*, const char* uri, WebKit::WebPageProxy*);
 void webkitWebContextRemoveDownload(WebKit::DownloadProxy*);
 void webkitWebContextDownloadStarted(WebKitWebContext*, WebKitDownload*);
-WebKit::WebSoupRequestManagerProxy* webkitWebContextGetRequestManager(WebKitWebContext*);
-void webkitWebContextReceivedURIRequest(WebKitWebContext*, WebKitURISchemeRequest*);
-void webkitWebContextDidFailToLoadURIRequest(WebKitWebContext*, uint64_t requestID);
-void webkitWebContextDidFinishURIRequest(WebKitWebContext*, uint64_t requestID);
+WebKit::WebSoupCustomProtocolRequestManager* webkitWebContextGetRequestManager(WebKitWebContext*);
+void webkitWebContextStartLoadingCustomProtocol(WebKitWebContext*, uint64_t customProtocolID, API::URLRequest*);
+void webkitWebContextStopLoadingCustomProtocol(WebKitWebContext*, uint64_t customProtocolID);
+void webkitWebContextDidFinishLoadingCustomProtocol(WebKitWebContext*, uint64_t customProtocolID);
 void webkitWebContextCreatePageForWebView(WebKitWebContext*, WebKitWebView*, WebKitWebViewGroup*);
 void webkitWebContextWebViewDestroyed(WebKitWebContext*, WebKitWebView*);
 WebKitWebView* webkitWebContextGetWebViewForPage(WebKitWebContext*, WebKit::WebPageProxy*);
index 1139d94..fbddf8f 100644 (file)
@@ -33,6 +33,7 @@
 #include "WebInspectorServer.h"
 #include "WebProcessCreationParameters.h"
 #include "WebProcessMessages.h"
+#include "WebSoupCustomProtocolRequestManager.h"
 #include <WebCore/FileSystem.h>
 #include <WebCore/NotImplemented.h>
 #include <WebCore/SchemeRegistry.h>
 #include "NetworkProcessMessages.h"
 #endif
 
-#if ENABLE(CUSTOM_PROTOCOLS)
-#include "WebSoupCustomProtocolRequestManager.h"
-#else
-#include "WebSoupRequestManagerProxy.h"
-#endif
-
 namespace WebKit {
 
 static void initInspectorServer()
@@ -104,11 +99,7 @@ void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& para
     }
 
     if (!usesNetworkProcess()) {
-#if ENABLE(CUSTOM_PROTOCOLS)
         parameters.urlSchemesRegisteredForCustomProtocols = supplement<WebSoupCustomProtocolRequestManager>()->registeredSchemesForCustomProtocols();
-#else
-        parameters.urlSchemesRegistered = supplement<WebSoupRequestManagerProxy>()->registeredURISchemes();
-#endif
 
         supplement<WebCookieManagerProxy>()->getCookiePersistentStorage(parameters.cookiePersistentStoragePath, parameters.cookiePersistentStorageType);
         parameters.cookieAcceptPolicy = m_initialHTTPCookieAcceptPolicy;
index 0c959c4..3c17708 100644 (file)
@@ -70,6 +70,7 @@
 
 #if PLATFORM(GTK)
 #define ENABLE_NETWORK_PROCESS 1
+#define ENABLE_CUSTOM_PROTOCOLS 1
 #endif
 
 /* When C++ exceptions are disabled, the C++ library defines |try| and |catch|
index f92914b..a4684ce 100644 (file)
@@ -1,3 +1,15 @@
+2014-01-27  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] Implement custom URI schemes with CustomProtocols
+        https://bugs.webkit.org/show_bug.cgi?id=127091
+
+        Reviewed by Gustavo Noronha Silva.
+
+        Temporarily disable the WebKitWebView check until we figure out
+        how to implement it with CustomProtocols.
+
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp:
+
 2014-01-26  Alexey Proskuryakov  <ap@apple.com>
 
         REGRESSION(r127412): http/tests/misc/link-rel-icon-beforeload.html is broken.
index 319eec4..4721823 100644 (file)
@@ -146,7 +146,8 @@ public:
         test->m_uriSchemeRequest = request;
         test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request));
 
-        g_assert(webkit_uri_scheme_request_get_web_view(request) == test->m_webView);
+        // FIXME: webkit_uri_scheme_request_get_web_view doesn't work with custom protocols.
+        // g_assert(webkit_uri_scheme_request_get_web_view(request) == test->m_webView);
 
         GRefPtr<GInputStream> inputStream = adoptGRef(g_memory_input_stream_new());
         test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(inputStream.get()));