Title: [94965] trunk/Source/WebKit/efl
Revision
94965
Author
[email protected]
Date
2011-09-12 10:54:33 -0700 (Mon, 12 Sep 2011)

Log Message

Patch by Flavio Ceolin <[email protected]> on 2011-09-12
Reviewed by Martin Robinson.

[EFL] Add custom network resource handler
https://bugs.webkit.org/show_bug.cgi?id=44759

This patch adds support for handling user-specific protocols.
It allows browsers to intercept and handle non-standard url schemes (such as preferences://)
allowing to load some resource from non-http/file storage, like a tar/zip/eet.

* CMakeListsEfl.txt:
* ewk/ewk_protocol_handler.cpp: Added.
* ewk/ewk_protocol_handler.h: Added.
* ewk/ewk_protocol_handler_soup.cpp: Added.
* ewk/ewk_protocol_handler_soup.h: Added.
* ewk/ewk_private.h:
* ewk/ewk_view.cpp:
(ewk_view_protocol_handler_set):
(ewk_view_protocol_handler_unset):
(ewk_view_protocol_handler_resource_get):
* ewk/ewk_view.h:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/efl/CMakeListsEfl.txt (94964 => 94965)


--- trunk/Source/WebKit/efl/CMakeListsEfl.txt	2011-09-12 17:52:51 UTC (rev 94964)
+++ trunk/Source/WebKit/efl/CMakeListsEfl.txt	2011-09-12 17:54:33 UTC (rev 94965)
@@ -73,6 +73,7 @@
     efl/ewk/ewk_main.cpp
     efl/ewk/ewk_network.cpp
     efl/ewk/ewk_settings.cpp
+    efl/ewk/ewk_protocol_handler.cpp
     efl/ewk/ewk_tiled_backing_store.c
     efl/ewk/ewk_tiled_matrix.c
     efl/ewk/ewk_tiled_model.c
@@ -115,6 +116,7 @@
   LIST(APPEND WebKit_SOURCES
     efl/ewk/ewk_auth.cpp
     efl/ewk/ewk_auth_soup.cpp
+    efl/ewk/ewk_protocol_handler_soup.cpp
   )
 ENDIF ()
 
@@ -235,6 +237,7 @@
     ${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_logging.h
     ${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_main.h
     ${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_network.h
+    ${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_protocol_handler.h
     ${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_settings.h
     ${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_view.h
     ${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_window_features.h

Modified: trunk/Source/WebKit/efl/ChangeLog (94964 => 94965)


--- trunk/Source/WebKit/efl/ChangeLog	2011-09-12 17:52:51 UTC (rev 94964)
+++ trunk/Source/WebKit/efl/ChangeLog	2011-09-12 17:54:33 UTC (rev 94965)
@@ -1,3 +1,26 @@
+2011-09-12  Flavio Ceolin  <[email protected]>
+
+        Reviewed by Martin Robinson.
+
+        [EFL] Add custom network resource handler
+        https://bugs.webkit.org/show_bug.cgi?id=44759
+
+        This patch adds support for handling user-specific protocols.
+        It allows browsers to intercept and handle non-standard url schemes (such as preferences://)
+        allowing to load some resource from non-http/file storage, like a tar/zip/eet.
+
+        * CMakeListsEfl.txt:
+        * ewk/ewk_protocol_handler.cpp: Added.
+        * ewk/ewk_protocol_handler.h: Added.
+        * ewk/ewk_protocol_handler_soup.cpp: Added.
+        * ewk/ewk_protocol_handler_soup.h: Added.
+        * ewk/ewk_private.h:
+        * ewk/ewk_view.cpp:
+        (ewk_view_protocol_handler_set):
+        (ewk_view_protocol_handler_unset):
+        (ewk_view_protocol_handler_resource_get):
+        * ewk/ewk_view.h:
+
 2011-09-04  Ryuan Choi  <[email protected]>
 
         [EFL] Rename ewk_view_(single|tiled).c to ewk_view_(single|tiled).cpp

Modified: trunk/Source/WebKit/efl/ewk/ewk_private.h (94964 => 94965)


--- trunk/Source/WebKit/efl/ewk/ewk_private.h	2011-09-12 17:52:51 UTC (rev 94964)
+++ trunk/Source/WebKit/efl/ewk/ewk_private.h	2011-09-12 17:54:33 UTC (rev 94965)
@@ -134,6 +134,7 @@
 void ewk_view_viewport_attributes_set(Evas_Object *o, const WebCore::ViewportArguments &arguments);
 
 void ewk_view_download_request(Evas_Object *o, Ewk_Download *download);
+void *ewk_view_protocol_handler_resource_get(Evas_Object *o, size_t *bytesRead, char **mime, const char *file);
 
 void ewk_view_editor_client_contents_changed(Evas_Object *o);
 void ewk_view_editor_client_selection_changed(Evas_Object *o);

Added: trunk/Source/WebKit/efl/ewk/ewk_protocol_handler.cpp (0 => 94965)


--- trunk/Source/WebKit/efl/ewk/ewk_protocol_handler.cpp	                        (rev 0)
+++ trunk/Source/WebKit/efl/ewk/ewk_protocol_handler.cpp	2011-09-12 17:54:33 UTC (rev 94965)
@@ -0,0 +1,45 @@
+/*
+    Copyright (C) 2011 ProFUSION embedded systems
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "ewk_protocol_handler.h"
+
+#if USE(SOUP)
+#include "ewk_protocol_handler_soup.h"
+#endif
+
+Eina_Bool ewk_custom_protocol_handler_set(const char** protocols)
+{
+#if USE(SOUP)
+    return ewk_custom_protocol_handler_soup_set(protocols);
+#else
+    EINA_LOG_CRIT("Not implemented");
+    return EINA_FALSE;
+#endif
+}
+
+Eina_Bool ewk_custom_protocol_handler_all_unset()
+{
+#if USE(SOUP)
+    return ewk_custom_protocol_handler_soup_all_unset();
+#else
+    EINA_LOG_CRIT("Not implemented");
+    return EINA_FALSE;
+#endif
+}

Added: trunk/Source/WebKit/efl/ewk/ewk_protocol_handler.h (0 => 94965)


--- trunk/Source/WebKit/efl/ewk/ewk_protocol_handler.h	                        (rev 0)
+++ trunk/Source/WebKit/efl/ewk/ewk_protocol_handler.h	2011-09-12 17:54:33 UTC (rev 94965)
@@ -0,0 +1,54 @@
+/*
+    Copyright (C) 2011 ProFUSION embedded systems
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+/**
+ * @file    ewk_protocol_handler.h
+ * @brief   Describes the custom protocol handler API.
+ */
+
+#ifndef ewk_protocol_handler_h
+#define ewk_protocol_handler_h
+
+#include <Eina.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Register a protocol handler.
+ *
+ * @param protocols the protocols that will be handled.
+ * @return @c EINA_TRUE if success, @c EINA_FALSE if not.
+ */
+EAPI Eina_Bool ewk_custom_protocol_handler_set(const char** protocols);
+
+/**
+ * Remove protocol handler.
+ *
+ * @return @c EINA_TRUE if success, @c EINA_FALSE if not.
+ */
+EAPI Eina_Bool ewk_custom_protocol_handler_all_unset();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // ewk_protocol_handler_h
+

Added: trunk/Source/WebKit/efl/ewk/ewk_protocol_handler_soup.cpp (0 => 94965)


--- trunk/Source/WebKit/efl/ewk/ewk_protocol_handler_soup.cpp	                        (rev 0)
+++ trunk/Source/WebKit/efl/ewk/ewk_protocol_handler_soup.cpp	2011-09-12 17:54:33 UTC (rev 94965)
@@ -0,0 +1,197 @@
+/*
+    Copyright (C) 2011 ProFUSION embedded systems
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "ewk_protocol_handler_soup.h"
+
+#include "FrameLoaderClientEfl.h"
+#include "FrameNetworkingContextEfl.h"
+#include "ResourceHandle.h"
+#include "ResourceHandleClient.h"
+#include "ResourceHandleInternal.h"
+#include "ewk_private.h"
+#include <glib-object.h>
+#include <glib.h>
+#include <libsoup/soup-requester.h>
+#include <libsoup/soup.h>
+
+struct _EwkProtocolHandlerPrivate {
+    char* mime;
+    size_t bytesRead;
+};
+
+G_DEFINE_TYPE(EwkCustomProtocolHandler, ewk_custom_protocol_handler, SOUP_TYPE_REQUEST)
+
+static char** schemes = 0;
+static unsigned customProtocolAddedCount = 0;
+
+static void ewk_custom_protocol_handler_init(EwkCustomProtocolHandler* customProtocolHandler)
+{
+    customProtocolHandler->priv = G_TYPE_INSTANCE_GET_PRIVATE(customProtocolHandler, EWK_TYPE_CUSTOM_PROTOCOL_HANDLER,
+                                                              EwkProtocolHandlerPrivate);
+    EINA_SAFETY_ON_NULL_RETURN(customProtocolHandler->priv);
+
+    customProtocolHandler->priv->mime = 0;
+    customProtocolHandler->priv->bytesRead = 0;
+}
+
+static void ewk_custom_protocol_handler_finalize(GObject* obj)
+{
+    EwkProtocolHandlerPrivate* priv  = G_TYPE_INSTANCE_GET_PRIVATE(obj, EWK_TYPE_CUSTOM_PROTOCOL_HANDLER,
+                                                                   EwkProtocolHandlerPrivate);
+    if (priv)
+        free(priv->mime);
+
+    G_OBJECT_CLASS(ewk_custom_protocol_handler_parent_class)->finalize(obj);
+}
+
+static gboolean ewk_custom_protocol_handler_check_uri(SoupRequest* request, SoupURI* uri, GError** error)
+{
+    return TRUE;
+}
+
+static GInputStream* ewk_custom_protocol_handler_send(SoupRequest* request, GCancellable* cancellable, GError** error)
+{
+    void* buffer;
+    char* mime = 0;
+    size_t bytesRead = 0;
+
+    WebCore::ResourceHandle* resource = static_cast<
+        WebCore::ResourceHandle*>(g_object_get_data(G_OBJECT(request), "webkit-resource"));
+    EINA_SAFETY_ON_NULL_RETURN_VAL(resource, 0);
+
+    const WebCore::FrameNetworkingContextEfl* frameContext = static_cast<
+        WebCore::FrameNetworkingContextEfl*>(resource->getInternal()->m_context.get());
+    EINA_SAFETY_ON_NULL_RETURN_VAL(frameContext, 0);
+
+    const WebCore::FrameLoaderClientEfl* frameLoaderClient = static_cast<
+        WebCore::FrameLoaderClientEfl*>(frameContext->coreFrame()->loader()->client());
+    EINA_SAFETY_ON_NULL_RETURN_VAL(frameLoaderClient, 0);
+
+    SoupURI* uri = soup_request_get_uri(request);
+    EINA_SAFETY_ON_NULL_RETURN_VAL(uri, 0);
+
+    EwkProtocolHandlerPrivate* priv = G_TYPE_INSTANCE_GET_PRIVATE(
+        reinterpret_cast<EwkCustomProtocolHandler*>(request),
+        EWK_TYPE_CUSTOM_PROTOCOL_HANDLER,
+        EwkProtocolHandlerPrivate);
+
+    EINA_SAFETY_ON_NULL_RETURN_VAL(priv, 0);
+
+
+    if (uri->path[0] == '/') {
+        buffer = ewk_view_protocol_handler_resource_get(frameLoaderClient->webView(),
+                                                        &bytesRead, &mime, uri->path + 1); // The path is always initialized with /.
+    } else
+        buffer = ewk_view_protocol_handler_resource_get(frameLoaderClient->webView(), &bytesRead, &mime, uri->host);
+
+    priv->bytesRead = bytesRead;
+    if (mime)
+        priv->mime = strdup(mime);
+
+    return g_memory_input_stream_new_from_data(buffer, bytesRead, free);
+}
+
+static goffset ewk_custom_protocol_handler_get_content_length(SoupRequest* request)
+{
+    EwkProtocolHandlerPrivate* priv  = G_TYPE_INSTANCE_GET_PRIVATE(reinterpret_cast<EwkCustomProtocolHandler*>(request),
+                                                                   EWK_TYPE_CUSTOM_PROTOCOL_HANDLER,
+                                                                   EwkProtocolHandlerPrivate);
+    return (priv) ? priv->bytesRead : 0;
+}
+
+static const char* ewk_custom_protocol_handler_get_content_type(SoupRequest* request)
+{
+    EwkProtocolHandlerPrivate* priv  = G_TYPE_INSTANCE_GET_PRIVATE(reinterpret_cast<EwkCustomProtocolHandler*>(request),
+                                                                   EWK_TYPE_CUSTOM_PROTOCOL_HANDLER,
+                                                                   EwkProtocolHandlerPrivate);
+    return (priv && priv->mime) ? priv->mime : "text/html";
+}
+
+static void ewk_custom_protocol_handler_class_init(EwkCustomProtocolHandlerClass* customProtocolHandlerClass)
+{
+    GObjectClass* gobjectClass = G_OBJECT_CLASS(customProtocolHandlerClass);
+    SoupRequestClass* requestClass = SOUP_REQUEST_CLASS(customProtocolHandlerClass);
+
+    gobjectClass->finalize = ewk_custom_protocol_handler_finalize;
+    requestClass->schemes = const_cast<const char**>(schemes);
+    requestClass->check_uri = ewk_custom_protocol_handler_check_uri;
+    requestClass->send = ewk_custom_protocol_handler_send;
+    requestClass->get_content_length = ewk_custom_protocol_handler_get_content_length;
+    requestClass->get_content_type = ewk_custom_protocol_handler_get_content_type;
+
+    g_type_class_add_private(customProtocolHandlerClass, sizeof(EwkProtocolHandlerPrivate));
+}
+
+Eina_Bool ewk_custom_protocol_handler_soup_set(const char** protocols)
+{
+    guint protocolsSize;
+    SoupSession* session = WebCore::ResourceHandle::defaultSession();
+    SoupSessionFeature* requester;
+
+    protocolsSize = g_strv_length(const_cast<gchar**>(protocols));
+
+    // This array must be null terminated.
+    EINA_SAFETY_ON_TRUE_RETURN_VAL(!protocolsSize || protocols[protocolsSize], EINA_FALSE);
+
+    requester = soup_session_get_feature(session, SOUP_TYPE_REQUESTER);
+    if (!requester) {
+        requester = SOUP_SESSION_FEATURE(soup_requester_new());
+        soup_session_add_feature(session, requester);
+        g_object_unref(requester);
+    }
+
+    if (soup_session_feature_has_feature(requester, EWK_TYPE_CUSTOM_PROTOCOL_HANDLER)) {
+        customProtocolAddedCount++;
+        return EINA_TRUE;
+    }
+
+    schemes = g_strdupv(const_cast<gchar**>(protocols));
+    if (!(schemes && soup_session_feature_add_feature(requester, EWK_TYPE_CUSTOM_PROTOCOL_HANDLER)))
+        return EINA_FALSE;
+
+    customProtocolAddedCount++;
+    return EINA_TRUE;
+}
+
+Eina_Bool ewk_custom_protocol_handler_soup_all_unset()
+{
+    SoupSession* session = WebCore::ResourceHandle::defaultSession();
+    SoupSessionFeature* requester;
+
+    if (!customProtocolAddedCount)
+        return EINA_FALSE;
+
+    requester = soup_session_get_feature(session, SOUP_TYPE_REQUESTER);
+    if (!requester)
+        return EINA_FALSE;
+
+    if (!soup_session_feature_has_feature(requester, EWK_TYPE_CUSTOM_PROTOCOL_HANDLER))
+        return EINA_FALSE;
+
+    if (customProtocolAddedCount == 1) {
+        if (soup_session_feature_remove_feature(requester, EWK_TYPE_CUSTOM_PROTOCOL_HANDLER))
+            g_strfreev(schemes);
+        else
+            return EINA_FALSE;
+    }
+
+    customProtocolAddedCount--;
+    return EINA_TRUE;
+}

Added: trunk/Source/WebKit/efl/ewk/ewk_protocol_handler_soup.h (0 => 94965)


--- trunk/Source/WebKit/efl/ewk/ewk_protocol_handler_soup.h	                        (rev 0)
+++ trunk/Source/WebKit/efl/ewk/ewk_protocol_handler_soup.h	2011-09-12 17:54:33 UTC (rev 94965)
@@ -0,0 +1,64 @@
+/*
+    Copyright (C) 2011 ProFUSION embedded systems
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#ifndef ewk_protocol_handler_soup_h
+#define ewk_protocol_handler_soup_h
+
+#include "ewk_protocol_handler.h"
+
+#include <glib-object.h>
+#include <glib.h>
+#define LIBSOUP_USE_UNSTABLE_REQUEST_API
+#include <libsoup/soup-request.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define EWK_TYPE_CUSTOM_PROTOCOL_HANDLER            (ewk_custom_protocol_handler_get_type ())
+#define EWK_CUSTOM_PROTOCOL_HANDLER(object)         (G_TYPE_CHECK_INSTANCE_CAST ((object), EWK_TYPE_CUSTOM_PROTOCOL_HANDLER, EwkCustomProtocolHandler))
+#define EWK_CUSTOM_PROTOCOL_HANDLER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), EWK_TYPE_CUSTOM_PROTOCOL_HANDLER, EwkCustomProtocolHandlerClass))
+#define EWK_IS_CUSTOM_PROTOCOL_HANDLER(object)      (G_TYPE_CHECK_INSTANCE_TYPE ((object), EWK_TYPE_CUSTOM_PROTOCOL_HANDLER))
+#define EWK_IS_CUSTOM_PROTOCOL_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EWK_TYPE_CUSTOM_PROTOCOL_HANDLER))
+#define EWK_CUSTOM_PROTOCOL_HANDLER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), EWK_TYPE_CUSTOM_PROTOCOL_HANDLER, EwkCustomProtocolHandlerClass))
+
+typedef struct _EwkProtocolHandlerPrivate EwkProtocolHandlerPrivate;
+
+typedef struct {
+    SoupRequest parent;
+    EwkProtocolHandlerPrivate *priv;
+} EwkCustomProtocolHandler;
+
+typedef struct {
+    SoupRequestClass parent;
+} EwkCustomProtocolHandlerClass;
+
+
+GType ewk_custom_protocol_handler_get_type();
+
+Eina_Bool ewk_custom_protocol_handler_soup_set(const char** protocols);
+
+Eina_Bool ewk_custom_protocol_handler_soup_all_unset();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // ewk_protocol_handler_soup_h
+

Modified: trunk/Source/WebKit/efl/ewk/ewk_view.cpp (94964 => 94965)


--- trunk/Source/WebKit/efl/ewk/ewk_view.cpp	2011-09-12 17:52:51 UTC (rev 94964)
+++ trunk/Source/WebKit/efl/ewk/ewk_view.cpp	2011-09-12 17:54:33 UTC (rev 94965)
@@ -50,6 +50,7 @@
 #include "RenderTheme.h"
 #include "c_instance.h"
 #include "ewk_private.h"
+#include "ewk_protocol_handler.h"
 
 #include <Ecore.h>
 #include <Eina.h>
@@ -93,6 +94,10 @@
     WebCore::ViewportArguments viewport_arguments;
     Ewk_History *history;
     struct {
+        void* context;
+        Ewk_View_Resource_Handler_Cb function;
+    } custom_resource_handler;
+    struct {
         Ewk_Menu menu;
         WebCore::PopupMenuClient *menu_client;
     } popup;
@@ -3596,7 +3601,46 @@
 #endif // ENABLE(NETSCAPE_PLUGIN_API)
 }
 
+Eina_Bool ewk_view_protocol_handler_set(Evas_Object* o, const char** protocols, Ewk_View_Resource_Handler_Cb handler, void* context)
+{
+    EWK_VIEW_SD_GET(o, sd);
+    EWK_VIEW_PRIV_GET(sd, priv);
 
+    if (!handler)
+        return EINA_FALSE;
+
+    priv->custom_resource_handler.function = handler;
+    priv->custom_resource_handler.context = context;
+
+    return ewk_custom_protocol_handler_set(protocols);
+}
+
+Eina_Bool ewk_view_protocol_handler_unset(Evas_Object* o)
+{
+    EWK_VIEW_SD_GET(o, sd);
+    EWK_VIEW_PRIV_GET(sd, priv);
+    Eina_Bool ret = ewk_custom_protocol_handler_all_unset();
+
+    if (ret) {
+        priv->custom_resource_handler.function = 0;
+        priv->custom_resource_handler.context = 0;
+    }
+
+    return ret;
+}
+
+void* ewk_view_protocol_handler_resource_get(Evas_Object* o, size_t* bytesRead, char** mime, const char* file)
+{
+    EWK_VIEW_SD_GET(o, sd);
+    EWK_VIEW_PRIV_GET(sd, priv);
+
+    Ewk_View_Resource_Handler_Cb function = priv->custom_resource_handler.function;
+    if (function)
+        return function(file, bytesRead, mime, priv->custom_resource_handler.context);
+
+    return 0;
+}
+
 /**
  * @internal
  * Reports that the contents have resized. The ewk_view calls contents_resize,

Modified: trunk/Source/WebKit/efl/ewk/ewk_view.h (94964 => 94965)


--- trunk/Source/WebKit/efl/ewk/ewk_view.h	2011-09-12 17:52:51 UTC (rev 94964)
+++ trunk/Source/WebKit/efl/ewk/ewk_view.h	2011-09-12 17:54:33 UTC (rev 94965)
@@ -99,6 +99,9 @@
 /// Creates a type name for @a _Ewk_View_Smart_Data.
 typedef struct _Ewk_View_Smart_Data Ewk_View_Smart_Data;
 
+/// Creates a type name for a Resource Handler Callback
+typedef void* (*Ewk_View_Resource_Handler_Cb)(const char *, size_t *, char **, void *);
+
 /// Creates a type name for @a _Ewk_View_Smart_Class.
 typedef struct _Ewk_View_Smart_Class Ewk_View_Smart_Class;
 /// Ewk view's class, to be overridden by sub-classes.
@@ -2144,6 +2147,26 @@
  * @return @c EINA_TRUE if object was added, @c EINA_FALSE if not.
  */
 EAPI Eina_Bool ewk_view_js_object_add(Evas_Object *o, Ewk_JS_Object *obj, const char *obj_name);
+
+/**
+ * Register a new protocol handler for handling an specific protocol (scheme).
+ *
+ * @param o view.
+ * @param protocols the protocols that will be handled.
+ * @param handler the function that will be executed for the protocols
+ * @param ctxt the handler context
+ * @return @c EINA_TRUE if success, @c EINA_FALSE if not.
+ */
+EAPI Eina_Bool ewk_view_protocol_handler_set(Evas_Object* o, const char** protocol, Ewk_View_Resource_Handler_Cb handler, void* ctxt);
+
+/**
+ * Remove the custom protocol handler.
+ *
+ * @param o view.
+ * @return @c EINA_TRUE if success, @c EINA_FALSE if not.
+ */
+EAPI Eina_Bool ewk_view_protocol_handler_unset(Evas_Object* o);
+
 #ifdef __cplusplus
 }
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to