Title: [149642] trunk
Revision
149642
Author
[email protected]
Date
2013-05-06 14:20:41 -0700 (Mon, 06 May 2013)

Log Message

[GTK] Add webkit_uri_scheme_request_finish_error
https://bugs.webkit.org/show_bug.cgi?id=94316

Patch by Manuel Rego Casasnovas <[email protected]> on 2013-05-06
Reviewed by Anders Carlsson.

Source/WebCore:

No behaviour change, covered by existing tests.

* platform/network/soup/ResourceError.h:
(ResourceError): Rename genericIOError() to genericGError().
* platform/network/soup/ResourceErrorSoup.cpp:
(WebCore::ResourceError::httpError): Use genercicGError() instead of
genericIOError().
(WebCore::ResourceError::genericGError): Use error domain instead of
always return a G_IO_ERROR.
* platform/network/soup/ResourceHandleSoup.cpp: Use genericGError()
instead of genericIOError().
(WebCore::redirectSkipCallback):
(WebCore::readCallback):

Source/WebKit2:

This new method will allow to finish WebKitURISchemeRequest with a
GError that will be passed to the WebKitWebView through the
"load-failed" signal.

* UIProcess/API/gtk/WebKitURISchemeRequest.cpp:
(webkit_uri_scheme_request_finish_error): Implement new method using
WebSoupRequestManagerProxy::didFailURIRequest().
* UIProcess/API/gtk/WebKitURISchemeRequest.h: Add new method header.
* UIProcess/API/gtk/WebKitWebContext.cpp: Include the usage of the new
method in the code example at webkit_web_context_register_uri_scheme()
documentation.
* UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Include the new
method.
* UIProcess/API/gtk/tests/LoadTrackingTest.cpp:
(loadFailedCallback): Set m_error to monitor it from the tests.
(LoadTrackingTest::loadURI): Clear m_error before each load.
(LoadTrackingTest::loadHtml): Ditto.
(LoadTrackingTest::loadPlainText): Ditto.
(LoadTrackingTest::loadRequest): Ditto.
(LoadTrackingTest::reload): Ditto.
(LoadTrackingTest::goBack): Ditto.
(LoadTrackingTest::goForward): Ditto.
* UIProcess/API/gtk/tests/LoadTrackingTest.h: Add new member m_error.
* UIProcess/API/gtk/tests/TestWebKitWebContext.cpp:
(testWebContextURIScheme): Modify test to check the behavior of the new
method.
* UIProcess/soup/WebSoupRequestManagerProxy.cpp:
(WebKit::WebSoupRequestManagerProxy::didFailURIRequest):
(WebKit): Implement new method using
WebSoupRequestManager::DidFailURIRequest().
* UIProcess/soup/WebSoupRequestManagerProxy.h:
(WebSoupRequestManagerProxy): Add new method header.
* WebProcess/soup/WebSoupRequestManager.cpp:
(WebKit):
(WebKit::WebSoupRequestManager::didFailURIRequest): Implement new method
setting the error and completing the request.
* WebProcess/soup/WebSoupRequestManager.h:
(WebSoupRequestManager): Add new method header.
* WebProcess/soup/WebSoupRequestManager.messages.in: Add new method
signature.

Tools:

* MiniBrowser/gtk/main.c:
(miniBrowserErrorQuark): Add function to create a global quark for
MiniBrowser.
(aboutURISchemeRequestCallback): Update MiniBrowser to use the new
function webkit_uri_scheme_request_finish_error().

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (149641 => 149642)


--- trunk/Source/WebCore/ChangeLog	2013-05-06 21:18:30 UTC (rev 149641)
+++ trunk/Source/WebCore/ChangeLog	2013-05-06 21:20:41 UTC (rev 149642)
@@ -1,3 +1,24 @@
+2013-05-06  Manuel Rego Casasnovas  <[email protected]>
+
+        [GTK] Add webkit_uri_scheme_request_finish_error
+        https://bugs.webkit.org/show_bug.cgi?id=94316
+
+        Reviewed by Anders Carlsson.
+
+        No behaviour change, covered by existing tests.
+
+        * platform/network/soup/ResourceError.h:
+        (ResourceError): Rename genericIOError() to genericGError().
+        * platform/network/soup/ResourceErrorSoup.cpp:
+        (WebCore::ResourceError::httpError): Use genercicGError() instead of
+        genericIOError().
+        (WebCore::ResourceError::genericGError): Use error domain instead of
+        always return a G_IO_ERROR.
+        * platform/network/soup/ResourceHandleSoup.cpp: Use genericGError()
+        instead of genericIOError().
+        (WebCore::redirectSkipCallback):
+        (WebCore::readCallback):
+
 2013-05-06  Bem Jones-Bey  <[email protected]>
 
         Heap-use-after-free in WebCore::InlineFlowBox::deleteLine

Modified: trunk/Source/WebCore/platform/network/soup/ResourceError.h (149641 => 149642)


--- trunk/Source/WebCore/platform/network/soup/ResourceError.h	2013-05-06 21:18:30 UTC (rev 149641)
+++ trunk/Source/WebCore/platform/network/soup/ResourceError.h	2013-05-06 21:20:41 UTC (rev 149642)
@@ -51,7 +51,7 @@
 
     static ResourceError httpError(SoupMessage*, GError*, SoupRequest*);
     static ResourceError transportError(SoupRequest*, int statusCode, const String& reasonPhrase);
-    static ResourceError genericIOError(GError*, SoupRequest*);
+    static ResourceError genericGError(GError*, SoupRequest*);
     static ResourceError tlsError(SoupRequest*, unsigned tlsErrors, GTlsCertificate*);
     static ResourceError timeoutError(const String& failingURL);
     static ResourceError authenticationError(SoupMessage*);

Modified: trunk/Source/WebCore/platform/network/soup/ResourceErrorSoup.cpp (149641 => 149642)


--- trunk/Source/WebCore/platform/network/soup/ResourceErrorSoup.cpp	2013-05-06 21:18:30 UTC (rev 149641)
+++ trunk/Source/WebCore/platform/network/soup/ResourceErrorSoup.cpp	2013-05-06 21:20:41 UTC (rev 149642)
@@ -58,7 +58,7 @@
         return transportError(request, message->status_code,
             String::fromUTF8(message->reason_phrase));
     else
-        return genericIOError(error, request);
+        return genericGError(error, request);
 }
 
 ResourceError ResourceError::authenticationError(SoupMessage* message)
@@ -68,9 +68,9 @@
         failingURI(soup_message_get_uri(message)), String::fromUTF8(message->reason_phrase));
 }
 
-ResourceError ResourceError::genericIOError(GError* error, SoupRequest* request)
+ResourceError ResourceError::genericGError(GError* error, SoupRequest* request)
 {
-    return ResourceError(g_quark_to_string(G_IO_ERROR), error->code,
+    return ResourceError(g_quark_to_string(error->domain), error->code,
         failingURI(request), String::fromUTF8(error->message));
 }
 

Modified: trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp (149641 => 149642)


--- trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp	2013-05-06 21:18:30 UTC (rev 149641)
+++ trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp	2013-05-06 21:20:41 UTC (rev 149642)
@@ -526,7 +526,7 @@
     ResourceHandleInternal* d = handle->getInternal();
     gssize bytesSkipped = g_input_stream_read_finish(d->m_inputStream.get(), asyncResult, &error.outPtr());
     if (error) {
-        handle->client()->didFail(handle.get(), ResourceError::genericIOError(error.get(), d->m_soupRequest.get()));
+        handle->client()->didFail(handle.get(), ResourceError::genericGError(error.get(), d->m_soupRequest.get()));
         cleanupSoupRequestOperation(handle.get());
         return;
     }
@@ -1317,7 +1317,7 @@
     gssize bytesRead = g_input_stream_read_finish(d->m_inputStream.get(), asyncResult, &error.outPtr());
 
     if (error) {
-        handle->client()->didFail(handle.get(), ResourceError::genericIOError(error.get(), d->m_soupRequest.get()));
+        handle->client()->didFail(handle.get(), ResourceError::genericGError(error.get(), d->m_soupRequest.get()));
         cleanupSoupRequestOperation(handle.get());
         return;
     }

Modified: trunk/Source/WebKit2/ChangeLog (149641 => 149642)


--- trunk/Source/WebKit2/ChangeLog	2013-05-06 21:18:30 UTC (rev 149641)
+++ trunk/Source/WebKit2/ChangeLog	2013-05-06 21:20:41 UTC (rev 149642)
@@ -1,3 +1,51 @@
+2013-05-06  Manuel Rego Casasnovas  <[email protected]>
+
+        [GTK] Add webkit_uri_scheme_request_finish_error
+        https://bugs.webkit.org/show_bug.cgi?id=94316
+
+        Reviewed by Anders Carlsson.
+
+        This new method will allow to finish WebKitURISchemeRequest with a
+        GError that will be passed to the WebKitWebView through the
+        "load-failed" signal.
+
+        * UIProcess/API/gtk/WebKitURISchemeRequest.cpp:
+        (webkit_uri_scheme_request_finish_error): Implement new method using
+        WebSoupRequestManagerProxy::didFailURIRequest().
+        * UIProcess/API/gtk/WebKitURISchemeRequest.h: Add new method header.
+        * UIProcess/API/gtk/WebKitWebContext.cpp: Include the usage of the new
+        method in the code example at webkit_web_context_register_uri_scheme()
+        documentation.
+        * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Include the new
+        method.
+        * UIProcess/API/gtk/tests/LoadTrackingTest.cpp:
+        (loadFailedCallback): Set m_error to monitor it from the tests.
+        (LoadTrackingTest::loadURI): Clear m_error before each load.
+        (LoadTrackingTest::loadHtml): Ditto.
+        (LoadTrackingTest::loadPlainText): Ditto.
+        (LoadTrackingTest::loadRequest): Ditto.
+        (LoadTrackingTest::reload): Ditto.
+        (LoadTrackingTest::goBack): Ditto.
+        (LoadTrackingTest::goForward): Ditto.
+        * UIProcess/API/gtk/tests/LoadTrackingTest.h: Add new member m_error.
+        * UIProcess/API/gtk/tests/TestWebKitWebContext.cpp:
+        (testWebContextURIScheme): Modify test to check the behavior of the new
+        method.
+        * UIProcess/soup/WebSoupRequestManagerProxy.cpp:
+        (WebKit::WebSoupRequestManagerProxy::didFailURIRequest):
+        (WebKit): Implement new method using
+        WebSoupRequestManager::DidFailURIRequest().
+        * UIProcess/soup/WebSoupRequestManagerProxy.h:
+        (WebSoupRequestManagerProxy): Add new method header.
+        * WebProcess/soup/WebSoupRequestManager.cpp:
+        (WebKit):
+        (WebKit::WebSoupRequestManager::didFailURIRequest): Implement new method
+        setting the error and completing the request.
+        * WebProcess/soup/WebSoupRequestManager.h:
+        (WebSoupRequestManager): Add new method header.
+        * WebProcess/soup/WebSoupRequestManager.messages.in: Add new method
+        signature.
+
 2013-05-06  Anders Carlsson  <[email protected]>
 
         Every LocalStorageDatabase should know about its tracker

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.cpp (149641 => 149642)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.cpp	2013-05-06 21:18:30 UTC (rev 149641)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.cpp	2013-05-06 21:20:41 UTC (rev 149642)
@@ -27,6 +27,7 @@
 #include "WebPageProxy.h"
 #include "WebSoupRequestManagerProxy.h"
 #include <WebCore/GOwnPtrSoup.h>
+#include <WebCore/ResourceError.h>
 #include <libsoup/soup.h>
 #include <wtf/gobject/GRefPtr.h>
 #include <wtf/text/CString.h>
@@ -213,3 +214,25 @@
     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));
 }
+
+/**
+ * webkit_uri_scheme_request_finish_error:
+ * @request: a #WebKitURISchemeRequest
+ * @error: a #GError that will be passed to the #WebKitWebView
+ *
+ * Finish a #WebKitURISchemeRequest with a #GError.
+ *
+ * Since: 2.2
+ */
+void webkit_uri_scheme_request_finish_error(WebKitURISchemeRequest* request, GError* error)
+{
+    g_return_if_fail(WEBKIT_IS_URI_SCHEME_REQUEST(request));
+    g_return_if_fail(error);
+
+    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);
+}

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.h (149641 => 149642)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.h	2013-05-06 21:18:30 UTC (rev 149641)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.h	2013-05-06 21:20:41 UTC (rev 149642)
@@ -72,6 +72,10 @@
                                         gint64                  stream_length,
                                         const gchar            *mime_type);
 
+WEBKIT_API void
+webkit_uri_scheme_request_finish_error (WebKitURISchemeRequest *request,
+                                        GError                 *error);
+
 G_END_DECLS
 
 #endif

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp (149641 => 149642)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp	2013-05-06 21:18:30 UTC (rev 149641)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp	2013-05-06 21:20:41 UTC (rev 149642)
@@ -568,8 +568,9 @@
  * #WebKitWebContext, the #WebKitURISchemeRequestCallback registered will be called with a
  * #WebKitURISchemeRequest.
  * It is possible to handle URI scheme requests asynchronously, by calling g_object_ref() on the
- * #WebKitURISchemeRequest and calling webkit_uri_scheme_request_finish() later when the data of
- * the request is available.
+ * #WebKitURISchemeRequest and calling webkit_uri_scheme_request_finish() later
+ * when the data of the request is available or
+ * webkit_uri_scheme_request_finish_error() in case of error.
  *
  * <informalexample><programlisting>
  * static void
@@ -587,12 +588,19 @@
  *         /<!-- -->* Create a GInputStream with the contents of memory about page, and set its length to stream_length *<!-- -->/
  *     } else if (!g_strcmp0 (path, "applications")) {
  *         /<!-- -->* Create a GInputStream with the contents of applications about page, and set its length to stream_length *<!-- -->/
- *     } else {
+ *     } else if (!g_strcmp0 (path, "example")) {
  *         gchar *contents;
  *
- *         contents = g_strdup_printf ("&lt;html&gt;&lt;body&gt;&lt;p&gt;Invalid about:%s page&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;", path);
+ *         contents = g_strdup_printf ("&lt;html&gt;&lt;body&gt;&lt;p&gt;Example about page&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;");
  *         stream_length = strlen (contents);
  *         stream = g_memory_input_stream_new_from_data (contents, stream_length, g_free);
+ *     } else {
+ *         GError *error;
+ *
+ *         error = g_error_new (ABOUT_HANDLER_ERROR, ABOUT_HANDLER_ERROR_INVALID, "Invalid about:%s page.", path);
+ *         webkit_uri_scheme_request_finish_error (request, error);
+ *         g_error_free (error);
+ *         return;
  *     }
  *     webkit_uri_scheme_request_finish (request, stream, stream_length, "text/html");
  *     g_object_unref (stream);

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt (149641 => 149642)


--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt	2013-05-06 21:18:30 UTC (rev 149641)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt	2013-05-06 21:20:41 UTC (rev 149642)
@@ -806,6 +806,7 @@
 webkit_uri_scheme_request_get_path
 webkit_uri_scheme_request_get_web_view
 webkit_uri_scheme_request_finish
+webkit_uri_scheme_request_finish_error
 
 <SUBSECTION Standard>
 WebKitURISchemeRequestClass

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp (149641 => 149642)


--- trunk/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp	2013-05-06 21:18:30 UTC (rev 149641)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp	2013-05-06 21:20:41 UTC (rev 149642)
@@ -63,6 +63,7 @@
 static void loadFailedCallback(WebKitWebView* webView, WebKitLoadEvent loadEvent, const char* failingURI, GError* error, LoadTrackingTest* test)
 {
     test->m_loadFailed = true;
+    test->m_error.set(g_error_copy(error));
 
     switch (loadEvent) {
     case WEBKIT_LOAD_STARTED:
@@ -153,6 +154,7 @@
 {
     m_loadEvents.clear();
     m_estimatedProgress = 0;
+    m_error.clear();
     WebViewTest::loadURI(uri);
 }
 
@@ -160,6 +162,7 @@
 {
     m_loadEvents.clear();
     m_estimatedProgress = 0;
+    m_error.clear();
     WebViewTest::loadHtml(html, baseURI);
 }
 
@@ -167,6 +170,7 @@
 {
     m_loadEvents.clear();
     m_estimatedProgress = 0;
+    m_error.clear();
     WebViewTest::loadPlainText(plainText);
 }
 
@@ -174,6 +178,7 @@
 {
     m_loadEvents.clear();
     m_estimatedProgress = 0;
+    m_error.clear();
     WebViewTest::loadRequest(request);
 }
 
@@ -181,6 +186,7 @@
 {
     m_loadEvents.clear();
     m_estimatedProgress = 0;
+    m_error.clear();
     webkit_web_view_reload(m_webView);
 }
 
@@ -188,6 +194,7 @@
 {
     m_loadEvents.clear();
     m_estimatedProgress = 0;
+    m_error.clear();
     WebViewTest::goBack();
 }
 
@@ -195,5 +202,6 @@
 {
     m_loadEvents.clear();
     m_estimatedProgress = 0;
+    m_error.clear();
     WebViewTest::goForward();
 }

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.h (149641 => 149642)


--- trunk/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.h	2013-05-06 21:18:30 UTC (rev 149641)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.h	2013-05-06 21:20:41 UTC (rev 149642)
@@ -59,6 +59,7 @@
     };
     bool m_runLoadUntilCompletion;
     bool m_loadFailed;
+    GOwnPtr<GError> m_error;
     Vector<LoadEvents> m_loadEvents;
     float m_estimatedProgress;
     CString m_redirectURI;

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp (149641 => 149642)


--- trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp	2013-05-06 21:18:30 UTC (rev 149641)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp	2013-05-06 21:20:41 UTC (rev 149642)
@@ -114,6 +114,9 @@
 
 static const char* kBarHTML = "<html><body>Bar</body></html>";
 static const char* kEchoHTMLFormat = "<html><body>%s</body></html>";
+static const char* errorDomain = "test";
+static const int errorCode = 10;
+static const char* errorMessage = "Error message.";
 
 class URISchemeTest: public LoadTrackingTest {
 public:
@@ -122,22 +125,19 @@
     struct URISchemeHandler {
         URISchemeHandler()
             : replyLength(0)
-            , replyWithPath(false)
         {
         }
 
-        URISchemeHandler(const char* reply, int replyLength, const char* mimeType, bool replyWithPath = false)
+        URISchemeHandler(const char* reply, int replyLength, const char* mimeType)
             : reply(reply)
             , replyLength(replyLength)
             , mimeType(mimeType)
-            , replyWithPath(replyWithPath)
         {
         }
 
         CString reply;
         int replyLength;
         CString mimeType;
-        bool replyWithPath;
     };
 
     static void uriSchemeRequestCallback(WebKitURISchemeRequest* request, gpointer userData)
@@ -151,22 +151,30 @@
         GRefPtr<GInputStream> inputStream = adoptGRef(g_memory_input_stream_new());
         test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(inputStream.get()));
 
-        String scheme(String::fromUTF8(webkit_uri_scheme_request_get_scheme(request)));
-        g_assert(!scheme.isEmpty());
-        g_assert(test->m_handlersMap.contains(scheme));
-        const URISchemeHandler& handler = test->m_handlersMap.get(scheme);
+        const char* scheme = webkit_uri_scheme_request_get_scheme(request);
+        g_assert(scheme);
+        g_assert(test->m_handlersMap.contains(String::fromUTF8(scheme)));
 
-        if (handler.replyWithPath) {
+        if (!g_strcmp0(scheme, "error")) {
+            GOwnPtr<GError> error(g_error_new_literal(g_quark_from_string(errorDomain), errorCode, errorMessage));
+            webkit_uri_scheme_request_finish_error(request, error.get());
+            return;
+        }
+
+        const URISchemeHandler& handler = test->m_handlersMap.get(String::fromUTF8(scheme));
+
+        if (!g_strcmp0(scheme, "echo")) {
             char* replyHTML = g_strdup_printf(handler.reply.data(), webkit_uri_scheme_request_get_path(request));
             g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(inputStream.get()), replyHTML, strlen(replyHTML), g_free);
         } else if (!handler.reply.isNull())
             g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(inputStream.get()), handler.reply.data(), handler.reply.length(), 0);
+
         webkit_uri_scheme_request_finish(request, inputStream.get(), handler.replyLength, handler.mimeType.data());
     }
 
-    void registerURISchemeHandler(const char* scheme, const char* reply, int replyLength, const char* mimeType, bool replyWithPath = false)
+    void registerURISchemeHandler(const char* scheme, const char* reply, int replyLength, const char* mimeType)
     {
-        m_handlersMap.set(String::fromUTF8(scheme), URISchemeHandler(reply, replyLength, mimeType, replyWithPath));
+        m_handlersMap.set(String::fromUTF8(scheme), URISchemeHandler(reply, replyLength, mimeType));
         webkit_web_context_register_uri_scheme(webkit_web_context_get_default(), scheme, uriSchemeRequestCallback, this, 0);
     }
 
@@ -184,7 +192,7 @@
     g_assert_cmpint(mainResourceDataSize, ==, strlen(kBarHTML));
     g_assert(!strncmp(mainResourceData, kBarHTML, mainResourceDataSize));
 
-    test->registerURISchemeHandler("echo", kEchoHTMLFormat, -1, "text/html", true);
+    test->registerURISchemeHandler("echo", kEchoHTMLFormat, -1, "text/html");
     test->loadURI("echo:hello world");
     test->waitUntilLoadFinished();
     GOwnPtr<char> echoHTML(g_strdup_printf(kEchoHTMLFormat, webkit_uri_scheme_request_get_path(test->m_uriSchemeRequest.get())));
@@ -205,6 +213,15 @@
     test->waitUntilLoadFinished();
     g_assert(!test->m_loadEvents.contains(LoadTrackingTest::ProvisionalLoadFailed));
     g_assert(!test->m_loadEvents.contains(LoadTrackingTest::LoadFailed));
+
+    test->registerURISchemeHandler("error", 0, 0, 0);
+    test->m_loadEvents.clear();
+    test->loadURI("error:error");
+    test->waitUntilLoadFinished();
+    g_assert(test->m_loadEvents.contains(LoadTrackingTest::ProvisionalLoadFailed));
+    g_assert(test->m_loadFailed);
+    g_assert_error(test->m_error.get(), g_quark_from_string(errorDomain), errorCode);
+    g_assert_cmpstr(test->m_error->message, ==, errorMessage);
 }
 
 static void testWebContextSpellChecker(Test* test, gconstpointer)

Modified: trunk/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerProxy.cpp (149641 => 149642)


--- trunk/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerProxy.cpp	2013-05-06 21:18:30 UTC (rev 149641)
+++ trunk/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerProxy.cpp	2013-05-06 21:20:41 UTC (rev 149642)
@@ -116,4 +116,13 @@
     m_client.didFailToLoadURIRequest(this, requestID);
 }
 
+void WebSoupRequestManagerProxy::didFailURIRequest(const WebCore::ResourceError& error, uint64_t requestID)
+{
+    if (!context())
+        return;
+
+    m_loadFailed = true;
+    context()->sendToAllProcesses(Messages::WebSoupRequestManager::DidFailURIRequest(error, requestID));
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerProxy.h (149641 => 149642)


--- trunk/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerProxy.h	2013-05-06 21:18:30 UTC (rev 149641)
+++ trunk/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerProxy.h	2013-05-06 21:20:41 UTC (rev 149642)
@@ -47,6 +47,7 @@
     void didHandleURIRequest(const WebData*, uint64_t contentLength, const String& mimeType, uint64_t requestID);
     void didReceiveURIRequestData(const WebData*, uint64_t requestID);
     void didReceiveURIRequest(const String& uriString, WebPageProxy*, uint64_t requestID);
+    void didFailURIRequest(const WebCore::ResourceError&, uint64_t requestID);
 
     const Vector<String>& registeredURISchemes() const { return m_registeredURISchemes; }
 

Modified: trunk/Source/WebKit2/WebProcess/soup/WebSoupRequestManager.cpp (149641 => 149642)


--- trunk/Source/WebKit2/WebProcess/soup/WebSoupRequestManager.cpp	2013-05-06 21:18:30 UTC (rev 149641)
+++ trunk/Source/WebKit2/WebProcess/soup/WebSoupRequestManager.cpp	2013-05-06 21:20:41 UTC (rev 149642)
@@ -155,6 +155,22 @@
         m_requestMap.remove(requestID);
 }
 
+void WebSoupRequestManager::didFailURIRequest(const WebCore::ResourceError& error, uint64_t requestID)
+{
+    WebSoupRequestAsyncData* data = ""
+    ASSERT(data);
+    GRefPtr<GSimpleAsyncResult> result = data->releaseResult();
+    ASSERT(result.get());
+
+    g_simple_async_result_take_error(result.get(),
+        g_error_new_literal(g_quark_from_string(error.domain().utf8().data()),
+            error.errorCode(),
+            error.localizedDescription().utf8().data()));
+    g_simple_async_result_complete(result.get());
+
+    m_requestMap.remove(requestID);
+}
+
 void WebSoupRequestManager::send(GSimpleAsyncResult* result, GCancellable* cancellable)
 {
     GRefPtr<WebKitSoupRequestGeneric> request = adoptGRef(WEBKIT_SOUP_REQUEST_GENERIC(g_async_result_get_source_object(G_ASYNC_RESULT(result))));

Modified: trunk/Source/WebKit2/WebProcess/soup/WebSoupRequestManager.h (149641 => 149642)


--- trunk/Source/WebKit2/WebProcess/soup/WebSoupRequestManager.h	2013-05-06 21:18:30 UTC (rev 149641)
+++ trunk/Source/WebKit2/WebProcess/soup/WebSoupRequestManager.h	2013-05-06 21:20:41 UTC (rev 149642)
@@ -22,6 +22,7 @@
 
 #include "DataReference.h"
 #include "MessageReceiver.h"
+#include <WebCore/ResourceError.h>
 #include <wtf/HashMap.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/OwnPtr.h>
@@ -53,6 +54,7 @@
 
     void didHandleURIRequest(const CoreIPC::DataReference&, uint64_t contentLength, const String& mimeType, uint64_t requestID);
     void didReceiveURIRequestData(const CoreIPC::DataReference&, uint64_t requestID);
+    void didFailURIRequest(const WebCore::ResourceError&, uint64_t requestID);
 
     WebProcess* m_process;
     GRefPtr<GPtrArray> m_schemes;

Modified: trunk/Source/WebKit2/WebProcess/soup/WebSoupRequestManager.messages.in (149641 => 149642)


--- trunk/Source/WebKit2/WebProcess/soup/WebSoupRequestManager.messages.in	2013-05-06 21:18:30 UTC (rev 149641)
+++ trunk/Source/WebKit2/WebProcess/soup/WebSoupRequestManager.messages.in	2013-05-06 21:20:41 UTC (rev 149642)
@@ -24,4 +24,5 @@
     RegisterURIScheme(WTF::String uriScheme);
     DidHandleURIRequest(CoreIPC::DataReference requestData, uint64_t contentLength, WTF::String mimeType, uint64_t requestID);
     DidReceiveURIRequestData(CoreIPC::DataReference requestData, uint64_t requestID);
+    DidFailURIRequest(WebCore::ResourceError error, uint64_t requestID);
 }

Modified: trunk/Tools/ChangeLog (149641 => 149642)


--- trunk/Tools/ChangeLog	2013-05-06 21:18:30 UTC (rev 149641)
+++ trunk/Tools/ChangeLog	2013-05-06 21:20:41 UTC (rev 149642)
@@ -1,3 +1,16 @@
+2013-05-06  Manuel Rego Casasnovas  <[email protected]>
+
+        [GTK] Add webkit_uri_scheme_request_finish_error
+        https://bugs.webkit.org/show_bug.cgi?id=94316
+
+        Reviewed by Anders Carlsson.
+
+        * MiniBrowser/gtk/main.c:
+        (miniBrowserErrorQuark): Add function to create a global quark for
+        MiniBrowser.
+        (aboutURISchemeRequestCallback): Update MiniBrowser to use the new
+        function webkit_uri_scheme_request_finish_error().
+
 2013-05-06  Mike Lattanzio  <[email protected]>
 
         [BlackBerry] Enable and Expose Text Autosizing through BlackBerry::WebKit::WebSettings

Modified: trunk/Tools/MiniBrowser/gtk/main.c (149641 => 149642)


--- trunk/Tools/MiniBrowser/gtk/main.c	2013-05-06 21:18:30 UTC (rev 149641)
+++ trunk/Tools/MiniBrowser/gtk/main.c	2013-05-06 21:20:41 UTC (rev 149642)
@@ -31,9 +31,20 @@
 #include <string.h>
 #include <webkit2/webkit2.h>
 
+#define MINI_BROWSER_ERROR (miniBrowserErrorQuark())
+
 static const gchar **uriArguments = NULL;
 static const char *miniBrowserAboutScheme = "minibrowser-about";
 
+typedef enum {
+    MINI_BROWSER_ERROR_INVALID_ABOUT_PATH
+} MiniBrowserError;
+
+static GQuark miniBrowserErrorQuark()
+{
+    return g_quark_from_string("minibrowser-quark");
+}
+
 static gchar *argumentToURL(const char *filename)
 {
     GFile *gfile = g_file_new_for_commandline_arg(filename);
@@ -206,21 +217,24 @@
     gsize streamLength;
     const gchar *path;
     gchar *contents;
+    GError *error;
 
     path = webkit_uri_scheme_request_get_path(request);
-    if (!g_strcmp0(path, "minibrowser"))
+    if (!g_strcmp0(path, "minibrowser")) {
         contents = g_strdup_printf("<html><body><h1>WebKitGTK+ MiniBrowser</h1><p>The WebKit2 test browser of the GTK+ port.</p><p>WebKit version: %d.%d.%d</p></body></html>",
             webkit_get_major_version(),
             webkit_get_minor_version(),
             webkit_get_micro_version());
-    else
-        contents = g_strdup_printf("<html><body><p>Invalid about:%s page.</p></body></html>", path);
+        streamLength = strlen(contents);
+        stream = g_memory_input_stream_new_from_data(contents, streamLength, g_free);
 
-    streamLength = strlen(contents);
-    stream = g_memory_input_stream_new_from_data(contents, streamLength, g_free);
-
-    webkit_uri_scheme_request_finish(request, stream, streamLength, "text/html");
-    g_object_unref(stream);
+        webkit_uri_scheme_request_finish(request, stream, streamLength, "text/html");
+        g_object_unref(stream);
+    } else {
+        error = g_error_new(MINI_BROWSER_ERROR, MINI_BROWSER_ERROR_INVALID_ABOUT_PATH, "Invalid about:%s page.", path);
+        webkit_uri_scheme_request_finish_error(request, error);
+        g_error_free(error);
+    }
 }
 
 int main(int argc, char *argv[])
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to