From: Steve Lamerton Date: Mon, 8 Aug 2011 15:12:33 +0000 (+0000) Subject: Use shared pointers to hold wxWebHandlers throughout. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/3baf235f60c2e924fee2cd2de03e544343c15529 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 --- diff --git a/include/wx/gtk/webview_webkit.h b/include/wx/gtk/webview_webkit.h index 9d3c500c0a..7d88128bed 100644 --- a/include/wx/gtk/webview_webkit.h +++ b/include/wx/gtk/webview_webkit.h @@ -122,8 +122,8 @@ public: virtual void RunScript(const wxString& javascript); //Virtual Filesystem Support - virtual void RegisterHandler(wxWebHandler* handler); - virtual wxVector GetHandlers() { return m_handlerList; } + virtual void RegisterHandler(wxSharedPtr handler); + virtual wxVector > GetHandlers() { return m_handlerList; } /** FIXME: hack to work around signals being received too early */ bool m_ready; @@ -136,8 +136,7 @@ public: * user) */ bool m_busy; - - bool m_guard; + wxString m_vfsurl; //We use this flag to stop recursion when we load a page from the navigation @@ -156,7 +155,7 @@ private: GtkWidget *web_view; gint m_historyLimit; - wxVector m_handlerList; + wxVector > m_handlerList; wxDECLARE_DYNAMIC_CLASS(wxWebViewWebKit); }; diff --git a/include/wx/msw/webview_ie.h b/include/wx/msw/webview_ie.h index aec06fc0d1..9d4671e422 100644 --- a/include/wx/msw/webview_ie.h +++ b/include/wx/msw/webview_ie.h @@ -110,7 +110,7 @@ public: virtual void RunScript(const wxString& javascript); //Virtual Filesystem Support - virtual void RegisterHandler(wxWebHandler* handler); + virtual void RegisterHandler(wxSharedPtr handler); // ---- IE-specific methods @@ -169,10 +169,10 @@ protected: VOID * fileP; wxFSFile* m_file; - wxWebHandler* m_handler; + wxSharedPtr m_handler; public: - VirtualProtocol(wxWebHandler *handler); + VirtualProtocol(wxSharedPtr handler); ~VirtualProtocol(); //IUnknown @@ -211,7 +211,7 @@ class ClassFactory : public IClassFactory private: ULONG m_refCount; public: - ClassFactory(wxWebHandler* handler) : m_handler(handler) {} + ClassFactory(wxSharedPtr 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: - wxWebHandler* m_handler; + wxSharedPtr m_handler; }; #endif // wxUSE_WEBVIEW_IE && defined(__WXMSW__) diff --git a/include/wx/osx/webview_webkit.h b/include/wx/osx/webview_webkit.h index 4af95519a5..4d93115bf1 100644 --- a/include/wx/osx/webview_webkit.h +++ b/include/wx/osx/webview_webkit.h @@ -114,7 +114,7 @@ public: void RunScript(const wxString& javascript); //Virtual Filesystem Support - virtual void RegisterHandler(wxWebHandler* WXUNUSED(handler)) {}; + virtual void RegisterHandler(wxSharedPtr WXUNUSED(handler)) {}; // ---- methods not from the parent (common) interface bool CanGetPageSource(); diff --git a/include/wx/webview.h b/include/wx/webview.h index 11958d379c..6f7b39f85c 100644 --- a/include/wx/webview.h +++ b/include/wx/webview.h @@ -339,7 +339,7 @@ public: virtual void Redo() = 0; //Virtual Filesystem Support - virtual void RegisterHandler(wxWebHandler* handler) = 0; + virtual void RegisterHandler(wxSharedPtr handler) = 0; wxDECLARE_ABSTRACT_CLASS(wxWebView); }; diff --git a/interface/wx/webview.h b/interface/wx/webview.h index c94540709e..1b82da4864 100644 --- a/interface/wx/webview.h +++ b/interface/wx/webview.h @@ -335,9 +335,9 @@ public: /** 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 handler) = 0; /** Reload the currently displayed URL. diff --git a/samples/web/web.cpp b/samples/web/web.cpp index 2ec69bd83c..5529c560db 100644 --- a/samples/web/web.cpp +++ b/samples/web/web.cpp @@ -195,7 +195,7 @@ WebFrame::WebFrame() : wxFrame(NULL, wxID_ANY, "wxWebView Sample") topsizer->Add(m_browser, wxSizerFlags().Expand().Proportion(1)); //We register the test:// protocol for testing purposes - m_browser->RegisterHandler(new wxWebFileHandler()); + m_browser->RegisterHandler(wxSharedPtr(new wxWebFileHandler())); SetSizer(topsizer); diff --git a/src/gtk/webview_webkit.cpp b/src/gtk/webview_webkit.cpp index ea424c8b16..e88a5bfe8c 100644 --- a/src/gtk/webview_webkit.cpp +++ b/src/gtk/webview_webkit.cpp @@ -103,10 +103,10 @@ wxgtk_webview_webkit_navigation(WebKitWebView *, else { wxString wxuri = uri; - wxWebHandler *handler = NULL; - wxVector hanlders = webKitCtrl->GetHandlers(); + wxSharedPtr handler; + wxVector > hanlders = webKitCtrl->GetHandlers(); //We are not vetoed so see if we match one of the additional handlers - for(wxVector::iterator it = hanlders.begin(); + for(wxVector >::iterator it = hanlders.begin(); it != hanlders.end(); ++it) { 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); - wxWebHandler *handler = NULL; - wxVector hanlders = webKitCtrl->GetHandlers(); + wxSharedPtr handler; + wxVector > hanlders = webKitCtrl->GetHandlers(); //We are not vetoed so see if we match one of the additional handlers - for(wxVector::iterator it = hanlders.begin(); + for(wxVector >::iterator it = hanlders.begin(); it != hanlders.end(); ++it) { if(uri.substr(0, (*it)->GetName().length()) == (*it)->GetName()) @@ -913,7 +913,7 @@ void wxWebViewWebKit::RunScript(const wxString& javascript) javascript.mb_str(wxConvUTF8)); } -void wxWebViewWebKit::RegisterHandler(wxWebHandler* handler) +void wxWebViewWebKit::RegisterHandler(wxSharedPtr handler) { m_handlerList.push_back(handler); } diff --git a/src/msw/webview_ie.cpp b/src/msw/webview_ie.cpp index bb3add6495..868877c9ef 100644 --- a/src/msw/webview_ie.cpp +++ b/src/msw/webview_ie.cpp @@ -665,7 +665,7 @@ void wxWebViewIE::RunScript(const wxString& javascript) document->Release(); } -void wxWebViewIE::RegisterHandler(wxWebHandler* handler) +void wxWebViewIE::RegisterHandler(wxSharedPtr handler) { ClassFactory* cf = new ClassFactory(handler); IInternetSession* session; @@ -959,7 +959,7 @@ void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt) evt.Skip(); } -VirtualProtocol::VirtualProtocol(wxWebHandler *handler) +VirtualProtocol::VirtualProtocol(wxSharedPtr handler) { m_refCount = 0; m_file = NULL;