From bc10d4058fe3dbf1f0ce6cd8e47585c83eda92ae Mon Sep 17 00:00:00 2001 From: "conrad%ingress.com" Date: Fri, 11 Aug 2000 20:10:06 +0000 Subject: [PATCH] 1. Removed NS_Init which took a path. 2. Added appfilelocation provider param. r=dougt --- embedding/base/nsEmbedAPI.cpp | 45 +++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/embedding/base/nsEmbedAPI.cpp b/embedding/base/nsEmbedAPI.cpp index d6bdecb8fbe..6f2bf9487c3 100644 --- a/embedding/base/nsEmbedAPI.cpp +++ b/embedding/base/nsEmbedAPI.cpp @@ -28,6 +28,9 @@ #include "nsIStringBundle.h" +#include "nsIDirectoryService.h" +#include "nsAppFileLocationProvider.h" + #include "nsEmbedAPI.h" static nsIServiceManager *sServiceManager = nsnull; @@ -66,24 +69,11 @@ static XPCOMCleanupHack sXPCOMCleanupHack; extern "C" void NS_SetupRegistry(); -nsresult NS_InitEmbedding(const char *aPath) +nsresult NS_InitEmbedding(nsILocalFile *mozBinDirectory, + nsIDirectoryServiceProvider *appFileLocProvider) { - // Create an object to represent the path - nsILocalFile *localFile = nsnull; - if (aPath && strlen(aPath) > 0) - { - NS_NewLocalFile(aPath, PR_FALSE, &localFile); - } + nsresult rv; - nsresult rv = NS_InitEmbedding(localFile); - NS_IF_RELEASE(localFile); - - return rv; -} - - -nsresult NS_InitEmbedding(nsILocalFile *aPath) -{ // Reentrant calls to this method do nothing except increment a counter sInitCounter++; if (sInitCounter > 1) @@ -96,19 +86,32 @@ nsresult NS_InitEmbedding(nsILocalFile *aPath) #endif { // Initialise XPCOM - NS_InitXPCOM(&sServiceManager, aPath); - + NS_InitXPCOM(&sServiceManager, mozBinDirectory); if (!sServiceManager) return NS_ERROR_NULL_POINTER; - + + // Hook up the file location provider - make one if nsnull was passed + if (!appFileLocProvider) + { + appFileLocProvider = new nsAppFileLocationProvider; + if (!appFileLocProvider) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(appFileLocProvider); + } + NS_WITH_SERVICE(nsIDirectoryService, directoryService, NS_DIRECTORY_SERVICE_PROGID, &rv); + if (NS_FAILED(rv)) + return rv; + rv = directoryService->RegisterProvider(appFileLocProvider); + if (NS_FAILED(rv)) + return rv; + NS_RELEASE(appFileLocProvider); // RegisterProvider did AddRef - It owns it now + #ifdef HACK_AROUND_NONREENTRANT_INITXPCOM sXPCOMInitializedFlag = PR_TRUE; sXPCOMCleanupHack.mCleanOnExit = PR_TRUE; #endif } - nsresult rv; - // Register components if (!sRegistryInitializedFlag) {