Use shared pointers to hold wxWebHandlers throughout.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68605 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Steve Lamerton
2011-08-08 15:12:33 +00:00
parent fea281f428
commit 3baf235f60
8 changed files with 23 additions and 24 deletions

View File

@@ -122,8 +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* handler); virtual void RegisterHandler(wxSharedPtr<wxWebHandler> handler);
virtual wxVector<wxWebHandler*> GetHandlers() { return m_handlerList; } virtual wxVector<wxSharedPtr<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;
@@ -137,7 +137,6 @@ public:
*/ */
bool m_busy; bool m_busy;
bool m_guard;
wxString m_vfsurl; wxString m_vfsurl;
//We use this flag to stop recursion when we load a page from the navigation //We use this flag to stop recursion when we load a page from the navigation
@@ -156,7 +155,7 @@ private:
GtkWidget *web_view; GtkWidget *web_view;
gint m_historyLimit; gint m_historyLimit;
wxVector<wxWebHandler*> m_handlerList; wxVector<wxSharedPtr<wxWebHandler> > m_handlerList;
wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit); wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit);
}; };

View File

@@ -110,7 +110,7 @@ public:
virtual void RunScript(const wxString& javascript); virtual void RunScript(const wxString& javascript);
//Virtual Filesystem Support //Virtual Filesystem Support
virtual void RegisterHandler(wxWebHandler* handler); virtual void RegisterHandler(wxSharedPtr<wxWebHandler> handler);
// ---- IE-specific methods // ---- IE-specific methods
@@ -169,10 +169,10 @@ protected:
VOID * fileP; VOID * fileP;
wxFSFile* m_file; wxFSFile* m_file;
wxWebHandler* m_handler; wxSharedPtr<wxWebHandler> m_handler;
public: public:
VirtualProtocol(wxWebHandler *handler); VirtualProtocol(wxSharedPtr<wxWebHandler> handler);
~VirtualProtocol(); ~VirtualProtocol();
//IUnknown //IUnknown
@@ -211,7 +211,7 @@ class ClassFactory : public IClassFactory
private: private:
ULONG m_refCount; ULONG m_refCount;
public: public:
ClassFactory(wxWebHandler* handler) : m_handler(handler) {} ClassFactory(wxSharedPtr<wxWebHandler> handler) : m_handler(handler) {}
//IUnknown //IUnknown
ULONG STDMETHODCALLTYPE AddRef(); ULONG STDMETHODCALLTYPE AddRef();
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject);
@@ -222,7 +222,7 @@ public:
REFIID riid, void** ppvObject); REFIID riid, void** ppvObject);
HRESULT STDMETHODCALLTYPE LockServer(BOOL fLock); HRESULT STDMETHODCALLTYPE LockServer(BOOL fLock);
private: private:
wxWebHandler* m_handler; wxSharedPtr<wxWebHandler> m_handler;
}; };
#endif // wxUSE_WEBVIEW_IE && defined(__WXMSW__) #endif // wxUSE_WEBVIEW_IE && defined(__WXMSW__)

View File

@@ -114,7 +114,7 @@ public:
void RunScript(const wxString& javascript); void RunScript(const wxString& javascript);
//Virtual Filesystem Support //Virtual Filesystem Support
virtual void RegisterHandler(wxWebHandler* WXUNUSED(handler)) {}; virtual void RegisterHandler(wxSharedPtr<wxWebHandler> WXUNUSED(handler)) {};
// ---- methods not from the parent (common) interface // ---- methods not from the parent (common) interface
bool CanGetPageSource(); bool CanGetPageSource();

View File

@@ -339,7 +339,7 @@ public:
virtual void Redo() = 0; virtual void Redo() = 0;
//Virtual Filesystem Support //Virtual Filesystem Support
virtual void RegisterHandler(wxWebHandler* handler) = 0; virtual void RegisterHandler(wxSharedPtr<wxWebHandler> handler) = 0;
wxDECLARE_ABSTRACT_CLASS(wxWebView); wxDECLARE_ABSTRACT_CLASS(wxWebView);
}; };

View File

@@ -335,9 +335,9 @@ public:
/** /**
Registers a custom scheme handler. Registers a custom scheme handler.
@param handler A pointer to a heap allocated wxWebHandler. @param handler A shared pointer to a wxWebHandler.
*/ */
virtual void RegisterHandler(wxWebHandler* handler) = 0; virtual void RegisterHandler(wxSharedPtr<wxWebHandler> handler) = 0;
/** /**
Reload the currently displayed URL. Reload the currently displayed URL.

View File

@@ -195,7 +195,7 @@ WebFrame::WebFrame() : wxFrame(NULL, wxID_ANY, "wxWebView Sample")
topsizer->Add(m_browser, wxSizerFlags().Expand().Proportion(1)); topsizer->Add(m_browser, wxSizerFlags().Expand().Proportion(1));
//We register the test:// protocol for testing purposes //We register the test:// protocol for testing purposes
m_browser->RegisterHandler(new wxWebFileHandler()); m_browser->RegisterHandler(wxSharedPtr<wxWebHandler>(new wxWebFileHandler()));
SetSizer(topsizer); SetSizer(topsizer);

View File

@@ -103,10 +103,10 @@ wxgtk_webview_webkit_navigation(WebKitWebView *,
else else
{ {
wxString wxuri = uri; wxString wxuri = uri;
wxWebHandler *handler = NULL; wxSharedPtr<wxWebHandler> handler;
wxVector<wxWebHandler*> hanlders = webKitCtrl->GetHandlers(); wxVector<wxSharedPtr<wxWebHandler> > hanlders = webKitCtrl->GetHandlers();
//We are not vetoed so see if we match one of the additional handlers //We are not vetoed so see if we match one of the additional handlers
for(wxVector<wxWebHandler*>::iterator it = hanlders.begin(); for(wxVector<wxSharedPtr<wxWebHandler> >::iterator it = hanlders.begin();
it != hanlders.end(); ++it) it != hanlders.end(); ++it)
{ {
if(wxuri.substr(0, (*it)->GetName().length()) == (*it)->GetName()) if(wxuri.substr(0, (*it)->GetName().length()) == (*it)->GetName())
@@ -328,11 +328,11 @@ wxgtk_webview_webkit_resource_req(WebKitWebView *,
{ {
wxString uri = webkit_network_request_get_uri(request); wxString uri = webkit_network_request_get_uri(request);
wxWebHandler *handler = NULL; wxSharedPtr<wxWebHandler> handler;
wxVector<wxWebHandler*> hanlders = webKitCtrl->GetHandlers(); wxVector<wxSharedPtr<wxWebHandler> > hanlders = webKitCtrl->GetHandlers();
//We are not vetoed so see if we match one of the additional handlers //We are not vetoed so see if we match one of the additional handlers
for(wxVector<wxWebHandler*>::iterator it = hanlders.begin(); for(wxVector<wxSharedPtr<wxWebHandler> >::iterator it = hanlders.begin();
it != hanlders.end(); ++it) it != hanlders.end(); ++it)
{ {
if(uri.substr(0, (*it)->GetName().length()) == (*it)->GetName()) if(uri.substr(0, (*it)->GetName().length()) == (*it)->GetName())
@@ -913,7 +913,7 @@ void wxWebViewWebKit::RunScript(const wxString& javascript)
javascript.mb_str(wxConvUTF8)); javascript.mb_str(wxConvUTF8));
} }
void wxWebViewWebKit::RegisterHandler(wxWebHandler* handler) void wxWebViewWebKit::RegisterHandler(wxSharedPtr<wxWebHandler> handler)
{ {
m_handlerList.push_back(handler); m_handlerList.push_back(handler);
} }

View File

@@ -665,7 +665,7 @@ void wxWebViewIE::RunScript(const wxString& javascript)
document->Release(); document->Release();
} }
void wxWebViewIE::RegisterHandler(wxWebHandler* handler) void wxWebViewIE::RegisterHandler(wxSharedPtr<wxWebHandler> handler)
{ {
ClassFactory* cf = new ClassFactory(handler); ClassFactory* cf = new ClassFactory(handler);
IInternetSession* session; IInternetSession* session;
@@ -959,7 +959,7 @@ void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt)
evt.Skip(); evt.Skip();
} }
VirtualProtocol::VirtualProtocol(wxWebHandler *handler) VirtualProtocol::VirtualProtocol(wxSharedPtr<wxWebHandler> handler)
{ {
m_refCount = 0; m_refCount = 0;
m_file = NULL; m_file = NULL;