Diff
Modified: trunk/Source/WebKit2/ChangeLog (121834 => 121835)
--- trunk/Source/WebKit2/ChangeLog 2012-07-04 07:30:11 UTC (rev 121834)
+++ trunk/Source/WebKit2/ChangeLog 2012-07-04 07:33:41 UTC (rev 121835)
@@ -1,3 +1,35 @@
+2012-07-04 Christophe Dumez <[email protected]>
+
+ [EFL][WK2] Ewk_View should report load errors
+ https://bugs.webkit.org/show_bug.cgi?id=90479
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ The Ewk_View now emits a "load,error" signal when the
+ main frame fails loading. Information about the error
+ is provided via the new Ewk_Web_Error type.
+
+ * PlatformEfl.cmake:
+ * UIProcess/API/efl/EWebKit2.h:
+ * UIProcess/API/efl/ewk_view.cpp:
+ (ewk_view_load_error):
+ * UIProcess/API/efl/ewk_view.h:
+ * UIProcess/API/efl/ewk_view_loader_client.cpp:
+ (didFailLoadWithErrorForFrame):
+ (ewk_view_loader_client_attach):
+ * UIProcess/API/efl/ewk_view_private.h:
+ * UIProcess/API/efl/ewk_web_error.cpp: Added.
+ (_Ewk_Web_Error):
+ (ewk_web_error_free):
+ (ewk_web_error_domain_get):
+ (ewk_web_error_url_get):
+ (ewk_web_error_code_get):
+ (ewk_web_error_description_get):
+ (ewk_web_error_cancellation_get):
+ (ewk_web_error_new):
+ * UIProcess/API/efl/ewk_web_error.h: Added.
+ * UIProcess/API/efl/ewk_web_error_private.h: Added.
+
2012-07-03 Christophe Dumez <[email protected]>
[WK2][EFL] Ewk_View should report the load progress
Modified: trunk/Source/WebKit2/PlatformEfl.cmake (121834 => 121835)
--- trunk/Source/WebKit2/PlatformEfl.cmake 2012-07-04 07:30:11 UTC (rev 121834)
+++ trunk/Source/WebKit2/PlatformEfl.cmake 2012-07-04 07:33:41 UTC (rev 121835)
@@ -36,6 +36,7 @@
UIProcess/API/efl/ewk_intent_service.cpp
UIProcess/API/efl/ewk_view.cpp
UIProcess/API/efl/ewk_view_loader_client.cpp
+ UIProcess/API/efl/ewk_web_error.cpp
UIProcess/cairo/BackingStoreCairo.cpp
Modified: trunk/Source/WebKit2/UIProcess/API/efl/EWebKit2.h (121834 => 121835)
--- trunk/Source/WebKit2/UIProcess/API/efl/EWebKit2.h 2012-07-04 07:30:11 UTC (rev 121834)
+++ trunk/Source/WebKit2/UIProcess/API/efl/EWebKit2.h 2012-07-04 07:33:41 UTC (rev 121835)
@@ -31,5 +31,6 @@
#include "ewk_intent.h"
#include "ewk_intent_service.h"
#include "ewk_view.h"
+#include "ewk_web_error.h"
#endif // EWebKit2_h
Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp (121834 => 121835)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp 2012-07-04 07:30:11 UTC (rev 121834)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp 2012-07-04 07:33:41 UTC (rev 121835)
@@ -678,6 +678,18 @@
evas_object_image_data_copy_set(smartData->image, imageData);
}
+/**
+ * @internal
+ * Reports load failed with error information.
+ *
+ * Emits signal: "load,error" with pointer to Ewk_Web_Error.
+ */
+void ewk_view_load_error(Evas_Object* ewkView, const Ewk_Web_Error* error)
+{
+ evas_object_smart_callback_call(ewkView, "load,error", const_cast<Ewk_Web_Error*>(error));
+}
+
+
#if ENABLE(WEB_INTENTS_TAG)
/**
* @internal
Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h (121834 => 121835)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h 2012-07-04 07:30:11 UTC (rev 121834)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h 2012-07-04 07:33:41 UTC (rev 121835)
@@ -28,6 +28,7 @@
*
* - "intent,request,new", Ewk_Intent_Request*: reports new Web intent request.
* - "intent,service,register", Ewk_Intent_Service*: reports new Web intent service registration.
+ * - "load,error", const Ewk_Web_Error*: reports main frame load failed.
* - "load,progress", double*: load progress has changed (value from 0.0 to 1.0).
* - "title,changed", const char*: title of the main frame was changed.
*/
Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp (121834 => 121835)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp 2012-07-04 07:30:11 UTC (rev 121834)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp 2012-07-04 07:33:41 UTC (rev 121835)
@@ -32,6 +32,8 @@
#include "ewk_intent_service_private.h"
#include "ewk_view_loader_client_private.h"
#include "ewk_view_private.h"
+#include "ewk_web_error.h"
+#include "ewk_web_error_private.h"
#include <wtf/text/CString.h>
using namespace WebKit;
@@ -71,6 +73,17 @@
ewk_view_load_progress_changed(ewkView, WKPageGetEstimatedProgress(page));
}
+static void didFailLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef, const void *clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+
+ Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo));
+ Ewk_Web_Error* ewkError = ewk_web_error_new(error);
+ ewk_view_load_error(ewkView, ewkError);
+ ewk_web_error_free(ewkError);
+}
+
void ewk_view_loader_client_attach(WKPageRef pageRef, Evas_Object* ewkView)
{
WKPageLoaderClient loadClient;
@@ -87,5 +100,6 @@
loadClient.didStartProgress = didChangeProgress;
loadClient.didChangeProgress = didChangeProgress;
loadClient.didFinishProgress = didChangeProgress;
+ loadClient.didFailLoadWithErrorForFrame = didFailLoadWithErrorForFrame;
WKPageSetPageLoaderClient(pageRef, &loadClient);
}
Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h (121834 => 121835)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h 2012-07-04 07:30:11 UTC (rev 121834)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h 2012-07-04 07:33:41 UTC (rev 121835)
@@ -30,6 +30,7 @@
class IntSize;
}
+typedef struct _Ewk_Web_Error Ewk_Web_Error;
#if ENABLE(WEB_INTENTS)
typedef struct _Ewk_Intent Ewk_Intent;
#endif
@@ -39,6 +40,7 @@
void ewk_view_display(Evas_Object* ewkView, const WebCore::IntRect& rect);
void ewk_view_image_data_set(Evas_Object* ewkView, void* imageData, const WebCore::IntSize& size);
+void ewk_view_load_error(Evas_Object* ewkView, const Ewk_Web_Error* error);
void ewk_view_load_progress_changed(Evas_Object* ewkView, double progress);
void ewk_view_title_changed(Evas_Object* ewkView, const char* title);
Added: trunk/Source/WebKit2/UIProcess/API/efl/ewk_web_error.cpp (0 => 121835)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_web_error.cpp (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_web_error.cpp 2012-07-04 07:33:41 UTC (rev 121835)
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ewk_web_error.h"
+
+#include "WKString.h"
+#include "WKURL.h"
+#include "ewk_web_error_private.h"
+#include <WKAPICast.h>
+#include <WKError.h>
+#include <WKRetainPtr.h>
+#include <wtf/text/CString.h>
+
+using namespace WebKit;
+
+// Copied from ErrorsGtk.h which is used by DownloadSoup.cpp.
+static const char errorDomainDownload[] = "WebKitDownloadError";
+
+struct _Ewk_Web_Error {
+ WKRetainPtr<WKErrorRef> wkError;
+
+ const char* url;
+ const char* description;
+};
+
+#define EWK_WEB_ERROR_WK_GET_OR_RETURN(error, wkError_, ...) \
+ if (!(error)) { \
+ EINA_LOG_CRIT("error is NULL."); \
+ return __VA_ARGS__; \
+ } \
+ if (!(error)->wkError) { \
+ EINA_LOG_CRIT("error->wkError is NULL."); \
+ return __VA_ARGS__; \
+ } \
+ WKErrorRef wkError_ = (error)->wkError.get()
+
+void ewk_web_error_free(Ewk_Web_Error *error)
+{
+ EINA_SAFETY_ON_NULL_RETURN(error);
+
+ eina_stringshare_del(error->url);
+ eina_stringshare_del(error->description);
+ free(error);
+}
+
+Ewk_Web_Error_Type ewk_web_error_type_get(const Ewk_Web_Error* error)
+{
+ EWK_WEB_ERROR_WK_GET_OR_RETURN(error, wkError, EWK_WEB_ERROR_TYPE_NONE);
+
+ WKRetainPtr<WKStringRef> wkDomain(AdoptWK, WKErrorCopyDomain(wkError));
+ WTF::String errorDomain = toWTFString(wkDomain.get());
+
+ if (errorDomain == String(g_quark_to_string(SOUP_HTTP_ERROR)))
+ return EWK_WEB_ERROR_TYPE_HTTP;
+ if (errorDomain == String(g_quark_to_string(G_IO_ERROR)))
+ return EWK_WEB_ERROR_TYPE_IO;
+ if (errorDomain == errorDomainDownload)
+ return EWK_WEB_ERROR_TYPE_DOWNLOAD;
+ return EWK_WEB_ERROR_TYPE_INTERNAL;
+}
+
+const char* ewk_web_error_url_get(const Ewk_Web_Error* error)
+{
+ EWK_WEB_ERROR_WK_GET_OR_RETURN(error, wkError, 0);
+
+ WKRetainPtr<WKURLRef> wkUrl(AdoptWK, WKErrorCopyFailingURL(wkError));
+ Ewk_Web_Error* ewkError = const_cast<Ewk_Web_Error*>(error);
+ eina_stringshare_replace(&ewkError->url, toImpl(wkUrl.get())->string().utf8().data());
+
+ return error->url;
+}
+
+int ewk_web_error_code_get(const Ewk_Web_Error* error)
+{
+ EWK_WEB_ERROR_WK_GET_OR_RETURN(error, wkError, 0);
+
+ return WKErrorGetErrorCode(wkError);
+}
+
+const char* ewk_web_error_description_get(const Ewk_Web_Error* error)
+{
+ EWK_WEB_ERROR_WK_GET_OR_RETURN(error, wkError, 0);
+
+ WKRetainPtr<WKStringRef> wkDescription(AdoptWK, WKErrorCopyLocalizedDescription(wkError));
+ Ewk_Web_Error* ewkError = const_cast<Ewk_Web_Error*>(error);
+ eina_stringshare_replace(&ewkError->description, toImpl(wkDescription.get())->string().utf8().data());
+
+ return error->description;
+}
+
+Eina_Bool ewk_web_error_cancellation_get(const Ewk_Web_Error* error)
+{
+ EWK_WEB_ERROR_WK_GET_OR_RETURN(error, wkError, false);
+
+ return toImpl(wkError)->platformError().isCancellation();
+}
+
+Ewk_Web_Error* ewk_web_error_new(WKErrorRef error)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(error, 0);
+
+ Ewk_Web_Error* ewkError = static_cast<Ewk_Web_Error*>(calloc(1, sizeof(Ewk_Web_Error)));
+ ewkError->wkError = error;
+
+ return ewkError;
+}
Added: trunk/Source/WebKit2/UIProcess/API/efl/ewk_web_error.h (0 => 121835)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_web_error.h (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_web_error.h 2012-07-04 07:33:41 UTC (rev 121835)
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @file ewk_web_error.h
+ * @brief Describes the Web Error API.
+ */
+
+#ifndef ewk_web_error_h
+#define ewk_web_error_h
+
+#include <Eina.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Creates a type name for @a Ewk_Web_Error. */
+typedef struct _Ewk_Web_Error Ewk_Web_Error;
+
+/// Creates a type name for Ewk_Web_Error_Type.
+typedef enum {
+ EWK_WEB_ERROR_TYPE_NONE,
+ EWK_WEB_ERROR_TYPE_INTERNAL,
+ EWK_WEB_ERROR_TYPE_HTTP,
+ EWK_WEB_ERROR_TYPE_IO,
+ EWK_WEB_ERROR_TYPE_DOWNLOAD
+} Ewk_Web_Error_Type;
+
+/**
+ * Frees the given object.
+ *
+ * @param error the error object to free
+ */
+EAPI void ewk_web_error_free(Ewk_Web_Error *error);
+
+/**
+ * Query type for this error.
+ *
+ * @param error error object to query.
+ *
+ * @return the error type, that may be @c NULL. This pointer is
+ * guaranteed to be eina_stringshare, so whenever possible
+ * save yourself some cpu cycles and use
+ * eina_stringshare_ref() instead of eina_stringshare_add() or
+ * strdup().
+ */
+EAPI Ewk_Web_Error_Type ewk_web_error_type_get(const Ewk_Web_Error *error);
+
+/**
+ * Query failing URL for this error.
+ *
+ * URL that failed loading.
+ *
+ * @param error error object to query.
+ *
+ * @return the URL pointer, that may be @c NULL. This pointer is
+ * guaranteed to be eina_stringshare, so whenever possible
+ * save yourself some cpu cycles and use
+ * eina_stringshare_ref() instead of eina_stringshare_add() or
+ * strdup().
+ */
+EAPI const char *ewk_web_error_url_get(const Ewk_Web_Error *error);
+
+/**
+ * Query HTTP error code.
+ *
+ * @param error error object to query.
+ *
+ * @return the HTTP error code.
+ */
+EAPI int ewk_web_error_code_get(const Ewk_Web_Error *error);
+
+/**
+ * Query description for this error.
+ *
+ * @param error error object to query.
+ *
+ * @return the description pointer, that may be @c NULL. This pointer is
+ * guaranteed to be eina_stringshare, so whenever possible
+ * save yourself some cpu cycles and use
+ * eina_stringshare_ref() instead of eina_stringshare_add() or
+ * strdup().
+ */
+EAPI const char *ewk_web_error_description_get(const Ewk_Web_Error *error);
+
+/**
+ * Query if error should be treated as a cancellation.
+ *
+ * @param error error object to query.
+ *
+ * @return @c EINA_TRUE if this error should be treated as a cancellation, @c EINA_FALSE otherwise
+ */
+EAPI Eina_Bool ewk_web_error_cancellation_get(const Ewk_Web_Error *error);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // ewk_web_error_h
Added: trunk/Source/WebKit2/UIProcess/API/efl/ewk_web_error_private.h (0 => 121835)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_web_error_private.h (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_web_error_private.h 2012-07-04 07:33:41 UTC (rev 121835)
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ewk_web_error_private_h
+#define ewk_web_error_private_h
+
+#include <WKError.h>
+
+typedef struct _Ewk_Web_Error Ewk_Web_Error;
+
+Ewk_Web_Error* ewk_web_error_new(WKErrorRef error);
+
+#endif // ewk_web_error_private_h