Initial work on virtual file system support for the WebKitGTK+ backend. It now supports loading single pages from the VFS system.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68503 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Steve Lamerton
2011-08-03 09:29:30 +00:00
parent 0aeb2e3f9b
commit f2049b6837
2 changed files with 36 additions and 2 deletions

View File

@@ -122,7 +122,8 @@ public:
virtual void RunScript(const wxString& javascript); virtual void RunScript(const wxString& javascript);
//Virtual Filesystem Support //Virtual Filesystem Support
virtual void RegisterHandler(wxWebHandler* WXUNUSED(handler)) {}; virtual void RegisterHandler(wxWebHandler* handler);
virtual wxVector<wxWebHandler*> GetHandlers() { return m_handlerList; }
/** FIXME: hack to work around signals being received too early */ /** FIXME: hack to work around signals being received too early */
bool m_ready; bool m_ready;
@@ -148,6 +149,8 @@ private:
GtkWidget *web_view; GtkWidget *web_view;
gint m_historyLimit; gint m_historyLimit;
wxVector<wxWebHandler*> m_handlerList;
wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit); wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit);
}; };

View File

@@ -16,6 +16,7 @@
#include "wx/gtk/webview_webkit.h" #include "wx/gtk/webview_webkit.h"
#include "wx/gtk/control.h" #include "wx/gtk/control.h"
#include "wx/gtk/private.h" #include "wx/gtk/private.h"
#include "wx/filesys.h"
#include "webkit/webkit.h" #include "webkit/webkit.h"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -62,7 +63,7 @@ wxgtk_webview_webkit_load_status(GtkWidget* widget,
} }
static gboolean static gboolean
wxgtk_webview_webkit_navigation(WebKitWebView*, wxgtk_webview_webkit_navigation(WebKitWebView *view,
WebKitWebFrame *frame, WebKitWebFrame *frame,
WebKitNetworkRequest *request, WebKitNetworkRequest *request,
WebKitWebNavigationAction *, WebKitWebNavigationAction *,
@@ -91,6 +92,31 @@ wxgtk_webview_webkit_navigation(WebKitWebView*,
} }
else else
{ {
wxString wxuri = uri;
wxWebHandler *handler = NULL;
wxVector<wxWebHandler*> hanlders = webKitCtrl->GetHandlers();
//We are not vetoed so see if we match one of the additional handlers
for(wxVector<wxWebHandler*>::iterator it = hanlders.begin();
it != hanlders.end(); ++it)
{
if(wxuri.substr(0, (*it)->GetName().length()) == (*it)->GetName())
{
handler = (*it);
}
}
//If we found a handler we can then use it to load the file directly
//ourselves
if(handler)
{
wxFSFile* file = handler->GetFile(wxuri);
g_signal_handlers_block_by_func(view,
(gpointer)wxgtk_webview_webkit_navigation,
webKitCtrl);
webKitCtrl->SetPage(*file->GetStream(), wxuri);
g_signal_handlers_unblock_by_func(view,
(gpointer)wxgtk_webview_webkit_navigation,
webKitCtrl);
}
return FALSE; return FALSE;
} }
} }
@@ -820,6 +846,11 @@ void wxWebViewWebKit::RunScript(const wxString& javascript)
javascript.mb_str(wxConvUTF8)); javascript.mb_str(wxConvUTF8));
} }
void wxWebViewWebKit::RegisterHandler(wxWebHandler* handler)
{
m_handlerList.push_back(handler);
}
// static // static
wxVisualAttributes wxVisualAttributes
wxWebViewWebKit::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant)) wxWebViewWebKit::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))