Allow using a fixed version with wxWebViewEdge
A fixed version may be distributed with the application and wxWebViewEdge::MSWSetBrowserExecutableDir() allows it's usage with wxWebViewEdge.
This commit is contained in:
@@ -66,6 +66,7 @@ public:
|
|||||||
ICoreWebView2Settings* GetSettings();
|
ICoreWebView2Settings* GetSettings();
|
||||||
|
|
||||||
static wxDynamicLibrary ms_loaderDll;
|
static wxDynamicLibrary ms_loaderDll;
|
||||||
|
static wxString ms_browserExecutableDir;
|
||||||
|
|
||||||
static bool Initialize();
|
static bool Initialize();
|
||||||
|
|
||||||
|
@@ -122,6 +122,8 @@ public:
|
|||||||
|
|
||||||
virtual void* GetNativeBackend() const wxOVERRIDE;
|
virtual void* GetNativeBackend() const wxOVERRIDE;
|
||||||
|
|
||||||
|
static void MSWSetBrowserExecutableDir(const wxString& path);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void DoSetPage(const wxString& html, const wxString& baseUrl) wxOVERRIDE;
|
virtual void DoSetPage(const wxString& html, const wxString& baseUrl) wxOVERRIDE;
|
||||||
|
|
||||||
|
@@ -330,6 +330,12 @@ public:
|
|||||||
- Make sure to add a note about using the WebView2 SDK to your application
|
- Make sure to add a note about using the WebView2 SDK to your application
|
||||||
documentation, as required by its licence
|
documentation, as required by its licence
|
||||||
|
|
||||||
|
If your application should use a
|
||||||
|
<a href="https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution#fixed-version-distribution-mode">
|
||||||
|
fixed version</a> of the WebView2 runtime you must use
|
||||||
|
wxWebViewEdge::MSWSetBrowserExecutableDir() to specify its usage before
|
||||||
|
using the edge backend.
|
||||||
|
|
||||||
@par wxWEBVIEW_WEBKIT (GTK)
|
@par wxWEBVIEW_WEBKIT (GTK)
|
||||||
|
|
||||||
Under GTK the WebKit backend uses
|
Under GTK the WebKit backend uses
|
||||||
|
@@ -30,6 +30,9 @@
|
|||||||
#if wxUSE_WEBVIEW_IE
|
#if wxUSE_WEBVIEW_IE
|
||||||
#include "wx/msw/webview_ie.h"
|
#include "wx/msw/webview_ie.h"
|
||||||
#endif
|
#endif
|
||||||
|
#if wxUSE_WEBVIEW_EDGE
|
||||||
|
#include "wx/msw/webview_edge.h"
|
||||||
|
#endif
|
||||||
#include "wx/webviewarchivehandler.h"
|
#include "wx/webviewarchivehandler.h"
|
||||||
#include "wx/webviewfshandler.h"
|
#include "wx/webviewfshandler.h"
|
||||||
#include "wx/numdlg.h"
|
#include "wx/numdlg.h"
|
||||||
@@ -37,6 +40,7 @@
|
|||||||
#include "wx/filesys.h"
|
#include "wx/filesys.h"
|
||||||
#include "wx/fs_arc.h"
|
#include "wx/fs_arc.h"
|
||||||
#include "wx/fs_mem.h"
|
#include "wx/fs_mem.h"
|
||||||
|
#include "wx/stdpaths.h"
|
||||||
|
|
||||||
#ifndef wxHAS_IMAGES_IN_RESOURCES
|
#ifndef wxHAS_IMAGES_IN_RESOURCES
|
||||||
#include "../sample.xpm"
|
#include "../sample.xpm"
|
||||||
@@ -373,6 +377,16 @@ WebFrame::WebFrame(const wxString& url) :
|
|||||||
// Create the webview
|
// Create the webview
|
||||||
wxString backend = wxWebViewBackendDefault;
|
wxString backend = wxWebViewBackendDefault;
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
|
// Check if a fixed version of edge is present in
|
||||||
|
// $executable_path/edge_fixed and use it
|
||||||
|
wxFileName edgeFixedDir(wxStandardPaths::Get().GetExecutablePath());
|
||||||
|
edgeFixedDir.SetFullName("");
|
||||||
|
edgeFixedDir.AppendDir("edge_fixed");
|
||||||
|
if (edgeFixedDir.DirExists())
|
||||||
|
{
|
||||||
|
wxWebViewEdge::MSWSetBrowserExecutableDir(edgeFixedDir.GetFullPath());
|
||||||
|
wxLogMessage("Using fixed edge version");
|
||||||
|
}
|
||||||
if (wxWebView::IsBackendAvailable(wxWebViewBackendEdge))
|
if (wxWebView::IsBackendAvailable(wxWebViewBackendEdge))
|
||||||
{
|
{
|
||||||
wxLogMessage("Using Edge backend");
|
wxLogMessage("Using Edge backend");
|
||||||
|
@@ -52,6 +52,7 @@ CreateCoreWebView2EnvironmentWithOptions_t wxCreateCoreWebView2EnvironmentWithOp
|
|||||||
GetAvailableCoreWebView2BrowserVersionString_t wxGetAvailableCoreWebView2BrowserVersionString = NULL;
|
GetAvailableCoreWebView2BrowserVersionString_t wxGetAvailableCoreWebView2BrowserVersionString = NULL;
|
||||||
|
|
||||||
wxDynamicLibrary wxWebViewEdgeImpl::ms_loaderDll;
|
wxDynamicLibrary wxWebViewEdgeImpl::ms_loaderDll;
|
||||||
|
wxString wxWebViewEdgeImpl::ms_browserExecutableDir;
|
||||||
|
|
||||||
wxWebViewEdgeImpl::wxWebViewEdgeImpl(wxWebViewEdge* webview):
|
wxWebViewEdgeImpl::wxWebViewEdgeImpl(wxWebViewEdge* webview):
|
||||||
m_ctrl(webview)
|
m_ctrl(webview)
|
||||||
@@ -85,7 +86,7 @@ bool wxWebViewEdgeImpl::Create()
|
|||||||
wxString userDataPath = wxStandardPaths::Get().GetUserLocalDataDir();
|
wxString userDataPath = wxStandardPaths::Get().GetUserLocalDataDir();
|
||||||
|
|
||||||
HRESULT hr = wxCreateCoreWebView2EnvironmentWithOptions(
|
HRESULT hr = wxCreateCoreWebView2EnvironmentWithOptions(
|
||||||
nullptr,
|
ms_browserExecutableDir.wc_str(),
|
||||||
userDataPath.wc_str(),
|
userDataPath.wc_str(),
|
||||||
nullptr,
|
nullptr,
|
||||||
Callback<ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler>(this,
|
Callback<ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler>(this,
|
||||||
@@ -127,7 +128,8 @@ bool wxWebViewEdgeImpl::Initialize()
|
|||||||
|
|
||||||
// Check if a Edge browser can be found by the loader DLL
|
// Check if a Edge browser can be found by the loader DLL
|
||||||
wxCoTaskMemPtr<wchar_t> versionStr;
|
wxCoTaskMemPtr<wchar_t> versionStr;
|
||||||
HRESULT hr = wxGetAvailableCoreWebView2BrowserVersionString(NULL, &versionStr);
|
HRESULT hr = wxGetAvailableCoreWebView2BrowserVersionString(
|
||||||
|
ms_browserExecutableDir.wc_str(), &versionStr);
|
||||||
if (FAILED(hr) || !versionStr)
|
if (FAILED(hr) || !versionStr)
|
||||||
{
|
{
|
||||||
wxLogApiError("GetCoreWebView2BrowserVersionInfo", hr);
|
wxLogApiError("GetCoreWebView2BrowserVersionInfo", hr);
|
||||||
@@ -780,6 +782,11 @@ bool wxWebViewEdge::QueryCommandEnabled(const wxString& command) const
|
|||||||
void wxWebViewEdge::ExecCommand(const wxString& command)
|
void wxWebViewEdge::ExecCommand(const wxString& command)
|
||||||
{
|
{
|
||||||
RunScript(wxString::Format("document.execCommand('%s');", command));
|
RunScript(wxString::Format("document.execCommand('%s');", command));
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxWebViewEdge::MSWSetBrowserExecutableDir(const wxString & path)
|
||||||
|
{
|
||||||
|
wxWebViewEdgeImpl::ms_browserExecutableDir = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWebViewEdge::RunScriptSync(const wxString& javascript, wxString* output)
|
bool wxWebViewEdge::RunScriptSync(const wxString& javascript, wxString* output)
|
||||||
|
Reference in New Issue
Block a user