Add wxWebView::GetBackendVersionInfo()
Allows to get the WebView backend version if available Currently implemented for IE, Edge and webkit2.
This commit is contained in:
@@ -198,6 +198,9 @@ public:
|
|||||||
long style = 0,
|
long style = 0,
|
||||||
const wxString& name = wxASCII_STR(wxWebViewNameStr)) wxOVERRIDE
|
const wxString& name = wxASCII_STR(wxWebViewNameStr)) wxOVERRIDE
|
||||||
{ return new wxWebViewWebKit(parent, id, url, pos, size, style, name); }
|
{ return new wxWebViewWebKit(parent, id, url, pos, size, style, name); }
|
||||||
|
#if wxUSE_WEBVIEW_WEBKIT2
|
||||||
|
virtual wxVersionInfo GetVersionInfo() wxOVERRIDE;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -67,6 +67,7 @@ public:
|
|||||||
|
|
||||||
static wxDynamicLibrary ms_loaderDll;
|
static wxDynamicLibrary ms_loaderDll;
|
||||||
static wxString ms_browserExecutableDir;
|
static wxString ms_browserExecutableDir;
|
||||||
|
static wxString ms_version;
|
||||||
|
|
||||||
static bool Initialize();
|
static bool Initialize();
|
||||||
|
|
||||||
|
@@ -154,6 +154,7 @@ public:
|
|||||||
return new wxWebViewEdge(parent, id, url, pos, size, style, name);
|
return new wxWebViewEdge(parent, id, url, pos, size, style, name);
|
||||||
}
|
}
|
||||||
virtual bool IsAvailable() wxOVERRIDE;
|
virtual bool IsAvailable() wxOVERRIDE;
|
||||||
|
virtual wxVersionInfo GetVersionInfo() wxOVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_EDGE && defined(__WXMSW__)
|
#endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_EDGE && defined(__WXMSW__)
|
||||||
|
@@ -192,6 +192,7 @@ public:
|
|||||||
long style = 0,
|
long style = 0,
|
||||||
const wxString& name = wxASCII_STR(wxWebViewNameStr)) wxOVERRIDE
|
const wxString& name = wxASCII_STR(wxWebViewNameStr)) wxOVERRIDE
|
||||||
{ return new wxWebViewIE(parent, id, url, pos, size, style, name); }
|
{ return new wxWebViewIE(parent, id, url, pos, size, style, name); }
|
||||||
|
virtual wxVersionInfo GetVersionInfo() wxOVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE && defined(__WXMSW__)
|
#endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE && defined(__WXMSW__)
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
#include "wx/sstream.h"
|
#include "wx/sstream.h"
|
||||||
#include "wx/sharedptr.h"
|
#include "wx/sharedptr.h"
|
||||||
#include "wx/vector.h"
|
#include "wx/vector.h"
|
||||||
|
#include "wx/versioninfo.h"
|
||||||
|
|
||||||
#if defined(__WXOSX__)
|
#if defined(__WXOSX__)
|
||||||
#include "wx/osx/webviewhistoryitem_webkit.h"
|
#include "wx/osx/webviewhistoryitem_webkit.h"
|
||||||
@@ -120,6 +121,7 @@ public:
|
|||||||
long style = 0,
|
long style = 0,
|
||||||
const wxString& name = wxASCII_STR(wxWebViewNameStr)) = 0;
|
const wxString& name = wxASCII_STR(wxWebViewNameStr)) = 0;
|
||||||
virtual bool IsAvailable() { return true; }
|
virtual bool IsAvailable() { return true; }
|
||||||
|
virtual wxVersionInfo GetVersionInfo() { return wxVersionInfo(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
WX_DECLARE_STRING_HASH_MAP(wxSharedPtr<wxWebViewFactory>, wxStringWebViewFactoryMap);
|
WX_DECLARE_STRING_HASH_MAP(wxSharedPtr<wxWebViewFactory>, wxStringWebViewFactoryMap);
|
||||||
@@ -158,6 +160,7 @@ public:
|
|||||||
static void RegisterFactory(const wxString& backend,
|
static void RegisterFactory(const wxString& backend,
|
||||||
wxSharedPtr<wxWebViewFactory> factory);
|
wxSharedPtr<wxWebViewFactory> factory);
|
||||||
static bool IsBackendAvailable(const wxString& backend);
|
static bool IsBackendAvailable(const wxString& backend);
|
||||||
|
static wxVersionInfo GetBackendVersionInfo(const wxString& backend);
|
||||||
|
|
||||||
// General methods
|
// General methods
|
||||||
virtual void EnableContextMenu(bool enable = true)
|
virtual void EnableContextMenu(bool enable = true)
|
||||||
|
@@ -231,6 +231,13 @@ public:
|
|||||||
@since 3.1.5
|
@since 3.1.5
|
||||||
*/
|
*/
|
||||||
virtual bool IsAvailable();
|
virtual bool IsAvailable();
|
||||||
|
|
||||||
|
/**
|
||||||
|
Retrieve the version information about this backend implementation.
|
||||||
|
|
||||||
|
@since 3.1.5
|
||||||
|
*/
|
||||||
|
virtual wxVersionInfo GetVersionInfo(const wxString& backend);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -492,6 +499,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
static bool IsBackendAvailable(const wxString& backend);
|
static bool IsBackendAvailable(const wxString& backend);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Retrieve the version information about the backend implementation.
|
||||||
|
|
||||||
|
@since 3.1.5
|
||||||
|
*/
|
||||||
|
static wxVersionInfo GetBackendVersionInfo(const wxString& backend);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the title of the current web page, or its URL/path if title is not
|
Get the title of the current web page, or its URL/path if title is not
|
||||||
|
@@ -398,6 +398,7 @@ WebFrame::WebFrame(const wxString& url) :
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
m_browser = wxWebView::New(backend);
|
m_browser = wxWebView::New(backend);
|
||||||
|
wxLogMessage("Backend version: %s", wxWebView::GetBackendVersionInfo(backend).ToString());
|
||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
// With WKWebView handlers need to be registered before creation
|
// With WKWebView handlers need to be registered before creation
|
||||||
m_browser->RegisterHandler(wxSharedPtr<wxWebViewHandler>(new wxWebViewArchiveHandler("wxfs")));
|
m_browser->RegisterHandler(wxSharedPtr<wxWebViewHandler>(new wxWebViewArchiveHandler("wxfs")));
|
||||||
|
@@ -94,6 +94,15 @@ bool wxWebView::IsBackendAvailable(const wxString& backend)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxVersionInfo wxWebView::GetBackendVersionInfo(const wxString& backend)
|
||||||
|
{
|
||||||
|
wxStringWebViewFactoryMap::iterator iter = FindFactory(backend);
|
||||||
|
if (iter != m_factoryMap.end())
|
||||||
|
return iter->second->GetVersionInfo();
|
||||||
|
else
|
||||||
|
return wxVersionInfo();
|
||||||
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
wxStringWebViewFactoryMap::iterator wxWebView::FindFactory(const wxString &backend)
|
wxStringWebViewFactoryMap::iterator wxWebView::FindFactory(const wxString &backend)
|
||||||
{
|
{
|
||||||
|
@@ -507,6 +507,16 @@ wxgtk_authorize_authenticated_peer_cb(GDBusAuthObserver *,
|
|||||||
|
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxWebViewFactoryWebKit
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxVersionInfo wxWebViewFactoryWebKit::GetVersionInfo()
|
||||||
|
{
|
||||||
|
return wxVersionInfo("webkit2", webkit_get_major_version(),
|
||||||
|
webkit_get_minor_version(), webkit_get_micro_version());
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxWebViewWebKit
|
// wxWebViewWebKit
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
#include "wx/stdpaths.h"
|
#include "wx/stdpaths.h"
|
||||||
#include "wx/thread.h"
|
#include "wx/thread.h"
|
||||||
|
#include "wx/tokenzr.h"
|
||||||
#include "wx/private/jsscriptwrapper.h"
|
#include "wx/private/jsscriptwrapper.h"
|
||||||
#include "wx/private/json.h"
|
#include "wx/private/json.h"
|
||||||
#include "wx/msw/private.h"
|
#include "wx/msw/private.h"
|
||||||
@@ -53,6 +54,7 @@ GetAvailableCoreWebView2BrowserVersionString_t wxGetAvailableCoreWebView2Browser
|
|||||||
|
|
||||||
wxDynamicLibrary wxWebViewEdgeImpl::ms_loaderDll;
|
wxDynamicLibrary wxWebViewEdgeImpl::ms_loaderDll;
|
||||||
wxString wxWebViewEdgeImpl::ms_browserExecutableDir;
|
wxString wxWebViewEdgeImpl::ms_browserExecutableDir;
|
||||||
|
wxString wxWebViewEdgeImpl::ms_version;
|
||||||
|
|
||||||
wxWebViewEdgeImpl::wxWebViewEdgeImpl(wxWebViewEdge* webview):
|
wxWebViewEdgeImpl::wxWebViewEdgeImpl(wxWebViewEdge* webview):
|
||||||
m_ctrl(webview)
|
m_ctrl(webview)
|
||||||
@@ -135,6 +137,7 @@ bool wxWebViewEdgeImpl::Initialize()
|
|||||||
wxLogApiError("GetCoreWebView2BrowserVersionInfo", hr);
|
wxLogApiError("GetCoreWebView2BrowserVersionInfo", hr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
ms_version = versionStr;
|
||||||
|
|
||||||
ms_loaderDll.Attach(loaderDll.Detach());
|
ms_loaderDll.Attach(loaderDll.Detach());
|
||||||
|
|
||||||
@@ -876,6 +879,18 @@ bool wxWebViewFactoryEdge::IsAvailable()
|
|||||||
return wxWebViewEdgeImpl::Initialize();
|
return wxWebViewEdgeImpl::Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxVersionInfo wxWebViewFactoryEdge::GetVersionInfo()
|
||||||
|
{
|
||||||
|
IsAvailable(); // Make sure ms_version string is initialized (if available)
|
||||||
|
long versions[3] = { 0, 0, 0 };
|
||||||
|
wxArrayString tokens = wxStringTokenize(wxWebViewEdgeImpl::ms_version, ". ");
|
||||||
|
for (size_t i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
if (tokens.size() > i)
|
||||||
|
tokens[i].ToLong(&versions[i]);
|
||||||
|
}
|
||||||
|
return wxVersionInfo("Microsoft Edge WebView2", versions[0], versions[1], versions[2]);
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Module ensuring all global/singleton objects are destroyed on shutdown.
|
// Module ensuring all global/singleton objects are destroyed on shutdown.
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
#include "wx/filesys.h"
|
#include "wx/filesys.h"
|
||||||
#include "wx/dynlib.h"
|
#include "wx/dynlib.h"
|
||||||
#include "wx/scopeguard.h"
|
#include "wx/scopeguard.h"
|
||||||
|
#include "wx/tokenzr.h"
|
||||||
|
|
||||||
#include "wx/msw/missing.h"
|
#include "wx/msw/missing.h"
|
||||||
#include "wx/msw/private.h"
|
#include "wx/msw/private.h"
|
||||||
@@ -51,6 +52,22 @@ enum //Internal find flags
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// wxWebViewFactoryIE
|
||||||
|
wxVersionInfo wxWebViewFactoryIE::GetVersionInfo()
|
||||||
|
{
|
||||||
|
wxRegKey key(wxRegKey::HKLM, "Software\\Microsoft\\Internet Explorer");
|
||||||
|
wxString value;
|
||||||
|
key.QueryValue("Version", value);
|
||||||
|
long versions[3] = { 0, 0, 0 };
|
||||||
|
wxArrayString tokens = wxStringTokenize(value, ". ");
|
||||||
|
for (size_t i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
if (tokens.size() > i)
|
||||||
|
tokens[i].ToLong(&versions[i]);
|
||||||
|
}
|
||||||
|
return wxVersionInfo("Internet Explorer", versions[0], versions[1], versions[2]);
|
||||||
|
}
|
||||||
|
|
||||||
//Convenience function for error conversion
|
//Convenience function for error conversion
|
||||||
#define WX_ERROR_CASE(error, wxerror) \
|
#define WX_ERROR_CASE(error, wxerror) \
|
||||||
case error: \
|
case error: \
|
||||||
|
Reference in New Issue
Block a user