summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Catanzaro <mcatanzaro@gnome.org>2021-04-19 10:54:56 -0500
committerMichael Catanzaro <mcatanzaro@gnome.org>2021-04-28 19:13:16 -0500
commit899e32c775b9c0a452b9daefe6514254f32f0291 (patch)
tree964d57c1a2431cb541382c91c44a0567a75a5825
parentc367e5e45d845340956f2daa4b2de50ca976716d (diff)
downloadepiphany-899e32c775b9c0a452b9daefe6514254f32f0291.tar.gz
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 recursion. This change also prevents websites from opening URLs without user intervention. Thanks to Adrian Perez for proposing this solution! Fixes #1385 Part-of: <https://gitlab.gnome.org/GNOME/epiphany/-/merge_requests/951>
-rw-r--r--src/ephy-window.c24
1 files changed, 6 insertions, 18 deletions
diff --git a/src/ephy-window.c b/src/ephy-window.c
index a0a48531b..d49bb5cd9 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -2103,27 +2103,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")) {
- 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);
- return accept_navigation_policy_decision (window, decision, uri);
- }
- }
+ 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);
+ return accept_navigation_policy_decision (window, decision, uri);
}
webkit_policy_decision_ignore (decision);
-
return TRUE;
}