mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add new CefBrowserHost::[Can]ExecuteChromeCommand methods for executing arbitrary Chrome commands. Add support for existing CefBrowserHost::ShowDevTools, CloseDevTools and HasDevTools methods. DevTools windows now support the same Views callbacks as normal popup windows with the new CefLifeSpanHandler::OnBeforeDevToolsPopup callback as the DevTools-specific equivalent of OnBeforePopup. Always create DevTools as an undocked window to support use of ShowDevTools with default Chrome browser windows. To test: Run `ceftests --enable-chrome-runtime [--use-views] --gtest_filter=V8Test.OnUncaughtExceptionDevTools` OR: 1. Run `cefclient --enable-chrome-runtime [--use-native]` 2. Select "Show DevTools", "Close DevTools" or "Inspect" from the right-click menu. 3. Notice that the DevTools window is Views-hosted (or native-hosted) and works as expected. Add --use-default-popup to get a default styled popup in step 3.
This commit is contained in:
@@ -12,6 +12,68 @@ index 2480282a19d12..dbd1fbf8a15b5 100644
|
||||
|
||||
return false;
|
||||
}
|
||||
diff --git chrome/browser/devtools/devtools_window.cc chrome/browser/devtools/devtools_window.cc
|
||||
index 4d99a769d6069..0ebd577182dc6 100644
|
||||
--- chrome/browser/devtools/devtools_window.cc
|
||||
+++ chrome/browser/devtools/devtools_window.cc
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/task_manager/web_contents_tags.h"
|
||||
#include "chrome/browser/ui/browser.h"
|
||||
+#include "chrome/browser/ui/browser_finder.h"
|
||||
#include "chrome/browser/ui/browser_list.h"
|
||||
#include "chrome/browser/ui/browser_tabstrip.h"
|
||||
#include "chrome/browser/ui/browser_window.h"
|
||||
@@ -1162,6 +1163,13 @@ DevToolsWindow* DevToolsWindow::Create(
|
||||
!browser->is_type_normal()) {
|
||||
can_dock = false;
|
||||
}
|
||||
+
|
||||
+#if BUILDFLAG(ENABLE_CEF)
|
||||
+ if (can_dock && browser && browser->cef_delegate()) {
|
||||
+ // Don't dock DevTools for CEF-managed browsers.
|
||||
+ can_dock = false;
|
||||
+ }
|
||||
+#endif
|
||||
}
|
||||
|
||||
// Create WebContents with devtools.
|
||||
@@ -1738,12 +1746,29 @@ void DevToolsWindow::CreateDevToolsBrowser() {
|
||||
Browser::CreationStatus::kOk) {
|
||||
return;
|
||||
}
|
||||
- browser_ =
|
||||
- Browser::Create(Browser::CreateParams::CreateForDevTools(profile_));
|
||||
- browser_->tab_strip_model()->AddWebContents(
|
||||
- OwnedMainWebContents::TakeWebContents(
|
||||
- std::move(owned_main_web_contents_)),
|
||||
- -1, ui::PAGE_TRANSITION_AUTO_TOPLEVEL, AddTabTypes::ADD_ACTIVE);
|
||||
+
|
||||
+ auto opener = chrome::FindBrowserWithWebContents(GetInspectedWebContents());
|
||||
+ auto devtools_contents = OwnedMainWebContents::TakeWebContents(
|
||||
+ std::move(owned_main_web_contents_));
|
||||
+
|
||||
+#if BUILDFLAG(ENABLE_CEF)
|
||||
+ if (opener && opener->cef_delegate()) {
|
||||
+ // If a Browser is created, it will take ownership of |devtools_contents|.
|
||||
+ browser_ = opener->cef_delegate()->CreateDevToolsBrowser(
|
||||
+ profile_, opener, devtools_contents);
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
+ if (!browser_) {
|
||||
+ auto create_params = Browser::CreateParams::CreateForDevTools(profile_);
|
||||
+ create_params.opener = opener;
|
||||
+
|
||||
+ browser_ = Browser::Create(std::move(create_params));
|
||||
+ browser_->tab_strip_model()->AddWebContents(
|
||||
+ std::move(devtools_contents),
|
||||
+ -1, ui::PAGE_TRANSITION_AUTO_TOPLEVEL, AddTabTypes::ADD_ACTIVE);
|
||||
+ }
|
||||
+
|
||||
OverrideAndSyncDevToolsRendererPrefs();
|
||||
}
|
||||
|
||||
diff --git chrome/browser/ui/BUILD.gn chrome/browser/ui/BUILD.gn
|
||||
index eca90c39e0d44..2157b6d86ab02 100644
|
||||
--- chrome/browser/ui/BUILD.gn
|
||||
@@ -333,7 +395,7 @@ index 9ba2025634365..b6ceaa7f0b531 100644
|
||||
case TYPE_NORMAL:
|
||||
return NormalBrowserSupportsWindowFeature(feature, check_can_support);
|
||||
diff --git chrome/browser/ui/browser.h chrome/browser/ui/browser.h
|
||||
index db37e861d2546..c47dfc31131f7 100644
|
||||
index db37e861d2546..ea85b9966267d 100644
|
||||
--- chrome/browser/ui/browser.h
|
||||
+++ chrome/browser/ui/browser.h
|
||||
@@ -22,6 +22,7 @@
|
||||
@@ -364,7 +426,7 @@ index db37e861d2546..c47dfc31131f7 100644
|
||||
+ scoped_refptr<cef::BrowserDelegate::CreateParams> cef_params;
|
||||
+
|
||||
+ // Specify the Browser that is opening this popup.
|
||||
+ // Currently only used with TYPE_PICTURE_IN_PICTURE.
|
||||
+ // Currently only used with TYPE_PICTURE_IN_PICTURE and TYPE_DEVTOOLS.
|
||||
+ raw_ptr<Browser, DanglingUntriaged> opener = nullptr;
|
||||
+#endif
|
||||
+
|
||||
|
@@ -231,7 +231,7 @@ index 59024587ef6b7..0c30aa71768cf 100644
|
||||
|
||||
void FindBarHost::RegisterAccelerators() {
|
||||
diff --git chrome/browser/ui/views/frame/browser_frame.cc chrome/browser/ui/views/frame/browser_frame.cc
|
||||
index bb4b3821bcfda..9734fe4aaffcf 100644
|
||||
index bb4b3821bcfda..4014f61a7057f 100644
|
||||
--- chrome/browser/ui/views/frame/browser_frame.cc
|
||||
+++ chrome/browser/ui/views/frame/browser_frame.cc
|
||||
@@ -114,15 +114,23 @@ ui::ColorProviderKey::SchemeVariant GetSchemeVariant(
|
||||
@@ -260,7 +260,7 @@ index bb4b3821bcfda..9734fe4aaffcf 100644
|
||||
}
|
||||
|
||||
BrowserFrame::~BrowserFrame() {}
|
||||
@@ -228,6 +236,12 @@ void BrowserFrame::LayoutWebAppWindowTitle(
|
||||
@@ -228,10 +236,20 @@ void BrowserFrame::LayoutWebAppWindowTitle(
|
||||
}
|
||||
|
||||
int BrowserFrame::GetTopInset() const {
|
||||
@@ -273,7 +273,15 @@ index bb4b3821bcfda..9734fe4aaffcf 100644
|
||||
return browser_frame_view_->GetTopInset(false);
|
||||
}
|
||||
|
||||
@@ -240,6 +254,8 @@ BrowserNonClientFrameView* BrowserFrame::GetFrameView() const {
|
||||
void BrowserFrame::UpdateThrobber(bool running) {
|
||||
+ if (!browser_frame_view_) {
|
||||
+ // Not supported with CEF Views-hosted DevTools windows.
|
||||
+ return;
|
||||
+ }
|
||||
browser_frame_view_->UpdateThrobber(running);
|
||||
}
|
||||
|
||||
@@ -240,6 +258,8 @@ BrowserNonClientFrameView* BrowserFrame::GetFrameView() const {
|
||||
}
|
||||
|
||||
bool BrowserFrame::UseCustomFrame() const {
|
||||
@@ -282,7 +290,7 @@ index bb4b3821bcfda..9734fe4aaffcf 100644
|
||||
return native_browser_frame_->UseCustomFrame();
|
||||
}
|
||||
|
||||
@@ -253,20 +269,30 @@ bool BrowserFrame::ShouldDrawFrameHeader() const {
|
||||
@@ -253,20 +273,30 @@ bool BrowserFrame::ShouldDrawFrameHeader() const {
|
||||
|
||||
void BrowserFrame::GetWindowPlacement(gfx::Rect* bounds,
|
||||
ui::WindowShowState* show_state) const {
|
||||
@@ -313,7 +321,7 @@ index bb4b3821bcfda..9734fe4aaffcf 100644
|
||||
browser_frame_view_->OnBrowserViewInitViewsComplete();
|
||||
}
|
||||
|
||||
@@ -367,6 +393,8 @@ ui::ColorProviderKey::ThemeInitializerSupplier* BrowserFrame::GetCustomTheme()
|
||||
@@ -367,6 +397,8 @@ ui::ColorProviderKey::ThemeInitializerSupplier* BrowserFrame::GetCustomTheme()
|
||||
}
|
||||
|
||||
void BrowserFrame::OnNativeWidgetWorkspaceChanged() {
|
||||
@@ -322,7 +330,7 @@ index bb4b3821bcfda..9734fe4aaffcf 100644
|
||||
chrome::SaveWindowWorkspace(browser_view_->browser(), GetWorkspace());
|
||||
chrome::SaveWindowVisibleOnAllWorkspaces(browser_view_->browser(),
|
||||
IsVisibleOnAllWorkspaces());
|
||||
@@ -478,6 +506,8 @@ void BrowserFrame::OnNativeThemeUpdated(ui::NativeTheme* observed_theme) {
|
||||
@@ -478,6 +510,8 @@ void BrowserFrame::OnNativeThemeUpdated(ui::NativeTheme* observed_theme) {
|
||||
|
||||
ui::ColorProviderKey BrowserFrame::GetColorProviderKey() const {
|
||||
auto key = Widget::GetColorProviderKey();
|
||||
@@ -331,7 +339,7 @@ index bb4b3821bcfda..9734fe4aaffcf 100644
|
||||
|
||||
key.app_controller = browser_view_->browser()->app_controller();
|
||||
|
||||
@@ -632,5 +662,8 @@ bool BrowserFrame::RegenerateFrameOnThemeChange(
|
||||
@@ -632,5 +666,8 @@ bool BrowserFrame::RegenerateFrameOnThemeChange(
|
||||
}
|
||||
|
||||
bool BrowserFrame::IsIncognitoBrowser() const {
|
||||
|
@@ -414,7 +414,7 @@ index 2f552f72074e3..3f057242d198c 100644
|
||||
}
|
||||
|
||||
diff --git ui/views/widget/widget.h ui/views/widget/widget.h
|
||||
index 419b75d0608b2..d772dc17d165c 100644
|
||||
index 419b75d0608b2..57bb1fca770ed 100644
|
||||
--- ui/views/widget/widget.h
|
||||
+++ ui/views/widget/widget.h
|
||||
@@ -351,6 +351,8 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate,
|
||||
@@ -426,6 +426,15 @@ index 419b75d0608b2..d772dc17d165c 100644
|
||||
// Specifies the initial bounds of the Widget. Default is empty, which means
|
||||
// the NativeWidget may specify a default size. If the parent is specified,
|
||||
// |bounds| is in the parent's coordinate system. If the parent is not
|
||||
@@ -742,7 +744,7 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate,
|
||||
void ShowInactive();
|
||||
|
||||
// Activates the widget, assuming it already exists and is visible.
|
||||
- void Activate();
|
||||
+ virtual void Activate();
|
||||
|
||||
// Deactivates the widget, making the next window in the Z order the active
|
||||
// window.
|
||||
diff --git ui/views/widget/widget_delegate.h ui/views/widget/widget_delegate.h
|
||||
index 6d87be86ae8b3..02fe7a11958d0 100644
|
||||
--- ui/views/widget/widget_delegate.h
|
||||
|
Reference in New Issue
Block a user