#include "wx/msw/missing.h"
#include "wx/filesys.h"
#include "wx/dynlib.h"
+#include <initguid.h>
+
+/* These GUID definitions are our own implementation to support interfaces
+ * normally in urlmon.h. See include/wx/msw/webview_ie.h
+ */
+
+namespace {
+
+DEFINE_GUID(wxIID_IInternetProtocolRoot,0x79eac9e3,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
+DEFINE_GUID(wxIID_IInternetProtocol,0x79eac9e4,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
+
+}
wxIMPLEMENT_DYNAMIC_CLASS(wxWebViewIE, wxWebView);
return true;
}
+wxWebViewIE::~wxWebViewIE()
+{
+ for(unsigned int i = 0; i < m_factories.size(); i++)
+ {
+ m_factories[i]->Release();
+ }
+}
void wxWebViewIE::LoadURL(const wxString& url)
{
- m_ie.CallMethod("Navigate", (BSTR) url.wc_str());
+ m_ie.CallMethod("Navigate", wxConvertStringToOle(url));
}
void wxWebViewIE::SetPage(const wxString& html, const wxString& baseUrl)
wxWebViewZoom wxWebViewIE::GetZoom() const
{
- if(m_zoomType == wxWEB_VIEW_ZOOM_TYPE_LAYOUT)
- return GetIEOpticalZoom();
- else if(m_zoomType == wxWEB_VIEW_ZOOM_TYPE_TEXT)
- return GetIETextZoom();
- else
- wxFAIL;
+ switch( m_zoomType )
+ {
+ case wxWEB_VIEW_ZOOM_TYPE_LAYOUT:
+ return GetIEOpticalZoom();
+ case wxWEB_VIEW_ZOOM_TYPE_TEXT:
+ return GetIETextZoom();
+ default:
+ wxFAIL;
+ }
//Dummy return to stop compiler warnings
return wxWEB_VIEW_ZOOM_MEDIUM;
void wxWebViewIE::SetZoom(wxWebViewZoom zoom)
{
- if(m_zoomType == wxWEB_VIEW_ZOOM_TYPE_LAYOUT)
- SetIEOpticalZoom(zoom);
- else if(m_zoomType == wxWEB_VIEW_ZOOM_TYPE_TEXT)
- SetIETextZoom(zoom);
- else
- wxFAIL;
+ switch( m_zoomType )
+ {
+ case wxWEB_VIEW_ZOOM_TYPE_LAYOUT:
+ SetIEOpticalZoom(zoom);
+ break;
+ case wxWEB_VIEW_ZOOM_TYPE_TEXT:
+ SetIETextZoom(zoom);
+ break;
+ default:
+ wxFAIL;
+ }
}
void wxWebViewIE::SetIETextZoom(wxWebViewZoom level)
V_VT(&zoomVariant) = VT_I4;
V_I4(&zoomVariant) = level;
- HRESULT result = m_webBrowser->ExecWB(OLECMDID_ZOOM,
- OLECMDEXECOPT_DONTPROMPTUSER,
- &zoomVariant, NULL);
+#if wxDEBUG_LEVEL
+ HRESULT result =
+#endif
+ m_webBrowser->ExecWB(OLECMDID_ZOOM,
+ OLECMDEXECOPT_DONTPROMPTUSER,
+ &zoomVariant, NULL);
wxASSERT(result == S_OK);
}
VariantInit (&zoomVariant);
V_VT(&zoomVariant) = VT_I4;
- HRESULT result = m_webBrowser->ExecWB(OLECMDID_ZOOM,
- OLECMDEXECOPT_DONTPROMPTUSER,
- NULL, &zoomVariant);
+#if wxDEBUG_LEVEL
+ HRESULT result =
+#endif
+ m_webBrowser->ExecWB(OLECMDID_ZOOM,
+ OLECMDEXECOPT_DONTPROMPTUSER,
+ NULL, &zoomVariant);
wxASSERT(result == S_OK);
//We can safely cast here as we know that the range matches our enum
wxFAIL;
}
- HRESULT result = m_webBrowser->ExecWB((OLECMDID)63 /*OLECMDID_OPTICAL_ZOOM*/,
- OLECMDEXECOPT_DODEFAULT,
- &zoomVariant,
- NULL);
+#if wxDEBUG_LEVEL
+ HRESULT result =
+#endif
+ m_webBrowser->ExecWB((OLECMDID)63 /*OLECMDID_OPTICAL_ZOOM*/,
+ OLECMDEXECOPT_DODEFAULT,
+ &zoomVariant,
+ NULL);
wxASSERT(result == S_OK);
}
VariantInit (&zoomVariant);
V_VT(&zoomVariant) = VT_I4;
- HRESULT result = m_webBrowser->ExecWB((OLECMDID)63 /*OLECMDID_OPTICAL_ZOOM*/,
- OLECMDEXECOPT_DODEFAULT, NULL,
- &zoomVariant);
+#if wxDEBUG_LEVEL
+ HRESULT result =
+#endif
+ m_webBrowser->ExecWB((OLECMDID)63 /*OLECMDID_OPTICAL_ZOOM*/,
+ OLECMDEXECOPT_DODEFAULT, NULL,
+ &zoomVariant);
wxASSERT(result == S_OK);
const int zoom = V_I4(&zoomVariant);
{
// FIXME: the wxWidgets docs do not really document what the return
// parameter of PutProperty is
- const bool success = m_ie.PutProperty("Offline", (offline ?
- VARIANT_TRUE :
- VARIANT_FALSE));
+#if wxDEBUG_LEVEL
+ const bool success =
+#endif
+ m_ie.PutProperty("Offline", (offline ?
+ VARIANT_TRUE :
+ VARIANT_FALSE));
wxASSERT(success);
}
wxDynamicLibrary urlMon(wxT("urlmon.dll"));
if(urlMon.HasSymbol(wxT("CoInternetGetSession")))
{
- typedef HRESULT (WINAPI *CoInternetGetSession_t)(DWORD, IInternetSession**, DWORD);
+ typedef HRESULT (WINAPI *CoInternetGetSession_t)(DWORD, wxIInternetSession**, DWORD);
wxDYNLIB_FUNCTION(CoInternetGetSession_t, CoInternetGetSession, urlMon);
ClassFactory* cf = new ClassFactory(handler);
- IInternetSession* session;
+ wxIInternetSession* session;
HRESULT res = (*pfnCoInternetGetSession)(0, &session, 0);
if(FAILED(res))
{
{
wxFAIL_MSG("Could not register protocol");
}
+ m_factories.push_back(cf);
}
else
{
wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_NAVIGATING,
GetId(), url, target);
- event.SetEventObject(this);
- HandleWindowEvent(event);
+
+ //skip empty javascript events.
+ if(url == "javascript:\"\"" && target.IsEmpty())
+ {
+ event.Veto();
+ }
+ else
+ {
+ event.SetEventObject(this);
+ HandleWindowEvent(event);
+ }
if (!event.IsAllowed())
{
HRESULT VirtualProtocol::QueryInterface(REFIID riid, void **ppvObject)
{
- if(riid == IID_IUnknown || riid == IID_IInternetProtocolRoot ||
- riid == IID_IInternetProtocol)
+ if(riid == IID_IUnknown || riid == wxIID_IInternetProtocolRoot ||
+ riid == wxIID_IInternetProtocol)
{
- *ppvObject = (IInternetProtocol*)this;
+ *ppvObject = (wxIInternetProtocol*)this;
AddRef();
return S_OK;
}
}
}
-HRESULT VirtualProtocol::Start(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink,
- IInternetBindInfo *pOIBindInfo, DWORD grfPI,
+HRESULT VirtualProtocol::Start(LPCWSTR szUrl, wxIInternetProtocolSink *pOIProtSink,
+ wxIInternetBindInfo *pOIBindInfo, DWORD grfPI,
HANDLE_PTR dwReserved)
{
wxUnusedVar(szUrl);
//We return the stream length for current and total size as we can always
//read the whole file from the stream
wxFileOffset length = m_file->GetStream()->GetLength();
- m_protocolSink->ReportData(BSCF_FIRSTDATANOTIFICATION |
- BSCF_DATAFULLYAVAILABLE |
- BSCF_LASTDATANOTIFICATION,
+ m_protocolSink->ReportData(wxBSCF_FIRSTDATANOTIFICATION |
+ wxBSCF_DATAFULLYAVAILABLE |
+ wxBSCF_LASTDATANOTIFICATION,
length, length);
return S_OK;
}