From eed6bdc0a71e069f1ae7fe2ddfe5a019621cac09 Mon Sep 17 00:00:00 2001 From: SLT World <76160587+SLT-World@users.noreply.github.com> Date: Wed, 28 Aug 2024 14:58:07 +0800 Subject: [PATCH] PR Chromium 126.2.70 to 127.3.50 (#27) * Upgrade to 127.3.5+g114ea2a+chromium-127.0.6533.120 * Change Cef.IsInitialized from bool to bool? * InitializeCefInternal() missing fix * Update ChromiumWebBrowser.cs --- .../CefSharp.Wpf.HwndHost.csproj | 6 ++-- .../ChromiumWebBrowser.cs | 29 ++++++++++++------- CefSharp.Wpf.HwndHost/appveyor.yml | 2 +- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/CefSharp.Wpf.HwndHost/CefSharp.Wpf.HwndHost/CefSharp.Wpf.HwndHost.csproj b/CefSharp.Wpf.HwndHost/CefSharp.Wpf.HwndHost/CefSharp.Wpf.HwndHost.csproj index 772c4751..ba20edc3 100644 --- a/CefSharp.Wpf.HwndHost/CefSharp.Wpf.HwndHost/CefSharp.Wpf.HwndHost.csproj +++ b/CefSharp.Wpf.HwndHost/CefSharp.Wpf.HwndHost/CefSharp.Wpf.HwndHost.csproj @@ -5,7 +5,7 @@ CefSharp.Wpf.HwndHost true true - 126.2.70 + 127.3.50 The CefSharp Authors The CefSharp Chromium-based browser component. The CefSharp.Wpf.HwndHost.ChromiumWebBrowser control is a drop in replacement for the CefSharp.Wpf.ChromiumWebBrowser that's rougly equivilent to hosting the WinForms version in WPF. Copyright © The CefSharp Authors @@ -23,11 +23,11 @@ - + - + diff --git a/CefSharp.Wpf.HwndHost/CefSharp.Wpf.HwndHost/ChromiumWebBrowser.cs b/CefSharp.Wpf.HwndHost/CefSharp.Wpf.HwndHost/ChromiumWebBrowser.cs index fc4ef5ca..21470fd2 100644 --- a/CefSharp.Wpf.HwndHost/CefSharp.Wpf.HwndHost/ChromiumWebBrowser.cs +++ b/CefSharp.Wpf.HwndHost/CefSharp.Wpf.HwndHost/ChromiumWebBrowser.cs @@ -31,6 +31,8 @@ public class ChromiumWebBrowser : System.Windows.Interop.HwndHost, IWebBrowserIn "The ChromiumWebBrowser instance creates the underlying Chromium Embedded Framework (CEF) browser instance in an async fashion. " + "The undelying CefBrowser instance is not yet initialized. Use the IsBrowserInitializedChanged event and check " + "the IsBrowserInitialized property to determine when the browser has been initialized."; + private const string CefInitializeFailedErrorMessage = "Cef.Initialize() failed.Check the log file see https://github.com/cefsharp/CefSharp/wiki/Trouble-Shooting#log-file for details."; + private const string CefIsInitializedFalseErrorMessage = "Cef.IsInitialized was false!.Check the log file for errors!. See https://github.com/cefsharp/CefSharp/wiki/Trouble-Shooting#log-file for details."; [DllImport("user32.dll", EntryPoint = "CreateWindowEx", CharSet = CharSet.Unicode)] private static extern IntPtr CreateWindowEx(int dwExStyle, @@ -629,16 +631,7 @@ public ChromiumWebBrowser(string initialAddress) [MethodImpl(MethodImplOptions.NoInlining)] private void NoInliningConstructor() { - //Initialize CEF if it hasn't already been initialized - if (!Cef.IsInitialized) - { - var settings = new CefSettings(); - - if (!Cef.Initialize(settings)) - { - throw new InvalidOperationException("Cef::Initialize() failed"); - } - } + InitializeCefInternal(); //Add this ChromiumWebBrowser instance to a list of IDisposable objects // that if still alive at the time Cef.Shutdown is called will be disposed of @@ -1716,6 +1709,22 @@ public IBrowser GetBrowser() return browser; } + private static void InitializeCefInternal() + { + if (Cef.IsInitialized == null) + { + if (!Cef.Initialize(new CefSettings())) + { + throw new InvalidOperationException(CefInitializeFailedErrorMessage); + } + } + + if (Cef.IsInitialized == false) + { + throw new InvalidOperationException(CefIsInitializedFalseErrorMessage); + } + } + /// /// Check is browserisinitialized /// diff --git a/CefSharp.Wpf.HwndHost/appveyor.yml b/CefSharp.Wpf.HwndHost/appveyor.yml index 53017097..d553b9e5 100644 --- a/CefSharp.Wpf.HwndHost/appveyor.yml +++ b/CefSharp.Wpf.HwndHost/appveyor.yml @@ -1,6 +1,6 @@ image: Visual Studio 2019 -version: 126.2.70-CI{build} +version: 127.3.50-CI{build} clone_depth: 10