From: Christian Dywan Date: Wed, 20 Oct 2010 18:56:05 +0000 (+0200) Subject: Ask GIO for supported URI schemes X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc23eac478f40acddd4dc0ca056bb31d1a9f92e8;p=midori Ask GIO for supported URI schemes sokoke_external_uri supersedes hardcoded support for tel: and callto: and notably doesn't count http(s). --- diff --git a/midori/midori-view.c b/midori/midori-view.c index 0679b2f4..9bda7bc2 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -949,7 +949,7 @@ midori_view_web_view_navigation_decision_cb (WebKitWebView* web_view MidoriView* view) { const gchar* uri = webkit_network_request_get_uri (request); - if (g_str_has_prefix (uri, "mailto:") || g_str_has_prefix (uri, "tel:")) + if (g_str_has_prefix (uri, "mailto:") || sokoke_external_uri (uri)) { if (sokoke_show_uri (gtk_widget_get_screen (GTK_WIDGET (web_view)), uri, GDK_CURRENT_TIME, NULL)) @@ -3861,9 +3861,7 @@ midori_view_set_uri (MidoriView* view, g_free (exception); } } - else if (g_str_has_prefix (uri, "mailto:") - || g_str_has_prefix (uri, "tel:") - || g_str_has_prefix (uri, "callto:")) + else if (g_str_has_prefix (uri, "mailto:") || sokoke_external_uri (uri)) { sokoke_show_uri (NULL, uri, GDK_CURRENT_TIME, NULL); } diff --git a/midori/sokoke.c b/midori/sokoke.c index 02910d6f..9a0d960b 100644 --- a/midori/sokoke.c +++ b/midori/sokoke.c @@ -739,6 +739,23 @@ sokoke_resolve_hostname (const gchar* hostname) return host_resolved == 1 ? TRUE : FALSE; } +gboolean +sokoke_external_uri (const gchar* uri) +{ + gchar* scheme; + GAppInfo* info; + + if (!uri || !strncmp (uri, "http", 4)) + return FALSE; + + scheme = g_uri_parse_scheme (uri); + info = g_app_info_get_default_for_uri_scheme (scheme); + g_free (scheme); + if (info) + g_object_unref (info); + return info != NULL; +} + /** * sokoke_magic_uri: * @uri: a string typed by a user @@ -761,8 +778,7 @@ sokoke_magic_uri (const gchar* uri) /* Just return if it's a javascript: or mailto: uri */ if (!strncmp (uri, "javascript:", 11) || !strncmp (uri, "mailto:", 7) - || !strncmp (uri, "tel:", 4) - || !strncmp (uri, "callto:", 7) + || sokoke_external_uri (uri) || !strncmp (uri, "data:", 5) || !strncmp (uri, "about:", 6)) return g_strdup (uri); diff --git a/midori/sokoke.h b/midori/sokoke.h index 5515486d..288e79ab 100644 --- a/midori/sokoke.h +++ b/midori/sokoke.h @@ -118,6 +118,9 @@ sokoke_hostname_from_uri (const gchar* uri, gchar* sokoke_uri_to_ascii (const gchar* uri); +gboolean +sokoke_external_uri (const gchar* uri); + gchar* sokoke_magic_uri (const gchar* uri);