Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 52293be

Browse files
committed
[[ Bug 21085 ]] Fix handling of unknown url scheme
The updated version of CEF we are now using appears to handle `ERR_UNKNOWN_URL_SCHEME` errors by calling `OnLoadError` immediately while previousluy it called `OnLoadStart`. This patch handles the error in `OnLoadError` to ensure `browserUnhandledLoadRequest` is sent to the widget.
1 parent de579a6 commit 52293be

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# [21085] Ensure browserUnhandledLoadRequest is sent for unknown protocols

libbrowser/src/libbrowser_cef.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,12 +1136,7 @@ class MCCefBrowserClient : public CefClient, CefLifeSpanHandler, CefRequestHandl
11361136
bool t_frame;
11371137
t_frame = !p_frame->IsMain();
11381138

1139-
if (t_is_error)
1140-
{
1141-
if (t_error_code == ERR_UNKNOWN_URL_SCHEME)
1142-
m_owner->OnNavigationRequestUnhandled(t_frame, t_url_str);
1143-
}
1144-
else
1139+
if (!t_is_error)
11451140
{
11461141
if (!t_frame)
11471142
m_owner->OnNavigationBegin(t_frame, t_url_str);
@@ -1209,10 +1204,23 @@ class MCCefBrowserClient : public CefClient, CefLifeSpanHandler, CefRequestHandl
12091204

12101205
virtual void OnLoadError(CefRefPtr<CefBrowser> p_browser, CefRefPtr<CefFrame> p_frame, CefLoadHandler::ErrorCode p_error_code, const CefString &p_error_text, const CefString &p_failed_url) OVERRIDE
12111206
{
1212-
// IM-2015-11-16: [[ Bug 16360 ]] Contrary to the CEF API docs, OnLoadEnd is NOT called after OnLoadError when the error code is ERR_ABORTED.
1213-
// This occurs when requesting a new url be loaded when in the middle of loading the previous url, or when the url load is otherwise cancelled.
1214-
if (p_error_code != ERR_ABORTED)
1207+
if (p_error_code == ERR_UNKNOWN_URL_SCHEME)
1208+
{
1209+
bool t_frame;
1210+
t_frame = !p_frame->IsMain();
1211+
1212+
char *t_url_str = nullptr;
1213+
if (MCCefStringToUtf8String(p_failed_url, t_url_str))
1214+
{
1215+
m_owner->OnNavigationRequestUnhandled(t_frame, t_url_str);
1216+
}
1217+
}
1218+
else if (p_error_code != ERR_ABORTED)
1219+
{
1220+
// IM-2015-11-16: [[ Bug 16360 ]] Contrary to the CEF API docs, OnLoadEnd is NOT called after OnLoadError when the error code is ERR_ABORTED.
1221+
// This occurs when requesting a new url be loaded when in the middle of loading the previous url, or when the url load is otherwise cancelled.
12151222
AddLoadErrorFrame(p_frame->GetIdentifier(), p_failed_url, p_error_text, p_error_code);
1223+
}
12161224
}
12171225

12181226
// ContextMenuHandler interface

0 commit comments

Comments
 (0)