Commit ce013449 authored by Michael Catanzaro's avatar Michael Catanzaro
Browse files

window: launch URLs whenever triggered by user gesture

Currently we check the default app for the URI scheme and call
gtk_show_uri_on_window() only if the default app is not NULL and is not
Epiphany. This fails under flatpak because there we cannot check the
user's default apps. It is always NULL, so we bail out and refuse to
launch any app for the URL. Oops.

This code was originally added to prevent us from launching Epiphany in
a recursive loop if it somehow gets registered as the default handler
for a scheme that it doesn't actually support, as in #1053. In this
case, we should only relaunch ourselves once because the second launch
will be triggered by API request, when the new instance calls
webkit_web_view_load_uri(). That's not a user gesture and will avoid the

This change also prevents websites from opening URLs without user

Thanks to Adrian Perez for proposing this solution!

Fixes #1385

Part-of: <>

(cherry picked from commit 6c223bb8b3e75026eeecc61424e5a73649aca1f2)
parent ae8254ba
......@@ -2121,27 +2121,15 @@ decide_navigation_policy (WebKitWebView *web_view,
request = webkit_navigation_action_get_request (navigation_action);
uri = webkit_uri_request_get_uri (request);
if (!ephy_embed_utils_address_has_web_scheme (uri)) {
g_autoptr (SoupURI) soup_uri = soup_uri_new (uri);
if (soup_uri) {
g_autoptr (GAppInfo) app_info = g_app_info_get_default_for_uri_scheme (soup_uri->scheme);
if (app_info && !g_str_has_prefix (g_app_info_get_id (app_info), "org.gnome.Epiphany")) {
if (!ephy_embed_utils_address_has_web_scheme (uri) && webkit_navigation_action_is_user_gesture (navigation_action)) {
g_autoptr (GError) error = NULL;
gtk_show_uri_on_window (GTK_WINDOW (window), uri, GDK_CURRENT_TIME, &error);
if (error) {
LOG ("failed to handle non web scheme: %s", error->message);
g_error_free (error);
LOG ("failed to handle non-web scheme: %s", error->message);
return accept_navigation_policy_decision (window, decision, uri);
webkit_policy_decision_ignore (decision);
return TRUE;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment