Description: Add a system-wide preferences folder Author: Alexander Sack Forwarded: no Index: mozilla/toolkit/xre/nsXREDirProvider.cpp =================================================================== --- mozilla.orig/toolkit/xre/nsXREDirProvider.cpp 2011-09-29 00:59:39.000000000 +0100 +++ mozilla/toolkit/xre/nsXREDirProvider.cpp 2011-09-29 10:22:10.700227676 +0100 @@ -591,6 +591,7 @@ } static const char *const kAppendPrefDir[] = { "defaults", "preferences", nsnull }; +static const char *const kAppendSysPrefDir[] = { "defaults", "syspref", nsnull }; #ifdef DEBUG_bsmedberg static void @@ -632,6 +633,9 @@ LoadAppDirIntoArray(mXULAppDir, kAppendPrefDir, directories); LoadDirsIntoArray(mAppBundleDirectories, kAppendPrefDir, directories); + LoadAppDirIntoArray(mXULAppDir, kAppendSysPrefDir, directories); + LoadDirsIntoArray(mAppBundleDirectories, + kAppendSysPrefDir, directories); rv = NS_NewArrayEnumerator(aResult, directories); } Index: mozilla/xpcom/io/nsAppDirectoryServiceDefs.h =================================================================== --- mozilla.orig/xpcom/io/nsAppDirectoryServiceDefs.h 2011-09-29 00:59:46.000000000 +0100 +++ mozilla/xpcom/io/nsAppDirectoryServiceDefs.h 2011-09-29 10:22:10.700227676 +0100 @@ -63,6 +63,7 @@ #define NS_APP_DEFAULTS_50_DIR "DefRt" // The root dir of all defaults dirs #define NS_APP_PREF_DEFAULTS_50_DIR "PrfDef" +#define NS_APP_SYSPREF_DEFAULTS_50_DIR "SysPrfDef" #define NS_APP_PROFILE_DEFAULTS_50_DIR "profDef" // The profile defaults of the "current" // locale. Should be first choice. #define NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR "ProfDefNoLoc" // The profile defaults of the "default" Index: mozilla/xpcom/io/nsAppFileLocationProvider.cpp =================================================================== --- mozilla.orig/xpcom/io/nsAppFileLocationProvider.cpp 2011-09-29 00:59:46.000000000 +0100 +++ mozilla/xpcom/io/nsAppFileLocationProvider.cpp 2011-09-29 10:22:10.700227676 +0100 @@ -94,6 +94,7 @@ #define DEFAULTS_DIR_NAME NS_LITERAL_CSTRING("defaults") #define DEFAULTS_PREF_DIR_NAME NS_LITERAL_CSTRING("pref") +#define DEFAULTS_SYSPREF_DIR_NAME NS_LITERAL_CSTRING("syspref") #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") @@ -158,6 +159,15 @@ rv = localFile->AppendRelativeNativePath(DEFAULTS_PREF_DIR_NAME); } } + else if (nsCRT::strcmp(prop, NS_APP_SYSPREF_DEFAULTS_50_DIR) == 0) + { + rv = CloneMozBinDirectory(getter_AddRefs(localFile)); + if (NS_SUCCEEDED(rv)) { + rv = localFile->AppendRelativeNativePath(DEFAULTS_DIR_NAME); + if (NS_SUCCEEDED(rv)) + rv = localFile->AppendRelativeNativePath(DEFAULTS_SYSPREF_DIR_NAME); + } + } else if (nsCRT::strcmp(prop, NS_APP_PROFILE_DEFAULTS_50_DIR) == 0 || nsCRT::strcmp(prop, NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR) == 0) { Index: mozilla/modules/libpref/src/Preferences.cpp =================================================================== --- mozilla.orig/modules/libpref/src/Preferences.cpp 2011-09-29 10:22:28.616227359 +0100 +++ mozilla/modules/libpref/src/Preferences.cpp 2011-09-29 10:26:43.716222825 +0100 @@ -1093,6 +1093,15 @@ if (NS_FAILED(rv)) NS_WARNING("Error parsing application default preferences."); + + /* Load $gre/defaults/syspref/*.js */ + rv = NS_GetSpecialDirectory(NS_APP_SYSPREF_DEFAULTS_50_DIR, getter_AddRefs(defaultPrefDir)); + NS_ENSURE_SUCCESS(rv, rv); + + rv = pref_LoadPrefsInDir(defaultPrefDir, specialFiles, NS_ARRAY_LENGTH(specialFiles)); + if (NS_FAILED(rv)) + NS_WARNING("Error parsing application system preferences."); + // Load jar:$app/omni.jar!/defaults/preferences/*.js nsZipArchive *appJarReader = mozilla::Omnijar::GetReader(mozilla::Omnijar::APP); if (appJarReader) {