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))
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);
}
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
/* 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);
gchar*
sokoke_uri_to_ascii (const gchar* uri);
+gboolean
+sokoke_external_uri (const gchar* uri);
+
gchar*
sokoke_magic_uri (const gchar* uri);