From dbe2d690dac4debe0dcddc65642b4a9953c42afc Mon Sep 17 00:00:00 2001 From: Faryan Rezagholi Date: Thu, 12 Aug 2021 21:00:26 +0200 Subject: [PATCH 1/7] removed majority of cefsharp related code --- ...onnection.Protocol.HTTP.DownloadHandler.cs | 34 ---- ...Connection.Protocol.HTTP.RequestHandler.cs | 68 ------- .../Http/Connection.Protocol.HTTPBase.cs | 173 +++++++----------- mRemoteNG/Properties/Settings.Designer.cs | 2 +- .../Resources/Language/Language.Designer.cs | 2 +- mRemoteNG/Resources/Language/Language.resx | 2 +- mRemoteNG/UI/Forms/frmMain.cs | 36 ---- mRemoteNG/app.config | 2 +- mRemoteNG/mRemoteNG.csproj | 11 +- 9 files changed, 73 insertions(+), 257 deletions(-) delete mode 100644 mRemoteNG/Connection/Protocol/Http/Connection.Protocol.HTTP.DownloadHandler.cs delete mode 100644 mRemoteNG/Connection/Protocol/Http/Connection.Protocol.HTTP.RequestHandler.cs diff --git a/mRemoteNG/Connection/Protocol/Http/Connection.Protocol.HTTP.DownloadHandler.cs b/mRemoteNG/Connection/Protocol/Http/Connection.Protocol.HTTP.DownloadHandler.cs deleted file mode 100644 index 214a768f..00000000 --- a/mRemoteNG/Connection/Protocol/Http/Connection.Protocol.HTTP.DownloadHandler.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright © 2013 The CefSharp Authors. All rights reserved. -// -// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. - -using CefSharp; -using System; - -namespace mRemoteNG.Connection.Protocol.Http -{ - public class DownloadHandler : IDownloadHandler - { - public event EventHandler OnBeforeDownloadFired; - - public event EventHandler OnDownloadUpdatedFired; - - public void OnBeforeDownload(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) - { - OnBeforeDownloadFired?.Invoke(this, downloadItem); - - if (!callback.IsDisposed) - { - using (callback) - { - callback.Continue(downloadItem.SuggestedFileName, showDialog: true); - } - } - } - - public void OnDownloadUpdated(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IDownloadItemCallback callback) - { - OnDownloadUpdatedFired?.Invoke(this, downloadItem); - } - } -} \ No newline at end of file diff --git a/mRemoteNG/Connection/Protocol/Http/Connection.Protocol.HTTP.RequestHandler.cs b/mRemoteNG/Connection/Protocol/Http/Connection.Protocol.HTTP.RequestHandler.cs deleted file mode 100644 index d2df2cb3..00000000 --- a/mRemoteNG/Connection/Protocol/Http/Connection.Protocol.HTTP.RequestHandler.cs +++ /dev/null @@ -1,68 +0,0 @@ -using CefSharp; -using System.Diagnostics; -using System.Security.Cryptography.X509Certificates; - -namespace mRemoteNG.Connection.Protocol.Http -{ - partial class RequestHandler : IRequestHandler - { - public bool GetAuthCredentials(IWebBrowser chromiumWebBrowser, IBrowser browser, string originUrl, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback) - { - return false; - } - - public IResourceRequestHandler GetResourceRequestHandler(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, bool isNavigation, bool isDownload, string requestInitiator, ref bool disableDefaultHandling) - { - return null; - } - - public bool OnBeforeBrowse(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, bool userGesture, bool isRedirect) - { - if (request.Url.StartsWith(Cef.CefCommitHash)) - { - return false; - } - else - { - Process.Start(request.Url); - return true; - } - } - - public void OnDocumentAvailableInMainFrame(IWebBrowser chromiumWebBrowser, IBrowser browser) - { - } - - public bool OnCertificateError(IWebBrowser chromiumWebBrowser, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback) - { - return false; - } - - public bool OnOpenUrlFromTab(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, string targetUrl, WindowOpenDisposition targetDisposition, bool userGesture) - { - return false; - } - - public void OnPluginCrashed(IWebBrowser chromiumWebBrowser, IBrowser browser, string pluginPath) - { - } - - public bool OnQuotaRequest(IWebBrowser chromiumWebBrowser, IBrowser browser, string originUrl, long newSize, IRequestCallback callback) - { - return true; - } - - public void OnRenderProcessTerminated(IWebBrowser chromiumWebBrowser, IBrowser browser, CefTerminationStatus status) - { - } - - public void OnRenderViewReady(IWebBrowser chromiumWebBrowser, IBrowser browser) - { - } - - public bool OnSelectClientCertificate(IWebBrowser chromiumWebBrowser, IBrowser browser, bool isProxy, string host, int port, X509Certificate2Collection certificates, ISelectClientCertificateCallback callback) - { - return true; - } - } -} \ No newline at end of file diff --git a/mRemoteNG/Connection/Protocol/Http/Connection.Protocol.HTTPBase.cs b/mRemoteNG/Connection/Protocol/Http/Connection.Protocol.HTTPBase.cs index 823a4fe3..0e828031 100644 --- a/mRemoteNG/Connection/Protocol/Http/Connection.Protocol.HTTPBase.cs +++ b/mRemoteNG/Connection/Protocol/Http/Connection.Protocol.HTTPBase.cs @@ -1,7 +1,6 @@ using System; using System.Windows.Forms; -using CefSharp; -using CefSharp.WinForms; +using Microsoft.Web.WebView2.WinForms; using mRemoteNG.Tools; using mRemoteNG.App; using mRemoteNG.Resources.Language; @@ -18,8 +17,6 @@ namespace mRemoteNG.Connection.Protocol.Http protected string httpOrS; protected int defaultPort; private string tabTitle; - private bool browserInitialised = false; - private bool connectCalled = false; #endregion @@ -29,9 +26,9 @@ namespace mRemoteNG.Connection.Protocol.Http { try { - if (RenderingEngine == RenderingEngine.CEF) + if (RenderingEngine == RenderingEngine.EdgeChromium) { - Control = new ChromiumWebBrowser("about:blank") + Control = new WebView2() { Dock = DockStyle.Fill, }; @@ -64,18 +61,24 @@ namespace mRemoteNG.Connection.Protocol.Http { wBrowser = Control; - if (InterfaceControl.Info.RenderingEngine == RenderingEngine.CEF) + if (InterfaceControl.Info.RenderingEngine == RenderingEngine.EdgeChromium) { - var CEFBrowser = (ChromiumWebBrowser)wBrowser; - if (CEFBrowser != null) - { - CEFBrowser.LoadingStateChanged += CefBrowser_LoadingStateChanged; - CEFBrowser.TitleChanged += WBrowser_DocumentTitleChanged; - } - else - { - throw new Exception("Failed to initialize CEF Rendering Engine."); - } + var edge = (WebView2)wBrowser; + + //edge.NavigationCompleted += Edge_NavigationCompleted;// += WBrowser_Navigated; + edge.TextChanged += WBrowser_DocumentTitleChanged; + + + + //if (edge != null) + //{ + // //CEFBrowser.ContentLoading += CEFBrowser_ContentLoading;// += CefBrowser_LoadingStateChanged; + // edge.TextChanged += WBrowser_DocumentTitleChanged; + //} + //else + //{ + // throw new Exception("Failed to initialize EdgeChromium Rendering Engine."); + //} } else { @@ -87,7 +90,6 @@ namespace mRemoteNG.Connection.Protocol.Http objWebBrowser.Navigated += WBrowser_Navigated; objWebBrowser.DocumentTitleChanged += WBrowser_DocumentTitleChanged; - browserInitialised = true; } return true; @@ -98,17 +100,17 @@ namespace mRemoteNG.Connection.Protocol.Http return false; } } - + public override bool Connect() { try { - if (InterfaceControl.Info.RenderingEngine == RenderingEngine.CEF) + if (InterfaceControl.Info.RenderingEngine == RenderingEngine.EdgeChromium) { - if (browserInitialised) - { - ((ChromiumWebBrowser)wBrowser).Load(GetURL()); - } + //if (browserInitialised) + //{ + ((WebView2)wBrowser).NavigateToString((GetURL())); + //} } else { @@ -116,7 +118,6 @@ namespace mRemoteNG.Connection.Protocol.Http } base.Connect(); - connectCalled = true; return true; } catch (Exception ex) @@ -173,23 +174,28 @@ namespace mRemoteNG.Connection.Protocol.Http #endregion #region Events - - private void CefBrowser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e) - { - browserInitialised = !e.IsLoading; - if (browserInitialised) - { - // Unhook the loading state changes now, as navigation is done by the user on links in the control - ((ChromiumWebBrowser)wBrowser).LoadingStateChanged -= CefBrowser_LoadingStateChanged; - - // If this Connection has already been asked to connect but the browser hadn't finished initalising - // then the connect wouldn't have been allowed to take place, so now we can call it! - if (connectCalled) - { - Connect(); - } - } - } + + //private void CEFBrowser_ContentLoading(object sender, Microsoft.Web.WebView2.Core.CoreWebView2ContentLoadingEventArgs e) + //{ + // throw new NotImplementedException(); + //} + // + //private void CefBrowser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e) + //{ + // browserInitialised = !e.IsLoading; + // if (browserInitialised) + // { + // // Unhook the loading state changes now, as navigation is done by the user on links in the control + // ((ChromiumWebBrowser)wBrowser).LoadingStateChanged -= CefBrowser_LoadingStateChanged; + // + // // If this Connection has already been asked to connect but the browser hadn't finished initalising + // // then the connect wouldn't have been allowed to take place, so now we can call it! + // if (connectCalled) + // { + // Connect(); + // } + // } + //} private void WBrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e) { @@ -207,28 +213,13 @@ namespace mRemoteNG.Connection.Protocol.Http { if (!(InterfaceControl.Parent is ConnectionTab tabP)) return; string shortTitle; - - if (InterfaceControl.Info.RenderingEngine == RenderingEngine.CEF) + if (((WebBrowser)wBrowser).DocumentTitle.Length >= 15) { - if (((TitleChangedEventArgs)e).Title.Length >= 15) - { - shortTitle = ((TitleChangedEventArgs)e).Title.Substring(0, 10) + "..."; - } - else - { - shortTitle = ((CefSharp.TitleChangedEventArgs)e).Title; - } + shortTitle = ((WebBrowser)wBrowser).DocumentTitle.Substring(0, 10) + "..."; } else { - if (((WebBrowser)wBrowser).DocumentTitle.Length >= 15) - { - shortTitle = ((WebBrowser)wBrowser).DocumentTitle.Substring(0, 10) + "..."; - } - else - { - shortTitle = ((WebBrowser)wBrowser).DocumentTitle; - } + shortTitle = ((WebBrowser)wBrowser).DocumentTitle; } if (!string.IsNullOrEmpty(tabTitle)) @@ -245,52 +236,20 @@ namespace mRemoteNG.Connection.Protocol.Http Runtime.MessageCollector.AddExceptionStackTrace(Language.HttpDocumentTileChangeFailed, ex); } } - - - private void geckoBrowser_DocumentTitleChanged(object sender, EventArgs e) - { - try - { - if (!(InterfaceControl.Parent is ConnectionTab tabP)) return; - string shortTitle; - - if (((WebBrowser)wBrowser).DocumentTitle.Length >= 15) - { - shortTitle = ((WebBrowser)wBrowser).DocumentTitle.Substring(0, 10) + "..."; - } - else - { - shortTitle = ((WebBrowser)wBrowser).DocumentTitle; - } - - if (!string.IsNullOrEmpty(tabTitle)) - { - tabP.TabText = tabTitle + @" - " + shortTitle; - } - else - { - tabP.TabText = shortTitle; - } - } - catch (Exception ex) - { - Runtime.MessageCollector.AddExceptionStackTrace(Language.HttpDocumentTileChangeFailed, ex); - } - } - - #endregion - - #region Enums - - public enum RenderingEngine - { - [LocalizedAttributes.LocalizedDescription(nameof(Language.HttpInternetExplorer))] - IE = 1, - - [LocalizedAttributes.LocalizedDescription(nameof(Language.HttpCEF))] - CEF = 2 - } - - #endregion } + + #endregion + + #region Enums + + public enum RenderingEngine + { + [LocalizedAttributes.LocalizedDescription(nameof(Language.HttpInternetExplorer))] + IE = 1, + + [LocalizedAttributes.LocalizedDescription(nameof(Language.HttpCEF))] + EdgeChromium = 2 + } + + #endregion } diff --git a/mRemoteNG/Properties/Settings.Designer.cs b/mRemoteNG/Properties/Settings.Designer.cs index d84a2309..eb5be0c3 100644 --- a/mRemoteNG/Properties/Settings.Designer.cs +++ b/mRemoteNG/Properties/Settings.Designer.cs @@ -1525,7 +1525,7 @@ namespace mRemoteNG.Properties { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("CEF")] + [global::System.Configuration.DefaultSettingValueAttribute("EdgeChromium")] public string ConDefaultRenderingEngine { get { return ((string)(this["ConDefaultRenderingEngine"])); diff --git a/mRemoteNG/Resources/Language/Language.Designer.cs b/mRemoteNG/Resources/Language/Language.Designer.cs index 0f6619e2..ba07fa43 100644 --- a/mRemoteNG/Resources/Language/Language.Designer.cs +++ b/mRemoteNG/Resources/Language/Language.Designer.cs @@ -2316,7 +2316,7 @@ namespace mRemoteNG.Resources.Language { } /// - /// Sucht eine lokalisierte Zeichenfolge, die CEF (Chromium) ähnelt. + /// Sucht eine lokalisierte Zeichenfolge, die Edge Chromium ähnelt. /// internal static string HttpCEF { get { diff --git a/mRemoteNG/Resources/Language/Language.resx b/mRemoteNG/Resources/Language/Language.resx index dd7ef42b..c610c94b 100644 --- a/mRemoteNG/Resources/Language/Language.resx +++ b/mRemoteNG/Resources/Language/Language.resx @@ -2133,7 +2133,7 @@ Nightly Channel includes Alphas, Betas & Release Candidates. Determines whether menus and windows can be displayed with animation effects in the remote session. - CEF (Chromium) + Edge Chromium Failed to contruct the URL to load diff --git a/mRemoteNG/UI/Forms/frmMain.cs b/mRemoteNG/UI/Forms/frmMain.cs index a0c62a97..ffa74f86 100644 --- a/mRemoteNG/UI/Forms/frmMain.cs +++ b/mRemoteNG/UI/Forms/frmMain.cs @@ -28,8 +28,6 @@ using System.Text; using System.Windows.Forms; using mRemoteNG.UI.Panels; using WeifenLuo.WinFormsUI.Docking; -using CefSharp; -using CefSharp.WinForms; using mRemoteNG.Resources.Language; using mRemoteNG.UI.Controls; using Settings = mRemoteNG.Properties.Settings; @@ -159,12 +157,6 @@ namespace mRemoteNG.UI.Forms SetMenuDependencies(); - //Monitor parent process exit and close subprocesses if parent process exits first - //This will at some point in the future becomes the default - CefSharpSettings.SubprocessExitIfParentProcessClosed = true; - - CefSetup(); - var uiLoader = new DockPanelLayoutLoader(this, messageCollector); uiLoader.LoadPanelsFromXml(); @@ -225,32 +217,6 @@ namespace mRemoteNG.UI.Forms panelAdder.AddPanel(panelName); } - private void CefSetup() - { - //For Windows 7 and above, best to include relevant app.manifest entries as well - Cef.EnableHighDPISupport(); - - string dir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), Application.ProductName); - if (Runtime.IsPortableEdition) dir = SettingsFileInfo.SettingsPath; - - CefSettings settings = new CefSettings() - { - CachePath = Path.Combine(dir, "CEFCache"), - LogFile = Path.Combine(dir, "mRemoteNG_cef.log"), - }; - - if (Settings.Default.TextLogMessageWriterWriteDebugMsgs) - settings.LogSeverity = LogSeverity.Verbose; - else if (Settings.Default.TextLogMessageWriterWriteInfoMsgs) - settings.LogSeverity = LogSeverity.Info; - else if (Settings.Default.TextLogMessageWriterWriteWarningMsgs) - settings.LogSeverity = LogSeverity.Warning; - else if (Settings.Default.TextLogMessageWriterWriteErrorMsgs) - settings.LogSeverity = LogSeverity.Error; - - Cef.Initialize(settings); - } - private void ApplyLanguage() { fileMenu.ApplyLanguage(); @@ -490,8 +456,6 @@ namespace mRemoteNG.UI.Forms Shutdown.Cleanup(_quickConnectToolStrip, _externalToolsToolStrip, _multiSshToolStrip, this); - Cef.Shutdown(); - Shutdown.StartUpdate(); Debug.Print("[END] - " + Convert.ToString(DateTime.Now, CultureInfo.InvariantCulture)); diff --git a/mRemoteNG/app.config b/mRemoteNG/app.config index e29caf70..e40ad670 100644 --- a/mRemoteNG/app.config +++ b/mRemoteNG/app.config @@ -412,7 +412,7 @@ - CEF + EdgeChromium False diff --git a/mRemoteNG/mRemoteNG.csproj b/mRemoteNG/mRemoteNG.csproj index 32022874..fecb9bf1 100644 --- a/mRemoteNG/mRemoteNG.csproj +++ b/mRemoteNG/mRemoteNG.csproj @@ -184,8 +184,6 @@ - - @@ -1319,12 +1317,6 @@ 1.8.9 - - 91.1.230 - - - 91.1.230 - 1.3.0 @@ -1349,6 +1341,9 @@ 2.0.12 + + 1.0.902.49 + 8.0.26 From 3c7e97d2d9242438cd5e8c9dd0a4e4b0f7111194 Mon Sep 17 00:00:00 2001 From: Faryan Rezagholi Date: Thu, 12 Aug 2021 22:46:07 +0200 Subject: [PATCH 2/7] replaced CefSharp with WebView2 --- .../Http/Connection.Protocol.HTTPBase.cs | 83 ++++++------------- 1 file changed, 27 insertions(+), 56 deletions(-) diff --git a/mRemoteNG/Connection/Protocol/Http/Connection.Protocol.HTTPBase.cs b/mRemoteNG/Connection/Protocol/Http/Connection.Protocol.HTTPBase.cs index 0e828031..bfdd4ec3 100644 --- a/mRemoteNG/Connection/Protocol/Http/Connection.Protocol.HTTPBase.cs +++ b/mRemoteNG/Connection/Protocol/Http/Connection.Protocol.HTTPBase.cs @@ -64,21 +64,8 @@ namespace mRemoteNG.Connection.Protocol.Http if (InterfaceControl.Info.RenderingEngine == RenderingEngine.EdgeChromium) { var edge = (WebView2)wBrowser; - - //edge.NavigationCompleted += Edge_NavigationCompleted;// += WBrowser_Navigated; - edge.TextChanged += WBrowser_DocumentTitleChanged; - - - //if (edge != null) - //{ - // //CEFBrowser.ContentLoading += CEFBrowser_ContentLoading;// += CefBrowser_LoadingStateChanged; - // edge.TextChanged += WBrowser_DocumentTitleChanged; - //} - //else - //{ - // throw new Exception("Failed to initialize EdgeChromium Rendering Engine."); - //} + edge.CoreWebView2InitializationCompleted += Edge_CoreWebView2InitializationCompleted; } else { @@ -100,17 +87,14 @@ namespace mRemoteNG.Connection.Protocol.Http return false; } } - + public override bool Connect() { try { if (InterfaceControl.Info.RenderingEngine == RenderingEngine.EdgeChromium) { - //if (browserInitialised) - //{ - ((WebView2)wBrowser).NavigateToString((GetURL())); - //} + ((WebView2)wBrowser).Source = new Uri(GetURL()); } else { @@ -174,28 +158,15 @@ namespace mRemoteNG.Connection.Protocol.Http #endregion #region Events - - //private void CEFBrowser_ContentLoading(object sender, Microsoft.Web.WebView2.Core.CoreWebView2ContentLoadingEventArgs e) - //{ - // throw new NotImplementedException(); - //} - // - //private void CefBrowser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e) - //{ - // browserInitialised = !e.IsLoading; - // if (browserInitialised) - // { - // // Unhook the loading state changes now, as navigation is done by the user on links in the control - // ((ChromiumWebBrowser)wBrowser).LoadingStateChanged -= CefBrowser_LoadingStateChanged; - // - // // If this Connection has already been asked to connect but the browser hadn't finished initalising - // // then the connect wouldn't have been allowed to take place, so now we can call it! - // if (connectCalled) - // { - // Connect(); - // } - // } - //} + + private void Edge_CoreWebView2InitializationCompleted(object sender, Microsoft.Web.WebView2.Core.CoreWebView2InitializationCompletedEventArgs e) + { + if (!e.IsSuccess) + { + //TODO: Log + MessageBox.Show($"WebView2 creation failed with exception = {e.InitializationException}"); + } + } private void WBrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e) { @@ -236,20 +207,20 @@ namespace mRemoteNG.Connection.Protocol.Http Runtime.MessageCollector.AddExceptionStackTrace(Language.HttpDocumentTileChangeFailed, ex); } } + + #endregion + + #region Enums + + public enum RenderingEngine + { + [LocalizedAttributes.LocalizedDescription(nameof(Language.HttpInternetExplorer))] + IE = 1, + + [LocalizedAttributes.LocalizedDescription(nameof(Language.HttpCEF))] + EdgeChromium = 2 + } + + #endregion } - - #endregion - - #region Enums - - public enum RenderingEngine - { - [LocalizedAttributes.LocalizedDescription(nameof(Language.HttpInternetExplorer))] - IE = 1, - - [LocalizedAttributes.LocalizedDescription(nameof(Language.HttpCEF))] - EdgeChromium = 2 - } - - #endregion } From ca8751c40cc0bdc4d2d62dfd7465f2761a4cf1ff Mon Sep 17 00:00:00 2001 From: Faryan Rezagholi Date: Thu, 12 Aug 2021 22:54:20 +0200 Subject: [PATCH 3/7] little code cleanup --- .../Http/Connection.Protocol.HTTPBase.cs | 50 ++++++++----------- .../Resources/Language/Language.Designer.cs | 9 ++++ mRemoteNG/Resources/Language/Language.de.resx | 3 ++ mRemoteNG/Resources/Language/Language.resx | 3 ++ 4 files changed, 35 insertions(+), 30 deletions(-) diff --git a/mRemoteNG/Connection/Protocol/Http/Connection.Protocol.HTTPBase.cs b/mRemoteNG/Connection/Protocol/Http/Connection.Protocol.HTTPBase.cs index bfdd4ec3..f3e63004 100644 --- a/mRemoteNG/Connection/Protocol/Http/Connection.Protocol.HTTPBase.cs +++ b/mRemoteNG/Connection/Protocol/Http/Connection.Protocol.HTTPBase.cs @@ -13,20 +13,20 @@ namespace mRemoteNG.Connection.Protocol.Http { #region Private Properties - private Control wBrowser; + private Control _wBrowser; + private string _tabTitle; protected string httpOrS; protected int defaultPort; - private string tabTitle; #endregion #region Public Methods - protected HTTPBase(RenderingEngine RenderingEngine) + protected HTTPBase(RenderingEngine renderingEngine) { try { - if (RenderingEngine == RenderingEngine.EdgeChromium) + if (renderingEngine == RenderingEngine.EdgeChromium) { Control = new WebView2() { @@ -50,26 +50,26 @@ namespace mRemoteNG.Connection.Protocol.Http try { - if (InterfaceControl.Parent is ConnectionTab objConnectionTab) tabTitle = objConnectionTab.TabText; + if (InterfaceControl.Parent is ConnectionTab objConnectionTab) _tabTitle = objConnectionTab.TabText; } catch (Exception) { - tabTitle = ""; + _tabTitle = ""; } try { - wBrowser = Control; + _wBrowser = Control; if (InterfaceControl.Info.RenderingEngine == RenderingEngine.EdgeChromium) { - var edge = (WebView2)wBrowser; + var edge = (WebView2)_wBrowser; edge.CoreWebView2InitializationCompleted += Edge_CoreWebView2InitializationCompleted; } else { - var objWebBrowser = (WebBrowser)wBrowser; + var objWebBrowser = (WebBrowser)_wBrowser; objWebBrowser.ScrollBarsEnabled = true; // http://stackoverflow.com/questions/4655662/how-to-ignore-script-errors-in-webbrowser @@ -94,11 +94,11 @@ namespace mRemoteNG.Connection.Protocol.Http { if (InterfaceControl.Info.RenderingEngine == RenderingEngine.EdgeChromium) { - ((WebView2)wBrowser).Source = new Uri(GetURL()); + ((WebView2)_wBrowser).Source = new Uri(GetUrl()); } else { - ((WebBrowser)wBrowser).Navigate(GetURL()); + ((WebBrowser)_wBrowser).Navigate(GetUrl()); } base.Connect(); @@ -115,22 +115,12 @@ namespace mRemoteNG.Connection.Protocol.Http #region Private Methods - private string GetURL() + private string GetUrl() { try { var strHost = InterfaceControl.Info.Hostname; - /* - * Commenting out since this codes doesn't actually do anything at this time... - * Possibly related to MR-221 and/or MR-533 ???? - * - string strAuth = ""; - if (((int)Force & (int)ConnectionInfo.Force.NoCredentials) != (int)ConnectionInfo.Force.NoCredentials && !string.IsNullOrEmpty(InterfaceControl.Info.Username) && !string.IsNullOrEmpty(InterfaceControl.Info.Password)) - { - strAuth = "Authorization: Basic " + Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(InterfaceControl.Info.Username + ":" + InterfaceControl.Info.Password)) + Environment.NewLine; - } - */ if (InterfaceControl.Info.Port != defaultPort) { if (strHost.EndsWith("/")) @@ -146,6 +136,7 @@ namespace mRemoteNG.Connection.Protocol.Http if (strHost.Contains(httpOrS + "://") == false) strHost = httpOrS + "://" + strHost; } + return strHost; } catch (Exception ex) @@ -163,14 +154,13 @@ namespace mRemoteNG.Connection.Protocol.Http { if (!e.IsSuccess) { - //TODO: Log - MessageBox.Show($"WebView2 creation failed with exception = {e.InitializationException}"); + Runtime.MessageCollector.AddExceptionStackTrace(Language.HttpFailedUrlBuild, e.InitializationException); } } private void WBrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e) { - if (!(wBrowser is WebBrowser objWebBrowser)) return; + if (!(_wBrowser is WebBrowser objWebBrowser)) return; // This can only be set once the WebBrowser control is shown, it will throw a COM exception otherwise. objWebBrowser.AllowWebBrowserDrop = false; @@ -184,18 +174,18 @@ namespace mRemoteNG.Connection.Protocol.Http { if (!(InterfaceControl.Parent is ConnectionTab tabP)) return; string shortTitle; - if (((WebBrowser)wBrowser).DocumentTitle.Length >= 15) + if (((WebBrowser)_wBrowser).DocumentTitle.Length >= 15) { - shortTitle = ((WebBrowser)wBrowser).DocumentTitle.Substring(0, 10) + "..."; + shortTitle = ((WebBrowser)_wBrowser).DocumentTitle.Substring(0, 10) + "..."; } else { - shortTitle = ((WebBrowser)wBrowser).DocumentTitle; + shortTitle = ((WebBrowser)_wBrowser).DocumentTitle; } - if (!string.IsNullOrEmpty(tabTitle)) + if (!string.IsNullOrEmpty(_tabTitle)) { - tabP.TabText = tabTitle + @" - " + shortTitle; + tabP.TabText = _tabTitle + @" - " + shortTitle; } else { diff --git a/mRemoteNG/Resources/Language/Language.Designer.cs b/mRemoteNG/Resources/Language/Language.Designer.cs index ba07fa43..5952579e 100644 --- a/mRemoteNG/Resources/Language/Language.Designer.cs +++ b/mRemoteNG/Resources/Language/Language.Designer.cs @@ -6082,6 +6082,15 @@ namespace mRemoteNG.Resources.Language { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die WebView2 creation failed with exception ähnelt. + /// + internal static string WebView2InitializationFailed { + get { + return ResourceManager.GetString("WebView2InitializationFailed", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Weekly ähnelt. /// diff --git a/mRemoteNG/Resources/Language/Language.de.resx b/mRemoteNG/Resources/Language/Language.de.resx index 61ebaacd..b25908c3 100644 --- a/mRemoteNG/Resources/Language/Language.de.resx +++ b/mRemoteNG/Resources/Language/Language.de.resx @@ -2022,4 +2022,7 @@ Nightly umfasst Alphas, Betas und Release Candidates. Fehlermeldung + + WebView2-Erstellung fehlgeschlagen + \ No newline at end of file diff --git a/mRemoteNG/Resources/Language/Language.resx b/mRemoteNG/Resources/Language/Language.resx index c610c94b..c102ad6c 100644 --- a/mRemoteNG/Resources/Language/Language.resx +++ b/mRemoteNG/Resources/Language/Language.resx @@ -2147,4 +2147,7 @@ Nightly Channel includes Alphas, Betas & Release Candidates. Start Program + + WebView2 creation failed with exception + \ No newline at end of file From 2ca356ee5cd230fc226b67339f18b43b2379cfad Mon Sep 17 00:00:00 2001 From: Faryan Rezagholi Date: Thu, 12 Aug 2021 22:55:40 +0200 Subject: [PATCH 4/7] removed CefSharp from credits --- CREDITS.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CREDITS.md b/CREDITS.md index 2b8955f9..1a6473ba 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -90,10 +90,6 @@ Copyright © 2004 Marc Merritt © 2008 Felix Deimel # Included Components -**[CefSharp](https://github.com/cefsharp/CefSharp)** -Copyright © The CefSharp Authors -MIT License - **[DockPanel Suite](https://github.com/dockpanelsuite/dockpanelsuite)** Copyright © 2018 @roken and @lextm (formerly Weifen Luo) MIT License From 3cf274c37a50ade6e4dd99a477a32d3c9bb328db Mon Sep 17 00:00:00 2001 From: Faryan Rezagholi Date: Thu, 12 Aug 2021 23:11:55 +0200 Subject: [PATCH 5/7] updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52af0484..8703aa65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - #283: Support for native PowerShell remoting as new protocol - #1850: Minify config xml ### Changed +- #2022: Replaced CefSharp with WebView2 - #2014: Revised icons - #2013: Removed components check - #2011: Removed screenshot manager From 300e668327399a5fbc5a9c624402656e7de8a7aa Mon Sep 17 00:00:00 2001 From: Faryan Rezagholi Date: Thu, 12 Aug 2021 23:26:18 +0200 Subject: [PATCH 6/7] updated wix file fragments --- .../Installer/Fragments/FilesFragment.wxs | 3572 +++++++++++++++-- 1 file changed, 3336 insertions(+), 236 deletions(-) diff --git a/mRemoteNGInstaller/Installer/Fragments/FilesFragment.wxs b/mRemoteNGInstaller/Installer/Fragments/FilesFragment.wxs index ad656d16..0df1d591 100644 --- a/mRemoteNGInstaller/Installer/Fragments/FilesFragment.wxs +++ b/mRemoteNGInstaller/Installer/Fragments/FilesFragment.wxs @@ -2,6 +2,7 @@ + @@ -15,17 +16,19 @@ - + + + + - @@ -38,57 +41,32 @@ + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - + + + + + + + + + + + @@ -101,18 +79,16 @@ - - + + + - - - @@ -125,32 +101,59 @@ - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -170,33 +173,37 @@ + - - - - - + + - - + + + + + + + + @@ -209,15 +216,15 @@ + + + - - - @@ -227,12 +234,18 @@ + + + + + + @@ -242,9 +255,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -266,12 +306,678 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -284,6 +990,9 @@ + + + @@ -332,6 +1041,9 @@ + + + @@ -386,171 +1098,1417 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -563,6 +2521,9 @@ + + + @@ -585,6 +2546,501 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -600,12 +3056,6 @@ - - - - - - @@ -632,14 +3082,664 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 6260cc3655f9ad86796bb3e7071f379c6aa1635b Mon Sep 17 00:00:00 2001 From: Faryan Rezagholi Date: Thu, 12 Aug 2021 23:35:19 +0200 Subject: [PATCH 7/7] fixed tests --- .../Csv/CsvConnectionsDeserializerMremotengFormatTests.cs | 2 +- mRemoteNGTests/Connection/AbstractConnectionInfoDataTests.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mRemoteNGTests/Config/Serializers/ConnectionSerializers/Csv/CsvConnectionsDeserializerMremotengFormatTests.cs b/mRemoteNGTests/Config/Serializers/ConnectionSerializers/Csv/CsvConnectionsDeserializerMremotengFormatTests.cs index 39ad1cc1..6505ec4c 100644 --- a/mRemoteNGTests/Config/Serializers/ConnectionSerializers/Csv/CsvConnectionsDeserializerMremotengFormatTests.cs +++ b/mRemoteNGTests/Config/Serializers/ConnectionSerializers/Csv/CsvConnectionsDeserializerMremotengFormatTests.cs @@ -98,7 +98,7 @@ namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers.Csv UseCredSsp = true, UseVmId = false, UseEnhancedMode = false, - RenderingEngine = HTTPBase.RenderingEngine.CEF, + RenderingEngine = HTTPBase.RenderingEngine.EdgeChromium, RDPAuthenticationLevel = AuthenticationLevel.WarnOnFailedAuth, Colors = RDPColors.Colors16Bit, Resolution = RDPResolutions.Res1366x768, diff --git a/mRemoteNGTests/Connection/AbstractConnectionInfoDataTests.cs b/mRemoteNGTests/Connection/AbstractConnectionInfoDataTests.cs index cca547e0..39433736 100644 --- a/mRemoteNGTests/Connection/AbstractConnectionInfoDataTests.cs +++ b/mRemoteNGTests/Connection/AbstractConnectionInfoDataTests.cs @@ -173,7 +173,7 @@ namespace mRemoteNGTests.Connection { var wasCalled = false; _testAbstractConnectionInfoData.PropertyChanged += (sender, args) => wasCalled = true; - _testAbstractConnectionInfoData.RenderingEngine = HTTPBase.RenderingEngine.CEF; + _testAbstractConnectionInfoData.RenderingEngine = HTTPBase.RenderingEngine.EdgeChromium; Assert.That(wasCalled, Is.True); }