diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index 99fee0054b94..bf78ca9fdeed 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -503,9 +503,6 @@ #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 @@ -629,12 +626,15 @@ bin/components/@DLL_PREFIX@nkgnomevfs@DLL_SUFFIX@ #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 diff --git a/browser/locales/Makefile.in b/browser/locales/Makefile.in index aea19d407ce6..c5a09d26bff3 100644 --- a/browser/locales/Makefile.in +++ b/browser/locales/Makefile.in @@ -211,7 +211,7 @@ 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 \ diff --git a/config/rules.mk b/config/rules.mk index 2458e0eaf253..c52223500a74 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -1371,7 +1371,7 @@ $(foreach namespace,$(EXPORTS_NAMESPACES),$(eval $(EXPORT_NAMESPACE_RULE))) 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 diff --git a/js/src/config/rules.mk b/js/src/config/rules.mk index 2458e0eaf253..c52223500a74 100644 --- a/js/src/config/rules.mk +++ b/js/src/config/rules.mk @@ -1371,7 +1371,7 @@ $(foreach namespace,$(EXPORTS_NAMESPACES),$(eval $(EXPORT_NAMESPACE_RULE))) 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 diff --git a/modules/libpref/src/Preferences.cpp b/modules/libpref/src/Preferences.cpp index 2d0d1093ecad..00742a883832 100644 --- a/modules/libpref/src/Preferences.cpp +++ b/modules/libpref/src/Preferences.cpp @@ -43,7 +43,6 @@ #include "mozilla/HashFunctions.h" #include "nsXULAppAPI.h" -#include "nsIXULAppInfo.h" #include "mozilla/Preferences.h" #include "nsAppDirectoryServiceDefs.h" @@ -85,8 +84,6 @@ namespace mozilla { #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); @@ -861,7 +858,7 @@ pref_LoadPrefsInDir(nsIFile* aDir, char const *const *aSpecialFiles, PRUint32 aS 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; } @@ -1018,14 +1015,10 @@ static nsresult pref_InitInitialObjects() // - $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 find; @@ -1049,30 +1042,6 @@ static nsresult pref_InitInitialObjects() } prefEntries.Sort(); - - // Load jar:$gre/omni.jar!/defaults/pref/$WEBAPPRT_APPID/*.js - // if we're running WebappRT. - nsCOMPtr 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)) @@ -1123,7 +1092,12 @@ static nsresult pref_InitInitialObjects() NS_WARNING("Error parsing application default preferences."); // Load jar:$app/omni.jar!/defaults/preferences/*.js + // or jar:$gre/omni.jar!/defaults/preferences/*.js. nsRefPtr 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); diff --git a/toolkit/locales/l10n.mk b/toolkit/locales/l10n.mk index c70e07012fe2..2409c0865421 100644 --- a/toolkit/locales/l10n.mk +++ b/toolkit/locales/l10n.mk @@ -172,6 +172,9 @@ 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) diff --git a/toolkit/mozapps/installer/Packager.pm b/toolkit/mozapps/installer/Packager.pm index 7d47816e90bf..cdf2a170cc62 100644 --- a/toolkit/mozapps/installer/Packager.pm +++ b/toolkit/mozapps/installer/Packager.pm @@ -234,7 +234,10 @@ sub do_copyfile # 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."); diff --git a/toolkit/mozapps/installer/packager.mk b/toolkit/mozapps/installer/packager.mk index 9603302fab46..414a87c375bf 100644 --- a/toolkit/mozapps/installer/packager.mk +++ b/toolkit/mozapps/installer/packager.mk @@ -547,13 +547,34 @@ UNPACK_OMNIJAR = \ 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)" @@ -720,6 +741,9 @@ endif @$(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)) @@ -873,6 +897,9 @@ ifeq (bundle,$(MOZ_FS_LAYOUT)) 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) - .) | \ diff --git a/toolkit/mozapps/installer/windows/nsis/makensis.mk b/toolkit/mozapps/installer/windows/nsis/makensis.mk index 05d298d70f49..9278aa39e197 100644 --- a/toolkit/mozapps/installer/windows/nsis/makensis.mk +++ b/toolkit/mozapps/installer/windows/nsis/makensis.mk @@ -113,6 +113,6 @@ 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 diff --git a/toolkit/xre/nsXREDirProvider.cpp b/toolkit/xre/nsXREDirProvider.cpp index 15fca16ffa1a..ecbcc0d2e0b5 100644 --- a/toolkit/xre/nsXREDirProvider.cpp +++ b/toolkit/xre/nsXREDirProvider.cpp @@ -99,8 +99,6 @@ #define PREF_OVERRIDE_DIRNAME "preferences" -#define WEBAPPRT_APPID "webapprt@mozilla.org" - static already_AddRefed CloneAndAppend(nsIFile* aFile, const char* name) { @@ -650,13 +648,6 @@ nsXREDirProvider::GetFilesInternal(const char* aProperty, 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)) { diff --git a/webapprt/WebappRTCommandLineHandler.js b/webapprt/CommandLineHandler.js similarity index 100% rename from webapprt/WebappRTCommandLineHandler.js rename to webapprt/CommandLineHandler.js diff --git a/webapprt/WebappRTDirectoryProvider.js b/webapprt/DirectoryProvider.js similarity index 96% rename from webapprt/WebappRTDirectoryProvider.js rename to webapprt/DirectoryProvider.js index 08f857ab7b1a..53dd1d9560c1 100644 --- a/webapprt/WebappRTDirectoryProvider.js +++ b/webapprt/DirectoryProvider.js @@ -11,7 +11,7 @@ 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"); +Cu.import("resource://webapprt/modules/WebappRT.jsm"); function DirectoryProvider() {} diff --git a/webapprt/Makefile.in b/webapprt/Makefile.in index bbc6e8f4cb6c..00b3fcc5e4ac 100644 --- a/webapprt/Makefile.in +++ b/webapprt/Makefile.in @@ -9,6 +9,10 @@ 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))) @@ -20,29 +24,32 @@ 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 diff --git a/webapprt/webapprt.ini.in b/webapprt/application.ini.in similarity index 100% rename from webapprt/webapprt.ini.in rename to webapprt/application.ini.in diff --git a/webapprt/WebappRTComponents.manifest b/webapprt/components.manifest similarity index 62% rename from webapprt/WebappRTComponents.manifest rename to webapprt/components.manifest index ad76433432b4..f33ef7f8b4e8 100644 --- a/webapprt/WebappRTComponents.manifest +++ b/webapprt/components.manifest @@ -1,9 +1,9 @@ -# WebappRTCommandLineHandler.js -component {6d69c782-40a3-469b-8bfd-3ee366105a4a} WebappRTCommandLineHandler.js application=webapprt@mozilla.org +# 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 -# WebappRTDirectoryProvider.js -component {e1799fda-4b2f-4457-b671-e0641d95698d} WebappRTDirectoryProvider.js 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 diff --git a/webapprt/content/webapp.js b/webapprt/content/webapp.js index 2f8fbe3363d4..f7b5afe53de9 100644 --- a/webapprt/content/webapp.js +++ b/webapprt/content/webapp.js @@ -6,7 +6,7 @@ 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() { diff --git a/webapprt/jar.mn b/webapprt/jar.mn index f64f668cb753..1874c89ae79f 100644 --- 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) diff --git a/webapprt/mac/webapprt.mm b/webapprt/mac/webapprt.mm index 3d6da1b6aeae..f48d5ca64c41 100644 --- a/webapprt/mac/webapprt.mm +++ b/webapprt/mac/webapprt.mm @@ -32,11 +32,14 @@ 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); @@ -212,10 +215,14 @@ main(int argc, char **argv) @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); @@ -229,13 +236,13 @@ main(int argc, char **argv) } 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."); } @@ -248,7 +255,7 @@ main(int argc, char **argv) SetAllocatedString(webShellAppData->profile, profile); nsCOMPtr 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."); } diff --git a/webapprt/prefs.js b/webapprt/prefs.js index e828e05481ed..00ea70414a09 100644 --- a/webapprt/prefs.js +++ b/webapprt/prefs.js @@ -3,11 +3,3 @@ * 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"); diff --git a/webapprt/win/Makefile.in b/webapprt/win/Makefile.in index e3ad2b4ef26d..8f0cc0e4faea 100644 --- a/webapprt/win/Makefile.in +++ b/webapprt/win/Makefile.in @@ -7,7 +7,7 @@ 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) @@ -51,8 +51,6 @@ 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. diff --git a/webapprt/win/webapprt.cpp b/webapprt/win/webapprt.cpp index 44f6d115f98b..93c4402de42f 100644 --- a/webapprt/win/webapprt.cpp +++ b/webapprt/win/webapprt.cpp @@ -27,7 +27,7 @@ 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"; @@ -262,10 +262,14 @@ namespace { 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. @@ -284,13 +288,11 @@ namespace { SetAllocatedString(webShellAppData->profile, profile); nsCOMPtr directory; - rv = XRE_GetFileFromPath(greDir, - getter_AddRefs(directory)); + rv = XRE_GetFileFromPath(rtPath, getter_AddRefs(directory)); NS_ENSURE_SUCCESS(rv, false); nsCOMPtr xreDir; - rv = XRE_GetFileFromPath(greDir, - getter_AddRefs(xreDir)); + rv = XRE_GetFileFromPath(greDir, getter_AddRefs(xreDir)); NS_ENSURE_SUCCESS(rv, false); xreDir.forget(&webShellAppData->xreDirectory); diff --git a/xpfe/appshell/src/nsAppShellService.cpp b/xpfe/appshell/src/nsAppShellService.cpp index 83a4d4dc8acc..bb91c183a48d 100644 --- a/xpfe/appshell/src/nsAppShellService.cpp +++ b/xpfe/appshell/src/nsAppShellService.cpp @@ -121,22 +121,8 @@ nsAppShellService::CreateHiddenWindow() 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;