Bug 595522 - Enumerate all prefs in defaults/pref, r=bsmedberg a=blocking2.0
authorMichael Wu <mwu@mozilla.com>
Tue, 08 Feb 2011 10:54:52 -0800
changeset 62149 fb3786a7d988257da0f42c2b64d949b523a79789
parent 62148 39959be42c6f52fc3e976d6826ad140896747daf
child 62150 a07bf48ebb0b40fa3f225b5e1cbd4cb4e2949386
push idunknown
push userunknown
push dateunknown
reviewersbsmedberg, blocking2.0
bugs595522
milestone2.0b12pre
Bug 595522 - Enumerate all prefs in defaults/pref, r=bsmedberg a=blocking2.0
modules/libpref/src/nsPrefService.cpp
--- a/modules/libpref/src/nsPrefService.cpp
+++ b/modules/libpref/src/nsPrefService.cpp
@@ -800,59 +800,29 @@ static nsresult pref_LoadPrefsInDirList(
 
 //----------------------------------------------------------------------------------------
 // Initialize default preference JavaScript buffers from
 // appropriate TEXT resources
 //----------------------------------------------------------------------------------------
 static nsresult pref_InitDefaults()
 {
   nsCOMPtr<nsIFile> greprefsFile;
-  nsCOMPtr<nsIFile> defaultPrefDir;
   nsresult          rv;
 
   rv = NS_GetSpecialDirectory(NS_GRE_DIR, getter_AddRefs(greprefsFile));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = greprefsFile->AppendNative(NS_LITERAL_CSTRING("greprefs.js"));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = openPrefFile(greprefsFile);
   if (NS_FAILED(rv)) {
     NS_WARNING("Error parsing GRE default preferences. Is this an old-style embedding app?");
   }
 
-  // now parse the "application" default preferences
-  rv = NS_GetSpecialDirectory(NS_APP_PREF_DEFAULTS_50_DIR, getter_AddRefs(defaultPrefDir));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  /* these pref file names should not be used: we process them after all other application pref files for backwards compatibility */
-  static const char* specialFiles[] = {
-#if defined(XP_MAC) || defined(XP_MACOSX)
-      "macprefs.js"
-#elif defined(XP_WIN)
-      "winpref.js"
-#elif defined(XP_UNIX)
-      "unix.js"
-#if defined(VMS)
-      , "openvms.js"
-#elif defined(_AIX)
-      , "aix.js"
-#endif
-#elif defined(XP_OS2)
-      "os2pref.js"
-#elif defined(XP_BEOS)
-      "beos.js"
-#endif
-  };
-
-  rv = pref_LoadPrefsInDir(defaultPrefDir, specialFiles, NS_ARRAY_LENGTH(specialFiles));
-  if (NS_FAILED(rv)) {
-    NS_WARNING("Error parsing application default preferences.");
-  }
-
   return NS_OK;
 }
 
 #ifdef MOZ_OMNIJAR
 static nsresult pref_ReadPrefFromJar(nsZipArchive* jarReader, const char *name)
 {
   nsZipItemPtr<char> manifest(jarReader, name, true);
   NS_ENSURE_TRUE(manifest.Buffer(), NS_ERROR_NOT_AVAILABLE);
@@ -891,50 +861,58 @@ static nsresult pref_InitAppDefaultsFrom
 
   prefEntries.Sort();
   for (PRUint32 i = prefEntries.Length(); i--; ) {
     rv = pref_ReadPrefFromJar(jarReader, prefEntries[i].get());
     if (NS_FAILED(rv))
       NS_WARNING("Error parsing preferences.");
   }
 
-  nsCOMPtr<nsIFile> file;
-  // Bug 591866 - channel-prefs.js should not be in omni.jar
-  rv = NS_GetSpecialDirectory(NS_APP_PREF_DEFAULTS_50_DIR, getter_AddRefs(file));
-  if (NS_FAILED(rv)) {
-    NS_WARNING("Error getting default prefs dir");
-    return NS_OK;
-  }
-
-  rv = file->AppendNative(NS_LITERAL_CSTRING("channel-prefs.js"));
-  if (NS_FAILED(rv)) {
-    NS_WARNING("Error setting channel-prefs.js path");
-    return NS_OK;
-  }
-
-  rv = openPrefFile(file);
-  if (NS_FAILED(rv))
-    NS_WARNING("Error reading channel-prefs.js");
-
   return NS_OK;
 }
 #endif
 
 static nsresult pref_InitInitialObjects()
 {
   nsresult rv;
 
   // first we parse the GRE default prefs. This also works if we're not using a GRE, 
 #ifdef MOZ_OMNIJAR
   rv = pref_InitAppDefaultsFromOmnijar();
 #else
   rv = pref_InitDefaults();
 #endif
   NS_ENSURE_SUCCESS(rv, rv);
 
+  nsCOMPtr<nsIFile> defaultPrefDir;
+  // now parse the "application" default preferences
+  rv = NS_GetSpecialDirectory(NS_APP_PREF_DEFAULTS_50_DIR, getter_AddRefs(defaultPrefDir));
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  /* these pref file names should not be used: we process them after all other application pref files for backwards compatibility */
+  static const char* specialFiles[] = {
+#if defined(XP_MAC) || defined(XP_MACOSX)
+      "macprefs.js"
+#elif defined(XP_WIN)
+      "winpref.js"
+#elif defined(XP_UNIX)
+      "unix.js"
+#if defined(_AIX)
+      , "aix.js"
+#endif
+#elif defined(XP_OS2)
+      "os2pref.js"
+#endif
+  };
+
+  rv = pref_LoadPrefsInDir(defaultPrefDir, specialFiles, NS_ARRAY_LENGTH(specialFiles));
+  if (NS_FAILED(rv)) {
+    NS_WARNING("Error parsing application default preferences.");
+  }
+
   rv = pref_LoadPrefsInDirList(NS_APP_PREFS_DEFAULTS_DIR_LIST);
   NS_ENSURE_SUCCESS(rv, rv);
 
   NS_CreateServicesFromCategory(NS_PREFSERVICE_APPDEFAULTS_TOPIC_ID,
                                 nsnull, NS_PREFSERVICE_APPDEFAULTS_TOPIC_ID);
 
   nsCOMPtr<nsIObserverService> observerService =
     mozilla::services::GetObserverService();