Changeset 42866 in webkit


Ignore:
Timestamp:
Apr 25, 2009 2:19:42 AM (15 years ago)
Author:
jmalonzo@webkit.org
Message:

2009-04-25 Jan Michael Alonzo <jmalonzo@webkit.org>

Reviewed by Xan Lopez.

[GTK] Error reporting
https://bugs.webkit.org/show_bug.cgi?id=18344

Fix the SOUP resource handle to report SOUP_HTTP_ERROR for Soup
errors and G_IO_ERROR for gio errors.

  • platform/network/soup/ResourceHandleSoup.cpp: (WebCore::finishedCallback): (WebCore::ResourceHandle::startHttp): (WebCore::ResourceHandle::start): (WebCore::readCallback): (WebCore::openCallback): (WebCore::queryInfoCallback): (WebCore::ResourceHandle::startGio):

2009-04-25 Jan Michael Alonzo <jmalonzo@webkit.org>

Reviewed by Xan Lopez.

[GTK] Error reporting
https://bugs.webkit.org/show_bug.cgi?id=18344

Update FrameLoad errors to use WebKitErrors.

  • WebCoreSupport/FrameLoaderClientGtk.cpp: (WebKit::FrameLoaderClient::cancelledError): (WebKit::FrameLoaderClient::blockedError): (WebKit::FrameLoaderClient::cannotShowURLError): (WebKit::FrameLoaderClient::interruptForPolicyChangeError): (WebKit::FrameLoaderClient::cannotShowMIMETypeError): (WebKit::FrameLoaderClient::fileDoesNotExistError): (WebKit::FrameLoaderClient::pluginWillHandleLoadError): (WebKit::FrameLoaderClient::shouldFallBack):
  • webkit/webkiterror.h: Added.
  • webkit/webkiterror.cpp: Added.

2009-04-25 Jan Michael Alonzo <jmalonzo@webkit.org>

Reviewed by Xan Lopez.

[GTK] Error reporting
https://bugs.webkit.org/show_bug.cgi?id=18344

Add webkiterror to the build.

  • GNUmakefile.am:
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r42865 r42866  
     12009-04-25  Jan Michael Alonzo  <jmalonzo@webkit.org>
     2
     3        Reviewed by Xan Lopez.
     4
     5        [GTK] Error reporting
     6        https://bugs.webkit.org/show_bug.cgi?id=18344
     7
     8        Add webkiterror to the build.
     9
     10        * GNUmakefile.am:
     11
    1122009-04-25  Jan Michael Alonzo  <jmalonzo@webkit.org>
    213
  • trunk/GNUmakefile.am

    r42865 r42866  
    316316        WebKit/gtk/webkit/webkitdefines.h \
    317317        WebKit/gtk/webkit/webkitdownload.h \
     318        WebKit/gtk/webkit/webkiterror.h \
    318319        WebKit/gtk/webkit/webkitnetworkrequest.h \
    319320        WebKit/gtk/webkit/webkitsoupauthdialog.h \
     
    350351        WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.cpp \
    351352        WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.h \
     353        WebKit/gtk/webkit/webkitdownload.cpp \
     354        WebKit/gtk/webkit/webkiterror.cpp \
    352355        WebKit/gtk/webkit/webkitnetworkrequest.cpp \
    353356        WebKit/gtk/webkit/webkitprivate.cpp \
     
    362365        WebKit/gtk/webkit/webkitwebpolicydecision.cpp \
    363366        WebKit/gtk/webkit/webkitwebsettings.cpp \
    364         WebKit/gtk/webkit/webkitdownload.cpp \
    365367        WebKit/gtk/webkit/webkitwebview.cpp \
    366368        WebKit/gtk/webkit/webkitwebwindowfeatures.cpp
  • trunk/WebCore/ChangeLog

    r42861 r42866  
     12009-04-25  Jan Michael Alonzo  <jmalonzo@webkit.org>
     2
     3        Reviewed by Xan Lopez.
     4
     5        [GTK] Error reporting
     6        https://bugs.webkit.org/show_bug.cgi?id=18344
     7
     8        Fix the SOUP resource handle to report SOUP_HTTP_ERROR for Soup
     9        errors and G_IO_ERROR for gio errors.
     10
     11        * platform/network/soup/ResourceHandleSoup.cpp:
     12        (WebCore::finishedCallback):
     13        (WebCore::ResourceHandle::startHttp):
     14        (WebCore::ResourceHandle::start):
     15        (WebCore::readCallback):
     16        (WebCore::openCallback):
     17        (WebCore::queryInfoCallback):
     18        (WebCore::ResourceHandle::startGio):
     19
    1202009-04-25  Gustavo Noronha Silva  <gustavo.noronha@collabora.co.uk>
    221
  • trunk/WebCore/platform/network/soup/ResourceHandleSoup.cpp

    r42861 r42866  
    122122}
    123123
    124 enum
    125 {
    126     ERROR_TRANSPORT,
    127     ERROR_UNKNOWN_PROTOCOL,
    128     ERROR_BAD_NON_HTTP_METHOD,
    129     ERROR_UNABLE_TO_OPEN_FILE,
    130 };
    131 
    132124static void cleanupGioOperation(ResourceHandleInternal* handle);
    133125
     
    338330
    339331    if (SOUP_STATUS_IS_TRANSPORT_ERROR(msg->status_code)) {
    340         char* uri = soup_uri_to_string(soup_message_get_uri(msg), false);
    341         ResourceError error("webkit-network-error", ERROR_TRANSPORT, uri, String::fromUTF8(msg->reason_phrase));
    342         g_free(uri);
     332        ResourceError error(g_quark_to_string(SOUP_HTTP_ERROR),
     333                            msg->status_code,
     334                            soup_uri_to_string(soup_message_get_uri(msg), false),
     335                            String::fromUTF8(msg->reason_phrase));
    343336        client->didFail(handle.get(), error);
    344337        return;
     
    533526
    534527                    if (error) {
    535                         ResourceError resourceError("webkit-network-error", ERROR_UNABLE_TO_OPEN_FILE, urlString, error->message);
     528                        ResourceError resourceError(g_quark_to_string(SOUP_HTTP_ERROR),
     529                                                    msg->status_code,
     530                                                    urlString,
     531                                                    String::fromUTF8(error->message));
    536532                        g_error_free(error);
    537533
     
    561557}
    562558
    563 static gboolean reportUnknownProtocolError(gpointer callback_data)
    564 {
    565     ResourceHandle* handle = static_cast<ResourceHandle*>(callback_data);
    566     ResourceHandleInternal* d = handle->getInternal();
    567     ResourceHandleClient* client = handle->client();
    568 
    569     if (d->m_cancelled || !client) {
    570         handle->deref();
    571         return false;
    572     }
    573 
    574     KURL url = handle->request().url();
    575     ResourceError error("webkit-network-error", ERROR_UNKNOWN_PROTOCOL, url.string(), url.protocol());
    576     client->didFail(handle, error);
    577 
    578     handle->deref();
    579     return false;
    580 }
    581 
    582559bool ResourceHandle::start(Frame* frame)
    583560{
     
    609586        return startGio(url);
    610587
    611     // Error must not be reported immediately, but through an idle function.
    612     // Despite error, we should return true so a proper handle is created,
    613     // to which this failure can be reported.
    614     ref();
    615     d->m_idleHandler = g_idle_add(reportUnknownProtocolError, this);
     588    // Error must not be reported immediately
     589    this->scheduleFailure(InvalidURLFailure);
     590
    616591    return true;
    617592}
     
    667642// GIO-based loader
    668643
    669 static inline ResourceError networkErrorForFile(GFile* file, GError* error)
    670 {
    671     // FIXME: Map gio errors to a more detailed error code when we have it in WebKit.
    672     gchar* uri = g_file_get_uri(file);
    673     ResourceError resourceError("webkit-network-error", ERROR_TRANSPORT, uri, error ? String::fromUTF8(error->message) : String());
    674     g_free(uri);
    675     return resourceError;
    676 }
    677 
    678644static void cleanupGioOperation(ResourceHandleInternal* d)
    679645{
     
    734700    gssize bytesRead = g_input_stream_read_finish(d->m_inputStream, res, &error);
    735701    if (error) {
    736         ResourceError resourceError = networkErrorForFile(d->m_gfile, error);
     702        ResourceError resourceError(g_quark_to_string(G_IO_ERROR),
     703                                    error->code,
     704                                    g_file_get_uri(d->m_gfile),
     705                                    error ? String::fromUTF8(error->message) : String());
    737706        g_error_free(error);
    738707        cleanupGioOperation(d);
     
    777746    GFileInputStream* in = g_file_read_finish(G_FILE(source), res, &error);
    778747    if (error) {
    779         ResourceError resourceError = networkErrorForFile(d->m_gfile, error);
     748        ResourceError resourceError(g_quark_to_string(G_IO_ERROR),
     749                                    error->code,
     750                                    g_file_get_uri(d->m_gfile),
     751                                    error ? String::fromUTF8(error->message) : String());
     752
    780753        g_error_free(error);
    781754        cleanupGioOperation(d);
     
    824797        // and set a timeout to unmount it later after it's been idle
    825798        // for a while).
    826 
    827         ResourceError resourceError = networkErrorForFile(d->m_gfile, error);
     799        ResourceError resourceError(g_quark_to_string(G_IO_ERROR),
     800                                    error->code,
     801                                    g_file_get_uri(d->m_gfile),
     802                                    error ? String::fromUTF8(error->message) : String());
    828803        g_error_free(error);
    829804        cleanupGioOperation(d);
     
    835810        // FIXME: what if the URI points to a directory? Should we
    836811        // generate a listing? How? What do other backends do here?
    837 
    838         ResourceError resourceError = networkErrorForFile(d->m_gfile, 0);
     812        ResourceError resourceError(g_quark_to_string(G_IO_ERROR),
     813                                    G_IO_ERROR_FAILED,
     814                                    g_file_get_uri(d->m_gfile),
     815                                    String());
    839816        cleanupGioOperation(d);
    840817        client->didFail(handle, resourceError);
     
    858835{
    859836    if (request().httpMethod() != "GET" && request().httpMethod() != "POST") {
    860         ResourceError error("webkit-network-error", ERROR_BAD_NON_HTTP_METHOD, url.string(), request().httpMethod());
     837        ResourceError error(g_quark_to_string(SOUP_HTTP_ERROR),
     838                            SOUP_STATUS_METHOD_NOT_ALLOWED,
     839                            url.string(), request().httpMethod());
    861840        d->client()->didFail(this, error);
    862841        return false;
  • trunk/WebKit/gtk/ChangeLog

    r42865 r42866  
    112009-04-25  Jan Michael Alonzo  <jmalonzo@webkit.org>
    22
    3          Reviewed by Xan Lopez.
    4 
    5          Display a default error page for load errors.
    6 
    7          * WebCoreSupport/FrameLoaderClientGtk.cpp:
    8          (WebKit::FrameLoaderClient::dispatchDidFailLoad):
    9          * resources/error.html: Added.
     3        Reviewed by Xan Lopez.
     4
     5        [GTK] Error reporting
     6        https://bugs.webkit.org/show_bug.cgi?id=18344
     7
     8        Update FrameLoad errors to use WebKitErrors.
     9
     10        * WebCoreSupport/FrameLoaderClientGtk.cpp:
     11        (WebKit::FrameLoaderClient::cancelledError):
     12        (WebKit::FrameLoaderClient::blockedError):
     13        (WebKit::FrameLoaderClient::cannotShowURLError):
     14        (WebKit::FrameLoaderClient::interruptForPolicyChangeError):
     15        (WebKit::FrameLoaderClient::cannotShowMIMETypeError):
     16        (WebKit::FrameLoaderClient::fileDoesNotExistError):
     17        (WebKit::FrameLoaderClient::pluginWillHandleLoadError):
     18        (WebKit::FrameLoaderClient::shouldFallBack):
     19        * webkit/webkiterror.h: Added.
     20        * webkit/webkiterror.cpp: Added.
     21
     222009-04-25  Jan Michael Alonzo  <jmalonzo@webkit.org>
     23
     24        Reviewed by Xan Lopez.
     25
     26        [GTK] Error reporting
     27        https://bugs.webkit.org/show_bug.cgi?id=18344
     28
     29        Display a default error page for load errors.
     30
     31        * WebCoreSupport/FrameLoaderClientGtk.cpp:
     32        (WebKit::FrameLoaderClient::dispatchDidFailLoad):
     33        * resources/error.html: Added.
    1034
    11352009-04-25  Jan Michael Alonzo  <jmalonzo@webkit.org>
  • trunk/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp

    r42865 r42866  
    5050#include "JSDOMBinding.h"
    5151#include "ScriptController.h"
    52 #include "webkitwebview.h"
     52#include "webkiterror.h"
    5353#include "webkitnetworkrequest.h"
     54#include "webkitprivate.h"
    5455#include "webkitwebframe.h"
    5556#include "webkitwebnavigationaction.h"
    5657#include "webkitwebpolicydecision.h"
    57 #include "webkitprivate.h"
     58#include "webkitwebview.h"
    5859
    5960#include <JavaScriptCore/APICast.h>
    6061#include <gio/gio.h>
    6162#include <glib.h>
     63#include <glib/gi18n-lib.h>
    6264#include <stdio.h>
    6365#if PLATFORM(UNIX)
     
    885887}
    886888
    887 ResourceError FrameLoaderClient::cancelledError(const ResourceRequest&)
    888 {
    889     notImplemented();
    890     ResourceError error("", 0, "", "");
    891     error.setIsCancellation(true);
    892     return error;
    893 }
    894 
    895 ResourceError FrameLoaderClient::blockedError(const ResourceRequest&)
    896 {
    897     notImplemented();
    898     return ResourceError("", 0, "", "");
    899 }
    900 
    901 ResourceError FrameLoaderClient::cannotShowURLError(const ResourceRequest&)
    902 {
    903     notImplemented();
    904     return ResourceError("", 0, "", "");
    905 }
    906 
    907 ResourceError FrameLoaderClient::interruptForPolicyChangeError(const ResourceRequest&)
    908 {
    909     notImplemented();
    910     return ResourceError("", 0, "", "");
    911 }
    912 
    913 ResourceError FrameLoaderClient::cannotShowMIMETypeError(const ResourceResponse&)
    914 {
    915     notImplemented();
    916     return ResourceError("", 0, "", "");
    917 }
    918 
    919 ResourceError FrameLoaderClient::fileDoesNotExistError(const ResourceResponse&)
    920 {
    921     notImplemented();
    922     return ResourceError("", 0, "", "");
    923 }
    924 
    925 ResourceError FrameLoaderClient::pluginWillHandleLoadError(const ResourceResponse&)
    926 {
    927     notImplemented();
    928     return ResourceError("", 0, "", "");
    929 }
    930 
    931 bool FrameLoaderClient::shouldFallBack(const ResourceError&)
    932 {
    933     notImplemented();
    934     return false;
     889ResourceError FrameLoaderClient::cancelledError(const ResourceRequest& request)
     890{
     891    return ResourceError(g_quark_to_string(WEBKIT_NETWORK_ERROR), WEBKIT_NETWORK_ERROR_CANCELLED,
     892                         request.url().string(), _("Load request cancelled"));
     893}
     894
     895ResourceError FrameLoaderClient::blockedError(const ResourceRequest& request)
     896{
     897    return ResourceError(g_quark_to_string(WEBKIT_POLICY_ERROR), WEBKIT_POLICY_ERROR_CANNOT_USE_RESTRICTED_PORT,
     898                         request.url().string(), _("Not allowed to use restricted network port"));
     899}
     900
     901ResourceError FrameLoaderClient::cannotShowURLError(const ResourceRequest& request)
     902{
     903    return ResourceError(g_quark_to_string(WEBKIT_POLICY_ERROR), WEBKIT_POLICY_ERROR_CANNOT_SHOW_URL,
     904                         request.url().string(), _("URL cannot be shown"));
     905}
     906
     907ResourceError FrameLoaderClient::interruptForPolicyChangeError(const ResourceRequest& request)
     908{
     909    return ResourceError(g_quark_to_string(WEBKIT_POLICY_ERROR), WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE,
     910                         request.url().string(), _("Frame load was interrupted"));
     911}
     912
     913ResourceError FrameLoaderClient::cannotShowMIMETypeError(const ResourceResponse& response)
     914{
     915    return ResourceError(g_quark_to_string(WEBKIT_POLICY_ERROR), WEBKIT_POLICY_ERROR_CANNOT_SHOW_MIME_TYPE,
     916                         response.url().string(), _("Content with the specified MIME type cannot be shown"));
     917}
     918
     919ResourceError FrameLoaderClient::fileDoesNotExistError(const ResourceResponse& response)
     920{
     921    return ResourceError(g_quark_to_string(WEBKIT_NETWORK_ERROR), WEBKIT_NETWORK_ERROR_FILE_DOES_NOT_EXIST,
     922                         response.url().string(), _("File does not exist"));
     923}
     924
     925ResourceError FrameLoaderClient::pluginWillHandleLoadError(const ResourceResponse& response)
     926{
     927    return ResourceError(g_quark_to_string(WEBKIT_PLUGIN_ERROR), WEBKIT_PLUGIN_ERROR_WILL_HANDLE_LOAD,
     928                         response.url().string(), _("Plugin will handle load"));
     929}
     930
     931bool FrameLoaderClient::shouldFallBack(const ResourceError& error)
     932{
     933    // FIXME: Needs to check domain.
     934    // FIXME: Mac checks for WebKitErrorPlugInWillHandleLoad here to avoid
     935    // loading plugin content twice. Do we need it?
     936    return error.errorCode() != WEBKIT_NETWORK_ERROR_CANCELLED;
    935937}
    936938
Note: See TracChangeset for help on using the changeset viewer.