Skip to content

Commit 0a04732

Browse files
committed
Fix Developer Tools
1 parent 87cc741 commit 0a04732

File tree

3 files changed

+37
-10
lines changed

3 files changed

+37
-10
lines changed

cef/browser_window.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ BrowserWindow::BrowserWindow(HWND inWindowHandle, bool isPopup)
104104
SetIconFromSettings();
105105

106106
if (IsPopup()) {
107-
LOGGER_DEBUG << "BrowserWindow::BrowserWindow() created for Popup";
107+
LOGGER_DEBUG << "Create browser window for popup, hwnd=" << (uintptr_t) inWindowHandle;
108108
} else {
109109
if (!CreateBrowserControl(Utf8ToWide(GetWebServerUrl()).c_str())) {
110110
FatalError(windowHandle_, "Could not create Browser control.\n"

cef/client_handler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ bool ClientHandler::OnBeforePopup(CefRefPtr<CefBrowser> browser,
213213
CefBrowserSettings& settings,
214214
CefRefPtr<CefDictionaryValue>& extra_info,
215215
bool* no_javascript_access) {
216-
LOGGER_DEBUG << "ClientHandler::OnBeforePopup()";
216+
LOGGER_DEBUG << "Before popup is created";
217217
// OnBeforePopup does not get called for the DevTools popup window.
218218
// The devtools window is created using CreatePopupWindow
219219
// ----

cef/devtools.cpp

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,44 @@
88
#include "../logger.h"
99
#include "../string_utils.h"
1010
#include "../popup_window.h"
11+
#include "../settings.h"
1112

12-
bool ShowDevTools(CefRefPtr<CefBrowser> browser) {
13-
CefWindowInfo windowInfo;
14-
CefBrowserSettings settings;
13+
bool ShowDevTools(CefRefPtr<CefBrowser> browser)
14+
{
15+
LOGGER_DEBUG << "Show DevTools";
16+
17+
json_value* settings = GetApplicationSettings();
18+
std::string runtime_style = (*settings)["chrome"]["runtime_style"];
19+
20+
CefWindowInfo window_info;
21+
CefBrowserSettings browser_settings;
22+
23+
if (runtime_style == "alloy") {
24+
LOGGER_INFO << "Runtime style: alloy";
25+
window_info.runtime_style = CEF_RUNTIME_STYLE_ALLOY;
26+
} else if (runtime_style == "chrome") {
27+
LOGGER_INFO << "Runtime style: chrome";
28+
window_info.runtime_style = CEF_RUNTIME_STYLE_CHROME;
29+
} else {
30+
LOGGER_INFO << "Invalid runtime style in settings.json: " << runtime_style;
31+
window_info.runtime_style = CEF_RUNTIME_STYLE_ALLOY;
32+
}
1533

16-
#if defined(OS_WIN)
17-
windowInfo.SetAsPopup(browser->GetHost()->GetWindowHandle(), "DevTools");
18-
#endif
34+
HWND popup_handle = CreatePopupWindow(browser->GetHost()->GetWindowHandle());
35+
if (!popup_handle) {
36+
LOGGER_ERROR << "Failed to create popup window";
37+
return false;
38+
}
39+
window_info.SetAsPopup(popup_handle, "DevTools");
40+
41+
browser->GetHost()->ShowDevTools(window_info, nullptr,
42+
browser_settings, CefPoint());
43+
44+
BrowserWindow* browser_window = GetBrowserWindow(popup_handle);
45+
if (browser_window) {
46+
browser_window->SetTitle(L"DevTools");
47+
}
1948

20-
browser->GetHost()->ShowDevTools(windowInfo, browser->GetHost()->GetClient(),
21-
settings, CefPoint());
2249
return true;
2350
}
2451

0 commit comments

Comments
 (0)