]> spindle.queued.net Git - midori/commitdiff
Abstract availability of Netscape plugin support
authorChristian Dywan <christian@twotoasts.de>
Sat, 25 Feb 2012 01:06:46 +0000 (02:06 +0100)
committerChristian Dywan <christian@twotoasts.de>
Sat, 25 Feb 2012 01:06:46 +0000 (02:06 +0100)
Disable if MOZ_PLUGIN_PATH is / or MIDORI_UNARMED.

INSTALL
extensions/statusbar-features.c
midori/main.c
midori/midori-view.c
midori/midori-websettings.c
midori/midori-websettings.h

diff --git a/INSTALL b/INSTALL
index aed4768ea866869d3a23a5cf2e1c47015b8e866a..50ae6001c4a65bda293876ce6613ba1559b5eaf7 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -67,6 +67,8 @@ If you want to "dry run" without WebKitGTK+ rendering, try this:
 
 'MIDORI_UNARMED=1 _build_/default/midori/midori'
 
+To disable Netscape plugins, use MOZ_PLUGIN_PATH=/.
+
 To debug extensions you can specify the path:
 
 'export MIDORI_EXTENSION_PATH=_build_/default/extensions'
index 9480fec7fb0eb7f0dd4d2d9884b46cb5beca573c..24e55f2a6abd10fd7acb4154c239bfafb7b1de8e 100644 (file)
@@ -142,8 +142,11 @@ statusbar_features_app_add_browser_cb (MidoriApp*       app,
     g_signal_connect (toolbar, "notify::toolbar-style",
         G_CALLBACK (statusbar_features_toolbar_notify_toolbar_style_cb), button);
     gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 2);
-    button = katze_property_proxy (settings, "enable-plugins", "toggle");
-    g_object_set_data (G_OBJECT (button), "feature-label", _("Netscape plugins"));
+    if (midori_web_settings_has_plugin_support ())
+    {
+        button = katze_property_proxy (settings, "enable-plugins", "toggle");
+        g_object_set_data (G_OBJECT (button), "feature-label", _("Netscape plugins"));
+    }
     image = gtk_image_new_from_stock (STOCK_PLUGINS, GTK_ICON_SIZE_MENU);
     gtk_button_set_image (GTK_BUTTON (button), image);
     gtk_widget_set_tooltip_text (button, _("Enable Netscape plugins"));
index 08b163a331d2c95f6733ad698eb522c4dac962d7..f0efec497f1c16430bf445b7cc27a72b73a8b6f4 100644 (file)
@@ -1743,6 +1743,8 @@ midori_clear_web_cookies_cb (void)
     }
 
     /* Local shared objects/ Flash cookies */
+    if (midori_web_settings_has_plugin_support ())
+    {
     #ifdef GDK_WINDOWING_X11
     cache = g_build_filename (g_get_home_dir (), ".macromedia", "Flash_Player", NULL);
     sokoke_remove_path (cache, TRUE);
@@ -1757,6 +1759,7 @@ midori_clear_web_cookies_cb (void)
     sokoke_remove_path (cache, TRUE);
     g_free (cache);
     #endif
+    }
 
     /* HTML5 databases */
     webkit_remove_all_web_databases ();
index 77b32737aab0816eac4b78e63387af38b6715891..a94881fa68eb5e8042e40dabcc564a18edc3a1a1 100644 (file)
@@ -3660,6 +3660,8 @@ midori_view_construct_web_view (MidoriView* view)
 
 static gchar* list_netscape_plugins ()
 {
+    if (midori_web_settings_has_plugin_support ())
+    {
     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);
@@ -3671,7 +3673,7 @@ static gchar* list_netscape_plugins ()
         "plugins (navigator.plugins)", NULL);
     gchar** items = g_strsplit (value, ",", 0);
     guint i = 0;
-    GString* ns_plugins = g_string_new (NULL);
+    GString* ns_plugins = g_string_new ("<h2>Netscape Plugins:</h2><table>");
     if (items != NULL)
         while (items[i] != NULL)
         {
@@ -3689,10 +3691,14 @@ static gchar* list_netscape_plugins ()
         }
         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>");
         g_strfreev (items);
         g_free (value);
     gtk_widget_destroy (web_view);
     return g_string_free (ns_plugins, FALSE);
+    }
+    else
+        return g_strdup ("");
 }
 
 static gchar*
@@ -4022,7 +4028,7 @@ midori_view_set_uri (MidoriView*  view,
                     "<tr><td>Identification</td><td>%s</td></tr>"
                     "<tr><td>Video&nbsp;Formats</td><td>%s</td></tr>"
                     "</table>"
-                    "<h2>Netscape Plugins:</h2><table>%s</table>"
+                    "%s"
                     "</body></html>",
                     _("Version numbers in brackets show the version used at runtime."),
                     command_line,
index 121d3149acd1119bb69b0edef8aa658965a113ef..d586261af59e1fcc57ca470b32b2263e9e5d3af8 100644 (file)
@@ -728,13 +728,8 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
                                      "enable-plugins",
                                      _("Enable Netscape plugins"),
                                      _("Enable embedded Netscape plugin objects"),
-    #ifdef G_OS_WIN32
-                                     FALSE,
-                                     G_PARAM_READABLE));
-    #else
-                                     TRUE,
-                                     flags));
-    #endif
+                                     midori_web_settings_has_plugin_support (),
+        midori_web_settings_has_plugin_support () ? flags : G_PARAM_READABLE));
     /* Override properties to override defaults */
     g_object_class_install_property (gobject_class,
                                      PROP_ENABLE_DEVELOPER_EXTRAS,
@@ -1191,6 +1186,26 @@ midori_web_settings_finalize (GObject* object)
     G_OBJECT_CLASS (midori_web_settings_parent_class)->finalize (object);
 }
 
+/**
+ * midori_web_settings_has_plugin_support:
+ *
+ * Determines if Netscape plugins are supported.
+ *
+ * Returns: %TRUE if Netscape plugins can be used
+ *
+ * Since: 0.4.4
+ **/
+gboolean
+midori_web_settings_has_plugin_support (void)
+{
+    #ifdef G_OS_WIN32
+    return FALSE;
+    #else
+    return g_getenv ("MIDORI_UNARMED") == NULL
+        && g_strcmp0 (g_getenv ("MOZ_PLUGIN_PATH"), "/");
+    #endif
+}
+
 #if (!HAVE_OSX && defined (G_OS_UNIX)) || defined (G_OS_WIN32)
 static gchar*
 get_sys_name (gchar** architecture)
index e11ffef3be39ea3c0367531feaba8ba386a7d326..3b96fc7aef56838fb4f4403b585465f8b742e3c3 100644 (file)
@@ -173,6 +173,9 @@ const gchar*
 midori_web_settings_get_system_name        (gchar**            architecture,
                                             gchar**            platform);
 
+gboolean
+midori_web_settings_has_plugin_support     (void);
+
 G_END_DECLS
 
 #endif /* __MIDORI_WEB_SETTINGS_H__ */