[Xfce4-commits] <midori:master> List Netscape plugins in --version

Christian Dywan noreply at xfce.org
Thu Feb 21 20:20:04 CET 2013


Updating branch refs/heads/master
         to 5520769a73c1e15a6b6b36a1b1a27284aa6952d4 (commit)
       from 615cee49051c6711e7f862824ec538f2b7631e1b (commit)

commit 5520769a73c1e15a6b6b36a1b1a27284aa6952d4
Author: Christian Dywan <christian at twotoasts.de>
Date:   Thu Feb 21 20:18:03 2013 +0100

    List Netscape plugins in --version

 midori/main.c        |    2 +
 midori/midori-view.c |   64 ++++++++++++++++++++++++++++++++++---------------
 midori/midori-view.h |    5 ++++
 3 files changed, 51 insertions(+), 20 deletions(-)

diff --git a/midori/main.c b/midori/main.c
index bd17860..ddfe9b7 100644
--- a/midori/main.c
+++ b/midori/main.c
@@ -161,7 +161,9 @@ main (int    argc,
     if (version)
     {
         GString* versions = g_string_new ("");
+        g_string_append_c (versions, '\n');
         midori_view_list_versions (versions, FALSE);
+        midori_view_list_plugins (NULL, versions, FALSE);
         g_print ("%s\n", versions->str);
         g_string_free (versions, TRUE);
 
diff --git a/midori/midori-view.c b/midori/midori-view.c
index 082c7c4..772e8a2 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -3786,13 +3786,39 @@ midori_view_list_versions (GString* markup,
         ));
 }
 
-static void
-list_netscape_plugins (GString*     ns_plugins,
-                       JSContextRef js_context)
+void
+midori_view_list_plugins (MidoriView* view,
+                          GString*    ns_plugins,
+                          gboolean    html)
 {
     if (!midori_web_settings_has_plugin_support ())
         return;
 
+    if (html)
+        g_string_append (ns_plugins, "<br><h2>Netscape Plugins:</h2>");
+    else
+        g_string_append_c (ns_plugins, '\n');
+
+    #if WEBKIT_CHECK_VERSION (1, 3, 8)
+    WebKitWebPluginDatabase* pdb = webkit_get_web_plugin_database ();
+    GSList* plugins = webkit_web_plugin_database_get_plugins (pdb);
+    GSList* plugin = plugins;
+    for (; plugin != NULL; plugin = g_slist_next (plugin))
+    {
+        const gchar* path = webkit_web_plugin_get_path (plugin->data);
+        if (!path || strstr (path, "npwrapper.") || strstr (path, "plugins-wrapped"))
+            continue;
+        midori_view_add_version (ns_plugins, html, g_strdup_printf ("%s\t%s",
+            webkit_web_plugin_get_name (plugin->data),
+            html ? webkit_web_plugin_get_description (plugin->data) : ""));
+    }
+    webkit_web_plugin_database_plugins_list_free (plugins);
+    #else
+    if (view == NULL)
+        return;
+
+    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);
     /* Joins available plugins like this: URI1|title1,URI2|title2 */
     gchar* value = sokoke_js_script_eval (js_context,
         "function plugins (l) { var f = new Array (); for (var i in l) "
@@ -3801,27 +3827,24 @@ list_netscape_plugins (GString*     ns_plugins,
         "plugins (navigator.plugins)", NULL);
     gchar** items = g_strsplit (value, ",", 0);
     guint i = 0;
-    g_string_append (ns_plugins, "<h2>Netscape Plugins:</h2><table>");
     if (items != NULL)
         while (items[i] != NULL)
         {
             gchar** parts = g_strsplit (items[i], "|", 2);
-            if (parts && *parts && !g_str_equal (parts[1], "undefined"))
-            {
-                g_string_append (ns_plugins, "<tr><td>");
-                g_string_append (ns_plugins, parts[1]);
-                g_string_append (ns_plugins, "</td><td>");
-                g_string_append (ns_plugins, parts[0]);
-                g_string_append (ns_plugins, "</tr>");
-            }
+            if (parts[0]
+             && !strstr (parts[1], "npwrapper.") && !strstr (parts[1], "plugins-wrapped")
+             && !g_str_equal (parts[1], "undefined"))
+                midori_view_add_version (ns_plugins, html, g_strdup_printf ("%s\t%s",
+                    parts[1], html ? parts[0] : ""));
             g_strfreev (parts);
             i++;
         }
         if (g_str_has_prefix (value, "undefined"))
-            g_string_append (ns_plugins, "<tr><td>No plugins found</td></tr>");
-        g_string_append (ns_plugins, "</table>");
+            midori_view_add_version (ns_plugins, html, g_strdup_printf ("%s",
+                "No plugins found"));
         g_strfreev (items);
         g_free (value);
+    #endif
 }
 
 static void
@@ -3862,8 +3885,10 @@ list_geolocation (GString* markup)
 }
 
 static gchar*
-list_video_formats (JSContextRef js_context)
+list_video_formats (MidoriView* 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);
     gchar* value = sokoke_js_script_eval (js_context,
         "var supported = function (format) { "
         "var video = document.createElement('video');"
@@ -4072,8 +4097,6 @@ midori_view_set_uri (MidoriView*  view,
                 const gchar* sys_name = midori_web_settings_get_system_name (
                     &architecture, &platform);
                 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));
-                JSContextRef js_context = webkit_web_frame_get_global_context (web_frame);
                 GString * tmp = g_string_new ("");
 
                 g_string_append_printf (tmp,
@@ -4092,10 +4115,11 @@ midori_view_set_uri (MidoriView*  view,
                 midori_view_add_version (tmp, TRUE, g_strdup_printf ("Identification %s",
                     ident));
                 midori_view_add_version (tmp, TRUE, g_strdup_printf ("Video Formats %s",
-                    list_video_formats (js_context)));
-                g_string_append (tmp, "</table>");
+                    list_video_formats (view)));
+                g_string_append (tmp, "</table><table>");
 
-                list_netscape_plugins (tmp, js_context);
+                midori_view_list_plugins (view, tmp, TRUE);
+                g_string_append (tmp, "</table>");
                 list_about_uris (tmp);
                 /* TODO: list active extensions */
 
diff --git a/midori/midori-view.h b/midori/midori-view.h
index 0101ec5..9e426c2 100644
--- a/midori/midori-view.h
+++ b/midori/midori-view.h
@@ -238,6 +238,11 @@ void
 midori_view_list_versions              (GString*           markup,
                                         gboolean           html);
 
+void
+midori_view_list_plugins               (MidoriView*        view,
+                                        GString*           markup,
+                                        gboolean           html);
+
 G_END_DECLS
 
 #endif /* __MIDORI_VIEW_H__ */


More information about the Xfce4-commits mailing list