Skip to content

Commit

Permalink
Merge pull request #221 from ThinBridge/fix-devtools
Browse files Browse the repository at this point in the history
[CEF125+] Fix DevTools to popup
  • Loading branch information
HashidaTKS authored Jul 10, 2024
2 parents 53ad551 + a93becb commit 245e840
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions BroView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1561,9 +1561,17 @@ void CChildView::ShowDevTools()
CefBrowserSettings settings;
CefRefPtr<CefClient> client;
CefPoint inspect_element_at;
// We use Chrome bootstrap + Alloy runtime style since CEF125.
// On that case, we should specify DevTools behaviour at
// ClientHandler::OnBeforeDevToolsPopup
// https://github.com/chromiumembedded/cef/issues/3685
// https://cef-builds.spotifycdn.com/docs/120.1/classCefLifeSpanHandler.html#a42d853d18238d79d2b17d04277bd636a
// https://magpcss.org/ceforum/viewtopic.php?f=6&t=19792&p=55334&hilit=Devtools+SetAsPopup#p55334
#if CHROME_VERSION_MAJOR < 125
// Show DevTools window as popup
// See https://www.magpcss.org/ceforum/viewtopic.php?f=6&t=17820
windowInfo.SetAsPopup(theApp.SafeWnd(this->m_hWnd), "ChronosDevTools");
#endif
m_cefBrowser->GetHost()->ShowDevTools(windowInfo, client, settings, inspect_element_at);
}
}
Expand Down
11 changes: 11 additions & 0 deletions client_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,17 @@ bool ClientHandler::OnBeforePopup(CefRefPtr<CefBrowser> browser,
return CefLifeSpanHandler::OnBeforePopup(browser, frame, target_url, target_frame_name, target_disposition, user_gesture, popupFeatures, windowInfo, client, settings, extra_info, no_javascript_access);
}

#if CHROME_VERSION_MAJOR > 125
void ClientHandler::OnBeforeDevToolsPopup(CefRefPtr<CefBrowser> browser,
CefWindowInfo& windowInfo,
CefRefPtr<CefClient>& client,
CefBrowserSettings& settings,
CefRefPtr<CefDictionaryValue>& extra_info,
bool* use_default_window)
{
}
#endif

void ClientHandler::OnBeforeContextMenu(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefContextMenuParams> params,
Expand Down
3 changes: 3 additions & 0 deletions client_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ class ClientHandler : public CefClient,
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) override;
virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) override;
virtual bool OnBeforePopup(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, const CefString& target_url, const CefString& target_frame_name, WindowOpenDisposition target_disposition, bool user_gesture, const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo, CefRefPtr<CefClient>& client, CefBrowserSettings& settings, CefRefPtr<CefDictionaryValue>& extra_info, bool* no_javascript_access) override;
#if CHROME_VERSION_MAJOR > 125
virtual void OnBeforeDevToolsPopup(CefRefPtr<CefBrowser> browser, CefWindowInfo& windowInfo, CefRefPtr<CefClient>& client, CefBrowserSettings& settings, CefRefPtr<CefDictionaryValue>& extra_info, bool* use_default_window);
#endif

// CefContextMenuHandler methods
virtual void OnBeforeContextMenu(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefContextMenuParams> params, CefRefPtr<CefMenuModel> model) override;
Expand Down

0 comments on commit 245e840

Please sign in to comment.