Bug 842334 - Move distribution/ back to the installation directory. r=bsmedberg,r=gavin,a=bajaj
authorMike Hommey <mh+mozilla@glandium.org>
Sat, 11 May 2013 20:14:58 +0200
changeset 137592 4186cd858b7d4f6a9c3dc9ec048a354f8c7f0ad6
parent 137591 581ea0e6531e9770d8d641cac00b55cb9d296f30
child 137593 e2a1e083e069cb4254974cd6c6541d2b5835ee01
push id2452
push userlsblakk@mozilla.com
push dateMon, 13 May 2013 16:59:38 +0000
treeherdermozilla-beta@d4b152d29d8d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg, gavin, bajaj
bugs842334
milestone22.0a2
Bug 842334 - Move distribution/ back to the installation directory. r=bsmedberg,r=gavin,a=bajaj
browser/components/dirprovider/DirectoryProvider.cpp
browser/components/distribution.js
browser/components/places/tests/unit/test_browserGlue_distribution.js
toolkit/xre/nsXREDirProvider.cpp
--- a/browser/components/dirprovider/DirectoryProvider.cpp
+++ b/browser/components/dirprovider/DirectoryProvider.cpp
@@ -130,22 +130,22 @@ AppendFileKey(const char *key, nsIProper
 // directory for the current locale, there is a pref:
 // "distribution.searchplugins.defaultLocale"
 // which specifies a default locale to use.
 
 static void
 AppendDistroSearchDirs(nsIProperties* aDirSvc, nsCOMArray<nsIFile> &array)
 {
   nsCOMPtr<nsIFile> searchPlugins;
-  nsresult rv = aDirSvc->Get(NS_XPCOM_CURRENT_PROCESS_DIR,
+  nsresult rv = aDirSvc->Get(XRE_EXECUTABLE_FILE,
                              NS_GET_IID(nsIFile),
                              getter_AddRefs(searchPlugins));
   if (NS_FAILED(rv))
     return;
-  searchPlugins->AppendNative(NS_LITERAL_CSTRING("distribution"));
+  searchPlugins->SetNativeLeafName(NS_LITERAL_CSTRING("distribution"));
   searchPlugins->AppendNative(NS_LITERAL_CSTRING("searchplugins"));
 
   bool exists;
   rv = searchPlugins->Exists(&exists);
   if (NS_FAILED(rv) || !exists)
     return;
 
   nsCOMPtr<nsIFile> commonPlugins;
--- a/browser/components/distribution.js
+++ b/browser/components/distribution.js
@@ -14,18 +14,18 @@ const DISTRIBUTION_CUSTOMIZATION_COMPLET
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
                                   "resource://gre/modules/PlacesUtils.jsm");
 
 this.DistributionCustomizer = function DistributionCustomizer() {
   let dirSvc = Cc["@mozilla.org/file/directory_service;1"].
                getService(Ci.nsIProperties);
-  let iniFile = dirSvc.get("XCurProcD", Ci.nsIFile);
-  iniFile.append("distribution");
+  let iniFile = dirSvc.get("XREExeF", Ci.nsIFile);
+  iniFile.leafName = "distribution";
   iniFile.append("distribution.ini");
   if (iniFile.exists())
     this._iniFile = iniFile;
 }
 
 DistributionCustomizer.prototype = {
   _iniFile: null,
 
--- a/browser/components/places/tests/unit/test_browserGlue_distribution.js
+++ b/browser/components/places/tests/unit/test_browserGlue_distribution.js
@@ -13,18 +13,18 @@ const TOPICDATA_DISTRIBUTION_CUSTOMIZATI
 const TOPIC_CUSTOMIZATION_COMPLETE = "distribution-customization-complete";
 const TOPIC_BROWSERGLUE_TEST = "browser-glue-test";
 
 function run_test()
 {
   do_test_pending();
 
   // Copy distribution.ini file to our app dir.
-  let distroDir = Services.dirsvc.get("XCurProcD", Ci.nsIFile);
-  distroDir.append("distribution");
+  let distroDir = Services.dirsvc.get("XREExeF", Ci.nsIFile);
+  distroDir.leafName = "distribution";
   let iniFile = distroDir.clone();
   iniFile.append("distribution.ini");
   if (iniFile.exists()) {
     iniFile.remove(false);
     print("distribution.ini already exists, did some test forget to cleanup?");
   }
   let testDistributionFile = gTestDir.clone();
   testDistributionFile.append("distribution.ini");
@@ -89,15 +89,15 @@ function onCustomizationComplete()
   do_check_eq(Services.prefs.getCharPref(PREF_DISTRIBUTION_ID), "516444");
 
   do_test_finished();
 }
 
 do_register_cleanup(function() {
   // Remove the distribution file, even if the test failed, otherwise all
   // next tests will import it.
-  let iniFile = Services.dirsvc.get("XCurProcD", Ci.nsIFile);
-  iniFile.append("distribution");
+  let iniFile = Services.dirsvc.get("XREExeF", Ci.nsIFile);
+  iniFile.leafName = "distribution";
   iniFile.append("distribution.ini");
   if (iniFile.exists())
     iniFile.remove(false);
   do_check_false(iniFile.exists());
 });
--- a/toolkit/xre/nsXREDirProvider.cpp
+++ b/toolkit/xre/nsXREDirProvider.cpp
@@ -368,19 +368,20 @@ nsXREDirProvider::GetFile(const char* aP
   else if (!strcmp(aProperty, XRE_USER_SYS_EXTENSION_DIR)) {
 #ifdef ENABLE_SYSTEM_EXTENSION_DIRS
     return GetSysUserExtensionsDirectory(aFile);
 #else
     return NS_ERROR_FAILURE;
 #endif
   }
   else if (!strcmp(aProperty, XRE_APP_DISTRIBUTION_DIR)) {
-    rv = GetAppDir()->Clone(getter_AddRefs(file));
+    bool persistent = false;
+    rv = GetFile(XRE_EXECUTABLE_FILE, &persistent, getter_AddRefs(file));
     if (NS_SUCCEEDED(rv))
-      rv = file->AppendNative(NS_LITERAL_CSTRING("distribution"));
+      rv = file->SetNativeLeafName(NS_LITERAL_CSTRING("distribution"));
   }
   else if (NS_SUCCEEDED(GetProfileStartupDir(getter_AddRefs(file)))) {
     // We need to allow component, xpt, and chrome registration to
     // occur prior to the profile-after-change notification.
     if (!strcmp(aProperty, NS_APP_USER_CHROME_DIR)) {
       rv = file->AppendNative(NS_LITERAL_CSTRING("chrome"));
     }
   }
@@ -606,21 +607,22 @@ nsXREDirProvider::LoadExtensionBundleDir
                              NS_SKIN_LOCATION);
   }
 }
 
 void
 nsXREDirProvider::LoadAppBundleDirs()
 {
   nsCOMPtr<nsIFile> dir;
-  nsresult rv = mXULAppDir->Clone(getter_AddRefs(dir));
+  bool persistent = false;
+  nsresult rv = GetFile(XRE_EXECUTABLE_FILE, &persistent, getter_AddRefs(dir));
   if (NS_FAILED(rv))
     return;
 
-  dir->AppendNative(NS_LITERAL_CSTRING("distribution"));
+  dir->SetNativeLeafName(NS_LITERAL_CSTRING("distribution"));
   dir->AppendNative(NS_LITERAL_CSTRING("bundles"));
 
   nsCOMPtr<nsISimpleEnumerator> e;
   rv = dir->GetDirectoryEntries(getter_AddRefs(e));
   if (NS_FAILED(rv))
     return;
 
   nsCOMPtr<nsIDirectoryEnumerator> files = do_QueryInterface(e);