Rename wxWebFileHandler to wxWebViewArchiveHandler, wxWebHandler to wxWebViewHandler. Update the documentation and the sample. Add a constructor taking a wxString to specify the scheme in wxWebViewHandler.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68689 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
3beb50e570
commit
7d8d6163ad
@ -122,8 +122,8 @@ public:
|
||||
virtual void RunScript(const wxString& javascript);
|
||||
|
||||
//Virtual Filesystem Support
|
||||
virtual void RegisterHandler(wxSharedPtr<wxWebHandler> handler);
|
||||
virtual wxVector<wxSharedPtr<wxWebHandler> > GetHandlers() { return m_handlerList; }
|
||||
virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler);
|
||||
virtual wxVector<wxSharedPtr<wxWebViewHandler> > GetHandlers() { return m_handlerList; }
|
||||
|
||||
/** FIXME: hack to work around signals being received too early */
|
||||
bool m_ready;
|
||||
@ -155,7 +155,7 @@ private:
|
||||
GtkWidget *web_view;
|
||||
gint m_historyLimit;
|
||||
|
||||
wxVector<wxSharedPtr<wxWebHandler> > m_handlerList;
|
||||
wxVector<wxSharedPtr<wxWebViewHandler> > m_handlerList;
|
||||
|
||||
wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit);
|
||||
};
|
||||
|
@ -110,7 +110,7 @@ public:
|
||||
virtual void RunScript(const wxString& javascript);
|
||||
|
||||
//Virtual Filesystem Support
|
||||
virtual void RegisterHandler(wxSharedPtr<wxWebHandler> handler);
|
||||
virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler);
|
||||
|
||||
// ---- IE-specific methods
|
||||
|
||||
@ -169,10 +169,10 @@ protected:
|
||||
VOID * fileP;
|
||||
|
||||
wxFSFile* m_file;
|
||||
wxSharedPtr<wxWebHandler> m_handler;
|
||||
wxSharedPtr<wxWebViewHandler> m_handler;
|
||||
|
||||
public:
|
||||
VirtualProtocol(wxSharedPtr<wxWebHandler> handler);
|
||||
VirtualProtocol(wxSharedPtr<wxWebViewHandler> handler);
|
||||
~VirtualProtocol();
|
||||
|
||||
//IUnknown
|
||||
@ -211,7 +211,7 @@ class ClassFactory : public IClassFactory
|
||||
private:
|
||||
ULONG m_refCount;
|
||||
public:
|
||||
ClassFactory(wxSharedPtr<wxWebHandler> handler) : m_handler(handler) {}
|
||||
ClassFactory(wxSharedPtr<wxWebViewHandler> handler) : m_handler(handler) {}
|
||||
//IUnknown
|
||||
ULONG STDMETHODCALLTYPE AddRef();
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject);
|
||||
@ -222,7 +222,7 @@ public:
|
||||
REFIID riid, void** ppvObject);
|
||||
HRESULT STDMETHODCALLTYPE LockServer(BOOL fLock);
|
||||
private:
|
||||
wxSharedPtr<wxWebHandler> m_handler;
|
||||
wxSharedPtr<wxWebViewHandler> m_handler;
|
||||
};
|
||||
|
||||
#endif // wxUSE_WEBVIEW_IE && defined(__WXMSW__)
|
||||
|
@ -114,7 +114,7 @@ public:
|
||||
void RunScript(const wxString& javascript);
|
||||
|
||||
//Virtual Filesystem Support
|
||||
virtual void RegisterHandler(wxSharedPtr<wxWebHandler> handler);
|
||||
virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler);
|
||||
|
||||
// ---- methods not from the parent (common) interface
|
||||
bool CanGetPageSource();
|
||||
|
@ -101,11 +101,14 @@ enum wxWebViewBackend
|
||||
};
|
||||
|
||||
//Base class for custom scheme handlers
|
||||
class WXDLLIMPEXP_WEB wxWebHandler
|
||||
class WXDLLIMPEXP_WEB wxWebViewHandler
|
||||
{
|
||||
public:
|
||||
virtual wxString GetName() const = 0;
|
||||
wxWebViewHandler(const wxString& scheme) : m_scheme(scheme) {}
|
||||
virtual wxString GetName() const { return m_scheme; }
|
||||
virtual wxFSFile* GetFile(const wxString &uri) = 0;
|
||||
private:
|
||||
wxString m_scheme;
|
||||
};
|
||||
|
||||
extern WXDLLIMPEXP_DATA_WEB(const char) wxWebViewNameStr[];
|
||||
@ -339,7 +342,7 @@ public:
|
||||
virtual void Redo() = 0;
|
||||
|
||||
//Virtual Filesystem Support
|
||||
virtual void RegisterHandler(wxSharedPtr<wxWebHandler> handler) = 0;
|
||||
virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler) = 0;
|
||||
|
||||
wxDECLARE_ABSTRACT_CLASS(wxWebView);
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: webviewfilehandler.h
|
||||
// Purpose: Custom handler for the file scheme to allow archive browsing
|
||||
// Name: webviewarchivehandler.h
|
||||
// Purpose: Custom webview handler to allow archive browsing
|
||||
// Author: Steven Lamerton
|
||||
// Id: $Id$
|
||||
// Copyright: (c) 2011 Steven Lamerton
|
||||
@ -19,17 +19,15 @@ class wxFileSystem;
|
||||
|
||||
#include "wx/webview.h"
|
||||
|
||||
//Loads from uris such as file:///C:/example/example.html or archives such as
|
||||
//file:///C:/example/example.zip;protocol=zip/example.html
|
||||
//Loads from uris such as scheme:///C:/example/example.html or archives such as
|
||||
//scheme:///C:/example/example.zip;protocol=zip/example.html
|
||||
|
||||
class WXDLLIMPEXP_WEB wxWebFileHandler : public wxWebHandler
|
||||
class WXDLLIMPEXP_WEB wxWebViewArchiveHandler : public wxWebViewHandler
|
||||
{
|
||||
public:
|
||||
wxWebFileHandler();
|
||||
virtual wxString GetName() const { return m_name; }
|
||||
wxWebViewArchiveHandler(const wxString& scheme);
|
||||
virtual wxFSFile* GetFile(const wxString &uri);
|
||||
private:
|
||||
wxString m_name;
|
||||
wxFileSystem* m_fileSystem;
|
||||
};
|
||||
|
@ -117,7 +117,7 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
@class wxWebHandler
|
||||
@class wxWebViewHandler
|
||||
|
||||
The base class for handling custom schemes in wxWebView, for example to
|
||||
allow virtual file system support.
|
||||
@ -127,16 +127,22 @@ public:
|
||||
|
||||
@see wxWebView
|
||||
*/
|
||||
class wxWebHandler
|
||||
class wxWebViewHandler
|
||||
{
|
||||
public:
|
||||
/**
|
||||
Constructor. Takes the name of the scheme that will be handled by this
|
||||
class for example @c file or @c zip.
|
||||
*/
|
||||
wxWebViewHandler(const wxString& scheme);
|
||||
|
||||
/**
|
||||
@return A pointer to the file represented by @c uri.
|
||||
*/
|
||||
virtual wxFSFile* GetFile(const wxString &uri) = 0;
|
||||
|
||||
/**
|
||||
@return The name of the scheme, for example @c file or @c http.
|
||||
@return The name of the scheme, as passed to the constructor.
|
||||
*/
|
||||
virtual wxString GetName() const = 0;
|
||||
};
|
||||
@ -196,8 +202,7 @@ public:
|
||||
|
||||
wxWebView supports the registering of custom scheme handlers, for example
|
||||
@c file or @c http. To do this create a new class which inherits from
|
||||
wxWebHandler, where the wxWebHandler::GetName() method returns the scheme
|
||||
you wish to handle and wxWebHandler::GetFile() returns a pointer to a
|
||||
wxWebViewHandler, where wxWebHandler::GetFile() returns a pointer to a
|
||||
wxFSFile which represents the given url. You can then register your handler
|
||||
with RegisterHandler() it will be called for all pages and resources.
|
||||
|
||||
@ -338,7 +343,7 @@ public:
|
||||
Registers a custom scheme handler.
|
||||
@param handler A shared pointer to a wxWebHandler.
|
||||
*/
|
||||
virtual void RegisterHandler(wxSharedPtr<wxWebHandler> handler) = 0;
|
||||
virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler) = 0;
|
||||
|
||||
/**
|
||||
Reload the currently displayed URL.
|
||||
|
@ -1,31 +1,31 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: webfilehandler.h
|
||||
// Purpose: interface of wxWebFileHandler
|
||||
// Purpose: interface of wxWebViewArchiveHandler
|
||||
// Author: wxWidgets team
|
||||
// RCS-ID: $Id$
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
@class wxWebFileHandler
|
||||
@class wxWebViewArchiveHandler
|
||||
|
||||
A custom handler for the file scheme which also supports loading from
|
||||
archives. The syntax for wxWebFileHandler differs from virtual file
|
||||
archives. The syntax for wxWebViewArchiveHandler differs from virtual file
|
||||
systems in the rest of wxWidgets by using a syntax such as
|
||||
@c file:///C:/exmaple/docs.zip;protocol=zip/main.htm Currently the only
|
||||
supported protocol is @c zip.
|
||||
<code> scheme:///C:/exmaple/docs.zip;protocol=zip/main.htm </code>
|
||||
Currently the only supported protocol is @c zip.
|
||||
|
||||
@library{wxweb}
|
||||
@category{web}
|
||||
|
||||
@see wxWebView, wxWebHandler
|
||||
@see wxWebView, wxWebViewHandler
|
||||
*/
|
||||
class wxWebFileHandler : public wxWebHandler
|
||||
class wxWebViewArchiveHandler : public wxWebViewHandler
|
||||
{
|
||||
public:
|
||||
/**
|
||||
@return The string @c "file"
|
||||
Constructor.
|
||||
*/
|
||||
virtual wxString GetName() const;
|
||||
wxWebViewArchiveHandler(const wxString& scheme);
|
||||
virtual wxFSFile* GetFile(const wxString &uri);
|
||||
};
|
@ -26,7 +26,7 @@
|
||||
#include "wx/notifmsg.h"
|
||||
#include "wx/settings.h"
|
||||
#include "wx/webview.h"
|
||||
#include "wx/webviewfilehandler.h"
|
||||
#include "wx/webviewarchivehandler.h"
|
||||
#include "wx/infobar.h"
|
||||
#include "wx/filesys.h"
|
||||
#include "wx/fs_arc.h"
|
||||
@ -209,8 +209,8 @@ WebFrame::WebFrame() : wxFrame(NULL, wxID_ANY, "wxWebView Sample")
|
||||
m_browser = wxWebView::New(this, wxID_ANY, "http://www.wxwidgets.org");
|
||||
topsizer->Add(m_browser, wxSizerFlags().Expand().Proportion(1));
|
||||
|
||||
//We register the file:// protocol for testing purposes
|
||||
m_browser->RegisterHandler(wxSharedPtr<wxWebHandler>(new wxWebFileHandler()));
|
||||
//We register the wxfs:// protocol for testing purposes
|
||||
m_browser->RegisterHandler(wxSharedPtr<wxWebViewHandler>(new wxWebViewArchiveHandler("wxfs")));
|
||||
|
||||
SetSizer(topsizer);
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: webviewfilehandler.cpp
|
||||
// Purpose: Custom handler for the file scheme to allow archive browsing
|
||||
// Purpose: Custom webview handler to allow archive browsing
|
||||
// Author: Steven Lamerton
|
||||
// Id: $Id$
|
||||
// Copyright: (c) 2011 Steven Lamerton
|
||||
@ -16,7 +16,7 @@
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#include "wx/webviewfilehandler.h"
|
||||
#include "wx/webviewarchivehandler.h"
|
||||
#include "wx/filesys.h"
|
||||
|
||||
//Taken from wx/filesys.cpp
|
||||
@ -44,13 +44,13 @@ static wxString EscapeFileNameCharsInURL(const char *in)
|
||||
return s;
|
||||
}
|
||||
|
||||
wxWebFileHandler::wxWebFileHandler()
|
||||
wxWebViewArchiveHandler::wxWebViewArchiveHandler(const wxString& scheme) :
|
||||
wxWebViewHandler(scheme)
|
||||
{
|
||||
m_name = "file";
|
||||
m_fileSystem = new wxFileSystem();
|
||||
}
|
||||
|
||||
wxFSFile* wxWebFileHandler::GetFile(const wxString &uri)
|
||||
wxFSFile* wxWebViewArchiveHandler::GetFile(const wxString &uri)
|
||||
{
|
||||
//If there is a fragment at the end of the path then we need to strip it
|
||||
//off as not all backends do this for us
|
@ -104,10 +104,10 @@ wxgtk_webview_webkit_navigation(WebKitWebView *,
|
||||
else
|
||||
{
|
||||
wxString wxuri = uri;
|
||||
wxSharedPtr<wxWebHandler> handler;
|
||||
wxVector<wxSharedPtr<wxWebHandler> > hanlders = webKitCtrl->GetHandlers();
|
||||
wxSharedPtr<wxWebViewHandler> handler;
|
||||
wxVector<wxSharedPtr<wxWebViewHandler> > hanlders = webKitCtrl->GetHandlers();
|
||||
//We are not vetoed so see if we match one of the additional handlers
|
||||
for(wxVector<wxSharedPtr<wxWebHandler> >::iterator it = hanlders.begin();
|
||||
for(wxVector<wxSharedPtr<wxWebViewHandler> >::iterator it = hanlders.begin();
|
||||
it != hanlders.end(); ++it)
|
||||
{
|
||||
if(wxuri.substr(0, (*it)->GetName().length()) == (*it)->GetName())
|
||||
@ -329,11 +329,11 @@ wxgtk_webview_webkit_resource_req(WebKitWebView *,
|
||||
{
|
||||
wxString uri = webkit_network_request_get_uri(request);
|
||||
|
||||
wxSharedPtr<wxWebHandler> handler;
|
||||
wxVector<wxSharedPtr<wxWebHandler> > hanlders = webKitCtrl->GetHandlers();
|
||||
wxSharedPtr<wxWebViewHandler> handler;
|
||||
wxVector<wxSharedPtr<wxWebViewHandler> > hanlders = webKitCtrl->GetHandlers();
|
||||
|
||||
//We are not vetoed so see if we match one of the additional handlers
|
||||
for(wxVector<wxSharedPtr<wxWebHandler> >::iterator it = hanlders.begin();
|
||||
for(wxVector<wxSharedPtr<wxWebViewHandler> >::iterator it = hanlders.begin();
|
||||
it != hanlders.end(); ++it)
|
||||
{
|
||||
if(uri.substr(0, (*it)->GetName().length()) == (*it)->GetName())
|
||||
@ -911,7 +911,7 @@ void wxWebViewWebKit::RunScript(const wxString& javascript)
|
||||
javascript.mb_str(wxConvUTF8));
|
||||
}
|
||||
|
||||
void wxWebViewWebKit::RegisterHandler(wxSharedPtr<wxWebHandler> handler)
|
||||
void wxWebViewWebKit::RegisterHandler(wxSharedPtr<wxWebViewHandler> handler)
|
||||
{
|
||||
m_handlerList.push_back(handler);
|
||||
}
|
||||
|
@ -665,7 +665,7 @@ void wxWebViewIE::RunScript(const wxString& javascript)
|
||||
document->Release();
|
||||
}
|
||||
|
||||
void wxWebViewIE::RegisterHandler(wxSharedPtr<wxWebHandler> handler)
|
||||
void wxWebViewIE::RegisterHandler(wxSharedPtr<wxWebViewHandler> handler)
|
||||
{
|
||||
ClassFactory* cf = new ClassFactory(handler);
|
||||
IInternetSession* session;
|
||||
@ -965,7 +965,7 @@ void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt)
|
||||
evt.Skip();
|
||||
}
|
||||
|
||||
VirtualProtocol::VirtualProtocol(wxSharedPtr<wxWebHandler> handler)
|
||||
VirtualProtocol::VirtualProtocol(wxSharedPtr<wxWebViewHandler> handler)
|
||||
{
|
||||
m_refCount = 0;
|
||||
m_file = NULL;
|
||||
|
@ -315,8 +315,8 @@ DEFINE_ONE_SHOT_HANDLER_GETTER( wxWebViewWebKitEventHandler )
|
||||
|
||||
@end
|
||||
|
||||
//We use a hash to map scheme names to wxWebHandlers
|
||||
WX_DECLARE_STRING_HASH_MAP(wxSharedPtr<wxWebHandler>, wxStringToWebHandlerMap);
|
||||
//We use a hash to map scheme names to wxWebViewHandler
|
||||
WX_DECLARE_STRING_HASH_MAP(wxSharedPtr<wxWebViewHandler>, wxStringToWebHandlerMap);
|
||||
|
||||
static wxStringToWebHandlerMap g_stringHandlerMap;
|
||||
|
||||
@ -982,7 +982,7 @@ void wxWebViewWebKit::Redo()
|
||||
[[m_webView undoManager] redo];
|
||||
}
|
||||
|
||||
void wxWebViewWebKit::RegisterHandler(wxSharedPtr<wxWebHandler> handler)
|
||||
void wxWebViewWebKit::RegisterHandler(wxSharedPtr<wxWebViewHandler> handler)
|
||||
{
|
||||
g_stringHandlerMap[handler->GetName()] = handler;
|
||||
}
|
||||
@ -1262,7 +1262,7 @@ wxString nsErrorToWxHtmlError(NSError* error, wxWebNavigationError* out)
|
||||
|
||||
+ (NSURLRequest *)canonicalRequestForRequest:(NSURLRequest *)request
|
||||
{
|
||||
//We don't do any processing here as the wxWebHandler classes do it
|
||||
//We don't do any processing here as the wxWebViewHandler classes do it
|
||||
return request;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user