From 00118ddcdbdd6f7a5ed6e131417e6fb222bb33b0 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Thu, 9 May 2024 12:18:57 -0400 Subject: [PATCH] cefsimple: Enable Chrome runtime by default (see #3685) Run with `--disable-chrome-runtime` to use the Alloy runtime. --- tests/cefsimple/cefsimple_linux.cc | 12 +++++------- tests/cefsimple/cefsimple_mac.mm | 13 ++++++------- tests/cefsimple/cefsimple_win.cc | 12 +++++------- tests/cefsimple/simple_app.cc | 25 ++++++++++++++++++++----- 4 files changed, 36 insertions(+), 26 deletions(-) diff --git a/tests/cefsimple/cefsimple_linux.cc b/tests/cefsimple/cefsimple_linux.cc index dd4622d03..7df0492ac 100644 --- a/tests/cefsimple/cefsimple_linux.cc +++ b/tests/cefsimple/cefsimple_linux.cc @@ -59,13 +59,11 @@ int main(int argc, char* argv[]) { CefSettings settings; #if !defined(DISABLE_ALLOY_BOOTSTRAP) - // Use the CEF Chrome runtime if "--enable-chrome-runtime" is specified via - // the command-line. Otherwise, use the CEF Alloy runtime. For more - // information about CEF runtimes see - // https://bitbucket.org/chromiumembedded/cef/wiki/Architecture.md#markdown-header-cef3 - if (command_line->HasSwitch("enable-chrome-runtime")) { - settings.chrome_runtime = true; - } + // Use the CEF Chrome bootstrap unless "--disable-chrome-runtime" is specified + // via the command-line. Otherwise, use the CEF Alloy bootstrap. The Alloy + // bootstrap is deprecated and will be removed in ~M127. See + // https://github.com/chromiumembedded/cef/issues/3685 + settings.chrome_runtime = !command_line->HasSwitch("disable-chrome-runtime"); #endif // When generating projects with CMake the CEF_USE_SANDBOX value will be defined diff --git a/tests/cefsimple/cefsimple_mac.mm b/tests/cefsimple/cefsimple_mac.mm index 0156968ce..401e30b9c 100644 --- a/tests/cefsimple/cefsimple_mac.mm +++ b/tests/cefsimple/cefsimple_mac.mm @@ -151,13 +151,12 @@ int main(int argc, char* argv[]) { CefSettings settings; #if !defined(DISABLE_ALLOY_BOOTSTRAP) - // Use the CEF Chrome runtime if "--enable-chrome-runtime" is specified via - // the command-line. Otherwise, use the CEF Alloy runtime. For more - // information about CEF runtimes see - // https://bitbucket.org/chromiumembedded/cef/wiki/Architecture.md#markdown-header-cef3 - if (command_line->HasSwitch("enable-chrome-runtime")) { - settings.chrome_runtime = true; - } + // Use the CEF Chrome bootstrap unless "--disable-chrome-runtime" is + // specified via the command-line. Otherwise, use the CEF Alloy bootstrap. + // The Alloy bootstrap is deprecated and will be removed in ~M127. See + // https://github.com/chromiumembedded/cef/issues/3685 + settings.chrome_runtime = + !command_line->HasSwitch("disable-chrome-runtime"); #endif // When generating projects with CMake the CEF_USE_SANDBOX value will be diff --git a/tests/cefsimple/cefsimple_win.cc b/tests/cefsimple/cefsimple_win.cc index 857186289..d1adaed17 100644 --- a/tests/cefsimple/cefsimple_win.cc +++ b/tests/cefsimple/cefsimple_win.cc @@ -75,13 +75,11 @@ int APIENTRY wWinMain(HINSTANCE hInstance, CefSettings settings; #if !defined(DISABLE_ALLOY_BOOTSTRAP) - // Use the CEF Chrome runtime if "--enable-chrome-runtime" is specified via - // the command-line. Otherwise, use the CEF Alloy runtime. For more - // information about CEF runtimes see - // https://bitbucket.org/chromiumembedded/cef/wiki/Architecture.md#markdown-header-cef3 - if (command_line->HasSwitch("enable-chrome-runtime")) { - settings.chrome_runtime = true; - } + // Use the CEF Chrome bootstrap unless "--disable-chrome-runtime" is specified + // via the command-line. Otherwise, use the CEF Alloy bootstrap. The Alloy + // bootstrap is deprecated and will be removed in ~M127. See + // https://github.com/chromiumembedded/cef/issues/3685 + settings.chrome_runtime = !command_line->HasSwitch("disable-chrome-runtime"); #endif #if !defined(CEF_USE_SANDBOX) diff --git a/tests/cefsimple/simple_app.cc b/tests/cefsimple/simple_app.cc index ede209ae8..ab24337b0 100644 --- a/tests/cefsimple/simple_app.cc +++ b/tests/cefsimple/simple_app.cc @@ -113,12 +113,17 @@ void SimpleApp::OnContextInitialized() { CefRefPtr command_line = CefCommandLine::GetGlobalCommandLine(); +#if !defined(DISABLE_ALLOY_BOOTSTRAP) + const bool enable_chrome_runtime = + !command_line->HasSwitch("disable-chrome-runtime"); +#endif + // Check if Alloy style will be used. Alloy style is always used with the // Alloy runtime bootstrap and optional with the Chrome runtime bootstrap. bool use_alloy_style = true; cef_runtime_style_t runtime_style = CEF_RUNTIME_STYLE_DEFAULT; #if !defined(DISABLE_ALLOY_BOOTSTRAP) - if (command_line->HasSwitch("enable-chrome-runtime")) + if (enable_chrome_runtime) #endif { use_alloy_style = command_line->HasSwitch("use-alloy-style"); @@ -142,10 +147,20 @@ void SimpleApp::OnContextInitialized() { url = "http://www.google.com"; } - // Create the browser using the Views framework if "--use-views" is specified - // via the command-line. Otherwise, create the browser using the native - // platform framework. - if (command_line->HasSwitch("use-views")) { + // Views is enabled by default with the Chrome bootstrap (add `--use-native` + // to disable). Views is disabled by default with the Alloy bootstrap (add + // `--use-views` to enable). +#if !defined(DISABLE_ALLOY_BOOTSTRAP) + const bool use_views = + (enable_chrome_runtime && !command_line->HasSwitch("use-native")) || + (!enable_chrome_runtime && command_line->HasSwitch("use-views")); +#else + const bool use_views = !command_line->HasSwitch("use-native"); +#endif + + // If using Views create the browser using the Views framework, otherwise + // create the browser using the native platform framework. + if (use_views) { // Create the BrowserView. CefRefPtr browser_view = CefBrowserView::CreateBrowserView( handler, url, browser_settings, nullptr, nullptr,