From 48137b9538c418cbfdfd988e7eb0e1acfb0f0fe8 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Mon, 20 May 2024 17:19:00 -0400 Subject: [PATCH] cefclient: Use default window for DevTools non-Views popup (see #3681) Chrome runtime only supports creation of a Views-hosted DevTools popup in ChromeBrowserDelegate::CreateDevToolsBrowser if the parent is also Views-hosted. To test: - Run `cefclient --use-native` - Right click, select "Show DevTools" - Close both windows and the app should exit --- .../cefclient/browser/root_window_manager.cc | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/tests/cefclient/browser/root_window_manager.cc b/tests/cefclient/browser/root_window_manager.cc index 8771d9a77..b8080d125 100644 --- a/tests/cefclient/browser/root_window_manager.cc +++ b/tests/cefclient/browser/root_window_manager.cc @@ -58,9 +58,13 @@ class ClientRequestContextHandler : public CefRequestContextHandler { // Ensure a compatible set of window creation attributes. void SanityCheckWindowConfig(const bool is_devtools, - bool& use_views, + const bool use_views, bool& use_alloy_style, bool& with_osr) { + // This configuration is not supported by cefclient architecture and + // should use default window creation instead. + CHECK(!(is_devtools && !use_views)); + #if !defined(DISABLE_ALLOY_BOOTSTRAP) if (MainContext::Get()->UseChromeBootstrap()) #endif @@ -71,13 +75,6 @@ void SanityCheckWindowConfig(const bool is_devtools, " using Chrome style."; use_alloy_style = false; } - - if (is_devtools && !use_views) { - LOG(WARNING) - << "Native parent is not supported with Chrome runtime DevTools;" - " using Views."; - use_views = true; - } } if (!use_alloy_style && with_osr) { @@ -141,15 +138,15 @@ scoped_refptr RootWindowManager::CreateRootWindowAsPopup( CefBrowserSettings& settings) { CEF_REQUIRE_UI_THREAD(); - SanityCheckWindowConfig(is_devtools, use_views, use_alloy_style, with_osr); - - if (MainContext::Get()->UseDefaultPopup()) { + if (MainContext::Get()->UseDefaultPopup() || (is_devtools && !use_views)) { // Use default window creation for the popup. A new |client| instance is // still required by cefclient architecture. client = new DefaultClientHandler(); return nullptr; } + SanityCheckWindowConfig(is_devtools, use_views, use_alloy_style, with_osr); + if (!temp_window_) { // TempWindow must be created on the UI thread. temp_window_.reset(new TempWindow());