Merge branch 'webview_ie-js' of https://github.com/MaartenBent/wxWidgets
Fix using JavaScript in wxWebViewIE with custom scheme.
This repairs a regression in 3.1.4 due to the changes of 6787b0548b
(Merge branch 'webview-ie-fixes', 2020-07-23).
See https://github.com/wxWidgets/wxWidgets/pull/2004
This commit is contained in:
@@ -152,7 +152,8 @@ wx_add_sample(typetest typetest.cpp typetest.h)
|
||||
wx_add_sample(uiaction DEPENDS wxUSE_UIACTIONSIMULATOR)
|
||||
wx_add_sample(validate validate.cpp validate.h DEPENDS wxUSE_VALIDATORS)
|
||||
wx_add_sample(vscroll vstest.cpp)
|
||||
wx_add_sample(webview LIBRARIES wxwebview NAME webviewsample DEPENDS wxUSE_WEBVIEW)
|
||||
wx_add_sample(webview LIBRARIES wxwebview DATA ../help/doc.zip:doc.zip
|
||||
NAME webviewsample DEPENDS wxUSE_WEBVIEW)
|
||||
if(TARGET webviewsample AND wxUSE_STC)
|
||||
wx_exe_link_libraries(webviewsample wxstc)
|
||||
endif()
|
||||
|
@@ -89,12 +89,16 @@ enum wxWebViewNavigationActionFlags
|
||||
class WXDLLIMPEXP_WEBVIEW wxWebViewHandler
|
||||
{
|
||||
public:
|
||||
wxWebViewHandler(const wxString& scheme) : m_scheme(scheme) {}
|
||||
wxWebViewHandler(const wxString& scheme)
|
||||
: m_scheme(scheme), m_securityURL() {}
|
||||
virtual ~wxWebViewHandler() {}
|
||||
virtual wxString GetName() const { return m_scheme; }
|
||||
virtual wxFSFile* GetFile(const wxString &uri) = 0;
|
||||
virtual void SetSecurityURL(const wxString& url) { m_securityURL = url; }
|
||||
virtual wxString GetSecurityURL() const { return m_securityURL; }
|
||||
private:
|
||||
wxString m_scheme;
|
||||
wxString m_securityURL;
|
||||
};
|
||||
|
||||
extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewNameStr[];
|
||||
|
@@ -252,6 +252,20 @@ public:
|
||||
@return The name of the scheme, as passed to the constructor.
|
||||
*/
|
||||
virtual wxString GetName() const;
|
||||
|
||||
/**
|
||||
Sets a custom security URL. Only used by wxWebViewIE.
|
||||
|
||||
@since 3.1.5
|
||||
*/
|
||||
virtual void SetSecurityURL(const wxString& url);
|
||||
|
||||
/**
|
||||
@return The custom security URL. Only used by wxWebViewIE.
|
||||
|
||||
@since 3.1.5
|
||||
*/
|
||||
virtual wxString GetSecurityURL() const;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -1077,7 +1077,7 @@ void wxWebViewIE::RegisterHandler(wxSharedPtr<wxWebViewHandler> handler)
|
||||
HRESULT res = (*pfnCoInternetGetSession)(0, &session, 0);
|
||||
if(FAILED(res))
|
||||
{
|
||||
wxFAIL_MSG("Could not retrive internet session");
|
||||
wxFAIL_MSG("Could not retrieve internet session");
|
||||
}
|
||||
|
||||
HRESULT hr = session->RegisterNameSpace(cf, CLSID_FileProtocol,
|
||||
@@ -1616,12 +1616,6 @@ VirtualProtocol::VirtualProtocol(wxSharedPtr<wxWebViewHandler> handler)
|
||||
m_handler = handler;
|
||||
}
|
||||
|
||||
BEGIN_IID_TABLE(VirtualProtocol)
|
||||
ADD_IID(Unknown)
|
||||
ADD_RAW_IID(wxIID_IInternetProtocolRoot)
|
||||
ADD_RAW_IID(wxIID_IInternetProtocol)
|
||||
END_IID_TABLE;
|
||||
|
||||
STDMETHODIMP VirtualProtocol::QueryInterface(REFIID riid, void **ppv)
|
||||
{
|
||||
wxLogQueryInterface(wxT("VirtualProtocol"), riid);
|
||||
@@ -1768,25 +1762,23 @@ HRESULT STDMETHODCALLTYPE VirtualProtocol::ParseUrl(
|
||||
DWORD dwReserved)
|
||||
{
|
||||
wxUnusedVar(pwzUrl);
|
||||
wxUnusedVar(ParseAction);
|
||||
wxUnusedVar(dwParseFlags);
|
||||
wxUnusedVar(pwzResult);
|
||||
wxUnusedVar(cchResult);
|
||||
wxUnusedVar(pcchResult);
|
||||
wxUnusedVar(dwReserved);
|
||||
|
||||
switch (ParseAction)
|
||||
const size_t secLen = m_handler->GetSecurityURL().length();
|
||||
if ( secLen > 0 )
|
||||
{
|
||||
case wxPARSE_SECURITY_URL:
|
||||
case wxPARSE_SECURITY_DOMAIN:
|
||||
switch ( ParseAction )
|
||||
{
|
||||
const wchar_t Result[] = L"http://localhost";
|
||||
size_t Len = wcslen(Result);
|
||||
if(cchResult <= Len)
|
||||
return S_FALSE;
|
||||
wcscpy(pwzResult, Result);
|
||||
*pcchResult = Len;
|
||||
return S_OK;
|
||||
case wxPARSE_SECURITY_URL:
|
||||
case wxPARSE_SECURITY_DOMAIN:
|
||||
{
|
||||
if ( cchResult < secLen )
|
||||
return S_FALSE;
|
||||
wcscpy(pwzResult, m_handler->GetSecurityURL().wc_str());
|
||||
*pcchResult = secLen;
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user