diff --git a/libcef/browser/chrome/extensions/chrome_extension_util.cc b/libcef/browser/chrome/extensions/chrome_extension_util.cc index 3bee3ad00..48620e3cb 100644 --- a/libcef/browser/chrome/extensions/chrome_extension_util.cc +++ b/libcef/browser/chrome/extensions/chrome_extension_util.cc @@ -64,4 +64,12 @@ bool GetAlloyTabById(int tab_id, return false; } +bool IsAlloyContents(content::WebContents* contents, bool primary_only) { + auto browser = CefBrowserHostBase::GetBrowserForContents(contents); + if (browser && browser->IsAlloyStyle()) { + return !primary_only || browser->GetWebContents() == contents; + } + return false; +} + } // namespace cef diff --git a/libcef/browser/chrome/extensions/chrome_extension_util.h b/libcef/browser/chrome/extensions/chrome_extension_util.h index 2f6873190..74a22cd5f 100644 --- a/libcef/browser/chrome/extensions/chrome_extension_util.h +++ b/libcef/browser/chrome/extensions/chrome_extension_util.h @@ -21,6 +21,10 @@ bool GetAlloyTabById(int tab_id, bool include_incognito, content::WebContents** contents); +// Returns true if |contents| is owned by an Alloy style CefBrowserHost. +// If |primary_only| is false then guest contents will also be matched. +bool IsAlloyContents(content::WebContents* contents, bool primary_only); + } // namespace cef #endif // CEF_LIBCEF_BROWSER_CHROME_EXTENSIONS_CHROME_EXTENSION_UTIL_H_ diff --git a/patch/patch.cfg b/patch/patch.cfg index 89d2a5845..e15826db3 100644 --- a/patch/patch.cfg +++ b/patch/patch.cfg @@ -257,6 +257,11 @@ patches = [ # https://github.com/chromiumembedded/cef/issues/2969 'name': 'chrome_browser_context_menus', }, + { + # Support DevTools windows with Chrome runtime Alloy style OSR. + # https://github.com/chromiumembedded/cef/issues/3681 + 'name': 'chrome_browser_devtools_osr', + }, { # Support use of chrome native dialogs with CEF runtimes. # - Adds support for FileSelectHelper and SelectFileDialog interception. diff --git a/patch/patches/chrome_browser_devtools_osr.patch b/patch/patches/chrome_browser_devtools_osr.patch new file mode 100644 index 000000000..9f1760902 --- /dev/null +++ b/patch/patches/chrome_browser_devtools_osr.patch @@ -0,0 +1,36 @@ +diff --git chrome/browser/devtools/chrome_devtools_manager_delegate.cc chrome/browser/devtools/chrome_devtools_manager_delegate.cc +index 19c2d39b6aa73..099dcb71a6373 100644 +--- chrome/browser/devtools/chrome_devtools_manager_delegate.cc ++++ chrome/browser/devtools/chrome_devtools_manager_delegate.cc +@@ -13,6 +13,7 @@ + #include "base/strings/utf_string_conversions.h" + #include "build/build_config.h" + #include "build/chromeos_buildflags.h" ++#include "cef/libcef/features/features.h" + #include "chrome/browser/browser_features.h" + #include "chrome/browser/devtools/chrome_devtools_session.h" + #include "chrome/browser/devtools/device/android_device_manager.h" +@@ -66,6 +67,10 @@ + #include "ash/constants/ash_switches.h" + #endif + ++#if BUILDFLAG(ENABLE_CEF) ++#include "cef/libcef/browser/chrome/extensions/chrome_extension_util.h" ++#endif ++ + using content::DevToolsAgentHost; + + const char ChromeDevToolsManagerDelegate::kTypeApp[] = "app"; +@@ -246,6 +251,12 @@ std::string ChromeDevToolsManagerDelegate::GetTargetType( + return DevToolsAgentHost::kTypePage; + } + ++#if BUILDFLAG(ENABLE_CEF) ++ if (cef::IsAlloyContents(web_contents, /*primary_only=*/true)) { ++ return DevToolsAgentHost::kTypePage; ++ } ++#endif ++ + return DevToolsAgentHost::kTypeOther; + } +