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:
parent
0aeb2e3f9b
commit
f2049b6837
@ -122,7 +122,8 @@ public:
|
||||
virtual void RunScript(const wxString& javascript);
|
||||
|
||||
//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 */
|
||||
bool m_ready;
|
||||
@ -148,6 +149,8 @@ private:
|
||||
GtkWidget *web_view;
|
||||
gint m_historyLimit;
|
||||
|
||||
wxVector<wxWebHandler*> m_handlerList;
|
||||
|
||||
wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit);
|
||||
};
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "wx/gtk/webview_webkit.h"
|
||||
#include "wx/gtk/control.h"
|
||||
#include "wx/gtk/private.h"
|
||||
#include "wx/filesys.h"
|
||||
#include "webkit/webkit.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -62,7 +63,7 @@ wxgtk_webview_webkit_load_status(GtkWidget* widget,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
wxgtk_webview_webkit_navigation(WebKitWebView*,
|
||||
wxgtk_webview_webkit_navigation(WebKitWebView *view,
|
||||
WebKitWebFrame *frame,
|
||||
WebKitNetworkRequest *request,
|
||||
WebKitWebNavigationAction *,
|
||||
@ -91,6 +92,31 @@ wxgtk_webview_webkit_navigation(WebKitWebView*,
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -820,6 +846,11 @@ void wxWebViewWebKit::RunScript(const wxString& javascript)
|
||||
javascript.mb_str(wxConvUTF8));
|
||||
}
|
||||
|
||||
void wxWebViewWebKit::RegisterHandler(wxWebHandler* handler)
|
||||
{
|
||||
m_handlerList.push_back(handler);
|
||||
}
|
||||
|
||||
// static
|
||||
wxVisualAttributes
|
||||
wxWebViewWebKit::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
|
||||
|
Loading…
Reference in New Issue
Block a user