Skip to content

Commit

Permalink
osr: Support DevTools windows with Chrome runtime Alloy style (see #3681
Browse files Browse the repository at this point in the history
)
  • Loading branch information
magreenblatt committed May 20, 2024
1 parent 6da73a3 commit 99c85e3
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
8 changes: 8 additions & 0 deletions libcef/browser/chrome/extensions/chrome_extension_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions libcef/browser/chrome/extensions/chrome_extension_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_
5 changes: 5 additions & 0 deletions patch/patch.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
36 changes: 36 additions & 0 deletions patch/patches/chrome_browser_devtools_osr.patch
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 99c85e3

Please sign in to comment.