Select Edge as the default backend on MSW
If enabled and available at runtime use the Edge backend. This is probably more useful for most users.
This commit is contained in:
@@ -160,7 +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);
|
static wxVersionInfo GetBackendVersionInfo(const wxString& backend = wxASCII_STR(wxWebViewBackendDefault));
|
||||||
|
|
||||||
// General methods
|
// General methods
|
||||||
virtual void EnableContextMenu(bool enable = true)
|
virtual void EnableContextMenu(bool enable = true)
|
||||||
|
@@ -337,6 +337,10 @@ 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 enabled and available at runtime edge will be selected as the default
|
||||||
|
backend. If you require the IE backend use @c wxWEBVIEW_BACKEND_IE when
|
||||||
|
using wxWebView::New().
|
||||||
|
|
||||||
If your application should use a
|
If your application should use a
|
||||||
<a href="https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution#fixed-version-distribution-mode">
|
<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
|
fixed version</a> of the WebView2 runtime you must use
|
||||||
@@ -504,7 +508,7 @@ public:
|
|||||||
|
|
||||||
@since 3.1.5
|
@since 3.1.5
|
||||||
*/
|
*/
|
||||||
static wxVersionInfo GetBackendVersionInfo(const wxString& backend);
|
static wxVersionInfo GetBackendVersionInfo(const wxString& backend = wxWebViewBackendDefault);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
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
|
||||||
|
@@ -374,9 +374,7 @@ WebFrame::WebFrame(const wxString& url) :
|
|||||||
// Create a log window
|
// Create a log window
|
||||||
new wxLogWindow(this, _("Logging"), true, false);
|
new wxLogWindow(this, _("Logging"), true, false);
|
||||||
|
|
||||||
// Create the webview
|
#if wxUSE_WEBVIEW_EDGE
|
||||||
wxString backend = wxWebViewBackendDefault;
|
|
||||||
#ifdef __WXMSW__
|
|
||||||
// Check if a fixed version of edge is present in
|
// Check if a fixed version of edge is present in
|
||||||
// $executable_path/edge_fixed and use it
|
// $executable_path/edge_fixed and use it
|
||||||
wxFileName edgeFixedDir(wxStandardPaths::Get().GetExecutablePath());
|
wxFileName edgeFixedDir(wxStandardPaths::Get().GetExecutablePath());
|
||||||
@@ -387,18 +385,12 @@ WebFrame::WebFrame(const wxString& url) :
|
|||||||
wxWebViewEdge::MSWSetBrowserExecutableDir(edgeFixedDir.GetFullPath());
|
wxWebViewEdge::MSWSetBrowserExecutableDir(edgeFixedDir.GetFullPath());
|
||||||
wxLogMessage("Using fixed edge version");
|
wxLogMessage("Using fixed edge version");
|
||||||
}
|
}
|
||||||
if (wxWebView::IsBackendAvailable(wxWebViewBackendEdge))
|
|
||||||
{
|
|
||||||
wxLogMessage("Using Edge backend");
|
|
||||||
backend = wxWebViewBackendEdge;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wxLogMessage("Edge backend not available");
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
m_browser = wxWebView::New(backend);
|
// Create the webview
|
||||||
wxLogMessage("Backend version: %s", wxWebView::GetBackendVersionInfo(backend).ToString());
|
m_browser = wxWebView::New();
|
||||||
|
// Log backend information
|
||||||
|
wxLogMessage("Backend: %s Version: %s", m_browser->GetClassInfo()->GetClassName(),
|
||||||
|
wxWebView::GetBackendVersionInfo().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")));
|
||||||
|
@@ -34,7 +34,7 @@ extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendEdge[] = "wxWebViewE
|
|||||||
extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendWebKit[] = "wxWebViewWebKit";
|
extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendWebKit[] = "wxWebViewWebKit";
|
||||||
|
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendDefault[] = "wxWebViewIE";
|
extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendDefault[] = "";
|
||||||
#else
|
#else
|
||||||
extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendDefault[] = "wxWebViewWebKit";
|
extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendDefault[] = "wxWebViewWebKit";
|
||||||
#endif
|
#endif
|
||||||
@@ -269,7 +269,22 @@ wxStringWebViewFactoryMap::iterator wxWebView::FindFactory(const wxString &backe
|
|||||||
// Initialise the map, it checks internally for existing factories
|
// Initialise the map, it checks internally for existing factories
|
||||||
InitFactoryMap();
|
InitFactoryMap();
|
||||||
|
|
||||||
return m_factoryMap.find(backend);
|
#ifdef __WXMSW__
|
||||||
|
// Use edge as default backend on MSW if available
|
||||||
|
if (backend.empty())
|
||||||
|
{
|
||||||
|
wxStringWebViewFactoryMap::iterator defaultBackend =
|
||||||
|
m_factoryMap.find(wxWebViewBackendIE);
|
||||||
|
#if wxUSE_WEBVIEW_EDGE
|
||||||
|
wxStringWebViewFactoryMap::iterator edgeFactory = m_factoryMap.find(wxWebViewBackendEdge);
|
||||||
|
if (edgeFactory->second->IsAvailable())
|
||||||
|
return edgeFactory;
|
||||||
|
#endif
|
||||||
|
return defaultBackend;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
return m_factoryMap.find(backend);
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
Reference in New Issue
Block a user