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(uiaction DEPENDS wxUSE_UIACTIONSIMULATOR)
|
||||||
wx_add_sample(validate validate.cpp validate.h DEPENDS wxUSE_VALIDATORS)
|
wx_add_sample(validate validate.cpp validate.h DEPENDS wxUSE_VALIDATORS)
|
||||||
wx_add_sample(vscroll vstest.cpp)
|
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)
|
if(TARGET webviewsample AND wxUSE_STC)
|
||||||
wx_exe_link_libraries(webviewsample wxstc)
|
wx_exe_link_libraries(webviewsample wxstc)
|
||||||
endif()
|
endif()
|
||||||
|
@@ -89,12 +89,16 @@ enum wxWebViewNavigationActionFlags
|
|||||||
class WXDLLIMPEXP_WEBVIEW wxWebViewHandler
|
class WXDLLIMPEXP_WEBVIEW wxWebViewHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxWebViewHandler(const wxString& scheme) : m_scheme(scheme) {}
|
wxWebViewHandler(const wxString& scheme)
|
||||||
|
: m_scheme(scheme), m_securityURL() {}
|
||||||
virtual ~wxWebViewHandler() {}
|
virtual ~wxWebViewHandler() {}
|
||||||
virtual wxString GetName() const { return m_scheme; }
|
virtual wxString GetName() const { return m_scheme; }
|
||||||
virtual wxFSFile* GetFile(const wxString &uri) = 0;
|
virtual wxFSFile* GetFile(const wxString &uri) = 0;
|
||||||
|
virtual void SetSecurityURL(const wxString& url) { m_securityURL = url; }
|
||||||
|
virtual wxString GetSecurityURL() const { return m_securityURL; }
|
||||||
private:
|
private:
|
||||||
wxString m_scheme;
|
wxString m_scheme;
|
||||||
|
wxString m_securityURL;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewNameStr[];
|
extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewNameStr[];
|
||||||
|
@@ -252,6 +252,20 @@ public:
|
|||||||
@return The name of the scheme, as passed to the constructor.
|
@return The name of the scheme, as passed to the constructor.
|
||||||
*/
|
*/
|
||||||
virtual wxString GetName() const;
|
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);
|
HRESULT res = (*pfnCoInternetGetSession)(0, &session, 0);
|
||||||
if(FAILED(res))
|
if(FAILED(res))
|
||||||
{
|
{
|
||||||
wxFAIL_MSG("Could not retrive internet session");
|
wxFAIL_MSG("Could not retrieve internet session");
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT hr = session->RegisterNameSpace(cf, CLSID_FileProtocol,
|
HRESULT hr = session->RegisterNameSpace(cf, CLSID_FileProtocol,
|
||||||
@@ -1616,12 +1616,6 @@ VirtualProtocol::VirtualProtocol(wxSharedPtr<wxWebViewHandler> handler)
|
|||||||
m_handler = 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)
|
STDMETHODIMP VirtualProtocol::QueryInterface(REFIID riid, void **ppv)
|
||||||
{
|
{
|
||||||
wxLogQueryInterface(wxT("VirtualProtocol"), riid);
|
wxLogQueryInterface(wxT("VirtualProtocol"), riid);
|
||||||
@@ -1768,27 +1762,25 @@ HRESULT STDMETHODCALLTYPE VirtualProtocol::ParseUrl(
|
|||||||
DWORD dwReserved)
|
DWORD dwReserved)
|
||||||
{
|
{
|
||||||
wxUnusedVar(pwzUrl);
|
wxUnusedVar(pwzUrl);
|
||||||
wxUnusedVar(ParseAction);
|
|
||||||
wxUnusedVar(dwParseFlags);
|
wxUnusedVar(dwParseFlags);
|
||||||
wxUnusedVar(pwzResult);
|
|
||||||
wxUnusedVar(cchResult);
|
|
||||||
wxUnusedVar(pcchResult);
|
|
||||||
wxUnusedVar(dwReserved);
|
wxUnusedVar(dwReserved);
|
||||||
|
|
||||||
switch (ParseAction)
|
const size_t secLen = m_handler->GetSecurityURL().length();
|
||||||
|
if ( secLen > 0 )
|
||||||
|
{
|
||||||
|
switch ( ParseAction )
|
||||||
{
|
{
|
||||||
case wxPARSE_SECURITY_URL:
|
case wxPARSE_SECURITY_URL:
|
||||||
case wxPARSE_SECURITY_DOMAIN:
|
case wxPARSE_SECURITY_DOMAIN:
|
||||||
{
|
{
|
||||||
const wchar_t Result[] = L"http://localhost";
|
if ( cchResult < secLen )
|
||||||
size_t Len = wcslen(Result);
|
|
||||||
if(cchResult <= Len)
|
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
wcscpy(pwzResult, Result);
|
wcscpy(pwzResult, m_handler->GetSecurityURL().wc_str());
|
||||||
*pcchResult = Len;
|
*pcchResult = secLen;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return INET_E_DEFAULT_ACTION;
|
return INET_E_DEFAULT_ACTION;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user