Commit 9e803e65 authored by carlosgc@webkit.org's avatar carlosgc@webkit.org

[GTK] Implement default error pages in WebKit2 GTK+ API

https://bugs.webkit.org/show_bug.cgi?id=69255

Reviewed by Martin Robinson.

* UIProcess/API/gtk/WebKitError.cpp:
(webkit_policy_error_quark): Add quark for policy errors.
(webkit_plugin_error_quark): Add quark for plugin errors.
* UIProcess/API/gtk/WebKitError.h: Add policy and plugin errors.
* UIProcess/API/gtk/WebKitWebLoaderClient.cpp:
(webkitWebLoaderClientLoadFailed): Load a custom error page when
load failed and signal has not been handled.
(webkit_web_loader_client_class_init): Add default implementation
for provisional_load_failed and load_failed virtual methods.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96616 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7b7d19e6
2011-10-04 Carlos Garcia Campos <cgarcia@igalia.com>
[GTK] Implement default error pages in WebKit2 GTK+ API
https://bugs.webkit.org/show_bug.cgi?id=69255
Reviewed by Martin Robinson.
* UIProcess/API/gtk/WebKitError.cpp:
(webkit_policy_error_quark): Add quark for policy errors.
(webkit_plugin_error_quark): Add quark for plugin errors.
* UIProcess/API/gtk/WebKitError.h: Add policy and plugin errors.
* UIProcess/API/gtk/WebKitWebLoaderClient.cpp:
(webkitWebLoaderClientLoadFailed): Load a custom error page when
load failed and signal has not been handled.
(webkit_web_loader_client_class_init): Add default implementation
for provisional_load_failed and load_failed virtual methods.
2011-10-04 Carlos Garcia Campos <cgarcia@igalia.com>
[GTK] Add webkit_web_view_load_alternate_html() to WebKit2 GTK+ API
......
......@@ -24,7 +24,7 @@
#include "WebKitPrivate.h"
#include <WebCore/ErrorsGtk.h>
GQuark webkit_network_error_quark(void)
GQuark webkit_network_error_quark()
{
return g_quark_from_static_string(WebCore::errorDomainNetwork);
}
......@@ -34,3 +34,26 @@ COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NETWORK_ERROR_TRANSPORT, NetworkErrorTranspo
COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NETWORK_ERROR_UNKNOWN_PROTOCOL, NetworkErrorUnknownProtocol);
COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NETWORK_ERROR_CANCELLED, NetworkErrorCancelled);
COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NETWORK_ERROR_FILE_DOES_NOT_EXIST, NetworkErrorFileDoesNotExist);
GQuark webkit_policy_error_quark()
{
return g_quark_from_static_string(WebCore::errorDomainPolicy);
}
COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_POLICY_ERROR_FAILED, PolicyErrorFailed);
COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_POLICY_ERROR_CANNOT_SHOW_MIME_TYPE, PolicyErrorCannotShowMimeType);
COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_POLICY_ERROR_CANNOT_SHOW_URL, PolicyErrorCannotShowURL);
COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE, PolicyErrorFrameLoadInterruptedByPolicyChange);
COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_POLICY_ERROR_CANNOT_USE_RESTRICTED_PORT, PolicyErrorCannotUseRestrictedPort);
GQuark webkit_plugin_error_quark()
{
return g_quark_from_static_string(WebCore::errorDomainPlugin);
}
COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_FAILED, PluginErrorFailed);
COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_CANNOT_FIND_PLUGIN, PluginErrorCannotFindPlugin);
COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_CANNOT_LOAD_PLUGIN, PluginErrorCannotLoadPlugin);
COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_JAVA_UNAVAILABLE, PluginErrorJavaUnavailable);
COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_CONNECTION_CANCELLED, PluginErrorConnectionCancelled);
COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_WILL_HANDLE_LOAD, PluginErrorWillHandleLoad);
......@@ -31,6 +31,8 @@
G_BEGIN_DECLS
#define WEBKIT_NETWORK_ERROR webkit_network_error_quark ()
#define WEBKIT_POLICY_ERROR webkit_policy_error_quark ()
#define WEBKIT_PLUGIN_ERROR webkit_plugin_error_quark ()
/**
* WebKitNetworkError:
......@@ -51,9 +53,32 @@ typedef enum {
WEBKIT_NETWORK_ERROR_FILE_DOES_NOT_EXIST = 303
} WebKitNetworkError;
typedef enum {
WEBKIT_POLICY_ERROR_FAILED = 199,
WEBKIT_POLICY_ERROR_CANNOT_SHOW_MIME_TYPE = 100,
WEBKIT_POLICY_ERROR_CANNOT_SHOW_URL = 101,
WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE = 102,
WEBKIT_POLICY_ERROR_CANNOT_USE_RESTRICTED_PORT = 103
} WebKitPolicyError;
typedef enum {
WEBKIT_PLUGIN_ERROR_FAILED = 299,
WEBKIT_PLUGIN_ERROR_CANNOT_FIND_PLUGIN = 200,
WEBKIT_PLUGIN_ERROR_CANNOT_LOAD_PLUGIN = 201,
WEBKIT_PLUGIN_ERROR_JAVA_UNAVAILABLE = 202,
WEBKIT_PLUGIN_ERROR_CONNECTION_CANCELLED = 203,
WEBKIT_PLUGIN_ERROR_WILL_HANDLE_LOAD = 204,
} WebKitPluginError;
WK_EXPORT GQuark
webkit_network_error_quark (void);
WK_EXPORT GQuark
webkit_policy_error_quark (void);
WK_EXPORT GQuark
webkit_plugin_error_quark (void);
G_END_DECLS
#endif
......@@ -20,6 +20,7 @@
#include "config.h"
#include "WebKitWebLoaderClient.h"
#include "WebKitError.h"
#include "WebKitMarshal.h"
#include "WebKitPrivate.h"
#include "WebKitWebView.h"
......@@ -158,6 +159,19 @@ static void webkitWebLoaderClientConstructed(GObject* object)
WKPageSetPageLoaderClient(toAPI(page), &loaderClient);
}
static gboolean webkitWebLoaderClientLoadFailed(WebKitWebLoaderClient* client, const gchar* failingURI, GError* error)
{
if (g_error_matches(error, WEBKIT_NETWORK_ERROR, WEBKIT_NETWORK_ERROR_CANCELLED)
|| g_error_matches(error, WEBKIT_POLICY_ERROR, WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE)
|| g_error_matches(error, WEBKIT_PLUGIN_ERROR, WEBKIT_PLUGIN_ERROR_WILL_HANDLE_LOAD))
return FALSE;
GOwnPtr<char> htmlString(g_strdup_printf("<html><body>%s</body></html>", error->message));
webkit_web_view_load_alternate_html(client->priv->view.get(), htmlString.get(), 0, failingURI);
return TRUE;
}
static void webkitWebLoaderClientSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec)
{
WebKitWebLoaderClient* client = WEBKIT_WEB_LOADER_CLIENT(object);
......@@ -206,6 +220,9 @@ static void webkit_web_loader_client_class_init(WebKitWebLoaderClientClass* clie
objectClass->constructed = webkitWebLoaderClientConstructed;
objectClass->finalize = webkitWebLoaderClientFinalize;
clientClass->provisional_load_failed = webkitWebLoaderClientLoadFailed;
clientClass->load_failed = webkitWebLoaderClientLoadFailed;
/**
* WebKitWebView:web-view:
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment