bug 746156 - isolate webapp runtime files into subdirectory of Firefox package; r=bsmedberg, a=akeybl
authorMyk Melez <myk@mozilla.org>
Thu, 19 Apr 2012 00:39:52 -0700
changeset 95266 e9e62564ab349a1c94376bce085ab807baff078f
parent 95265 7a227bcb5bdee5d018c0953b9fdd1042ac5e95cd
child 95267 ee38392142edd0298275dba2273ffc2713c92bdb
child 95270 01cf4fb5a8c324853c5f1ab8fd00c15c35944b08
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg, akeybl
bugs746156
milestone14.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 746156 - isolate webapp runtime files into subdirectory of Firefox package; r=bsmedberg, a=akeybl
browser/installer/package-manifest.in
browser/locales/Makefile.in
config/rules.mk
js/src/config/rules.mk
modules/libpref/src/Preferences.cpp
toolkit/locales/l10n.mk
toolkit/mozapps/installer/Packager.pm
toolkit/mozapps/installer/packager.mk
toolkit/mozapps/installer/windows/nsis/makensis.mk
toolkit/xre/nsXREDirProvider.cpp
webapprt/CommandLineHandler.js
webapprt/DirectoryProvider.js
webapprt/Makefile.in
webapprt/WebappRTCommandLineHandler.js
webapprt/WebappRTComponents.manifest
webapprt/WebappRTDirectoryProvider.js
webapprt/application.ini.in
webapprt/components.manifest
webapprt/content/webapp.js
webapprt/jar.mn
webapprt/mac/webapprt.mm
webapprt/prefs.js
webapprt/webapprt.ini.in
webapprt/win/Makefile.in
webapprt/win/webapprt.cpp
xpfe/appshell/src/nsAppShellService.cpp
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -498,19 +498,16 @@
 ; [Default Preferences]
 ; All the pref files must be part of base to prevent migration bugs
 @BINPATH@/@PREF_DIR@/firefox.js
 @BINPATH@/@PREF_DIR@/firefox-branding.js
 @BINPATH@/@PREF_DIR@/channel-prefs.js
 #ifdef MOZ_SERVICES_SYNC
 @BINPATH@/@PREF_DIR@/services-sync.js
 #endif
-#ifdef MOZ_WEBAPP_RUNTIME
-@BINPATH@/@PREF_DIR@/webapprt@mozilla.org/prefs.js
-#endif
 @BINPATH@/greprefs.js
 @BINPATH@/defaults/autoconfig/platform.js
 @BINPATH@/defaults/autoconfig/prefcalls.js
 @BINPATH@/defaults/profile/prefs.js
 
 ; [Layout Engine Resources]
 ; Style Sheets, Graphics and other Resources used by the layout engine. 
 @BINPATH@/res/EditorOverride.css
@@ -624,17 +621,20 @@ bin/components/@DLL_PREFIX@nkgnomevfs@DL
 ; [OS/2]
 #ifdef XP_OS2
 @BINPATH@/MozSounds.cmd
 @BINPATH@/*.xqs
 @BINPATH@/components/*.xqs
 #endif
 
 #ifdef MOZ_WEBAPP_RUNTIME
-; [Webapp Runtime]
+[WebappRuntime]
 @BINPATH@/webapprt-stub@BIN_SUFFIX@
-@BINPATH@/chrome/webapprt@JAREXT@
-@BINPATH@/chrome/webapprt.manifest
-@BINPATH@/components/WebappRTComponents.manifest
-@BINPATH@/components/WebappRTDirectoryProvider.js
-@BINPATH@/components/WebappRTCommandLineHandler.js
-@BINPATH@/webapprt.ini
+@BINPATH@/webapprt/application.ini
+@BINPATH@/webapprt/chrome.manifest
+@BINPATH@/webapprt/chrome/webapprt@JAREXT@
+@BINPATH@/webapprt/chrome/webapprt.manifest
+@BINPATH@/webapprt/components/CommandLineHandler.js
+@BINPATH@/webapprt/components/DirectoryProvider.js
+@BINPATH@/webapprt/components/components.manifest
+@BINPATH@/webapprt/defaults/preferences/prefs.js
+@BINPATH@/webapprt/modules/WebappRT.jsm
 #endif
--- a/browser/locales/Makefile.in
+++ b/browser/locales/Makefile.in
@@ -206,17 +206,17 @@ repackage-win32-installer-%:
 else
 repackage-win32-installer-%: ;
 endif
 
 
 clobber-zip:
 	$(RM) $(STAGEDIST)/chrome/$(AB_CD).jar \
 	  $(STAGEDIST)/chrome/$(AB_CD).manifest \
-	  $(STAGEDIST)/defaults/pref/firefox-l10n.js
+	  $(STAGEDIST)/$(PREF_DIR)/firefox-l10n.js
 	$(RM) -rf  $(STAGEDIST)/searchplugins \
 	  $(STAGEDIST)/dictionaries \
 	  $(STAGEDIST)/hyphenation \
 	  $(STAGEDIST)/defaults/profile \
 	  $(STAGEDIST)/chrome/$(AB_CD)
 
 
 langpack: langpack-$(AB_CD)
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -1366,17 +1366,17 @@ endef
 $(foreach namespace,$(EXPORTS_NAMESPACES),$(eval $(EXPORT_NAMESPACE_RULE)))
 
 ################################################################################
 # Copy each element of PREF_JS_EXPORTS
 
 ifdef GRE_MODULE
 PREF_DIR = greprefs
 else
-ifneq (,$(XPI_NAME)$(LIBXUL_SDK))
+ifneq (,$(XPI_NAME)$(LIBXUL_SDK)$(MOZ_PHOENIX))
 PREF_DIR = defaults/preferences
 else
 PREF_DIR = defaults/pref
 endif
 endif
 
 ifneq ($(PREF_JS_EXPORTS),)
 # on win32, pref files need CRLF line endings... see bug 206029
--- a/js/src/config/rules.mk
+++ b/js/src/config/rules.mk
@@ -1366,17 +1366,17 @@ endef
 $(foreach namespace,$(EXPORTS_NAMESPACES),$(eval $(EXPORT_NAMESPACE_RULE)))
 
 ################################################################################
 # Copy each element of PREF_JS_EXPORTS
 
 ifdef GRE_MODULE
 PREF_DIR = greprefs
 else
-ifneq (,$(XPI_NAME)$(LIBXUL_SDK))
+ifneq (,$(XPI_NAME)$(LIBXUL_SDK)$(MOZ_PHOENIX))
 PREF_DIR = defaults/preferences
 else
 PREF_DIR = defaults/pref
 endif
 endif
 
 ifneq ($(PREF_JS_EXPORTS),)
 # on win32, pref files need CRLF line endings... see bug 206029
--- a/modules/libpref/src/Preferences.cpp
+++ b/modules/libpref/src/Preferences.cpp
@@ -38,17 +38,16 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "mozilla/dom/ContentChild.h"
 
 #include "mozilla/Util.h"
 #include "mozilla/HashFunctions.h"
 
 #include "nsXULAppAPI.h"
-#include "nsIXULAppInfo.h"
 
 #include "mozilla/Preferences.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsICategoryManager.h"
 #include "nsCategoryManagerUtils.h"
 #include "nsNetUtil.h"
 #include "nsIFile.h"
@@ -80,18 +79,16 @@
 #include "nsRefPtrHashtable.h"
 
 namespace mozilla {
 
 // Definitions
 #define INITIAL_PREF_FILES 10
 static NS_DEFINE_CID(kZipReaderCID, NS_ZIPREADER_CID);
 
-#define WEBAPPRT_APPID "webapprt@mozilla.org"
-
 // Prototypes
 static nsresult openPrefFile(nsIFile* aFile);
 static nsresult pref_InitInitialObjects(void);
 static nsresult pref_LoadPrefsInDirList(const char *listId);
 static nsresult ReadExtensionPrefs(nsIFile *aFile);
 
 Preferences* Preferences::sPreferences = nsnull;
 nsIPrefBranch* Preferences::sRootBranch = nsnull;
@@ -856,17 +853,17 @@ pref_LoadPrefsInDir(nsIFile* aDir, char 
 
   nsCOMPtr<nsISimpleEnumerator> dirIterator;
 
   // this may fail in some normal cases, such as embedders who do not use a GRE
   rv = aDir->GetDirectoryEntries(getter_AddRefs(dirIterator));
   if (NS_FAILED(rv)) {
     // If the directory doesn't exist, then we have no reason to complain.  We
     // loaded everything (and nothing) successfully.
-    if (rv == NS_ERROR_FILE_NOT_FOUND)
+    if (rv == NS_ERROR_FILE_NOT_FOUND || rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST)
       rv = NS_OK;
     return rv;
   }
 
   rv = dirIterator->HasMoreElements(&hasMoreElements);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMArray<nsIFile> prefFiles(INITIAL_PREF_FILES);
@@ -1013,24 +1010,20 @@ static nsresult pref_InitInitialObjects(
   // 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
-  //
-  // When we're running WebappRT (i.e. $app == WEBAPPRT_APPID), in omni.jar
-  // case, we also load:
-  // - jar:$gre/omni.jar!/defaults/pref/$WEBAPPRT_APPID/*.js
-  // This allows WebappRT-specific prefs to override those of another app
-  // with whom it shares an app dir (i.e. Firefox).
-  // (A $WEBAPPRT_APPID dir is similarly hardcoded into the app pref dir list
-  // in nsXREDirProvider for when we're running WebappRT in non omni.jar case.)
+  // When $app == $gre, we additionally load, in omni.jar case:
+  // - jar:$gre/omni.jar!/defaults/preferences/*.js
+  // Thus, in omni.jar case, we always load app-specific default preferences
+  // from omni.jar, whether or not $app == $gre.
 
   nsZipFind *findPtr;
   nsAutoPtr<nsZipFind> find;
   nsTArray<nsCString> prefEntries;
   const char *entryName;
   PRUint16 entryNameLen;
 
   nsRefPtr<nsZipArchive> jarReader = mozilla::Omnijar::GetReader(mozilla::Omnijar::GRE);
@@ -1044,40 +1037,16 @@ static nsresult pref_InitInitialObjects(
     NS_ENSURE_SUCCESS(rv, rv);
 
     find = findPtr;
     while (NS_SUCCEEDED(find->FindNext(&entryName, &entryNameLen))) {
       prefEntries.AppendElement(Substring(entryName, entryNameLen));
     }
 
     prefEntries.Sort();
-
-    // Load jar:$gre/omni.jar!/defaults/pref/$WEBAPPRT_APPID/*.js
-    // if we're running WebappRT.
-    nsCOMPtr<nsIXULAppInfo> appInfo =
-      do_GetService("@mozilla.org/xre/app-info;1", &rv);
-    if (NS_SUCCEEDED(rv)) {
-      nsCAutoString appID;
-      if (NS_SUCCEEDED(appInfo->GetID(appID)) && appID.Equals(WEBAPPRT_APPID)) {
-        nsCAutoString prefsPath("defaults/pref/");
-        prefsPath.Append(appID);
-        prefsPath.AppendLiteral("/*.js$");
-        rv = jarReader->FindInit(prefsPath.get(), &findPtr);
-        NS_ENSURE_SUCCESS(rv, rv);
-
-        // Make sure the files get read last by putting them at the beginning
-        // of the list of pref entries (which is processed backwards), so prefs
-        // in these app-specific files override those in non-app-specific ones.
-        find = findPtr;
-        while (NS_SUCCEEDED(find->FindNext(&entryName, &entryNameLen))) {
-          prefEntries.InsertElementAt(0, Substring(entryName, entryNameLen));
-        }
-      }
-    }
-
     for (PRUint32 i = prefEntries.Length(); i--; ) {
       rv = pref_ReadPrefFromJar(jarReader, prefEntries[i].get());
       if (NS_FAILED(rv))
         NS_WARNING("Error parsing preferences.");
     }
   } else {
     // Load $gre/greprefs.js
     nsCOMPtr<nsIFile> greprefsFile;
@@ -1118,17 +1087,22 @@ static nsresult pref_InitInitialObjects(
 #endif
   };
 
   rv = pref_LoadPrefsInDir(defaultPrefDir, specialFiles, ArrayLength(specialFiles));
   if (NS_FAILED(rv))
     NS_WARNING("Error parsing application default preferences.");
 
   // Load jar:$app/omni.jar!/defaults/preferences/*.js
+  // or jar:$gre/omni.jar!/defaults/preferences/*.js.
   nsRefPtr<nsZipArchive> appJarReader = mozilla::Omnijar::GetReader(mozilla::Omnijar::APP);
+  // GetReader(mozilla::Omnijar::APP) returns null when $app == $gre, in which
+  // case we look for app-specific default preferences in $gre.
+  if (!appJarReader)
+    appJarReader = mozilla::Omnijar::GetReader(mozilla::Omnijar::GRE);
   if (appJarReader) {
     rv = appJarReader->FindInit("defaults/preferences/*.js$", &findPtr);
     NS_ENSURE_SUCCESS(rv, rv);
     find = findPtr;
     prefEntries.Clear();
     while (NS_SUCCEEDED(find->FindNext(&entryName, &entryNameLen))) {
       prefEntries.AppendElement(Substring(entryName, entryNameLen));
     }
--- a/toolkit/locales/l10n.mk
+++ b/toolkit/locales/l10n.mk
@@ -167,16 +167,19 @@ endif
 # packaging done, undo l10n stuff
 ifneq (en,$(AB))
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 	mv $(_ABS_DIST)/l10n-stage/$(MOZ_PKG_DIR)/$(_APPNAME)/Contents/Resources/$(AB).lproj $(_ABS_DIST)/l10n-stage/$(MOZ_PKG_DIR)/$(_APPNAME)/Contents/Resources/en.lproj
 endif
 endif
 ifdef MOZ_OMNIJAR
 	@(cd $(STAGEDIST) && $(UNPACK_OMNIJAR))
+ifdef MOZ_WEBAPP_RUNTIME
+	@(cd $(STAGEDIST)/webapprt && $(UNPACK_OMNIJAR_WEBAPP_RUNTIME))
+endif
 endif
 	$(MAKE) clobber-zip AB_CD=$(AB_CD)
 	$(NSINSTALL) -D $(DIST)/$(PKG_PATH)
 	mv -f "$(DIST)/l10n-stage/$(PACKAGE)" "$(ZIP_OUT)"
 	if test -f "$(DIST)/l10n-stage/$(PACKAGE).asc"; then mv -f "$(DIST)/l10n-stage/$(PACKAGE).asc" "$(ZIP_OUT).asc"; fi
 
 repackage-zip-%: $(STAGEDIST)
 	@$(MAKE) repackage-zip AB_CD=$* ZIP_IN="$(ZIP_IN)"
--- a/toolkit/mozapps/installer/Packager.pm
+++ b/toolkit/mozapps/installer/Packager.pm
@@ -229,17 +229,20 @@ sub do_copyfile
     return;
   }
   else {
     ($debug >= 10) && print " '$srcpath$srcname$srcsuffix' is not a directory\n";
   }
 
   # set the destination path, if alternate destination given, use it.
   if ($flat) {
-    if ($srcsuffix eq ".manifest" && $srcpath =~ m'/(chrome|components)/$') {
+    # WebappRuntime has manifests that shouldn't be flattened, even though it
+    # gets packaged with Firefox, which does get flattened, so special-case it.
+    if ($srcsuffix eq ".manifest" && $srcpath =~ m'/(chrome|components)/$' &&
+        $component ne "WebappRuntime") {
       my $subdir = $1;
       if ($component eq "") {
         die ("Manifest file was not part of a component.");
       }
 
       $destpathcomp = "$srcdir/manifests/$component/$subdir";
       $altdest = "$srcname$srcsuffix";
     }
--- a/toolkit/mozapps/installer/packager.mk
+++ b/toolkit/mozapps/installer/packager.mk
@@ -542,23 +542,44 @@ UNPACK_OMNIJAR	= \
   $(OPTIMIZE_JARS_CMD) --deoptimize $(JARLOG_DIR_AB_CD) ./ ./ && \
   $(UNZIP) -o $(OMNIJAR_NAME) && \
   rm -f components/binary.manifest && \
   for m in components/*.manifest; do \
     sed -e 's/^\#binary-component/binary-component/' $$m > tmp.manifest && \
     mv tmp.manifest $$m; \
   done
 
+ifdef MOZ_WEBAPP_RUNTIME
+# It's simpler to pack the webapp runtime, because it doesn't have any
+# binary components.  We also don't pre-generate the startup cache, which seems
+# unnecessary, given the small size of the runtime, although it might become
+# more valuable over time.
+PACK_OMNIJAR_WEBAPP_RUNTIME	= \
+  rm -f $(OMNIJAR_NAME); \
+  $(ZIP) -r9m $(OMNIJAR_NAME) $(OMNIJAR_FILES) -x $(NON_OMNIJAR_FILES) && \
+  $(OPTIMIZE_JARS_CMD) --optimize $(JARLOG_DIR_AB_CD) ./ ./
+UNPACK_OMNIJAR_WEBAPP_RUNTIME	= \
+  $(OPTIMIZE_JARS_CMD) --deoptimize $(JARLOG_DIR_AB_CD) ./ ./ && \
+  $(UNZIP) -o $(OMNIJAR_NAME)
+
+PREPARE_PACKAGE	= (cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH) && $(PACK_OMNIJAR)) && \
+	              (cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/webapprt && $(PACK_OMNIJAR_WEBAPP_RUNTIME)) && \
+	              (cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH) && $(CREATE_PRECOMPLETE_CMD))
+UNMAKE_PACKAGE	= $(INNER_UNMAKE_PACKAGE) && \
+	              (cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH) && $(UNPACK_OMNIJAR)) && \
+	              (cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/webapprt && $(UNPACK_OMNIJAR_WEBAPP_RUNTIME))
+else # ndef MOZ_WEBAPP_RUNTIME
 PREPARE_PACKAGE	= (cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH) && $(PACK_OMNIJAR)) && \
 	              (cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH) && $(CREATE_PRECOMPLETE_CMD))
 UNMAKE_PACKAGE	= $(INNER_UNMAKE_PACKAGE) && (cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH) && $(UNPACK_OMNIJAR))
-else
+endif # def MOZ_WEBAPP_RUNTIME
+else # ndef MOZ_OMNIJAR
 PREPARE_PACKAGE	= (cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH) && $(CREATE_PRECOMPLETE_CMD))
 UNMAKE_PACKAGE	= $(INNER_UNMAKE_PACKAGE)
-endif
+endif # def MOZ_OMNIJAR
 
 ifdef MOZ_INTERNAL_SIGNING_FORMAT
 MOZ_SIGN_PREPARED_PACKAGE_CMD=$(MOZ_SIGN_CMD) $(foreach f,$(MOZ_INTERNAL_SIGNING_FORMAT),-f $(f)) $(foreach i,$(SIGN_INCLUDES),-i $(i)) $(foreach x,$(SIGN_EXCLUDES),-x $(x)) --nsscmd "$(SIGN_CMD)"
 endif
 
 # For final GPG / authenticode signing / dmg signing if required
 ifdef MOZ_EXTERNAL_SIGNING_FORMAT
 MOZ_SIGN_PACKAGE_CMD=$(MOZ_SIGN_CMD) $(foreach f,$(MOZ_EXTERNAL_SIGNING_FORMAT),-f $(f))
@@ -715,16 +736,19 @@ installer-stage: stage-package
 ifndef MOZ_PKG_MANIFEST
 	$(error MOZ_PKG_MANIFEST unspecified!)
 endif
 	@rm -rf $(DEPTH)/installer-stage $(DIST)/xpt
 	@echo "Staging installer files..."
 	@$(NSINSTALL) -D $(DEPTH)/installer-stage/core
 ifdef MOZ_OMNIJAR
 	@(cd $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH) && $(PACK_OMNIJAR))
+ifdef MOZ_WEBAPP_RUNTIME
+	@(cd $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/webapprt && $(PACK_OMNIJAR_WEBAPP_RUNTIME))
+endif
 endif
 	@cp -av $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/. $(DEPTH)/installer-stage/core
 	@(cd $(DEPTH)/installer-stage/core && $(CREATE_PRECOMPLETE_CMD))
 ifdef MOZ_OPTIONAL_PKG_LIST
 	@$(NSINSTALL) -D $(DEPTH)/installer-stage/optional
 	$(call PACKAGER_COPY, "$(call core_abspath,$(DIST))",\
 	  "$(call core_abspath,$(DEPTH)/installer-stage/optional)", \
 	  "$(MOZ_PKG_MANIFEST)", "$(PKGCP_OS)", 1, 0, 1 \
@@ -868,16 +892,19 @@ install:: stage-package
 ifeq ($(OS_ARCH),WINNT)
 	$(error "make install" is not supported on this platform. Use "make package" instead.)
 endif
 ifeq (bundle,$(MOZ_FS_LAYOUT))
 	$(error "make install" is not supported on this platform. Use "make package" instead.)
 endif
 ifdef MOZ_OMNIJAR
 	cd $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH) && $(PACK_OMNIJAR)
+ifdef MOZ_WEBAPP_RUNTIME
+	cd $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/webapprt && $(PACK_OMNIJAR_WEBAPP_RUNTIME))
+endif
 endif
 	$(NSINSTALL) -D $(DESTDIR)$(installdir)
 	(cd $(DIST)/$(MOZ_PKG_DIR) && tar $(TAR_CREATE_FLAGS) - .) | \
 	  (cd $(DESTDIR)$(installdir) && tar -xf -)
 	$(NSINSTALL) -D $(DESTDIR)$(bindir)
 	$(RM) -f $(DESTDIR)$(bindir)/$(MOZ_APP_NAME)
 	ln -s $(installdir)/$(MOZ_APP_NAME) $(DESTDIR)$(bindir)
 ifdef INSTALL_SDK # Here comes the hard part
--- a/toolkit/mozapps/installer/windows/nsis/makensis.mk
+++ b/toolkit/mozapps/installer/windows/nsis/makensis.mk
@@ -108,11 +108,11 @@ maintenanceservice_installer::
 	cp $(CONFIG_DIR)/maintenanceservice_installer.exe $(DIST)/bin
 endif
 
 ifdef MOZ_WEBAPP_RUNTIME
 webapp_uninstaller::
 	$(INSTALL) $(addprefix $(MOZILLA_DIR)/toolkit/mozapps/installer/windows/nsis/,$(TOOLKIT_NSIS_FILES)) $(CONFIG_DIR)
 	$(INSTALL) $(addprefix $(MOZILLA_DIR)/other-licenses/nsis/Plugins/,$(CUSTOM_NSIS_PLUGINS)) $(CONFIG_DIR)
 	cd $(CONFIG_DIR) && $(MAKENSISU) webapp-uninstaller.nsi
-	$(NSINSTALL) -D $(DIST)/bin/
-	cp $(CONFIG_DIR)/webapp-uninstaller.exe $(DIST)/bin
+	$(NSINSTALL) -D $(FINAL_TARGET)
+	cp $(CONFIG_DIR)/webapp-uninstaller.exe $(FINAL_TARGET)
 endif
--- a/toolkit/xre/nsXREDirProvider.cpp
+++ b/toolkit/xre/nsXREDirProvider.cpp
@@ -94,18 +94,16 @@
 #elif defined(XP_WIN) || defined(XP_OS2)
 #define APP_REGISTRY_NAME "registry.dat"
 #else
 #define APP_REGISTRY_NAME "appreg"
 #endif
 
 #define PREF_OVERRIDE_DIRNAME "preferences"
 
-#define WEBAPPRT_APPID "webapprt@mozilla.org"
-
 static already_AddRefed<nsILocalFile>
 CloneAndAppend(nsIFile* aFile, const char* name)
 {
   nsCOMPtr<nsIFile> file;
   aFile->Clone(getter_AddRefs(file));
   nsCOMPtr<nsILocalFile> lfile = do_QueryInterface(file);
   lfile->AppendNative(nsDependentCString(name));
   return lfile.forget();
@@ -645,23 +643,16 @@ nsXREDirProvider::GetFilesInternal(const
   }
   else if (!strcmp(aProperty, NS_APP_PREFS_DEFAULTS_DIR_LIST)) {
     nsCOMArray<nsIFile> directories;
 
     LoadDirIntoArray(mXULAppDir, kAppendPrefDir, directories);
     LoadDirsIntoArray(mAppBundleDirectories,
                       kAppendPrefDir, directories);
 
-    // Include the WebappRT-specific prefs dir if we're running WebappRT.
-    if (gAppData && !strcmp(gAppData->ID, WEBAPPRT_APPID)) {
-      const char *const kAppendAppIDPrefDir[] =
-        { "defaults", "pref", gAppData->ID, nsnull };
-      LoadDirIntoArray(mXULAppDir, kAppendAppIDPrefDir, directories);
-    }
-
     rv = NS_NewArrayEnumerator(aResult, directories);
   }
   else if (!strcmp(aProperty, NS_EXT_PREFS_DEFAULTS_DIR_LIST)) {
     nsCOMArray<nsIFile> directories;
 
     LoadDirsIntoArray(mExtensionDirectories,
                       kAppendPrefDir, directories);
 
new file mode 100644
--- /dev/null
+++ b/webapprt/CommandLineHandler.js
@@ -0,0 +1,31 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+const Cu = Components.utils;
+
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+Cu.import("resource://gre/modules/Services.jsm");
+
+function CommandLineHandler() {}
+
+CommandLineHandler.prototype = {
+  classID: Components.ID("{6d69c782-40a3-469b-8bfd-3ee366105a4a}"),
+
+  QueryInterface: XPCOMUtils.generateQI([Ci.nsICommandLineHandler]),
+
+  handle: function handle(cmdLine) {
+    Services.ww.openWindow(null,
+                           "chrome://webapprt/content/webapp.xul",
+                           "_blank",
+                           "chrome,dialog=no,all,resizable",
+                           null);
+  },
+
+  helpInfo : "",
+};
+
+let components = [CommandLineHandler];
+let NSGetFactory = XPCOMUtils.generateNSGetFactory(components);
new file mode 100644
--- /dev/null
+++ b/webapprt/DirectoryProvider.js
@@ -0,0 +1,55 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+const Cu = Components.utils;
+
+const WEBAPP_REGISTRY_DIR = "WebappRegD";
+const NS_APP_CHROME_DIR_LIST = "AChromDL";
+
+Cu.import("resource://gre/modules/FileUtils.jsm");
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+Cu.import("resource://webapprt/modules/WebappRT.jsm");
+
+function DirectoryProvider() {}
+
+DirectoryProvider.prototype = {
+  classID: Components.ID("{e1799fda-4b2f-4457-b671-e0641d95698d}"),
+
+  QueryInterface: XPCOMUtils.generateQI([Ci.nsIDirectoryServiceProvider,
+                                         Ci.nsIDirectoryServiceProvider2]),
+
+  getFile: function(prop, persistent) {
+    if (prop == WEBAPP_REGISTRY_DIR) {
+      let dir = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
+      dir.initWithPath(WebappRT.config.registryDir);
+      return dir;
+    }
+
+    // We return null to show failure instead of throwing an error,
+    // which works with the way the interface is called (per bug 529077).
+    return null;
+  },
+
+  getFiles: function(prop, persistent) {
+    if (prop == NS_APP_CHROME_DIR_LIST) {
+      return {
+        _done: false,
+        QueryInterface: XPCOMUtils.generateQI([Ci.nsISimpleEnumerator]),
+        hasMoreElements: function() {
+          return !this._done;
+        },
+        getNext: function() {
+          this._done = true;
+          return FileUtils.getDir("AppRegD", ["chrome"], false);
+        }
+      };
+    }
+
+    return null;
+  },
+};
+
+const NSGetFactory = XPCOMUtils.generateNSGetFactory([DirectoryProvider]);
--- a/webapprt/Makefile.in
+++ b/webapprt/Makefile.in
@@ -4,45 +4,52 @@
 
 DEPTH     = ..
 topsrcdir = @top_srcdir@
 srcdir    = @srcdir@
 VPATH     = @srcdir@
 
 include $(topsrcdir)/config/config.mk
 
+# config.mk sets FINAL_TARGET to $(DIST)/bin, but we want to copy build products
+# into a WebappRT-specific subdirectory, so we redefine it here.
+FINAL_TARGET = $(DIST)/bin/webapprt
+
 DIRS = $(NULL)
 
 ifneq (,$(filter WINNT,$(OS_ARCH)))
 DIRS += win
 else
 ifeq ($(OS_ARCH),Darwin)
 DIRS += mac
 endif # mac
 endif # windows
 
 EXTRA_PP_COMPONENTS = \
-  WebappRTComponents.manifest \
-  WebappRTCommandLineHandler.js \
-  WebappRTDirectoryProvider.js \
+  components.manifest \
+  CommandLineHandler.js \
+  DirectoryProvider.js \
   $(NULL)
 
 EXTRA_JS_MODULES = \
-	WebappRT.jsm \
-	$(NULL)
+  WebappRT.jsm \
+  $(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
+libs::
+	$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest "resource webapprt ./"
+
 libs:: prefs.js
-	$(NSINSTALL) -D $(DIST)/bin/defaults/pref/webapprt@mozilla.org
-	$(INSTALL) $^ $(DIST)/bin/defaults/pref/webapprt@mozilla.org
+	$(NSINSTALL) -D $(FINAL_TARGET)/defaults/preferences
+	$(INSTALL) $^ $(FINAL_TARGET)/defaults/preferences
 
 GRE_MILESTONE := $(shell tail -n 1 $(topsrcdir)/config/milestone.txt 2>/dev/null || tail -1 $(topsrcdir)/config/milestone.txt)
 GRE_BUILDID := $(shell cat $(DEPTH)/config/buildid)
 DEFINES += -DGRE_MILESTONE=$(GRE_MILESTONE) -DGRE_BUILDID=$(GRE_BUILDID)
 
-webapprt.ini: webapprt.ini.in $(DEPTH)/config/buildid $(topsrcdir)/config/milestone.txt
+application.ini: application.ini.in $(DEPTH)/config/buildid $(topsrcdir)/config/milestone.txt
 	$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $< > $@
 
-libs:: webapprt.ini
-	$(INSTALL) webapprt.ini $(DIST)/bin
+libs:: application.ini
+	$(INSTALL) application.ini $(FINAL_TARGET)
 
-GARBAGE += webapprt.ini
+GARBAGE += application.ini
deleted file mode 100644
--- a/webapprt/WebappRTCommandLineHandler.js
+++ /dev/null
@@ -1,31 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cu = Components.utils;
-
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-Cu.import("resource://gre/modules/Services.jsm");
-
-function CommandLineHandler() {}
-
-CommandLineHandler.prototype = {
-  classID: Components.ID("{6d69c782-40a3-469b-8bfd-3ee366105a4a}"),
-
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsICommandLineHandler]),
-
-  handle: function handle(cmdLine) {
-    Services.ww.openWindow(null,
-                           "chrome://webapprt/content/webapp.xul",
-                           "_blank",
-                           "chrome,dialog=no,all,resizable",
-                           null);
-  },
-
-  helpInfo : "",
-};
-
-let components = [CommandLineHandler];
-let NSGetFactory = XPCOMUtils.generateNSGetFactory(components);
deleted file mode 100644
--- a/webapprt/WebappRTComponents.manifest
+++ /dev/null
@@ -1,9 +0,0 @@
-# WebappRTCommandLineHandler.js
-component {6d69c782-40a3-469b-8bfd-3ee366105a4a} WebappRTCommandLineHandler.js application=webapprt@mozilla.org
-contract @mozilla.org/webapprt/clh;1 {6d69c782-40a3-469b-8bfd-3ee366105a4a} application=webapprt@mozilla.org
-category command-line-handler x-default @mozilla.org/webapprt/clh;1 application=webapprt@mozilla.org
-
-# WebappRTDirectoryProvider.js
-component {e1799fda-4b2f-4457-b671-e0641d95698d} WebappRTDirectoryProvider.js application=webapprt@mozilla.org
-contract @mozilla.org/webapprt/directory-provider;1 {e1799fda-4b2f-4457-b671-e0641d95698d} application=webapprt@mozilla.org
-category xpcom-directory-providers webapprt-directory-provider @mozilla.org/webapprt/directory-provider;1 application=webapprt@mozilla.org
deleted file mode 100644
--- a/webapprt/WebappRTDirectoryProvider.js
+++ /dev/null
@@ -1,55 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cu = Components.utils;
-
-const WEBAPP_REGISTRY_DIR = "WebappRegD";
-const NS_APP_CHROME_DIR_LIST = "AChromDL";
-
-Cu.import("resource://gre/modules/FileUtils.jsm");
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-Cu.import("resource://gre/modules/WebappRT.jsm");
-
-function DirectoryProvider() {}
-
-DirectoryProvider.prototype = {
-  classID: Components.ID("{e1799fda-4b2f-4457-b671-e0641d95698d}"),
-
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIDirectoryServiceProvider,
-                                         Ci.nsIDirectoryServiceProvider2]),
-
-  getFile: function(prop, persistent) {
-    if (prop == WEBAPP_REGISTRY_DIR) {
-      let dir = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
-      dir.initWithPath(WebappRT.config.registryDir);
-      return dir;
-    }
-
-    // We return null to show failure instead of throwing an error,
-    // which works with the way the interface is called (per bug 529077).
-    return null;
-  },
-
-  getFiles: function(prop, persistent) {
-    if (prop == NS_APP_CHROME_DIR_LIST) {
-      return {
-        _done: false,
-        QueryInterface: XPCOMUtils.generateQI([Ci.nsISimpleEnumerator]),
-        hasMoreElements: function() {
-          return !this._done;
-        },
-        getNext: function() {
-          this._done = true;
-          return FileUtils.getDir("AppRegD", ["chrome"], false);
-        }
-      };
-    }
-
-    return null;
-  },
-};
-
-const NSGetFactory = XPCOMUtils.generateNSGetFactory([DirectoryProvider]);
new file mode 100644
--- /dev/null
+++ b/webapprt/application.ini.in
@@ -0,0 +1,18 @@
+#if 0
+; This Source Code Form is subject to the terms of the Mozilla Public
+; License, v. 2.0. If a copy of the MPL was not distributed with this file,
+; You can obtain one at http://mozilla.org/MPL/2.0/.
+#endif
+
+#filter substitution
+
+[App]
+ID=webapprt@mozilla.org
+Vendor=Mozilla
+Name=Webapp Runtime
+Version=@GRE_MILESTONE@
+BuildID=@GRE_BUILDID@
+
+[Gecko]
+MinVersion=@GRE_MILESTONE@
+MaxVersion=@GRE_MILESTONE@
new file mode 100644
--- /dev/null
+++ b/webapprt/components.manifest
@@ -0,0 +1,9 @@
+# CommandLineHandler.js
+component {6d69c782-40a3-469b-8bfd-3ee366105a4a} CommandLineHandler.js application=webapprt@mozilla.org
+contract @mozilla.org/webapprt/clh;1 {6d69c782-40a3-469b-8bfd-3ee366105a4a} application=webapprt@mozilla.org
+category command-line-handler x-default @mozilla.org/webapprt/clh;1 application=webapprt@mozilla.org
+
+# DirectoryProvider.js
+component {e1799fda-4b2f-4457-b671-e0641d95698d} DirectoryProvider.js application=webapprt@mozilla.org
+contract @mozilla.org/webapprt/directory-provider;1 {e1799fda-4b2f-4457-b671-e0641d95698d} application=webapprt@mozilla.org
+category xpcom-directory-providers webapprt-directory-provider @mozilla.org/webapprt/directory-provider;1 application=webapprt@mozilla.org
--- a/webapprt/content/webapp.js
+++ b/webapprt/content/webapp.js
@@ -1,17 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cu = Components.utils;
 
-Cu.import("resource://gre/modules/WebappRT.jsm");
+Cu.import("resource://webapprt/modules/WebappRT.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 
 function onLoad() {
   window.removeEventListener("load", onLoad, false);
 
   let installRecord = WebappRT.config.app;
   let manifest = WebappRT.config.app.manifest;
 
--- a/webapprt/jar.mn
+++ b/webapprt/jar.mn
@@ -1,4 +1,4 @@
 webapprt.jar:
-%  content webapprt %content/
-*       content/webapp.js                         (content/webapp.js)
-*       content/webapp.xul                        (content/webapp.xul)
+% content webapprt %content/
+* content/webapp.js                     (content/webapp.js)
+* content/webapp.xul                    (content/webapp.xul)
--- a/webapprt/mac/webapprt.mm
+++ b/webapprt/mac/webapprt.mm
@@ -27,21 +27,24 @@
 #include "nsComponentManagerUtils.h"
 #include "nsCOMPtr.h"
 #include "nsILocalFile.h"
 #include "nsStringGlue.h"
 
 const char WEBAPPRT_EXECUTABLE[] = "webapprt-stub";
 const char FXAPPINI_NAME[] = "application.ini";
 const char WEBAPPINI_NAME[] = "webapp.ini";
-const char WEBRTINI_NAME[] = "webapprt.ini";
+const char WEBRTINI_NAME[] = "application.ini";
 
 //need the correct relative path here
 const char APP_CONTENTS_PATH[] = "/Contents/MacOS/";
 
+//the path to the WebappRT subdir within the Firefox app contents dir
+const char WEBAPPRT_PATH[] = "webapprt/";
+
 void ExecNewBinary(NSString* launchPath);
 
 NSString *PathToWebRT(NSString* alternateBinaryID);
 
 NSException* MakeException(NSString* name, NSString* message);
 
 void DisplayErrorAlert(NSString* title, NSString* message);
 
@@ -207,53 +210,57 @@ main(int argc, char **argv)
       NS_LogInit();
       { // Scope for any XPCOM stuff we create
         nsINIParser parser;
         if (NS_FAILED(parser.Init(appEnv))) {
           NSLog(@"%s was not found\n", appEnv);
           @throw MakeException(@"Error", @"Unable to parse environment files for application startup");
         }
 
-        // Get the path to the runtime's INI file.  This should be in the
-        // same directory as the GRE.
-        snprintf(rtINIPath, MAXPATHLEN, "%s%s%s", [firefoxPath UTF8String], APP_CONTENTS_PATH, WEBRTINI_NAME);
-        NSLog(@"webapprt.ini path: %s", rtINIPath);
+        // Get the path to the runtime directory.
+        char rtDir[MAXPATHLEN];
+        snprintf(rtDir, MAXPATHLEN, "%s%s%s", [firefoxPath UTF8String], APP_CONTENTS_PATH, WEBAPPRT_PATH);
+
+        // Get the path to the runtime's INI file.  This is in the runtime
+        // directory.
+        snprintf(rtINIPath, MAXPATHLEN, "%s%s%s%s", [firefoxPath UTF8String], APP_CONTENTS_PATH, WEBAPPRT_PATH, WEBRTINI_NAME);
+        NSLog(@"WebappRT application.ini path: %s", rtINIPath);
         if (![[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%s", rtINIPath]]) {
           NSString* msg = [NSString stringWithFormat: @"This copy of Firefox (%@) cannot run web applications, because it is missing important files", firefoxVersion];
           @throw MakeException(@"Missing WebRT Files", msg);
         }
 
         // Load the runtime's INI from its path.
         nsCOMPtr<nsILocalFile> rtINI;
         if (NS_FAILED(XRE_GetFileFromPath(rtINIPath, getter_AddRefs(rtINI)))) {
           NSLog(@"Runtime INI path not recognized: '%s'\n", rtINIPath);
           @throw MakeException(@"Error", @"Incorrect path to base INI file.");
         }
 
         if (!rtINI) {
-          NSLog(@"Error: missing webapprt.ini");
+          NSLog(@"Error: missing WebappRT application.ini");
           @throw MakeException(@"Error", @"Missing base INI file.");
         }
 
         nsXREAppData *webShellAppData;
         if (NS_FAILED(XRE_CreateAppData(rtINI, &webShellAppData))) {
-          NSLog(@"Couldn't read webapprt.ini: %s", rtINIPath);
+          NSLog(@"Couldn't read WebappRT application.ini: %s", rtINIPath);
           @throw MakeException(@"Error", @"Unable to parse base INI file.");
         }
 
         char profile[MAXPATHLEN];
         if (NS_FAILED(parser.GetString("Webapp", "Profile", profile, MAXPATHLEN))) {
           NSLog(@"Unable to retrieve profile from web app INI file");
           @throw MakeException(@"Error", @"Unable to retrieve installation profile.");
         }
         NSLog(@"setting app profile: %s", profile);
         SetAllocatedString(webShellAppData->profile, profile);
 
         nsCOMPtr<nsILocalFile> directory;
-        if (NS_FAILED(XRE_GetFileFromPath(greDir, getter_AddRefs(directory)))) {
+        if (NS_FAILED(XRE_GetFileFromPath(rtDir, getter_AddRefs(directory)))) {
           NSLog(@"Unable to open app dir");
           @throw MakeException(@"Error", @"Unable to open application directory.");
         }
 
         nsCOMPtr<nsILocalFile> xreDir;
         if (NS_FAILED(XRE_GetFileFromPath(greDir, getter_AddRefs(xreDir)))) {
           NSLog(@"Unable to open XRE dir");
           @throw MakeException(@"Error", @"Unable to open application XRE directory.");
--- a/webapprt/prefs.js
+++ b/webapprt/prefs.js
@@ -1,13 +1,5 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 pref("browser.chromeURL", "chrome://webapprt/content/webapp.xul");
-
-// We set this to the value of DEFAULT_HIDDENWINDOW_URL in nsAppShellService.cpp
-// so our app is treated as not having an application-provided hidden window.
-// Ideally, we could just leave it out, but because we are being distributed
-// in a unified directory with Firefox, Firefox's preferences are being read
-// before ours, which means this preference is being set by Firefox, and we need
-// to set it here to override the Firefox-provided value.
-pref("browser.hiddenWindowChromeURL", "resource://gre-resources/hiddenWindow.html");
deleted file mode 100644
--- a/webapprt/webapprt.ini.in
+++ /dev/null
@@ -1,18 +0,0 @@
-#if 0
-; This Source Code Form is subject to the terms of the Mozilla Public
-; License, v. 2.0. If a copy of the MPL was not distributed with this file,
-; You can obtain one at http://mozilla.org/MPL/2.0/.
-#endif
-
-#filter substitution
-
-[App]
-ID=webapprt@mozilla.org
-Vendor=Mozilla
-Name=Webapp Runtime
-Version=@GRE_MILESTONE@
-BuildID=@GRE_BUILDID@
-
-[Gecko]
-MinVersion=@GRE_MILESTONE@
-MaxVersion=@GRE_MILESTONE@
--- a/webapprt/win/Makefile.in
+++ b/webapprt/win/Makefile.in
@@ -2,17 +2,17 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 
 DEPTH     = ../..
 topsrcdir = @top_srcdir@
 srcdir    = @srcdir@
 VPATH     = @srcdir@
 
-include $(DEPTH)/config/autoconf.mk
+include $(topsrcdir)/config/config.mk
 
 # Build a binary bootstrapping with XRE_main
 PROGRAM   = webapprt-stub$(BIN_SUFFIX)
 
 CPPSRCS   = webapprt.cpp
 
 # Don't create a dependency on mozglue, which is impossible (difficult?)
 # to dynamically link into our executable, as we copy it to arbitrary locations.
@@ -46,18 +46,16 @@ endif
 # Installer stuff
 include $(topsrcdir)/toolkit/mozapps/installer/package-name.mk
 
 CONFIG_DIR = instgen
 SFX_MODULE = $(topsrcdir)/other-licenses/7zstub/firefox/7zSD.sfx
 APP_VERSION := $(shell cat $(topsrcdir)/browser/config/version.txt)
 DEFINES += -DAPP_VERSION=$(APP_VERSION)
 
-include $(topsrcdir)/config/config.mk
-
 ifdef _MSC_VER
 # Always enter a Windows program through wmain, whether or not we're
 # a console application.
 WIN32_EXE_LDFLAGS += -ENTRY:wmainCRTStartup
 endif
 
 OS_LIBS += $(call EXPAND_LIBNAME,shell32)
 
--- a/webapprt/win/webapprt.cpp
+++ b/webapprt/win/webapprt.cpp
@@ -22,17 +22,17 @@
 XRE_GetFileFromPathType XRE_GetFileFromPath;
 XRE_CreateAppDataType XRE_CreateAppData;
 XRE_FreeAppDataType XRE_FreeAppData;
 XRE_mainType XRE_main;
 
 namespace {
   const char kAPP_INI[] = "application.ini";
   const char kWEBAPP_INI[] = "webapp.ini";
-  const char kWEBAPPRT_INI[] = "webapprt.ini";
+  const char kWEBAPPRT_PATH[] = "webapprt";
   const char kAPP_ENV_PREFIX[] = "XUL_APP_FILE=";
   const char kAPP_RT[] = "webapprt-stub.exe";
 
   const wchar_t kAPP_RT_BACKUP[] = L"webapprt.old";
 
   wchar_t curExePath[MAXPATHLEN];
   wchar_t backupFilePath[MAXPATHLEN];
   wchar_t iconPath[MAXPATHLEN];
@@ -257,20 +257,24 @@ namespace {
     rv = XPCOMGlueLoadXULFunctions(kXULFuncs);
     NS_ENSURE_SUCCESS(rv, false);
 
     // NOTE: The GRE has successfully loaded, so we can use XPCOM now
     { // Scope for any XPCOM stuff we create
 
       ScopedLogging log;
 
-      // Get the path to the runtime's INI file.  This should be in the
-      // same directory as the GRE.
+      // Get the path to the runtime.
+      char rtPath[MAXPATHLEN];
+      rv = joinPath(rtPath, greDir, kWEBAPPRT_PATH, MAXPATHLEN);
+      NS_ENSURE_SUCCESS(rv, rv);
+
+      // Get the path to the runtime's INI file.
       char rtIniPath[MAXPATHLEN];
-      rv = joinPath(rtIniPath, greDir, kWEBAPPRT_INI, MAXPATHLEN);
+      rv = joinPath(rtIniPath, rtPath, kAPP_INI, MAXPATHLEN);
       NS_ENSURE_SUCCESS(rv, false);
 
       // Load the runtime's INI from its path.
       nsCOMPtr<nsILocalFile> rtINI;
       rv = XRE_GetFileFromPath(rtIniPath, getter_AddRefs(rtINI));
       NS_ENSURE_SUCCESS(rv, false);
 
       if (!rtINI) {
@@ -279,23 +283,21 @@ namespace {
 
       ScopedXREAppData webShellAppData;
       rv = webShellAppData.create(rtINI);
       NS_ENSURE_SUCCESS(rv, rv);
 
       SetAllocatedString(webShellAppData->profile, profile);
 
       nsCOMPtr<nsILocalFile> directory;
-      rv = XRE_GetFileFromPath(greDir,
-                               getter_AddRefs(directory));
+      rv = XRE_GetFileFromPath(rtPath, getter_AddRefs(directory));
       NS_ENSURE_SUCCESS(rv, false);
 
       nsCOMPtr<nsILocalFile> xreDir;
-      rv = XRE_GetFileFromPath(greDir,
-                               getter_AddRefs(xreDir));
+      rv = XRE_GetFileFromPath(greDir, getter_AddRefs(xreDir));
       NS_ENSURE_SUCCESS(rv, false);
 
       xreDir.forget(&webShellAppData->xreDirectory);
       NS_IF_RELEASE(webShellAppData->directory);
       directory.forget(&webShellAppData->directory);
 
       // There is only XUL.
       XRE_main(*pargc, *pargv, webShellAppData);
--- a/xpfe/appshell/src/nsAppShellService.cpp
+++ b/xpfe/appshell/src/nsAppShellService.cpp
@@ -116,32 +116,18 @@ nsAppShellService::CreateHiddenWindow()
 {
   nsresult rv;
   PRInt32 initialHeight = 100, initialWidth = 100;
     
 #ifdef XP_MACOSX
   PRUint32    chromeMask = 0;
   nsAdoptingCString prefVal =
       Preferences::GetCString("browser.hiddenWindowChromeURL");
-
-  // Set mApplicationProvidedHiddenWindow to true only if there is a hidden
-  // window chrome URL in preferences AND it is set to a non-default value.
-  // This enables an app that doesn't have a hidden window (like WebappRT)
-  // to share an app directory with one that does (like Firefox), the former
-  // taking advantage of this behavior to "unset" the latter's hidden window
-  // pref by setting it to the default value.
-  //
-  // (Ideally, the former would be able to simply unset the latter's pref,
-  // but there is no way to do that; even more ideally, the two apps would not
-  // share an app directory, but in the case of WebappRT and Firefox that's
-  // a longer-term fix.)
-  //
-  mApplicationProvidedHiddenWindow = prefVal.get() && strcmp(prefVal.get(), DEFAULT_HIDDENWINDOW_URL) ? true : false;
-
-  const char* hiddenWindowURL = mApplicationProvidedHiddenWindow ? prefVal.get() : DEFAULT_HIDDENWINDOW_URL;
+  const char* hiddenWindowURL = prefVal.get() ? prefVal.get() : DEFAULT_HIDDENWINDOW_URL;
+  mApplicationProvidedHiddenWindow = prefVal.get() ? true : false;
 #else
   static const char hiddenWindowURL[] = DEFAULT_HIDDENWINDOW_URL;
   PRUint32    chromeMask =  nsIWebBrowserChrome::CHROME_ALL;
 #endif
 
   nsCOMPtr<nsIURI> url;
   rv = NS_NewURI(getter_AddRefs(url), hiddenWindowURL);
   NS_ENSURE_SUCCESS(rv, rv);