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
This commit is contained in:
Marshall Greenblatt 2024-05-20 17:19:00 -04:00
parent 99c85e32ac
commit 3ccd305f6d
1 changed files with 8 additions and 11 deletions

View File

@ -115,9 +115,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 (MainContext::Get()->UseChromeBootstrap()) {
if (is_devtools && use_alloy_style) {
LOG(WARNING)
@ -125,13 +129,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) {
@ -195,15 +192,15 @@ scoped_refptr<RootWindow> 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());