[Xfce4-commits] <midori:master> Ask GIO for supported URI schemes
Christian Dywan
noreply at xfce.org
Wed Oct 20 21:00:01 CEST 2010
Updating branch refs/heads/master
to fc23eac478f40acddd4dc0ca056bb31d1a9f92e8 (commit)
from 6bc27b9cd5a3c3ee54312c3da830f6eab780e454 (commit)
commit fc23eac478f40acddd4dc0ca056bb31d1a9f92e8
Author: Christian Dywan <christian at twotoasts.de>
Date: Wed Oct 20 20:56:05 2010 +0200
Ask GIO for supported URI schemes
sokoke_external_uri supersedes hardcoded support for tel:
and callto: and notably doesn't count http(s).
midori/midori-view.c | 6 ++----
midori/sokoke.c | 20 ++++++++++++++++++--
midori/sokoke.h | 3 +++
3 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/midori/midori-view.c b/midori/midori-view.c
index 0679b2f..9bda7bc 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 02910d6..9a0d960 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 5515486..288e79a 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);
More information about the Xfce4-commits
mailing list