diff --git a/xpcom/io/nsAppDirectoryServiceDefs.h b/xpcom/io/nsAppDirectoryServiceDefs.h index dcc49a2d001..cd68ab356b8 100755 --- a/xpcom/io/nsAppDirectoryServiceDefs.h +++ b/xpcom/io/nsAppDirectoryServiceDefs.h @@ -106,4 +106,5 @@ #define NS_APP_NEWS_50_DIR "NewsD" #define NS_APP_MESSENGER_FOLDER_CACHE_50_DIR "MFCaD" +#define NS_APP_INSTALL_CLEANUP_DIR "XPIClnupD" //location of xpicleanup.dat xpicleanup.exe #endif diff --git a/xpcom/io/nsAppFileLocationProvider.cpp b/xpcom/io/nsAppFileLocationProvider.cpp index 62d5e7b5946..23982dee9af 100755 --- a/xpcom/io/nsAppFileLocationProvider.cpp +++ b/xpcom/io/nsAppFileLocationProvider.cpp @@ -61,6 +61,7 @@ #if defined(XP_MAC) /* || defined(XP_MACOSX) REMIND HACKING FOR MACOS X!!! */ #define APP_REGISTRY_NAME "Application Registry" +#define ESSENTIAL_FILES "Essential Files" #elif defined(XP_WIN) || defined(XP_OS2) #define APP_REGISTRY_NAME "registry.dat" #else @@ -204,7 +205,17 @@ nsAppFileLocationProvider::GetFile(const char *prop, PRBool *persistant, nsIFile if (NS_SUCCEEDED(rv)) rv = localFile->AppendRelativePath(SEARCH_DIR_NAME); } - + else if (nsCRT::strcmp(prop, NS_APP_INSTALL_CLEANUP_DIR) == 0) + { + // This is cloned so that embeddors will have a hook to override + // with their own cleanup dir. See bugzilla bug #105087 + rv = CloneMozBinDirectory(getter_AddRefs(localFile)); +#ifdef XP_MAC + if (NS_SUCCEEDED(rv)) + rv = localFile->Append(ESSENTIAL_FILES); +#endif + + } if (localFile && NS_SUCCEEDED(rv)) return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)_retval); diff --git a/xpfe/bootstrap/nsAppRunner.cpp b/xpfe/bootstrap/nsAppRunner.cpp index 82557da73ee..c2e72a6f009 100644 --- a/xpfe/bootstrap/nsAppRunner.cpp +++ b/xpfe/bootstrap/nsAppRunner.cpp @@ -1137,15 +1137,12 @@ static nsresult VerifyInstallation(int argc, char **argv) do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv); if (NS_FAILED(rv)) return NS_OK; - rv = directoryService->Get(NS_OS_CURRENT_PROCESS_DIR, + rv = directoryService->Get(NS_APP_INSTALL_CLEANUP_DIR, NS_GET_IID(nsIFile), getter_AddRefs(registryFile)); if (NS_FAILED(rv) || !registryFile) - return NS_OK; + return NS_ERROR_FAILURE; -#ifdef XP_MAC - registryFile->Append(ESSENTIAL_FILES); -#endif registryFile->Append(CLEANUP_REGISTRY); PRBool exists; diff --git a/xpinstall/src/ScheduledTasks.cpp b/xpinstall/src/ScheduledTasks.cpp index d70cd8441c6..f0f588adac3 100644 --- a/xpinstall/src/ScheduledTasks.cpp +++ b/xpinstall/src/ScheduledTasks.cpp @@ -35,6 +35,7 @@ #include "nsSpecialSystemDirectory.h" #include "nsDirectoryService.h" #include "nsDirectoryServiceDefs.h" +#include "nsAppDirectoryServiceDefs.h" static nsresult GetPersistentStringFromSpec(nsIFile* inSpec, char **string) @@ -135,15 +136,28 @@ char* GetRegFilePath() if (NS_FAILED(rv)) return nsnull; - directoryService->Get(NS_OS_CURRENT_PROCESS_DIR, - NS_GET_IID(nsIFile), - getter_AddRefs(iFileUtilityPath)); - if (!iFileUtilityPath) - return nsnull; + if (nsSoftwareUpdate::GetProgramDirectory()) // In the stub installer + { + nsCOMPtr tmp; + rv = nsSoftwareUpdate::GetProgramDirectory()->Clone(getter_AddRefs(tmp)); + + if (NS_FAILED(rv) || !tmp) + return nsnull; #if defined (XP_MAC) - iFileUtilityPath->Append(ESSENTIAL_FILES); + tmp->Append(ESSENTIAL_FILES); #endif + iFileUtilityPath = do_QueryInterface(tmp); + } + else + { + rv = directoryService->Get(NS_APP_INSTALL_CLEANUP_DIR, + NS_GET_IID(nsIFile), + getter_AddRefs(iFileUtilityPath)); + } + if (NS_FAILED(rv) || !iFileUtilityPath) + return nsnull; + iFileUtilityPath->Append(CLEANUP_REGISTRY); //Yes, we know using GetPath is buggy on the Mac. diff --git a/xpinstall/src/nsInstallFolder.cpp b/xpinstall/src/nsInstallFolder.cpp index d7c5def8a3c..bab8ca50187 100644 --- a/xpinstall/src/nsInstallFolder.cpp +++ b/xpinstall/src/nsInstallFolder.cpp @@ -175,12 +175,7 @@ nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRe do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv); if (!directoryService) return; - directoryService->Get(NS_OS_CURRENT_PROCESS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(mFileSpec)); -#ifdef XP_MAC - mFileSpec->Append("Plug-ins"); -#else - mFileSpec->Append("plugins"); -#endif + directoryService->Get(NS_APP_PLUGINS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(mFileSpec)); } else { @@ -188,11 +183,7 @@ nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRe if (NS_SUCCEEDED(rv)) { -#ifdef XP_MAC - mFileSpec->Append("Plug-ins"); -#else - mFileSpec->Append("plugins"); -#endif + mFileSpec->Append(INSTALL_PLUGINS_DIR); } else mFileSpec = nsnull; @@ -285,18 +276,9 @@ nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRe nsCOMPtr directoryService = do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv); if (!directoryService) return; - directoryService->Get(NS_OS_CURRENT_PROCESS_DIR, + directoryService->Get(NS_XPCOM_COMPONENT_DIR, NS_GET_IID(nsIFile), getter_AddRefs(mFileSpec)); - - if (NS_SUCCEEDED(rv)) - { -#ifdef XP_MAC - mFileSpec->Append("Components"); -#else - mFileSpec->Append("components"); -#endif - } } else { @@ -304,11 +286,7 @@ nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRe if (NS_SUCCEEDED(rv)) { -#ifdef XP_MAC - mFileSpec->Append("Components"); -#else - mFileSpec->Append("components"); -#endif + mFileSpec->Append(INSTALL_COMPONENTS_DIR); } else mFileSpec = nsnull; @@ -321,19 +299,9 @@ nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRe nsCOMPtr directoryService = do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv); if (!directoryService) return; - directoryService->Get(NS_OS_CURRENT_PROCESS_DIR, + directoryService->Get(NS_APP_CHROME_DIR, NS_GET_IID(nsIFile), getter_AddRefs(mFileSpec)); - - - if (NS_SUCCEEDED(rv)) - { -#ifdef XP_MAC - mFileSpec->Append("Chrome"); -#else - mFileSpec->Append("chrome"); -#endif - } } else { @@ -341,11 +309,7 @@ nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRe if (NS_SUCCEEDED(rv)) { -#ifdef XP_MAC - mFileSpec->Append("Chrome"); -#else - mFileSpec->Append("chrome"); -#endif + mFileSpec->Append(INSTALL_CHROME_DIR); } } break; diff --git a/xpinstall/src/nsInstallFolder.h b/xpinstall/src/nsInstallFolder.h index adcf51f495a..7074863c9c6 100644 --- a/xpinstall/src/nsInstallFolder.h +++ b/xpinstall/src/nsInstallFolder.h @@ -34,6 +34,16 @@ #include "nsFileSpec.h" #include "nsSpecialSystemDirectory.h" +#ifdef XP_MAC +#define INSTALL_PLUGINS_DIR "Plug-ins" +#define INSTALL_COMPONENTS_DIR "Components" +#define INSTALL_CHROME_DIR "Chrome" +#else +#define INSTALL_PLUGINS_DIR "plugins" +#define INSTALL_COMPONENTS_DIR "components" +#define INSTALL_CHROME_DIR "chrome" +#endif + class nsInstallFolder { public: diff --git a/xpinstall/src/nsRegisterItem.cpp b/xpinstall/src/nsRegisterItem.cpp index 2f8768b3e3a..489714ce2a5 100644 --- a/xpinstall/src/nsRegisterItem.cpp +++ b/xpinstall/src/nsRegisterItem.cpp @@ -33,6 +33,7 @@ #include "nsIChromeRegistry.h" #include "nsIDirectoryService.h" #include "nsDirectoryServiceDefs.h" +#include "nsAppDirectoryServiceDefs.h" MOZ_DECL_CTOR_COUNTER(nsRegisterItem) @@ -259,36 +260,52 @@ PRInt32 nsRegisterItem::Complete() { // Either script asked for delayed chrome or we can't find // the chrome registry to do it now. - NS_ASSERTION(mProgDir, "this.Prepare() failed to set mProgDir"); // construct a reference to the magic file PRFileDesc* fd = nsnull; nsCOMPtr tmp; PRBool bExists = PR_FALSE; - rv = mProgDir->Clone(getter_AddRefs(tmp)); - if (NS_SUCCEEDED(rv)) + if (!nsSoftwareUpdate::GetProgramDirectory()) // not in the stub installer + { + nsCOMPtr directoryService = + do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv); + if (NS_SUCCEEDED(rv) && directoryService) + { + rv = directoryService->Get(NS_APP_CHROME_DIR, + NS_GET_IID(nsIFile), + getter_AddRefs(tmp)); + if(NS_FAILED(rv)) + { + result = nsInstall::CHROME_REGISTRY_ERROR; + return result; + } + } + } + else { - nsCOMPtr startupFile( do_QueryInterface(tmp, &rv) ); + rv = nsSoftwareUpdate::GetProgramDirectory()->Clone(getter_AddRefs(tmp)); if (NS_SUCCEEDED(rv)) { - rv = startupFile->Append("chrome"); + tmp->Append(INSTALL_CHROME_DIR); + } + } + nsCOMPtr startupFile( do_QueryInterface(tmp, &rv) ); + + if (NS_SUCCEEDED(rv)) + { + rv = startupFile->Exists(&bExists); + if (NS_SUCCEEDED(rv) && !bExists) + rv = startupFile->Create(nsIFile::DIRECTORY_TYPE, 0755); + if (NS_SUCCEEDED(rv)) + { + rv = startupFile->Append("installed-chrome.txt"); if (NS_SUCCEEDED(rv)) { - rv = startupFile->Exists(&bExists); - if (NS_SUCCEEDED(rv) && !bExists) - rv = startupFile->Create(nsIFile::DIRECTORY_TYPE, 0755); - if (NS_SUCCEEDED(rv)) - { - rv = startupFile->Append("installed-chrome.txt"); - if (NS_SUCCEEDED(rv)) - { - rv = startupFile->OpenNSPRFileDesc( - PR_CREATE_FILE | PR_WRONLY, - 0744, - &fd); - } - } + rv = startupFile->OpenNSPRFileDesc( + PR_CREATE_FILE | PR_WRONLY, + 0744, + &fd); } } } diff --git a/xpinstall/src/nsSoftwareUpdate.cpp b/xpinstall/src/nsSoftwareUpdate.cpp index 7d2985ba450..4cd0c68a252 100644 --- a/xpinstall/src/nsSoftwareUpdate.cpp +++ b/xpinstall/src/nsSoftwareUpdate.cpp @@ -41,6 +41,7 @@ #include "VerReg.h" #include "nsIDirectoryService.h" #include "nsDirectoryServiceDefs.h" +#include "nsAppDirectoryServiceDefs.h" #include "nsInstall.h" #include "nsSoftwareUpdateIIDs.h" @@ -199,12 +200,26 @@ nsSoftwareUpdate::Shutdown() //Get the program directory nsCOMPtr directoryService = do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv); - directoryService->Get(NS_OS_CURRENT_PROCESS_DIR, - NS_GET_IID(nsIFile), - getter_AddRefs(pathToCleanupUtility)); + + if (nsSoftwareUpdate::GetProgramDirectory()) // In the stub installer + { + nsCOMPtr tmp; + rv = nsSoftwareUpdate::GetProgramDirectory()->Clone(getter_AddRefs(tmp)); #if defined (XP_MAC) - pathToCleanupUtility->Append(ESSENTIAL_FILES); + tmp->Append(ESSENTIAL_FILES); #endif + pathToCleanupUtility = do_QueryInterface(tmp); + + } + else + { + rv = directoryService->Get(NS_APP_INSTALL_CLEANUP_DIR, + NS_GET_IID(nsIFile), + getter_AddRefs(pathToCleanupUtility)); + } + + NS_ASSERTION(pathToCleanupUtility,"No path to cleanup utility in nsSoftwareUpdate::Shutdown()"); + //Create the Process framework pathToCleanupUtility->Append(CLEANUP_UTIL); nsCOMPtr cleanupProcess = do_CreateInstance(kIProcessCID);