Ask GIO for supported URI schemes
sokoke_external_uri supersedes hardcoded support for tel: and callto: and notably doesn't count http(s).
This commit is contained in:
parent
6bc27b9cd5
commit
fc23eac478
3 changed files with 23 additions and 6 deletions
|
@ -949,7 +949,7 @@ midori_view_web_view_navigation_decision_cb (WebKitWebView* web_view
|
||||||
MidoriView* view)
|
MidoriView* view)
|
||||||
{
|
{
|
||||||
const gchar* uri = webkit_network_request_get_uri (request);
|
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)),
|
if (sokoke_show_uri (gtk_widget_get_screen (GTK_WIDGET (web_view)),
|
||||||
uri, GDK_CURRENT_TIME, NULL))
|
uri, GDK_CURRENT_TIME, NULL))
|
||||||
|
@ -3861,9 +3861,7 @@ midori_view_set_uri (MidoriView* view,
|
||||||
g_free (exception);
|
g_free (exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (g_str_has_prefix (uri, "mailto:")
|
else if (g_str_has_prefix (uri, "mailto:") || sokoke_external_uri (uri))
|
||||||
|| g_str_has_prefix (uri, "tel:")
|
|
||||||
|| g_str_has_prefix (uri, "callto:"))
|
|
||||||
{
|
{
|
||||||
sokoke_show_uri (NULL, uri, GDK_CURRENT_TIME, NULL);
|
sokoke_show_uri (NULL, uri, GDK_CURRENT_TIME, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -739,6 +739,23 @@ sokoke_resolve_hostname (const gchar* hostname)
|
||||||
return host_resolved == 1 ? TRUE : FALSE;
|
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:
|
* sokoke_magic_uri:
|
||||||
* @uri: a string typed by a user
|
* @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 */
|
/* Just return if it's a javascript: or mailto: uri */
|
||||||
if (!strncmp (uri, "javascript:", 11)
|
if (!strncmp (uri, "javascript:", 11)
|
||||||
|| !strncmp (uri, "mailto:", 7)
|
|| !strncmp (uri, "mailto:", 7)
|
||||||
|| !strncmp (uri, "tel:", 4)
|
|| sokoke_external_uri (uri)
|
||||||
|| !strncmp (uri, "callto:", 7)
|
|
||||||
|| !strncmp (uri, "data:", 5)
|
|| !strncmp (uri, "data:", 5)
|
||||||
|| !strncmp (uri, "about:", 6))
|
|| !strncmp (uri, "about:", 6))
|
||||||
return g_strdup (uri);
|
return g_strdup (uri);
|
||||||
|
|
|
@ -118,6 +118,9 @@ sokoke_hostname_from_uri (const gchar* uri,
|
||||||
gchar*
|
gchar*
|
||||||
sokoke_uri_to_ascii (const gchar* uri);
|
sokoke_uri_to_ascii (const gchar* uri);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
sokoke_external_uri (const gchar* uri);
|
||||||
|
|
||||||
gchar*
|
gchar*
|
||||||
sokoke_magic_uri (const gchar* uri);
|
sokoke_magic_uri (const gchar* uri);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue