Skip to content

Commit

Permalink
Add IWindowInfo.RuntimeStyle
Browse files Browse the repository at this point in the history
- CEF will remove the alloy bootstrap (likely in M127)
- Change examples to use the `Chrome Runtime`
-

Issue chromiumembedded/cef#3685
  • Loading branch information
amaitland committed May 6, 2024
1 parent 0ab5d1a commit 7af16b9
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 4 deletions.
12 changes: 12 additions & 0 deletions CefSharp.Core.Runtime/WindowInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,18 @@ namespace CefSharp
}
}

virtual property CefRuntimeStyle RuntimeStyle
{
CefRuntimeStyle get()
{
return (CefRuntimeStyle)_windowInfo->runtime_style;
}
void set(CefRuntimeStyle style)
{
_windowInfo->runtime_style = (cef_runtime_style_t)style;
}
}

virtual void SetAsChild(IntPtr parentHandle)
{
CefWindowInfo window;
Expand Down
7 changes: 3 additions & 4 deletions CefSharp.Core/CefSettingsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,9 @@ public CommandLineArgDictionary CefCommandLineArgs
}

/// <summary>
/// **Experimental**
/// Set to true to enable use of the Chrome runtime in CEF. This feature is
/// considered experimental and is not recommended for most users at this time.
/// See issue https://github.com/chromiumembedded/cef/issues/2969
/// Set to true to enable use of the Chrome runtime in CEF. This will
/// be removed in version 127 (as the Chrome Bootstrap will used in all cases).
/// See issue https://github.com/chromiumembedded/cef/issues/3685
/// </summary>
public bool ChromeRuntime
{
Expand Down
8 changes: 8 additions & 0 deletions CefSharp.Core/WindowInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
//NOTE:Classes in the CefSharp.Core namespace have been hidden from intellisnse so users don't use them directly

using System;
using CefSharp.Enums;
using CefSharp.Structs;

namespace CefSharp
Expand Down Expand Up @@ -98,6 +99,13 @@ public string WindowName
set { windowInfo.WindowName = value; }
}

/// <inheritdoc/>
public CefRuntimeStyle RuntimeStyle
{
get { return windowInfo.RuntimeStyle; }
set { windowInfo.RuntimeStyle = value; }
}

/// <inheritdoc/>
public void Dispose()
{
Expand Down
1 change: 1 addition & 0 deletions CefSharp.OffScreen.Example/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public static int Main(string[] args)
Cef.EnableWaitForBrowsersToClose();

var settings = new CefSettings();
settings.ChromeRuntime = true;
//The location where cache data will be stored on disk. If empty an in-memory cache will be used for some features and a temporary disk cache for others.
//HTML5 databases such as localStorage will only persist across sessions if a cache path is specified.
settings.CachePath = Path.GetFullPath("cache");
Expand Down
1 change: 1 addition & 0 deletions CefSharp.Test/CefSharpFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ private void CefInitialize()
//HTML5 databases such as localStorage will only persist across sessions if a cache path is specified.
settings.CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Tests\\Cache");
settings.RootCachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Tests");
settings.ChromeRuntime = true;
//settings.CefCommandLineArgs.Add("renderer-startup-dialog");
//settings.CefCommandLineArgs.Add("disable-site-isolation-trials");

Expand Down
2 changes: 2 additions & 0 deletions CefSharp.WinForms.Example/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public static int Main(string[] args)

var settings = new CefSettings();
settings.BrowserSubprocessPath = System.IO.Path.GetFullPath("CefSharp.WinForms.Example.exe");
settings.ChromeRuntime = true;

Cef.Initialize(settings);

Expand Down Expand Up @@ -95,6 +96,7 @@ public static int Main(string[] args)
var settings = new CefSettings();
settings.MultiThreadedMessageLoop = multiThreadedMessageLoop;
settings.ExternalMessagePump = externalMessagePump;
settings.ChromeRuntime = true;

CefExample.Init(settings, browserProcessHandler: browserProcessHandler);

Expand Down
1 change: 1 addition & 0 deletions CefSharp.WinForms/ChromiumWebBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ private void OnHandleDestroyedInternal()
protected virtual IWindowInfo CreateBrowserWindowInfo(IntPtr handle)
{
var windowInfo = Core.ObjectFactory.CreateWindowInfo();
windowInfo.RuntimeStyle = CefRuntimeStyle.Alloy;
windowInfo.SetAsChild(handle);

if (!ActivateBrowserOnCreation)
Expand Down
1 change: 1 addition & 0 deletions CefSharp.Wpf.Example/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ protected override void OnStartup(StartupEventArgs e)
var settings = new CefSettings();
settings.MultiThreadedMessageLoop = multiThreadedMessageLoop;
settings.ExternalMessagePump = !multiThreadedMessageLoop;
settings.ChromeRuntime = true;

CefExample.Init(settings, browserProcessHandler: browserProcessHandler);

Expand Down
49 changes: 49 additions & 0 deletions CefSharp/Enums/CefRuntimeStyle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
namespace CefSharp
{
/// <summary>
/// CEF supports both a Chrome runtime (based on the Chrome UI layer) and an
/// Alloy runtime (based on the Chromium content layer). The Chrome runtime
/// provides the full Chrome UI and browser functionality whereas the Alloy
/// runtime provides less default browser functionality but adds additional
/// client callbacks and support for windowless (off-screen) rendering. For
/// additional comparative details on runtime types see
/// https://bitbucket.org/chromiumembedded/cef/wiki/Architecture.md#markdown-header-cef3
///
/// Each runtime is composed of a bootstrap component and a style component. The
/// bootstrap component is configured via CefSettings.ChromeRuntime and cannot
/// be changed after CefInitialize. The style component is individually
/// configured for each window/browser at creation time and, in combination with
/// the Chrome bootstrap, different styles can be mixed during runtime.
///
/// Windowless rendering will always use Alloy style. Windowed rendering with a
/// default window or client-provided parent window can configure the style via
/// CefWindowInfo.runtime_style. Windowed rendering with the Views framework can
/// configure the style via CefWindowDelegate::GetWindowRuntimeStyle and
/// CefBrowserViewDelegate::GetBrowserRuntimeStyle. Alloy style Windows with the
/// Views framework can host only Alloy style BrowserViews but Chrome style
/// Windows can host both style BrowserViews. Additionally, a Chrome style
/// Window can host at most one Chrome style BrowserView but potentially
/// multiple Alloy style BrowserViews. See CefWindowInfo.runtime_style
/// documentation for any additional platform-specific limitations.
/// </summary>
public enum CefRuntimeStyle
{
/// <summary>
/// Use the default runtime style. The default style will match the
/// CefSettings.ChromeRuntime value in most cases. See above documentation
/// for exceptions.
/// </summary>
Default,

/// <summary>
/// Use the Chrome runtime style. Only supported with the Chrome runtime.
/// </summary>
Chrome,

/// <summary>
/// Use the Alloy runtime style. Supported with both the Alloy and Chrome
/// runtime.
/// </summary>
Alloy,
}
}
8 changes: 8 additions & 0 deletions CefSharp/IWindowInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

using System;
using CefSharp.Enums;
using CefSharp.Structs;

namespace CefSharp
Expand Down Expand Up @@ -70,6 +71,13 @@ public interface IWindowInfo : IDisposable
/// </summary>
string WindowName { get; set; }

/// <summary>
/// Optionally change the runtime style. Alloy style will always be used if
/// <see cref="WindowlessRenderingEnabled"> is true. See <see cref="CefRuntimeStyle"/>
/// documentation for details.
/// </summary>
CefRuntimeStyle RuntimeStyle { get; set; }

/// <summary>
/// Create the browser as a child window.
/// Calls GetClientRect(Hwnd) to obtain the window bounds
Expand Down

0 comments on commit 7af16b9

Please sign in to comment.