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-19 10:59:44 -0500
commit2573bc74c8df2849e5e2c9acc3f654759edf2492 (patch)
treef34408b8ed86d36d7f690c60dec0d47bbf0adccd
parent7e31b93d937625602e910d7397d00cc6082a37be (diff)
downloadepiphany-mcatanzaro/#1385.tar.gz
window: launch URLs whenever triggered by user gesturemcatanzaro/#1385
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
-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 67fdf2266..d8b93b1cd 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -2110,27 +2110,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;
}