~ubuntu-branches/ubuntu/precise/thunderbird/precise-security

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
Description: Add a system-wide preferences folder
Author: Alexander Sack <asac@ubuntu.com>
Forwarded: no

Index: mozilla/mozilla/toolkit/xre/nsXREDirProvider.cpp
===================================================================
--- mozilla.orig/mozilla/toolkit/xre/nsXREDirProvider.cpp	2011-09-29 00:59:39.000000000 +0100
+++ mozilla/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/mozilla/xpcom/io/nsAppDirectoryServiceDefs.h
===================================================================
--- mozilla.orig/mozilla/xpcom/io/nsAppDirectoryServiceDefs.h	2011-09-29 00:59:46.000000000 +0100
+++ mozilla/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/mozilla/xpcom/io/nsAppFileLocationProvider.cpp
===================================================================
--- mozilla.orig/mozilla/xpcom/io/nsAppFileLocationProvider.cpp	2011-09-29 00:59:46.000000000 +0100
+++ mozilla/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/mozilla/modules/libpref/src/Preferences.cpp
===================================================================
--- mozilla.orig/mozilla/modules/libpref/src/Preferences.cpp	2011-09-29 10:22:28.616227359 +0100
+++ mozilla/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) {