Changeset 149642 in webkit


Ignore:
Timestamp:
May 6, 2013 2:20:41 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

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

Patch by Manuel Rego Casasnovas <Manuel Rego Casasnovas> 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().

Location:
trunk
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r149641 r149642  
     12013-05-06  Manuel Rego Casasnovas  <rego@igalia.com>
     2
     3        [GTK] Add webkit_uri_scheme_request_finish_error
     4        https://bugs.webkit.org/show_bug.cgi?id=94316
     5
     6        Reviewed by Anders Carlsson.
     7
     8        No behaviour change, covered by existing tests.
     9
     10        * platform/network/soup/ResourceError.h:
     11        (ResourceError): Rename genericIOError() to genericGError().
     12        * platform/network/soup/ResourceErrorSoup.cpp:
     13        (WebCore::ResourceError::httpError): Use genercicGError() instead of
     14        genericIOError().
     15        (WebCore::ResourceError::genericGError): Use error domain instead of
     16        always return a G_IO_ERROR.
     17        * platform/network/soup/ResourceHandleSoup.cpp: Use genericGError()
     18        instead of genericIOError().
     19        (WebCore::redirectSkipCallback):
     20        (WebCore::readCallback):
     21
    1222013-05-06  Bem Jones-Bey  <bjonesbe@adobe.com>
    223
  • trunk/Source/WebCore/platform/network/soup/ResourceError.h

    r139239 r149642  
    5252    static ResourceError httpError(SoupMessage*, GError*, SoupRequest*);
    5353    static ResourceError transportError(SoupRequest*, int statusCode, const String& reasonPhrase);
    54     static ResourceError genericIOError(GError*, SoupRequest*);
     54    static ResourceError genericGError(GError*, SoupRequest*);
    5555    static ResourceError tlsError(SoupRequest*, unsigned tlsErrors, GTlsCertificate*);
    5656    static ResourceError timeoutError(const String& failingURL);
  • trunk/Source/WebCore/platform/network/soup/ResourceErrorSoup.cpp

    r148507 r149642  
    5959            String::fromUTF8(message->reason_phrase));
    6060    else
    61         return genericIOError(error, request);
     61        return genericGError(error, request);
    6262}
    6363
     
    6969}
    7070
    71 ResourceError ResourceError::genericIOError(GError* error, SoupRequest* request)
     71ResourceError ResourceError::genericGError(GError* error, SoupRequest* request)
    7272{
    73     return ResourceError(g_quark_to_string(G_IO_ERROR), error->code,
     73    return ResourceError(g_quark_to_string(error->domain), error->code,
    7474        failingURI(request), String::fromUTF8(error->message));
    7575}
  • trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp

    r149383 r149642  
    527527    gssize bytesSkipped = g_input_stream_read_finish(d->m_inputStream.get(), asyncResult, &error.outPtr());
    528528    if (error) {
    529         handle->client()->didFail(handle.get(), ResourceError::genericIOError(error.get(), d->m_soupRequest.get()));
     529        handle->client()->didFail(handle.get(), ResourceError::genericGError(error.get(), d->m_soupRequest.get()));
    530530        cleanupSoupRequestOperation(handle.get());
    531531        return;
     
    13181318
    13191319    if (error) {
    1320         handle->client()->didFail(handle.get(), ResourceError::genericIOError(error.get(), d->m_soupRequest.get()));
     1320        handle->client()->didFail(handle.get(), ResourceError::genericGError(error.get(), d->m_soupRequest.get()));
    13211321        cleanupSoupRequestOperation(handle.get());
    13221322        return;
  • trunk/Source/WebKit2/ChangeLog

    r149639 r149642  
     12013-05-06  Manuel Rego Casasnovas  <rego@igalia.com>
     2
     3        [GTK] Add webkit_uri_scheme_request_finish_error
     4        https://bugs.webkit.org/show_bug.cgi?id=94316
     5
     6        Reviewed by Anders Carlsson.
     7
     8        This new method will allow to finish WebKitURISchemeRequest with a
     9        GError that will be passed to the WebKitWebView through the
     10        "load-failed" signal.
     11
     12        * UIProcess/API/gtk/WebKitURISchemeRequest.cpp:
     13        (webkit_uri_scheme_request_finish_error): Implement new method using
     14        WebSoupRequestManagerProxy::didFailURIRequest().
     15        * UIProcess/API/gtk/WebKitURISchemeRequest.h: Add new method header.
     16        * UIProcess/API/gtk/WebKitWebContext.cpp: Include the usage of the new
     17        method in the code example at webkit_web_context_register_uri_scheme()
     18        documentation.
     19        * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Include the new
     20        method.
     21        * UIProcess/API/gtk/tests/LoadTrackingTest.cpp:
     22        (loadFailedCallback): Set m_error to monitor it from the tests.
     23        (LoadTrackingTest::loadURI): Clear m_error before each load.
     24        (LoadTrackingTest::loadHtml): Ditto.
     25        (LoadTrackingTest::loadPlainText): Ditto.
     26        (LoadTrackingTest::loadRequest): Ditto.
     27        (LoadTrackingTest::reload): Ditto.
     28        (LoadTrackingTest::goBack): Ditto.
     29        (LoadTrackingTest::goForward): Ditto.
     30        * UIProcess/API/gtk/tests/LoadTrackingTest.h: Add new member m_error.
     31        * UIProcess/API/gtk/tests/TestWebKitWebContext.cpp:
     32        (testWebContextURIScheme): Modify test to check the behavior of the new
     33        method.
     34        * UIProcess/soup/WebSoupRequestManagerProxy.cpp:
     35        (WebKit::WebSoupRequestManagerProxy::didFailURIRequest):
     36        (WebKit): Implement new method using
     37        WebSoupRequestManager::DidFailURIRequest().
     38        * UIProcess/soup/WebSoupRequestManagerProxy.h:
     39        (WebSoupRequestManagerProxy): Add new method header.
     40        * WebProcess/soup/WebSoupRequestManager.cpp:
     41        (WebKit):
     42        (WebKit::WebSoupRequestManager::didFailURIRequest): Implement new method
     43        setting the error and completing the request.
     44        * WebProcess/soup/WebSoupRequestManager.h:
     45        (WebSoupRequestManager): Add new method header.
     46        * WebProcess/soup/WebSoupRequestManager.messages.in: Add new method
     47        signature.
     48
    1492013-05-06  Anders Carlsson  <andersca@apple.com>
    250
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.cpp

    r137469 r149642  
    2828#include "WebSoupRequestManagerProxy.h"
    2929#include <WebCore/GOwnPtrSoup.h>
     30#include <WebCore/ResourceError.h>
    3031#include <libsoup/soup.h>
    3132#include <wtf/gobject/GRefPtr.h>
     
    214215                              reinterpret_cast<GAsyncReadyCallback>(webkitURISchemeRequestReadCallback), g_object_ref(request));
    215216}
     217
     218/**
     219 * webkit_uri_scheme_request_finish_error:
     220 * @request: a #WebKitURISchemeRequest
     221 * @error: a #GError that will be passed to the #WebKitWebView
     222 *
     223 * Finish a #WebKitURISchemeRequest with a #GError.
     224 *
     225 * Since: 2.2
     226 */
     227void webkit_uri_scheme_request_finish_error(WebKitURISchemeRequest* request, GError* error)
     228{
     229    g_return_if_fail(WEBKIT_IS_URI_SCHEME_REQUEST(request));
     230    g_return_if_fail(error);
     231
     232    WebKitURISchemeRequestPrivate* priv = request->priv;
     233
     234    WebCore::ResourceError resourceError(g_quark_to_string(error->domain), error->code, priv->uri.data(), String::fromUTF8(error->message));
     235    priv->webRequestManager->didFailURIRequest(resourceError, priv->requestID);
     236
     237    webkitWebContextDidFinishURIRequest(priv->webContext, priv->requestID);
     238}
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.h

    r148679 r149642  
    7373                                        const gchar            *mime_type);
    7474
     75WEBKIT_API void
     76webkit_uri_scheme_request_finish_error (WebKitURISchemeRequest *request,
     77                                        GError                 *error);
     78
    7579G_END_DECLS
    7680
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp

    r149117 r149642  
    569569 * #WebKitURISchemeRequest.
    570570 * It is possible to handle URI scheme requests asynchronously, by calling g_object_ref() on the
    571  * #WebKitURISchemeRequest and calling webkit_uri_scheme_request_finish() later when the data of
    572  * the request is available.
     571 * #WebKitURISchemeRequest and calling webkit_uri_scheme_request_finish() later
     572 * when the data of the request is available or
     573 * webkit_uri_scheme_request_finish_error() in case of error.
    573574 *
    574575 * <informalexample><programlisting>
     
    588589 *     } else if (!g_strcmp0 (path, "applications")) {
    589590 *         /<!-- -->* Create a GInputStream with the contents of applications about page, and set its length to stream_length *<!-- -->/
    590  *     } else {
     591 *     } else if (!g_strcmp0 (path, "example")) {
    591592 *         gchar *contents;
    592593 *
    593  *         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);
     594 *         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;");
    594595 *         stream_length = strlen (contents);
    595596 *         stream = g_memory_input_stream_new_from_data (contents, stream_length, g_free);
     597 *     } else {
     598 *         GError *error;
     599 *
     600 *         error = g_error_new (ABOUT_HANDLER_ERROR, ABOUT_HANDLER_ERROR_INVALID, "Invalid about:%s page.", path);
     601 *         webkit_uri_scheme_request_finish_error (request, error);
     602 *         g_error_free (error);
     603 *         return;
    596604 *     }
    597605 *     webkit_uri_scheme_request_finish (request, stream, stream_length, "text/html");
  • trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt

    r149440 r149642  
    807807webkit_uri_scheme_request_get_web_view
    808808webkit_uri_scheme_request_finish
     809webkit_uri_scheme_request_finish_error
    809810
    810811<SUBSECTION Standard>
  • trunk/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp

    r129223 r149642  
    6464{
    6565    test->m_loadFailed = true;
     66    test->m_error.set(g_error_copy(error));
    6667
    6768    switch (loadEvent) {
     
    154155    m_loadEvents.clear();
    155156    m_estimatedProgress = 0;
     157    m_error.clear();
    156158    WebViewTest::loadURI(uri);
    157159}
     
    161163    m_loadEvents.clear();
    162164    m_estimatedProgress = 0;
     165    m_error.clear();
    163166    WebViewTest::loadHtml(html, baseURI);
    164167}
     
    168171    m_loadEvents.clear();
    169172    m_estimatedProgress = 0;
     173    m_error.clear();
    170174    WebViewTest::loadPlainText(plainText);
    171175}
     
    175179    m_loadEvents.clear();
    176180    m_estimatedProgress = 0;
     181    m_error.clear();
    177182    WebViewTest::loadRequest(request);
    178183}
     
    182187    m_loadEvents.clear();
    183188    m_estimatedProgress = 0;
     189    m_error.clear();
    184190    webkit_web_view_reload(m_webView);
    185191}
     
    189195    m_loadEvents.clear();
    190196    m_estimatedProgress = 0;
     197    m_error.clear();
    191198    WebViewTest::goBack();
    192199}
     
    196203    m_loadEvents.clear();
    197204    m_estimatedProgress = 0;
     205    m_error.clear();
    198206    WebViewTest::goForward();
    199207}
  • trunk/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.h

    r124456 r149642  
    6060    bool m_runLoadUntilCompletion;
    6161    bool m_loadFailed;
     62    GOwnPtr<GError> m_error;
    6263    Vector<LoadEvents> m_loadEvents;
    6364    float m_estimatedProgress;
  • trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp

    r130507 r149642  
    115115static const char* kBarHTML = "<html><body>Bar</body></html>";
    116116static const char* kEchoHTMLFormat = "<html><body>%s</body></html>";
     117static const char* errorDomain = "test";
     118static const int errorCode = 10;
     119static const char* errorMessage = "Error message.";
    117120
    118121class URISchemeTest: public LoadTrackingTest {
     
    123126        URISchemeHandler()
    124127            : replyLength(0)
    125             , replyWithPath(false)
    126128        {
    127129        }
    128130
    129         URISchemeHandler(const char* reply, int replyLength, const char* mimeType, bool replyWithPath = false)
     131        URISchemeHandler(const char* reply, int replyLength, const char* mimeType)
    130132            : reply(reply)
    131133            , replyLength(replyLength)
    132134            , mimeType(mimeType)
    133             , replyWithPath(replyWithPath)
    134135        {
    135136        }
     
    138139        int replyLength;
    139140        CString mimeType;
    140         bool replyWithPath;
    141141    };
    142142
     
    152152        test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(inputStream.get()));
    153153
    154         String scheme(String::fromUTF8(webkit_uri_scheme_request_get_scheme(request)));
    155         g_assert(!scheme.isEmpty());
    156         g_assert(test->m_handlersMap.contains(scheme));
    157         const URISchemeHandler& handler = test->m_handlersMap.get(scheme);
    158 
    159         if (handler.replyWithPath) {
     154        const char* scheme = webkit_uri_scheme_request_get_scheme(request);
     155        g_assert(scheme);
     156        g_assert(test->m_handlersMap.contains(String::fromUTF8(scheme)));
     157
     158        if (!g_strcmp0(scheme, "error")) {
     159            GOwnPtr<GError> error(g_error_new_literal(g_quark_from_string(errorDomain), errorCode, errorMessage));
     160            webkit_uri_scheme_request_finish_error(request, error.get());
     161            return;
     162        }
     163
     164        const URISchemeHandler& handler = test->m_handlersMap.get(String::fromUTF8(scheme));
     165
     166        if (!g_strcmp0(scheme, "echo")) {
    160167            char* replyHTML = g_strdup_printf(handler.reply.data(), webkit_uri_scheme_request_get_path(request));
    161168            g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(inputStream.get()), replyHTML, strlen(replyHTML), g_free);
    162169        } else if (!handler.reply.isNull())
    163170            g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(inputStream.get()), handler.reply.data(), handler.reply.length(), 0);
     171
    164172        webkit_uri_scheme_request_finish(request, inputStream.get(), handler.replyLength, handler.mimeType.data());
    165173    }
    166174
    167     void registerURISchemeHandler(const char* scheme, const char* reply, int replyLength, const char* mimeType, bool replyWithPath = false)
    168     {
    169         m_handlersMap.set(String::fromUTF8(scheme), URISchemeHandler(reply, replyLength, mimeType, replyWithPath));
     175    void registerURISchemeHandler(const char* scheme, const char* reply, int replyLength, const char* mimeType)
     176    {
     177        m_handlersMap.set(String::fromUTF8(scheme), URISchemeHandler(reply, replyLength, mimeType));
    170178        webkit_web_context_register_uri_scheme(webkit_web_context_get_default(), scheme, uriSchemeRequestCallback, this, 0);
    171179    }
     
    185193    g_assert(!strncmp(mainResourceData, kBarHTML, mainResourceDataSize));
    186194
    187     test->registerURISchemeHandler("echo", kEchoHTMLFormat, -1, "text/html", true);
     195    test->registerURISchemeHandler("echo", kEchoHTMLFormat, -1, "text/html");
    188196    test->loadURI("echo:hello world");
    189197    test->waitUntilLoadFinished();
     
    206214    g_assert(!test->m_loadEvents.contains(LoadTrackingTest::ProvisionalLoadFailed));
    207215    g_assert(!test->m_loadEvents.contains(LoadTrackingTest::LoadFailed));
     216
     217    test->registerURISchemeHandler("error", 0, 0, 0);
     218    test->m_loadEvents.clear();
     219    test->loadURI("error:error");
     220    test->waitUntilLoadFinished();
     221    g_assert(test->m_loadEvents.contains(LoadTrackingTest::ProvisionalLoadFailed));
     222    g_assert(test->m_loadFailed);
     223    g_assert_error(test->m_error.get(), g_quark_from_string(errorDomain), errorCode);
     224    g_assert_cmpstr(test->m_error->message, ==, errorMessage);
    208225}
    209226
  • trunk/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerProxy.cpp

    r141658 r149642  
    117117}
    118118
     119void WebSoupRequestManagerProxy::didFailURIRequest(const WebCore::ResourceError& error, uint64_t requestID)
     120{
     121    if (!context())
     122        return;
     123
     124    m_loadFailed = true;
     125    context()->sendToAllProcesses(Messages::WebSoupRequestManager::DidFailURIRequest(error, requestID));
     126}
     127
    119128} // namespace WebKit
  • trunk/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerProxy.h

    r147403 r149642  
    4848    void didReceiveURIRequestData(const WebData*, uint64_t requestID);
    4949    void didReceiveURIRequest(const String& uriString, WebPageProxy*, uint64_t requestID);
     50    void didFailURIRequest(const WebCore::ResourceError&, uint64_t requestID);
    5051
    5152    const Vector<String>& registeredURISchemes() const { return m_registeredURISchemes; }
  • trunk/Source/WebKit2/WebProcess/soup/WebSoupRequestManager.cpp

    r148507 r149642  
    156156}
    157157
     158void WebSoupRequestManager::didFailURIRequest(const WebCore::ResourceError& error, uint64_t requestID)
     159{
     160    WebSoupRequestAsyncData* data = m_requestMap.get(requestID);
     161    ASSERT(data);
     162    GRefPtr<GSimpleAsyncResult> result = data->releaseResult();
     163    ASSERT(result.get());
     164
     165    g_simple_async_result_take_error(result.get(),
     166        g_error_new_literal(g_quark_from_string(error.domain().utf8().data()),
     167            error.errorCode(),
     168            error.localizedDescription().utf8().data()));
     169    g_simple_async_result_complete(result.get());
     170
     171    m_requestMap.remove(requestID);
     172}
     173
    158174void WebSoupRequestManager::send(GSimpleAsyncResult* result, GCancellable* cancellable)
    159175{
  • trunk/Source/WebKit2/WebProcess/soup/WebSoupRequestManager.h

    r141366 r149642  
    2323#include "DataReference.h"
    2424#include "MessageReceiver.h"
     25#include <WebCore/ResourceError.h>
    2526#include <wtf/HashMap.h>
    2627#include <wtf/Noncopyable.h>
     
    5455    void didHandleURIRequest(const CoreIPC::DataReference&, uint64_t contentLength, const String& mimeType, uint64_t requestID);
    5556    void didReceiveURIRequestData(const CoreIPC::DataReference&, uint64_t requestID);
     57    void didFailURIRequest(const WebCore::ResourceError&, uint64_t requestID);
    5658
    5759    WebProcess* m_process;
  • trunk/Source/WebKit2/WebProcess/soup/WebSoupRequestManager.messages.in

    r116738 r149642  
    2525    DidHandleURIRequest(CoreIPC::DataReference requestData, uint64_t contentLength, WTF::String mimeType, uint64_t requestID);
    2626    DidReceiveURIRequestData(CoreIPC::DataReference requestData, uint64_t requestID);
     27    DidFailURIRequest(WebCore::ResourceError error, uint64_t requestID);
    2728}
  • trunk/Tools/ChangeLog

    r149638 r149642  
     12013-05-06  Manuel Rego Casasnovas  <rego@igalia.com>
     2
     3        [GTK] Add webkit_uri_scheme_request_finish_error
     4        https://bugs.webkit.org/show_bug.cgi?id=94316
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * MiniBrowser/gtk/main.c:
     9        (miniBrowserErrorQuark): Add function to create a global quark for
     10        MiniBrowser.
     11        (aboutURISchemeRequestCallback): Update MiniBrowser to use the new
     12        function webkit_uri_scheme_request_finish_error().
     13
    1142013-05-06  Mike Lattanzio  <mlattanzio@blackberry.com>
    215
  • trunk/Tools/MiniBrowser/gtk/main.c

    r147624 r149642  
    3232#include <webkit2/webkit2.h>
    3333
     34#define MINI_BROWSER_ERROR (miniBrowserErrorQuark())
     35
    3436static const gchar **uriArguments = NULL;
    3537static const char *miniBrowserAboutScheme = "minibrowser-about";
     38
     39typedef enum {
     40    MINI_BROWSER_ERROR_INVALID_ABOUT_PATH
     41} MiniBrowserError;
     42
     43static GQuark miniBrowserErrorQuark()
     44{
     45    return g_quark_from_string("minibrowser-quark");
     46}
    3647
    3748static gchar *argumentToURL(const char *filename)
     
    207218    const gchar *path;
    208219    gchar *contents;
     220    GError *error;
    209221
    210222    path = webkit_uri_scheme_request_get_path(request);
    211     if (!g_strcmp0(path, "minibrowser"))
     223    if (!g_strcmp0(path, "minibrowser")) {
    212224        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>",
    213225            webkit_get_major_version(),
    214226            webkit_get_minor_version(),
    215227            webkit_get_micro_version());
    216     else
    217         contents = g_strdup_printf("<html><body><p>Invalid about:%s page.</p></body></html>", path);
    218 
    219     streamLength = strlen(contents);
    220     stream = g_memory_input_stream_new_from_data(contents, streamLength, g_free);
    221 
    222     webkit_uri_scheme_request_finish(request, stream, streamLength, "text/html");
    223     g_object_unref(stream);
     228        streamLength = strlen(contents);
     229        stream = g_memory_input_stream_new_from_data(contents, streamLength, g_free);
     230
     231        webkit_uri_scheme_request_finish(request, stream, streamLength, "text/html");
     232        g_object_unref(stream);
     233    } else {
     234        error = g_error_new(MINI_BROWSER_ERROR, MINI_BROWSER_ERROR_INVALID_ABOUT_PATH, "Invalid about:%s page.", path);
     235        webkit_uri_scheme_request_finish_error(request, error);
     236        g_error_free(error);
     237    }
    224238}
    225239
Note: See TracChangeset for help on using the changeset viewer.