[Xfce4-commits] <midori:master> Implement internal about:plugins page

Christian Dywan noreply at xfce.org
Thu Feb 24 22:28:01 CET 2011


Updating branch refs/heads/master
         to 667c94389a83e09a8014ac2b4d4b2b4fa637eb94 (commit)
       from 215a5c1ca24c6662d5e5b1a72000f4d013cf2816 (commit)

commit 667c94389a83e09a8014ac2b4d4b2b4fa637eb94
Author: Christian Dywan <christian at twotoasts.de>
Date:   Thu Feb 24 22:27:55 2011 +0100

    Implement internal about:plugins page

 midori/midori-view.c |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/midori/midori-view.c b/midori/midori-view.c
index e928f4a..6ede1e3 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -3914,6 +3914,45 @@ midori_view_set_uri (MidoriView*  view,
                 g_free (ident);
                 g_free (sys_name);
             }
+            else if (!strcmp (uri, "about:plugins"))
+            {
+                GtkWidget* web_view = webkit_web_view_new ();
+                WebKitWebFrame* web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
+                JSContextRef js_context = webkit_web_frame_get_global_context (web_frame);
+                /* This snippet joins the available plugins into a string like this:
+                   URI1|title1,URI2|title2 */
+                gchar* value = sokoke_js_script_eval (js_context,
+                    "function plugins (l) { var f = new Array (); for (i in l) "
+                    "{ var p = l[i].name + '|' + l[i].filename; "
+                    "if (f.indexOf (p) == -1) f.push (p); } return f; }"
+                    "plugins (navigator.plugins)", NULL);
+                gchar** items = g_strsplit (value, ",", 0);
+                guint i = 0;
+                GString* ns_plugins = g_string_new (
+                    "<html><head><title>about:plugins</title><head><body>");
+                if (items != NULL)
+                while (items[i] != NULL)
+                {
+                    gchar** parts = g_strsplit (items[i], "|", 2);
+                    if (parts && *parts && !g_str_equal (parts[1], "undefined"))
+                    {
+                        gchar* desc = parts[1];
+                        gsize j = 0;
+                        while (desc[j++])
+                            if (desc[j-1] == ';')
+                                desc[j-1] = '\n';
+                        g_string_append (ns_plugins, parts[0]);
+                        g_string_append (ns_plugins, "   ");
+                        g_string_append (ns_plugins, desc);
+                        g_string_append (ns_plugins, "<br>");
+                    }
+                    g_strfreev (parts);
+                    i++;
+                }
+                g_string_append (ns_plugins, "</body>");
+                katze_assign (view->uri, g_strdup (uri));
+                data = g_string_free (ns_plugins, FALSE);
+            }
             else
             {
                 katze_assign (view->uri, g_strdup (uri));



More information about the Xfce4-commits mailing list