Bug 671798 - Always load $gre/defaults/pref prefs. r=bsmedberg
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 28 Jul 2011 09:04:08 +0200
changeset 73463 366a1e04921c7be323023463ec4763bc1b2e3b22
parent 73462 b774154497e1836160006eecbc837409cb2b43db
child 73464 895aeb0f1b4565a6da1fab639f76bab3bfd49c1b
push id20871
push usereakhgari@mozilla.com
push dateThu, 28 Jul 2011 14:37:48 +0000
treeherdermozilla-central@fe48bbfeff94 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs671798
milestone8.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 671798 - Always load $gre/defaults/pref prefs. r=bsmedberg
modules/libpref/src/Preferences.cpp
--- a/modules/libpref/src/Preferences.cpp
+++ b/modules/libpref/src/Preferences.cpp
@@ -1004,21 +1004,22 @@ static nsresult pref_InitInitialObjects(
   nsresult rv;
 
   // In omni.jar case, we load the following prefs:
   // - jar:$gre/omni.jar!/greprefs.js
   // - jar:$gre/omni.jar!/defaults/pref/*.js
   // In non omni.jar case, we load:
   // - $gre/greprefs.js
   //
-  // When $app == $gre, we additionally load, in all cases:
+  // In both cases, we also load:
   // - $gre/defaults/pref/*.js
-  // This is kept for bug 591866 (channel-prefs.js should not be in omni.jar).
-  // We load all files instead of channel-prefs.js only to have the same
-  // behaviour as $app != $gre.
+  // This is kept for bug 591866 (channel-prefs.js should not be in omni.jar)
+  // on $app == $gre case ; we load all files instead of channel-prefs.js only
+  // to have the same behaviour as $app != $gre, where this is required as
+  // a supported location for GRE preferences.
   //
   // When $app != $gre, we additionally load, in omni.jar case:
   // - jar:$app/omni.jar!/defaults/preferences/*.js
   // - $app/defaults/preferences/*.js
   // and in non omni.jar case:
   // - $app/defaults/preferences/*.js
 
   nsZipFind *findPtr;
@@ -1057,47 +1058,45 @@ static nsresult pref_InitInitialObjects(
     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?");
   }
 
-  if (!mozilla::Omnijar::HasOmnijar(mozilla::Omnijar::APP)) {
-    // Load $gre/defaults/pref/*.js
-    nsCOMPtr<nsIFile> defaultPrefDir;
+  // Load $gre/defaults/pref/*.js
+  nsCOMPtr<nsIFile> defaultPrefDir;
 
-    rv = NS_GetSpecialDirectory(NS_APP_PREF_DEFAULTS_50_DIR, getter_AddRefs(defaultPrefDir));
-    NS_ENSURE_SUCCESS(rv, rv);
+  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[] = {
+  /* 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_MACOSX)
-      "macprefs.js"
+    "macprefs.js"
 #elif defined(XP_WIN)
-      "winpref.js"
+    "winpref.js"
 #elif defined(XP_UNIX)
-      "unix.js"
+    "unix.js"
 #if defined(VMS)
-      , "openvms.js"
+    , "openvms.js"
 #elif defined(_AIX)
-      , "aix.js"
+    , "aix.js"
 #endif
 #elif defined(XP_OS2)
-      "os2pref.js"
+    "os2pref.js"
 #elif defined(XP_BEOS)
-      "beos.js"
+    "beos.js"
 #endif
-    };
+  };
 
-    rv = pref_LoadPrefsInDir(defaultPrefDir, specialFiles, NS_ARRAY_LENGTH(specialFiles));
-    if (NS_FAILED(rv))
-      NS_WARNING("Error parsing application default preferences.");
-  }
+  rv = pref_LoadPrefsInDir(defaultPrefDir, specialFiles, NS_ARRAY_LENGTH(specialFiles));
+  if (NS_FAILED(rv))
+    NS_WARNING("Error parsing application default preferences.");
 
   // Load jar:$app/omni.jar!/defaults/preferences/*.js
   nsZipArchive *appJarReader = mozilla::Omnijar::GetReader(mozilla::Omnijar::APP);
   if (appJarReader) {
     rv = appJarReader->FindInit("defaults/preferences/*.js$", &findPtr);
     NS_ENSURE_SUCCESS(rv, rv);
     find = findPtr;
     prefEntries.Clear();