WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
0001-EFL-Add-custom-network-resource-handler.patch (text/plain), 14.99 KB, created by
Flavio Ceolin
on 2011-06-10 14:28:02 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Flavio Ceolin
Created:
2011-06-10 14:28:02 PDT
Size:
14.99 KB
patch
obsolete
>From 5384165f538a3e0211e9aba6416077d00b13c06d Mon Sep 17 00:00:00 2001 >From: Flavio Ceolin <flavio.ceolin@profusion.mobi> >Date: Fri, 10 Jun 2011 18:21:14 -0300 >Subject: [PATCH] [EFL] Add custom network resource handler > https://bugs.webkit.org/show_bug.cgi?id=44759 This > patch adds support for handling user-specific protocols > (schemes). That means load some resource from > non-http/file storage, like a tar/zip/eet. > >--- > Source/WebCore/ChangeLog | 17 ++++ > .../platform/network/soup/ResourceHandleSoup.cpp | 68 ++++++++++++++++ > Source/WebKit/ChangeLog | 33 ++++++++ > .../efl/WebCoreSupport/FrameLoaderClientEfl.cpp | 33 ++++++++ > .../efl/WebCoreSupport/FrameLoaderClientEfl.h | 2 + > Source/WebKit/efl/ewk/ewk_private.h | 3 + > Source/WebKit/efl/ewk/ewk_view.cpp | 85 +++++++++++++++++++- > Source/WebKit/efl/ewk/ewk_view.h | 10 +++ > 8 files changed, 250 insertions(+), 1 deletions(-) > >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index e36679d..2e6dd67 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,20 @@ >+2011-06-10 Flavio Ceolin <flavio.ceolin@profusion.mobi> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ [EFL] Add custom network resource handler >+ https://bugs.webkit.org/show_bug.cgi?id=44759 >+ >+ This patch adds support for handling user-specific protocols (schemes). >+ That means load some resource from non-http/file storage, like a tar/zip/eet. >+ >+ EFL port does not have automated test yet, so no new tests. >+ >+ * platform/network/soup/ResourceHandleSoup.cpp: >+ (WebCore::): In this part is checked if the protocol will be handled by >+ a custom resource handler, if yes, ask for the FrameLoaderClientEfl the resources for >+ the protocol >+ > 2011-06-10 Luke Macpherson <macpherson@chromium.org> > > Reviewed by Eric Seidel. >diff --git a/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp b/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp >index 0c855d4..af9827c 100644 >--- a/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp >+++ b/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp >@@ -55,9 +55,15 @@ > #include <libsoup/soup-requester.h> > #include <libsoup/soup.h> > #include <sys/stat.h> >+#include <sys/time.h> > #include <sys/types.h> > #include <unistd.h> > >+#if PLATFORM(EFL) >+#include "FrameLoaderClientEfl.h" >+#include "FrameNetworkingContextEfl.h" >+#endif >+ > namespace WebCore { > > #define READ_BUFFER_SIZE 8192 >@@ -131,6 +137,10 @@ static void readCallback(GObject*, GAsyncResult*, gpointer); > static void closeCallback(GObject*, GAsyncResult*, gpointer); > static bool startNonHTTPRequest(ResourceHandle*, KURL); > >+#if PLATFORM(EFL) >+static bool startCustomHandler(ResourceHandle*, KURL); >+#endif >+ > ResourceHandleInternal::~ResourceHandleInternal() > { > if (m_soupRequest) >@@ -663,6 +673,15 @@ bool ResourceHandle::start(NetworkingContext* context) > // Used to set the authentication dialog toplevel; may be NULL > d->m_context = context; > >+#if PLATFORM(EFL) >+ FrameNetworkingContextEfl* frameContext = static_cast<FrameNetworkingContextEfl*>(context); >+ FrameLoaderClientEfl* frameLoaderClient = static_cast<FrameLoaderClientEfl*>(frameContext->coreFrame()->loader()->client()); >+ if (frameLoaderClient->shouldHandleScheme(protocol)) { >+ if (startCustomHandler(this, url)) >+ return true; >+ } >+#endif >+ > if (equalIgnoringCase(protocol, "http") || equalIgnoringCase(protocol, "https")) { > if (startHTTPRequest(this)) > return true; >@@ -853,4 +872,53 @@ SoupSession* ResourceHandle::defaultSession() > return session; > } > >+#if PLATFORM(EFL) >+static bool startCustomHandler(ResourceHandle* handle, KURL url) >+{ >+ ASSERT(handle); >+ >+ ResourceResponse response; >+ String mime; >+ void* buf; >+ struct timeval tv; >+ ResourceHandleInternal* d = handle->getInternal(); >+ size_t bytesRead; >+ ResourceHandleClient* client = handle->client(); >+ >+ if (handle->firstRequest().httpMethod() != "GET" && handle->firstRequest().httpMethod() != "POST") >+ return false; >+ >+ url.removeFragmentIdentifier(); >+ url.setQuery(String()); >+ url.removePort(); >+ >+ FrameNetworkingContextEfl* fr = static_cast<FrameNetworkingContextEfl *>(d->m_context.get()); >+ FrameLoaderClientEfl* frameLoaderClient = static_cast<FrameLoaderClientEfl*>(fr->coreFrame()->loader()->client()); >+ buf = frameLoaderClient->handleScheme(url, mime, &bytesRead); >+ if (!buf) >+ return false; >+ >+ // balanced by a deref() in cleanupGioOperation, which should always run >+ handle->ref(); >+ >+ gettimeofday(&tv, 0); >+ response.setURL(KURL(KURL(), url.string().utf8().data())); >+ response.setExpectedContentLength(bytesRead); >+ response.setLastModifiedDate(tv.tv_sec); >+ response.setMimeType(mime); >+ client->didReceiveResponse(handle, response); >+ >+ d->m_inputStream = g_memory_input_stream_new_from_data(buf, bytesRead, free); >+ d->m_bodySize = bytesRead; >+ d->m_buffer = static_cast<char*>(g_malloc(d->m_bodySize)); >+ >+ g_object_set_data(G_OBJECT(d->m_inputStream.get()), "webkit-resource", handle); >+ g_input_stream_read_async(d->m_inputStream.get(), d->m_buffer, d->m_bodySize, >+ G_PRIORITY_DEFAULT, d->m_cancellable.get(), >+ readCallback, 0); >+ >+ return true; >+} >+#endif >+ > } >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 268fd80..7ecd1e5 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,36 @@ >+2011-06-10 Flavio Ceolin <flavio.ceolin@profusion.mobi> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ [EFL] Add custom network resource handler >+ https://bugs.webkit.org/show_bug.cgi?id=44759 >+ >+ This patch adds support for handling user-specific protocols (schemes). >+ That means load some resource from non-http/file storage, like a tar/zip/eet. >+ >+ EFL port does not have automated test yet, so no new tests. >+ >+ >+ * efl/WebCoreSupport/FrameLoaderClientEfl.cpp: >+ (WebCore::FrameLoaderClientEfl::shouldHandleScheme): >+ (WebCore::FrameLoaderClientEfl::handleScheme): >+ >+ It's the pipe between ResourceHandlerSoup and the ewk_view >+ >+ * WebCoreSupport/FrameLoaderClientEfl.h: >+ >+ * ewk/ewk_private.h: >+ * ewk/ewk_view.cpp: >+ (_ewk_view_priv_new): >+ (_ewk_view_priv_del): >+ (ewk_view_protocol_handler_register): >+ (ewk_view_protocol_handler_unregister): >+ (ewk_view_protocol_handler_valid_is): >+ (ewk_view_protocol_handler_get): >+ * ewk/ewk_view.h: >+ >+ Where the custom resource handler is stored. >+ > 2011-06-02 Adam Barth <abarth@webkit.org> > > Reviewed by Ryosuke Niwa. >diff --git a/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp b/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp >index 5295e4a..7429610 100644 >--- a/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp >+++ b/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp >@@ -921,4 +921,37 @@ PassRefPtr<FrameNetworkingContext> FrameLoaderClientEfl::createNetworkingContext > return FrameNetworkingContextEfl::create(ewk_frame_core_get(m_frame)); > } > >+bool FrameLoaderClientEfl::shouldHandleScheme(const String& scheme) >+{ >+ if (!m_view) >+ return false; >+ >+ if (ewk_view_protocol_handler_valid_is(m_view, scheme.utf8().data())) >+ return true; >+ >+ return false; >+} >+ >+void* FrameLoaderClientEfl::handleScheme(const KURL url, String& mime, size_t* bytesRead) >+{ >+ Ewk_View_Resource_Handler_Cb func; >+ Ewk_View_Resource_Handler* handler; >+ char* mimetype = 0; >+ void* buf; >+ >+ handler = static_cast<Ewk_View_Resource_Handler *>(ewk_view_protocol_handler_get(m_view, url.protocol().utf8().data())); >+ func = handler->func; >+ >+ if (url.lastPathComponent().isEmpty()) >+ buf = func(url.string().utf8().data() + url.protocol().length() + 3, bytesRead, >+ &mimetype, handler->ctxt); >+ else >+ buf = func(url.lastPathComponent().utf8().data(), bytesRead, &mimetype, handler->ctxt); >+ >+ mime = (!mimetype) ? "text/html" : mimetype; >+ free(mimetype); >+ >+ return buf; >+} >+ > } >diff --git a/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.h b/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.h >index d5775c6..aed28b4 100644 >--- a/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.h >+++ b/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.h >@@ -210,6 +210,8 @@ class FrameLoaderClientEfl : public FrameLoaderClient { > virtual void download(ResourceHandle*, const ResourceRequest&, const ResourceRequest&, const ResourceResponse&); > > virtual PassRefPtr<WebCore::FrameNetworkingContext> createNetworkingContext(); >+ virtual bool shouldHandleScheme(const String&); >+ virtual void* handleScheme(const KURL, String&, size_t*); > private: > Evas_Object *m_view; > Evas_Object *m_frame; >diff --git a/Source/WebKit/efl/ewk/ewk_private.h b/Source/WebKit/efl/ewk/ewk_private.h >index 11f0d62..3400a83 100644 >--- a/Source/WebKit/efl/ewk/ewk_private.h >+++ b/Source/WebKit/efl/ewk/ewk_private.h >@@ -111,6 +111,9 @@ void ewk_view_viewport_attributes_set(Evas_Object *o, const WebCore::ViewportArg > > void ewk_view_download_request(Evas_Object *o, Ewk_Download *download); > >+Eina_Bool ewk_view_protocol_handler_valid_is(Evas_Object *o, const char *scheme); >+void *ewk_view_protocol_handler_get(Evas_Object *o, const char *scheme); >+ > int ewk_util_dpi_get(void); > > #if ENABLE(TOUCH_EVENTS) >diff --git a/Source/WebKit/efl/ewk/ewk_view.cpp b/Source/WebKit/efl/ewk/ewk_view.cpp >index 3e3e796..54391c3 100644 >--- a/Source/WebKit/efl/ewk/ewk_view.cpp >+++ b/Source/WebKit/efl/ewk/ewk_view.cpp >@@ -1,3 +1,4 @@ >+ > /* > Copyright (C) 2009-2010 ProFUSION embedded systems > Copyright (C) 2009-2011 Samsung Electronics >@@ -43,6 +44,7 @@ > #include "PlatformMouseEvent.h" > #include "PopupMenuClient.h" > #include "ProgressTracker.h" >+#include "ResourceHandle.h" > #include "ewk_private.h" > > #include <Ecore.h> >@@ -73,6 +75,7 @@ struct _Ewk_View_Private_Data { > WebCore::Frame* main_frame; > WebCore::ViewportArguments viewport_arguments; > Ewk_History* history; >+ Eina_Hash* resource_handlers; > struct { > Ewk_Menu menu; > WebCore::PopupMenuClient* menu_client; >@@ -632,6 +635,12 @@ static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* sd) > priv->settings.zoom_range.user_scalable = EINA_TRUE; > priv->settings.device_pixel_ratio = DEVICE_PIXEL_RATIO; > >+ priv->resource_handlers = eina_hash_string_small_new(0); >+ if (!priv->resource_handlers) { >+ CRITICAL("Could not create resource handlers hash."); >+ goto error_resource_handlers; >+ } >+ > priv->main_frame = _ewk_view_core_frame_new(sd, priv, 0).get(); > if (!priv->main_frame) { > CRITICAL("Could not create main frame."); >@@ -649,6 +658,8 @@ static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* sd) > error_history: > // delete priv->main_frame; /* do not delete priv->main_frame */ > error_main_frame: >+error_resource_handlers: >+ eina_hash_free(priv->resource_handlers); > error_settings: > delete priv->page; > error_page: >@@ -677,6 +688,7 @@ static void _ewk_view_priv_del(Ewk_View_Private_Data* priv) > eina_stringshare_del(priv->settings.font_serif); > eina_stringshare_del(priv->settings.font_sans_serif); > eina_stringshare_del(priv->settings.local_storage_database_path); >+ eina_hash_free(priv->resource_handlers); > > if (priv->animated_zoom.animator) > ecore_animator_del(priv->animated_zoom.animator); >@@ -4465,7 +4477,77 @@ WebCore::FloatRect ewk_view_page_rect_get(Evas_Object *o) > > WebCore::Frame* main_frame = priv->page->mainFrame(); > return main_frame->view()->frameRect(); >-} >+} >+ >+Eina_Bool ewk_view_protocol_handler_valid_is(Evas_Object* o, const char* scheme) >+{ >+ EWK_VIEW_SD_GET(o, sd); >+ EWK_VIEW_PRIV_GET(sd, priv); >+ >+ if (eina_hash_find(priv->resource_handlers, scheme)) >+ return EINA_TRUE; >+ >+ return EINA_FALSE; >+} >+ >+void* ewk_view_protocol_handler_get(Evas_Object* o, const char* scheme) >+{ >+ EWK_VIEW_SD_GET(o, sd); >+ EWK_VIEW_PRIV_GET(sd, priv); >+ >+ return eina_hash_find(priv->resource_handlers, scheme); >+} >+ >+/** >+ * Register a new protocol handler. >+ * >+ * @param o view. >+ * @param protocol the protocol that will be handled. >+ * @param handler the function that will be executed for the protocol >+ * @param ctxt the handler context >+ * @return @c EINA_TRUE if success, @c EINA_FALSE if not. >+ */ >+Eina_Bool ewk_view_protocol_handler_register(Evas_Object* o, const char* protocol, Ewk_View_Resource_Handler_Cb handler, void* ctxt) >+{ >+ EWK_VIEW_SD_GET(o, sd); >+ EWK_VIEW_PRIV_GET(sd, priv); >+ >+ if (!handler) >+ return EINA_FALSE; >+ >+ Ewk_View_Resource_Handler* r = static_cast<Ewk_View_Resource_Handler*> >+ (malloc(sizeof(Ewk_View_Resource_Handler))); >+ >+ if (!r) >+ return EINA_FALSE; >+ >+ r->ctxt = ctxt; >+ r->func = handler; >+ if (!eina_hash_direct_add(priv->resource_handlers, protocol, static_cast<void *>(r))) { >+ free(r); >+ return EINA_FALSE; >+ } >+ >+ return EINA_TRUE; >+} >+ >+/** >+ * Remove protocol handler. >+ * >+ * @param o view. >+ * @param protocol the protocol that will be removed. >+ * @return @c EINA_TRUE if success, @c EINA_FALSE if not. >+ */ >+Eina_Bool ewk_view_protocol_handler_unregister(Evas_Object* o, const char* protocol) >+{ >+ EWK_VIEW_SD_GET(o, sd); >+ EWK_VIEW_PRIV_GET(sd, priv); >+ >+ if (!protocol) >+ return EINA_FALSE; >+ >+ return eina_hash_del_by_key(priv->resource_handlers, protocol); >+} > > #if ENABLE(TOUCH_EVENTS) > void ewk_view_need_touch_events_set(Evas_Object* o, bool needed) >@@ -4482,4 +4564,5 @@ Eina_Bool ewk_view_need_touch_events_get(Evas_Object* o) > EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, EINA_FALSE); > return priv->flags.need_touch_events; > } >+ > #endif >diff --git a/Source/WebKit/efl/ewk/ewk_view.h b/Source/WebKit/efl/ewk/ewk_view.h >index 0360fee..5e90e0a 100644 >--- a/Source/WebKit/efl/ewk/ewk_view.h >+++ b/Source/WebKit/efl/ewk/ewk_view.h >@@ -91,6 +91,13 @@ extern "C" { > * - "tooltip,text,set", const char*: sets tooltip text and displays if it is currently hidden. > */ > >+typedef void* (*Ewk_View_Resource_Handler_Cb)(const char *, size_t *, char **, void *); >+typedef struct _Ewk_View_Resource_Handler Ewk_View_Resource_Handler; >+struct _Ewk_View_Resource_Handler { >+ void *ctxt; >+ Ewk_View_Resource_Handler_Cb func; >+}; >+ > typedef struct _Ewk_View_Smart_Data Ewk_View_Smart_Data; > > /** >@@ -515,6 +522,9 @@ EAPI void ewk_view_layout_if_needed_recursive(Ewk_View_Private_Data *priv); > > EAPI void ewk_view_scrolls_process(Ewk_View_Smart_Data *sd); > >+EAPI Eina_Bool ewk_view_protocol_handler_register(Evas_Object *o, const char *protocol, Ewk_View_Resource_Handler_Cb handler, void *ctxt); >+EAPI Eina_Bool ewk_view_protocol_handler_unregister(Evas_Object *o, const char *protocol); >+ > /** > * Structure that keeps paint context. > * >-- >1.7.5.2 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 44759
:
65700
|
66764
|
96774
|
96789
|
100128
|
100153
|
105627
|
107055