Bug 440506 - Add a globally shared location for plugins; r=joshmoz sr=jst
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 10 Oct 2008 17:54:33 +0200
changeset 20262 dda85c54599d
parent 20261 eee86e5513ad
child 20263 f4821e598b76
push id2752
push usersgautherie.bz@free.fr
push date2008-10-10 15:54 +0000
treeherdermozilla-central@dda85c54599d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjoshmoz, jst
bugs440506
milestone1.9.1b2pre
Bug 440506 - Add a globally shared location for plugins; r=joshmoz sr=jst
xpcom/io/nsAppFileLocationProvider.cpp
--- a/xpcom/io/nsAppFileLocationProvider.cpp
+++ b/xpcom/io/nsAppFileLocationProvider.cpp
@@ -90,16 +90,18 @@
 // Locally defined keys used by nsAppDirectoryEnumerator
 #define NS_ENV_PLUGINS_DIR          "EnvPlugins"    // env var MOZ_PLUGIN_PATH
 #define NS_USER_PLUGINS_DIR         "UserPlugins"
 
 #ifdef XP_MACOSX
 #define NS_MACOSX_USER_PLUGIN_DIR   "OSXUserPlugins"
 #define NS_MACOSX_LOCAL_PLUGIN_DIR  "OSXLocalPlugins"
 #define NS_MAC_CLASSIC_PLUGIN_DIR   "MacSysPlugins"
+#elif XP_UNIX
+#define NS_SYSTEM_PLUGINS_DIR       "SysPlugins"
 #endif
 
 #define DEFAULTS_DIR_NAME           NS_LITERAL_CSTRING("defaults")
 #define DEFAULTS_PREF_DIR_NAME      NS_LITERAL_CSTRING("pref")
 #define DEFAULTS_PROFILE_DIR_NAME   NS_LITERAL_CSTRING("profile")
 #define RES_DIR_NAME                NS_LITERAL_CSTRING("res")
 #define CHROME_DIR_NAME             NS_LITERAL_CSTRING("chrome")
 #define PLUGINS_DIR_NAME            NS_LITERAL_CSTRING("plugins")
@@ -245,16 +247,23 @@ nsAppFileLocationProvider::GetFile(const
             rv = NS_NewNativeLocalFile(nsDependentCString(pathVar), PR_TRUE, getter_AddRefs(localFile));
     }
     else if (nsCRT::strcmp(prop, NS_USER_PLUGINS_DIR) == 0)
     {
         rv = GetProductDirectory(getter_AddRefs(localFile));
         if (NS_SUCCEEDED(rv))
             rv = localFile->AppendRelativeNativePath(PLUGINS_DIR_NAME);
     }
+#ifdef XP_UNIX
+    else if (nsCRT::strcmp(prop, NS_SYSTEM_PLUGINS_DIR) == 0) {
+        static const char *const sysLPlgDir = "/usr/lib/mozilla/plugins";
+        rv = NS_NewNativeLocalFile(nsDependentCString(sysLPlgDir),
+                                   PR_FALSE, getter_AddRefs(localFile));
+    }
+#endif
 #endif
     else if (nsCRT::strcmp(prop, NS_APP_SEARCH_DIR) == 0)
     {
         rv = CloneMozBinDirectory(getter_AddRefs(localFile));
         if (NS_SUCCEEDED(rv))
             rv = localFile->AppendRelativeNativePath(SEARCH_DIR_NAME);
     }
     else if (nsCRT::strcmp(prop, NS_APP_USER_SEARCH_DIR) == 0)
@@ -578,17 +587,21 @@ nsAppFileLocationProvider::GetFiles(cons
             OSErr err;
             long response;
             err = ::Gestalt(gestaltSystemVersion, &response); 
             keys = (!err && response >= 0x00001000) ? osXKeys : os9Keys;
         }
 
         *_retval = new nsAppDirectoryEnumerator(this, keys);
 #else
+#ifdef XP_UNIX
+        static const char* keys[] = { nsnull, NS_USER_PLUGINS_DIR, NS_APP_PLUGINS_DIR, NS_SYSTEM_PLUGINS_DIR, nsnull };
+#else
         static const char* keys[] = { nsnull, NS_USER_PLUGINS_DIR, NS_APP_PLUGINS_DIR, nsnull };
+#endif
         if (!keys[0] && !(keys[0] = PR_GetEnv("MOZ_PLUGIN_PATH"))) {
             static const char nullstr = 0;
             keys[0] = &nullstr;
         }
         *_retval = new nsPathsDirectoryEnumerator(this, keys);
 #endif
         NS_IF_ADDREF(*_retval);
         rv = *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;