List available about: URLs in about:version

Strings are built with GString to avoid printf limits.
This commit is contained in:
Christian Dywan 2012-04-10 21:54:38 +02:00
parent 89dbbcc1b0
commit 12d49e36c2

View file

@ -3790,11 +3790,13 @@ midori_view_construct_web_view (MidoriView* view)
NULL); NULL);
} }
static gchar* static void
list_netscape_plugins (JSContextRef js_context) list_netscape_plugins (GString* ns_plugins,
JSContextRef js_context)
{ {
if (midori_web_settings_has_plugin_support ()) if (!midori_web_settings_has_plugin_support ())
{ return;
/* Joins available plugins like this: URI1|title1,URI2|title2 */ /* Joins available plugins like this: URI1|title1,URI2|title2 */
gchar* value = sokoke_js_script_eval (js_context, gchar* value = sokoke_js_script_eval (js_context,
"function plugins (l) { var f = new Array (); for (var i in l) " "function plugins (l) { var f = new Array (); for (var i in l) "
@ -3803,7 +3805,7 @@ list_netscape_plugins (JSContextRef js_context)
"plugins (navigator.plugins)", NULL); "plugins (navigator.plugins)", NULL);
gchar** items = g_strsplit (value, ",", 0); gchar** items = g_strsplit (value, ",", 0);
guint i = 0; guint i = 0;
GString* ns_plugins = g_string_new ("<h2>Netscape Plugins:</h2><table>"); g_string_append (ns_plugins, "<h2>Netscape Plugins:</h2><table>");
if (items != NULL) if (items != NULL)
while (items[i] != NULL) while (items[i] != NULL)
{ {
@ -3824,16 +3826,12 @@ list_netscape_plugins (JSContextRef js_context)
g_string_append (ns_plugins, "</table>"); g_string_append (ns_plugins, "</table>");
g_strfreev (items); g_strfreev (items);
g_free (value); g_free (value);
return g_string_free (ns_plugins, FALSE);
}
else
return g_strdup ("");
} }
static const gchar* static void
list_geolocation () list_geolocation (GString* markup)
{ {
return g_string_append (markup,
"<a href=\"http://dev.w3.org/geo/api/spec-source.html\" id=\"method\"></a>" "<a href=\"http://dev.w3.org/geo/api/spec-source.html\" id=\"method\"></a>"
"<span id=\"locationInfo\"><noscript>No Geolocation without Javascript</noscript></span>" "<span id=\"locationInfo\"><noscript>No Geolocation without Javascript</noscript></span>"
"<script>" "<script>"
@ -3864,7 +3862,7 @@ list_geolocation ()
" }" " }"
"} else" "} else"
" document.getElementById('locationInfo').innerHTML = 'Geolocation unavailable';" " document.getElementById('locationInfo').innerHTML = 'Geolocation unavailable';"
"</script>"; "</script>");
} }
static gchar* static gchar*
@ -3885,6 +3883,23 @@ list_video_formats (JSContextRef js_context)
return value; return value;
} }
static const gchar* valid_about_uris[] = {
"about:widgets",
"about:private",
"error:nodocs",
"http://.invalid",
};
static void
list_about_uris (GString* markup)
{
g_string_append (markup, "<p>");
guint i;
for (i = 0; i < G_N_ELEMENTS (valid_about_uris); i++)
g_string_append_printf (markup, "<a href=\"%s\">%s</a> &nbsp;",
valid_about_uris[i], valid_about_uris[i]);
}
static gchar* static gchar*
prepare_speed_dial_html (MidoriView* view, prepare_speed_dial_html (MidoriView* view,
gboolean load_missing) gboolean load_missing)
@ -4168,8 +4183,11 @@ midori_view_set_uri (MidoriView* view,
gchar* ident = katze_object_get_string (view->settings, "user-agent"); gchar* ident = katze_object_get_string (view->settings, "user-agent");
WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view)); WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view));
JSContextRef js_context = webkit_web_frame_get_global_context (web_frame); JSContextRef js_context = webkit_web_frame_get_global_context (web_frame);
gchar* netscape_plugins = list_netscape_plugins (js_context);
gchar* video_formats = list_video_formats (js_context); gchar* video_formats = list_video_formats (js_context);
GString* more = g_string_new ("");
list_netscape_plugins (more, js_context);
list_geolocation (more);
list_about_uris (more);
katze_assign (view->uri, g_strdup (uri)); katze_assign (view->uri, g_strdup (uri));
data = g_strdup_printf ( data = g_strdup_printf (
@ -4193,7 +4211,7 @@ midori_view_set_uri (MidoriView* view,
"<tr><td>Identification</td><td>%s</td></tr>" "<tr><td>Identification</td><td>%s</td></tr>"
"<tr><td>Video&nbsp;Formats</td><td>%s</td></tr>" "<tr><td>Video&nbsp;Formats</td><td>%s</td></tr>"
"</table>" "</table>"
"%s %s" "%s"
"</body></html>", "</body></html>",
_("Version numbers in brackets show the version used at runtime."), _("Version numbers in brackets show the version used at runtime."),
command_line, command_line,
@ -4220,12 +4238,12 @@ midori_view_set_uri (MidoriView* view,
"Sockets", "Sockets",
#endif #endif
platform, sys_name, architecture ? architecture : "", ident, platform, sys_name, architecture ? architecture : "", ident,
video_formats, list_geolocation (), netscape_plugins); video_formats, (gchar*)(more->str));
g_free (command_line); g_free (command_line);
g_free (arguments); g_free (arguments);
g_free (ident); g_free (ident);
g_free (netscape_plugins);
g_free (video_formats); g_free (video_formats);
g_string_free (more, TRUE);
} }
else else
{ {