Skip to content

Commit 7fa3822

Browse files
WizardCMRytoEX
authored andcommitted
REALLY don't allow browser docks to arbitrarily close OBS
The previous solution only worked for code that ran *after* the page had *finished* loading.
1 parent e873fb0 commit 7fa3822

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

panel/browser-panel-client.cpp

+13-6
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,19 @@ bool QCefBrowserClient::OnContextMenuCommand(
395395
return false;
396396
}
397397

398+
void QCefBrowserClient::OnLoadStart(CefRefPtr<CefBrowser>,
399+
CefRefPtr<CefFrame> frame, TransitionType)
400+
{
401+
if (!frame->IsMain())
402+
return;
403+
404+
std::string script = "window.close = () => ";
405+
script += "console.log(";
406+
script += "'OBS browser docks cannot be closed using JavaScript.'";
407+
script += ");";
408+
frame->ExecuteJavaScript(script, "", 0);
409+
}
410+
398411
void QCefBrowserClient::OnLoadEnd(CefRefPtr<CefBrowser>,
399412
CefRefPtr<CefFrame> frame, int)
400413
{
@@ -405,12 +418,6 @@ void QCefBrowserClient::OnLoadEnd(CefRefPtr<CefBrowser>,
405418
frame->ExecuteJavaScript(widget->script, CefString(), 0);
406419
else if (!script.empty())
407420
frame->ExecuteJavaScript(script, CefString(), 0);
408-
409-
std::string script2 = "window.close = () => ";
410-
script2 += "console.log(";
411-
script2 += "'OBS browser docks cannot be closed using JavaScript.'";
412-
script2 += ");";
413-
frame->ExecuteJavaScript(script2, "", 0);
414421
}
415422

416423
bool QCefBrowserClient::OnJSDialog(CefRefPtr<CefBrowser>, const CefString &,

panel/browser-panel-client.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ class QCefBrowserClient : public CefClient,
9595
CefContextMenuHandler::EventFlags event_flags) override;
9696

9797
/* CefLoadHandler */
98+
virtual void OnLoadStart(CefRefPtr<CefBrowser> browser,
99+
CefRefPtr<CefFrame> frame,
100+
TransitionType transition_type) override;
101+
98102
virtual void OnLoadEnd(CefRefPtr<CefBrowser> browser,
99103
CefRefPtr<CefFrame> frame,
100104
int httpStatusCode) override;

0 commit comments

Comments
 (0)