зеркало из https://github.com/mozilla/gecko-dev.git
I know it's unorthodox to do a top level checkin like this, but I've got so many files
in so many different directories, that I think it's the best way. I've pulled and clobber_all'd my tree and got r=dp on this checkin. Here are the touched files: M mozilla/embedding/browser/activex/src/control/MozillaBrowser.cpp M mozilla/embedding/browser/activex/src/control/MozillaBrowser.h M mozilla/js/src/xpconnect/shell/xpcshell.cpp M mozilla/netwerk/protocol/res/src/nsResProtocolHandler.cpp M mozilla/xpcom/build/nsXPComInit.cpp M mozilla/xpcom/components/nsComponentManager.cpp M mozilla/xpcom/components/nsIServiceManager.h M mozilla/xpcom/components/nsServiceManager.cpp M mozilla/xpcom/io/nsSpecialSystemDirectory.cpp M mozilla/xpcom/io/nsSpecialSystemDirectory.h M mozilla/xpcom/tests/TestBuffers.cpp M mozilla/xpcom/tests/TestPipes.cpp M mozilla/xpcom/tests/TestShutdown.cpp M mozilla/xpcom/tests/windows/TestHelloXPLoop.cpp M mozilla/xpcom/tools/registry/regExport.cpp M mozilla/xpcom/tools/registry/regxpcom.cpp M mozilla/xpinstall/stub/xpistub.cpp M mozilla/webshell/embed/ActiveX/MozillaBrowser.cpp M mozilla/webshell/embed/ActiveX/MozillaBrowser.h M mozilla/webshell/tests/viewer/nsMacMain.cpp M mozilla/webshell/tests/viewer/nsPhMain.cpp M mozilla/webshell/tests/viewer/nsWinMain.cpp M mozilla/webshell/tests/viewer/unix/gtk/nsGtkMain.cpp M mozilla/xpfe/appshell/src/nsFileLocations.cpp M mozilla/xpfe/bootstrap/nsAppRunner.cpp The heart of this checkin is a change in the signature and symantics of NS_InitXPCOM. The new signature is extern NS_COM nsresult NS_InitXPCOM(nsIServiceManager* *result, nsFileSpec* binDirectory); I filed a bug for this problem: b=23157 The original manifestation of this bug was in mozilla/netwerk/protocol/res/src/nsResProtocolHandler.cpp It used the current process directory to find resources, which is not correct when the current process is not mozilla.exe. I have added a new type to nsSpecialSystemDirectory, Moz_BinDirectory, and made nsResProtocolHandler use that value.
This commit is contained in:
Родитель
7fe9af64f4
Коммит
13be6d7ebf
|
@ -54,8 +54,7 @@ static const tstring c_szHelpKey = _T("Software\\Microsoft\\Windows\\CurrentVers
|
|||
|
||||
#define MOZ_CONTROL_REG_KEY _T("Software\\Mozilla\\")
|
||||
#define MOZ_CONTROL_REG_VALUE_DIR _T("Dir")
|
||||
#define MOZ_CONTROL_REG_VALUE_COMPONENT_PATH _T("ComponentPath")
|
||||
#define MOZ_CONTROL_REG_VALUE_COMPONENT_FILE _T("ComponentFile")
|
||||
#define MOZ_CONTROL_REG_VALUE_BIN_DIRECTORY_PATH _T("BinDirectoryPath")
|
||||
|
||||
BOOL CMozillaBrowser::m_bRegistryInitialized = FALSE;
|
||||
|
||||
|
@ -107,8 +106,7 @@ CMozillaBrowser::CMozillaBrowser()
|
|||
m_UserKey.Create(HKEY_CURRENT_USER, MOZ_CONTROL_REG_KEY);
|
||||
|
||||
// Component path and file
|
||||
m_pComponentPath = NULL;
|
||||
m_pComponentFile = NULL;
|
||||
m_pBinDirPath = NULL;
|
||||
|
||||
// Initialise the web shell
|
||||
InitWebShell();
|
||||
|
@ -566,26 +564,21 @@ static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
|||
HRESULT CMozillaBrowser::InitWebShell()
|
||||
{
|
||||
// Initialise XPCOM
|
||||
TCHAR szComponentPath[MAX_PATH];
|
||||
TCHAR szComponentFile[MAX_PATH];
|
||||
DWORD dwComponentPath = sizeof(szComponentPath) / sizeof(szComponentPath[0]);
|
||||
DWORD dwComponentFile = sizeof(szComponentFile) / sizeof(szComponentFile[0]);
|
||||
TCHAR szBinDirPath[MAX_PATH];
|
||||
DWORD dwBinDirPath = sizeof(szBinDirPath) / sizeof(szBinDirPath[0]);
|
||||
|
||||
memset(szComponentPath, 0, sizeof(szComponentPath));
|
||||
memset(szComponentFile, 0, sizeof(szComponentFile));
|
||||
if (m_SystemKey.QueryValue(szComponentPath, MOZ_CONTROL_REG_VALUE_COMPONENT_PATH, &dwComponentPath) == ERROR_SUCCESS &&
|
||||
m_SystemKey.QueryValue(szComponentFile, MOZ_CONTROL_REG_VALUE_COMPONENT_FILE, &dwComponentFile) == ERROR_SUCCESS)
|
||||
memset(szBinDirPath, 0, sizeof(szBinDirPath));
|
||||
if (m_SystemKey.QueryValue(szBinDirPath, MOZ_CONTROL_REG_VALUE_BIN_DIRECTORY_PATH, &dwBinDirPath) == ERROR_SUCCESS)
|
||||
{
|
||||
USES_CONVERSION;
|
||||
|
||||
m_pComponentPath = new nsFileSpec(T2A(szComponentPath));
|
||||
m_pComponentFile = new nsFileSpec(T2A(szComponentFile));
|
||||
m_pBinDirPath = new nsFileSpec(T2A(szBinDirPath));
|
||||
|
||||
NS_InitXPCOM(&m_pIServiceManager, m_pComponentFile, m_pComponentPath);
|
||||
NS_InitXPCOM(&m_pIServiceManager, m_pBinDirPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_InitXPCOM(&m_pIServiceManager, nsnull, nsnull);
|
||||
NS_InitXPCOM(&m_pIServiceManager, nsnull);
|
||||
}
|
||||
|
||||
// Register components
|
||||
|
@ -622,15 +615,10 @@ HRESULT CMozillaBrowser::TermWebShell()
|
|||
NS_ShutdownXPCOM(m_pIServiceManager);
|
||||
m_pIServiceManager = nsnull;
|
||||
|
||||
if (m_pComponentPath)
|
||||
if (m_pBinDirPath)
|
||||
{
|
||||
delete m_pComponentPath;
|
||||
m_pComponentPath = NULL;
|
||||
}
|
||||
if (m_pComponentFile)
|
||||
{
|
||||
delete m_pComponentFile;
|
||||
m_pComponentFile = NULL;
|
||||
delete m_pBinDirPath;
|
||||
m_pBinDirPath = NULL;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
|
@ -2790,4 +2778,4 @@ HRESULT _stdcall CMozillaBrowser::EditCommandHandler(CMozillaBrowser *pThis, con
|
|||
{
|
||||
pThis->OnEditorCommand(nCmdID);
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -326,10 +326,8 @@ protected:
|
|||
// List of registered browser helper objects
|
||||
ObjectList m_cBrowserHelperList;
|
||||
|
||||
// Pointer to the component folder
|
||||
nsFileSpec *m_pComponentPath;
|
||||
// Pointer to the component file
|
||||
nsFileSpec *m_pComponentFile;
|
||||
// Pointer to the bin directory
|
||||
nsFileSpec *m_pBinDirPath;
|
||||
|
||||
virtual HRESULT CreateWebShell();
|
||||
virtual HRESULT InitWebShell();
|
||||
|
|
|
@ -643,7 +643,7 @@ main(int argc, char **argv)
|
|||
gErrFile = stderr;
|
||||
gOutFile = stdout;
|
||||
|
||||
rv = NS_InitXPCOM(NULL, NULL, NULL);
|
||||
rv = NS_InitXPCOM(NULL, NULL);
|
||||
NS_ASSERTION( NS_SUCCEEDED(rv), "NS_InitXPCOM failed" );
|
||||
|
||||
SetupRegistry();
|
||||
|
|
|
@ -58,11 +58,11 @@ nsResProtocolHandler::Init()
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
// set up initial mappings
|
||||
rv = SetSpecialDir("ProgramDir", nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
|
||||
rv = SetSpecialDir("ProgramDir", nsSpecialSystemDirectory::Moz_BinDirectory);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// make "res:///" == "resource:/"
|
||||
rv = SetSpecialDir("", nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
|
||||
rv = SetSpecialDir("", nsSpecialSystemDirectory::Moz_BinDirectory);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = SetSpecialDir("CurrentDir", nsSpecialSystemDirectory::OS_CurrentWorkingDirectory);
|
||||
|
|
|
@ -54,8 +54,7 @@ static const tstring c_szHelpKey = _T("Software\\Microsoft\\Windows\\CurrentVers
|
|||
|
||||
#define MOZ_CONTROL_REG_KEY _T("Software\\Mozilla\\")
|
||||
#define MOZ_CONTROL_REG_VALUE_DIR _T("Dir")
|
||||
#define MOZ_CONTROL_REG_VALUE_COMPONENT_PATH _T("ComponentPath")
|
||||
#define MOZ_CONTROL_REG_VALUE_COMPONENT_FILE _T("ComponentFile")
|
||||
#define MOZ_CONTROL_REG_VALUE_BIN_DIRECTORY_PATH _T("BinDirectoryPath")
|
||||
|
||||
BOOL CMozillaBrowser::m_bRegistryInitialized = FALSE;
|
||||
|
||||
|
@ -107,8 +106,7 @@ CMozillaBrowser::CMozillaBrowser()
|
|||
m_UserKey.Create(HKEY_CURRENT_USER, MOZ_CONTROL_REG_KEY);
|
||||
|
||||
// Component path and file
|
||||
m_pComponentPath = NULL;
|
||||
m_pComponentFile = NULL;
|
||||
m_pBinDirPath = NULL;
|
||||
|
||||
// Initialise the web shell
|
||||
InitWebShell();
|
||||
|
@ -566,26 +564,21 @@ static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
|||
HRESULT CMozillaBrowser::InitWebShell()
|
||||
{
|
||||
// Initialise XPCOM
|
||||
TCHAR szComponentPath[MAX_PATH];
|
||||
TCHAR szComponentFile[MAX_PATH];
|
||||
DWORD dwComponentPath = sizeof(szComponentPath) / sizeof(szComponentPath[0]);
|
||||
DWORD dwComponentFile = sizeof(szComponentFile) / sizeof(szComponentFile[0]);
|
||||
TCHAR szBinDirPath[MAX_PATH];
|
||||
DWORD dwBinDirPath = sizeof(szBinDirPath) / sizeof(szBinDirPath[0]);
|
||||
|
||||
memset(szComponentPath, 0, sizeof(szComponentPath));
|
||||
memset(szComponentFile, 0, sizeof(szComponentFile));
|
||||
if (m_SystemKey.QueryValue(szComponentPath, MOZ_CONTROL_REG_VALUE_COMPONENT_PATH, &dwComponentPath) == ERROR_SUCCESS &&
|
||||
m_SystemKey.QueryValue(szComponentFile, MOZ_CONTROL_REG_VALUE_COMPONENT_FILE, &dwComponentFile) == ERROR_SUCCESS)
|
||||
memset(szBinDirPath, 0, sizeof(szBinDirPath));
|
||||
if (m_SystemKey.QueryValue(szBinDirPath, MOZ_CONTROL_REG_VALUE_BIN_DIRECTORY_PATH, &dwBinDirPath) == ERROR_SUCCESS)
|
||||
{
|
||||
USES_CONVERSION;
|
||||
|
||||
m_pComponentPath = new nsFileSpec(T2A(szComponentPath));
|
||||
m_pComponentFile = new nsFileSpec(T2A(szComponentFile));
|
||||
m_pBinDirPath = new nsFileSpec(T2A(szBinDirPath));
|
||||
|
||||
NS_InitXPCOM(&m_pIServiceManager, m_pComponentFile, m_pComponentPath);
|
||||
NS_InitXPCOM(&m_pIServiceManager, m_pBinDirPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_InitXPCOM(&m_pIServiceManager, nsnull, nsnull);
|
||||
NS_InitXPCOM(&m_pIServiceManager, nsnull);
|
||||
}
|
||||
|
||||
// Register components
|
||||
|
@ -622,15 +615,10 @@ HRESULT CMozillaBrowser::TermWebShell()
|
|||
NS_ShutdownXPCOM(m_pIServiceManager);
|
||||
m_pIServiceManager = nsnull;
|
||||
|
||||
if (m_pComponentPath)
|
||||
if (m_pBinDirPath)
|
||||
{
|
||||
delete m_pComponentPath;
|
||||
m_pComponentPath = NULL;
|
||||
}
|
||||
if (m_pComponentFile)
|
||||
{
|
||||
delete m_pComponentFile;
|
||||
m_pComponentFile = NULL;
|
||||
delete m_pBinDirPath;
|
||||
m_pBinDirPath = NULL;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
|
@ -2790,4 +2778,4 @@ HRESULT _stdcall CMozillaBrowser::EditCommandHandler(CMozillaBrowser *pThis, con
|
|||
{
|
||||
pThis->OnEditorCommand(nCmdID);
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -326,10 +326,8 @@ protected:
|
|||
// List of registered browser helper objects
|
||||
ObjectList m_cBrowserHelperList;
|
||||
|
||||
// Pointer to the component folder
|
||||
nsFileSpec *m_pComponentPath;
|
||||
// Pointer to the component file
|
||||
nsFileSpec *m_pComponentFile;
|
||||
// Pointer to the bin directory
|
||||
nsFileSpec *m_pBinDirPath;
|
||||
|
||||
virtual HRESULT CreateWebShell();
|
||||
virtual HRESULT InitWebShell();
|
||||
|
|
|
@ -394,7 +394,7 @@ int main(int argc, char **argv)
|
|||
NS_ASSERTION((err==noErr), "AEInstallEventHandler failed");
|
||||
|
||||
// Start up XPCOM?
|
||||
nsresult rv = NS_InitXPCOM(nsnull, nsnull, nsnull);
|
||||
nsresult rv = NS_InitXPCOM(nsnull, nsnull);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_InitXPCOM failed");
|
||||
|
||||
// Hack to get il_ss set so it doesn't fail in xpcompat.c
|
||||
|
|
|
@ -170,7 +170,7 @@ int main(int argc, char **argv)
|
|||
signal(SIGABRT, abnormal_exit_handler);
|
||||
|
||||
// Initialize XPCOM
|
||||
nsresult rv = NS_InitXPCOM(nsnull, nsnull, nsnull);
|
||||
nsresult rv = NS_InitXPCOM(nsnull, nsnull);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_InitXPCOM failed");
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// The toolkit service in mozilla will look in the environment
|
||||
|
|
|
@ -129,7 +129,7 @@ nsNativeBrowserWindow::DispatchMenuItem(PRInt32 aID)
|
|||
int main(int argc, char **argv)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = NS_InitXPCOM(nsnull, nsnull, nsnull);
|
||||
rv = NS_InitXPCOM(nsnull, nsnull);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_InitXPCOM failed");
|
||||
nsViewerApp* app = new nsNativeViewerApp();
|
||||
NS_ADDREF(app);
|
||||
|
|
|
@ -152,7 +152,7 @@ int main(int argc, char **argv)
|
|||
#endif // CRAWL_STACK_ON_SIGSEGV
|
||||
|
||||
// Initialize XPCOM
|
||||
nsresult rv = NS_InitXPCOM(nsnull, nsnull, nsnull);
|
||||
nsresult rv = NS_InitXPCOM(nsnull, nsnull);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_InitXPCOM failed");
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// The toolkit service in mozilla will look in the environment
|
||||
|
|
|
@ -172,7 +172,7 @@ extern nsIServiceManager* gServiceManager;
|
|||
extern PRBool gShuttingDown;
|
||||
|
||||
nsresult NS_COM NS_InitXPCOM(nsIServiceManager* *result,
|
||||
nsFileSpec *registryFile, nsFileSpec *componentDir)
|
||||
nsFileSpec *binDirectory)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
|
@ -205,15 +205,10 @@ nsresult NS_COM NS_InitXPCOM(nsIServiceManager* *result,
|
|||
NS_ADDREF(compMgr);
|
||||
|
||||
// Set the registry file
|
||||
if (registryFile && registryFile->IsFile())
|
||||
if (binDirectory && binDirectory->IsDirectory())
|
||||
{
|
||||
nsSpecialSystemDirectory::Set(nsSpecialSystemDirectory::XPCOM_CurrentProcessComponentRegistry,
|
||||
registryFile);
|
||||
}
|
||||
if (componentDir && componentDir->IsDirectory())
|
||||
{
|
||||
nsSpecialSystemDirectory::Set(nsSpecialSystemDirectory::XPCOM_CurrentProcessComponentDirectory,
|
||||
componentDir);
|
||||
nsSpecialSystemDirectory::Set(nsSpecialSystemDirectory::Moz_BinDirectory,
|
||||
binDirectory);
|
||||
}
|
||||
rv = compMgr->Init();
|
||||
if (NS_FAILED(rv))
|
||||
|
|
|
@ -2251,7 +2251,7 @@ NS_GetGlobalComponentManager(nsIComponentManager* *result)
|
|||
if (nsComponentManagerImpl::gComponentManager == NULL)
|
||||
{
|
||||
// XPCOM needs initialization.
|
||||
rv = NS_InitXPCOM(NULL, NULL, NULL);
|
||||
rv = NS_InitXPCOM(NULL, NULL);
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
|
|
|
@ -332,12 +332,12 @@ NS_NewServiceManager(nsIServiceManager* *result);
|
|||
// before any call can be made to XPCOM. Currently we are coping with this
|
||||
// not being called and internally initializing XPCOM if not already.
|
||||
//
|
||||
// registryFileName is the absolute path to the registry file. This
|
||||
// file will be checked for existence. If it does not exist, it
|
||||
// will use the current process directory name, and tack on "component.reg"
|
||||
|
||||
// binDirectory is the absolute path to the mozilla bin directory.
|
||||
// directory must contain a "components" directory and a component.reg file.
|
||||
|
||||
extern NS_COM nsresult
|
||||
NS_InitXPCOM(nsIServiceManager* *result, nsFileSpec* registryFile, nsFileSpec* componentDir);
|
||||
NS_InitXPCOM(nsIServiceManager* *result, nsFileSpec* binDirectory);
|
||||
|
||||
extern NS_COM nsresult
|
||||
NS_ShutdownXPCOM(nsIServiceManager* servMgr);
|
||||
|
|
|
@ -473,7 +473,7 @@ nsServiceManager::GetGlobalServiceManager(nsIServiceManager* *result)
|
|||
nsresult rv = NS_OK;
|
||||
if (gServiceManager == NULL) {
|
||||
// XPCOM not initialized yet. Let us do initialization of our module.
|
||||
rv = NS_InitXPCOM(NULL, NULL, NULL);
|
||||
rv = NS_InitXPCOM(NULL, NULL);
|
||||
}
|
||||
// No ADDREF as we are advicing no release of this.
|
||||
if (NS_SUCCEEDED(rv))
|
||||
|
|
|
@ -294,6 +294,12 @@ void nsSpecialSystemDirectory::operator = (SystemDirectories aSystemSystemDirect
|
|||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
SystemDirectoriesKey dirKey(aSystemSystemDirectory);
|
||||
SystemDirectoriesKey mozBinDirKey(Moz_BinDirectory);
|
||||
|
||||
// This flag is used to tell whether or not we need to append something
|
||||
// onto the *this. Search for needToAppend to how it's used.
|
||||
// IT's VERY IMPORTANT that needToAppend is initialized to PR_TRUE.
|
||||
PRBool needToAppend = PR_TRUE;
|
||||
|
||||
*this = (const char*)nsnull;
|
||||
switch (aSystemSystemDirectory)
|
||||
|
@ -353,10 +359,22 @@ void nsSpecialSystemDirectory::operator = (SystemDirectories aSystemSystemDirect
|
|||
case XPCOM_CurrentProcessComponentRegistry:
|
||||
{
|
||||
nsFileSpec *dirSpec = NULL;
|
||||
if (systemDirectoriesLocations)
|
||||
{
|
||||
dirSpec = (nsFileSpec *) systemDirectoriesLocations->Get(&dirKey);
|
||||
|
||||
// if someone has called nsSpecialSystemDirectory::Set()
|
||||
if (systemDirectoriesLocations) {
|
||||
// look for the value for the argument key
|
||||
if (!(dirSpec = (nsFileSpec *)systemDirectoriesLocations->Get(&dirKey))) {
|
||||
// if not found, try Moz_BinDirectory
|
||||
dirSpec = (nsFileSpec *)
|
||||
systemDirectoriesLocations->Get(&mozBinDirKey);
|
||||
}
|
||||
else {
|
||||
// if the value is found for the argument key,
|
||||
// we don't need to append.
|
||||
needToAppend = PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (dirSpec)
|
||||
{
|
||||
*this = *dirSpec;
|
||||
|
@ -364,6 +382,9 @@ void nsSpecialSystemDirectory::operator = (SystemDirectories aSystemSystemDirect
|
|||
else
|
||||
{
|
||||
GetCurrentProcessDirectory(*this);
|
||||
}
|
||||
|
||||
if (needToAppend) {
|
||||
// XXX We need to unify these names across all platforms
|
||||
#ifdef XP_MAC
|
||||
*this += "Component Registry";
|
||||
|
@ -377,9 +398,19 @@ void nsSpecialSystemDirectory::operator = (SystemDirectories aSystemSystemDirect
|
|||
case XPCOM_CurrentProcessComponentDirectory:
|
||||
{
|
||||
nsFileSpec *dirSpec = NULL;
|
||||
if (systemDirectoriesLocations)
|
||||
{
|
||||
dirSpec = (nsFileSpec *) systemDirectoriesLocations->Get(&dirKey);
|
||||
// if someone has called nsSpecialSystemDirectory::Set()
|
||||
if (systemDirectoriesLocations) {
|
||||
// look for the value for the argument key
|
||||
if (!(dirSpec = (nsFileSpec *)systemDirectoriesLocations->Get(&dirKey))) {
|
||||
// if not found, try Moz_BinDirectory
|
||||
dirSpec = (nsFileSpec *)
|
||||
systemDirectoriesLocations->Get(&mozBinDirKey);
|
||||
}
|
||||
else {
|
||||
// if the value is found for the argument key,
|
||||
// we don't need to append.
|
||||
needToAppend = PR_FALSE;
|
||||
}
|
||||
}
|
||||
if (dirSpec)
|
||||
{
|
||||
|
@ -389,6 +420,9 @@ void nsSpecialSystemDirectory::operator = (SystemDirectories aSystemSystemDirect
|
|||
{
|
||||
// <exedir>/Components
|
||||
GetCurrentProcessDirectory(*this);
|
||||
}
|
||||
|
||||
if (needToAppend) {
|
||||
// XXX We need to unify these names across all platforms
|
||||
#ifdef XP_MAC
|
||||
*this += "Components";
|
||||
|
@ -399,6 +433,24 @@ void nsSpecialSystemDirectory::operator = (SystemDirectories aSystemSystemDirect
|
|||
}
|
||||
break;
|
||||
|
||||
case Moz_BinDirectory:
|
||||
{
|
||||
nsFileSpec *dirSpec = NULL;
|
||||
// if someone has called nsSpecialSystemDirectory::Set()
|
||||
if (systemDirectoriesLocations) {
|
||||
// look for the value for the argument key
|
||||
dirSpec = (nsFileSpec *)
|
||||
systemDirectoriesLocations->Get(&dirKey);
|
||||
}
|
||||
if (dirSpec) {
|
||||
*this = *dirSpec;
|
||||
}
|
||||
else {
|
||||
GetCurrentProcessDirectory(*this);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
#ifdef XP_MAC
|
||||
case Mac_SystemDirectory:
|
||||
*this = kSystemFolderType;
|
||||
|
@ -672,27 +724,24 @@ void nsSpecialSystemDirectory::operator = (SystemDirectories aSystemSystemDirect
|
|||
}
|
||||
}
|
||||
|
||||
// XXX what does this return value mean?! It isn't checked anywhere,
|
||||
// and a NULL return from the hashtable->Put() isn't an error.
|
||||
PRBool
|
||||
void
|
||||
nsSpecialSystemDirectory::Set(SystemDirectories dirToSet, nsFileSpec *dirSpec)
|
||||
{
|
||||
PRBool rc = PR_FALSE;
|
||||
SystemDirectoriesKey dirKey(dirToSet);
|
||||
|
||||
PR_ASSERT(NULL != dirSpec);
|
||||
|
||||
|
||||
if (NULL == systemDirectoriesLocations) {
|
||||
systemDirectoriesLocations = new nsHashtable(NS_SYSTEMDIR_HASH_NUM);
|
||||
}
|
||||
PR_ASSERT(NULL != systemDirectoriesLocations);
|
||||
|
||||
nsFileSpec *newSpec = new nsFileSpec(*dirSpec);
|
||||
if (newSpec && NULL != systemDirectoriesLocations->Put(&dirKey, newSpec)) {
|
||||
rc = PR_TRUE;
|
||||
if (NULL != newSpec) {
|
||||
systemDirectoriesLocations->Put(&dirKey, newSpec);
|
||||
}
|
||||
|
||||
return rc;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef XP_MAC
|
||||
|
|
|
@ -48,6 +48,8 @@ class NS_COM nsSpecialSystemDirectory : public nsFileSpec
|
|||
|
||||
, XPCOM_CurrentProcessComponentDirectory= 5
|
||||
, XPCOM_CurrentProcessComponentRegistry= 6
|
||||
|
||||
, Moz_BinDirectory = 10
|
||||
|
||||
, Mac_SystemDirectory = 101
|
||||
, Mac_DesktopDirectory = 102
|
||||
|
@ -119,7 +121,7 @@ class NS_COM nsSpecialSystemDirectory : public nsFileSpec
|
|||
|
||||
*/
|
||||
|
||||
static PRBool Set(SystemDirectories dirToSet, nsFileSpec *dirSpec);
|
||||
static void Set(SystemDirectories dirToSet, nsFileSpec *dirSpec);
|
||||
|
||||
|
||||
private:
|
||||
|
|
|
@ -345,7 +345,7 @@ main(int argc, char* argv[])
|
|||
gVerbose = PR_TRUE;
|
||||
}
|
||||
|
||||
rv = NS_InitXPCOM(&servMgr, NULL, NULL);
|
||||
rv = NS_InitXPCOM(&servMgr, NULL);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = TestWriteSegments(NS_OK);
|
||||
|
|
|
@ -582,7 +582,7 @@ main(int argc, char* argv[])
|
|||
nsresult rv;
|
||||
nsIServiceManager* servMgr;
|
||||
|
||||
rv = NS_InitXPCOM(&servMgr, NULL, NULL);
|
||||
rv = NS_InitXPCOM(&servMgr, NULL);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (argc > 1 && nsCRT::strcmp(argv[1], "-trace") == 0)
|
||||
|
|
|
@ -29,7 +29,7 @@ void main(int argc, char* argv[])
|
|||
{
|
||||
nsresult rv;
|
||||
nsIServiceManager* servMgr;
|
||||
rv = NS_InitXPCOM(&servMgr, NULL, NULL);
|
||||
rv = NS_InitXPCOM(&servMgr, NULL);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_InitXPCOM failed");
|
||||
|
||||
// try loading a component and releasing it to see if it leaks
|
||||
|
|
|
@ -49,7 +49,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prevInstance, LPSTR lpszCmdLine,
|
|||
int retCode;
|
||||
|
||||
nsresult rv;
|
||||
rv = NS_InitXPCOM(NULL, NULL, NULL);
|
||||
rv = NS_InitXPCOM(NULL, NULL);
|
||||
{ // Needed to scope all nsCOMPtr within XPCOM Init and Shutdown
|
||||
if(NS_FAILED(rv))
|
||||
{
|
||||
|
|
|
@ -55,7 +55,7 @@ int main( int argc, char *argv[] ) {
|
|||
|
||||
// Initialize XPCOM
|
||||
nsIServiceManager *servMgr = NULL;
|
||||
rv = NS_InitXPCOM(&servMgr, NULL, NULL);
|
||||
rv = NS_InitXPCOM(&servMgr, NULL);
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
// Cannot initialize XPCOM
|
||||
|
|
|
@ -119,7 +119,7 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
int ret = 0;
|
||||
|
||||
NS_InitXPCOM(NULL, NULL, NULL);
|
||||
NS_InitXPCOM(NULL, NULL);
|
||||
|
||||
/* With no arguments, RegFactory will autoregister */
|
||||
if (argc <= 1)
|
||||
|
|
|
@ -215,7 +215,7 @@ static void GetDefaultUserProfileRoot(nsFileSpec& outSpec)
|
|||
static void GetDefaultsFolder(nsFileSpec& outSpec)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsSpecialSystemDirectory cwd(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
|
||||
nsSpecialSystemDirectory cwd(nsSpecialSystemDirectory::Moz_BinDirectory);
|
||||
|
||||
#if defined(XP_MAC)
|
||||
cwd += "Defaults";
|
||||
|
|
|
@ -674,7 +674,7 @@ int main(int argc, char* argv[])
|
|||
if( !NS_CanRun() )
|
||||
return 1;
|
||||
NS_ShowSplashScreen();
|
||||
rv = NS_InitXPCOM(NULL, NULL, NULL);
|
||||
rv = NS_InitXPCOM(NULL, NULL);
|
||||
NS_ASSERTION( NS_SUCCEEDED(rv), "NS_InitXPCOM failed" );
|
||||
|
||||
{
|
||||
|
|
|
@ -93,36 +93,23 @@ PR_PUBLIC_API(nsresult) XPI_Init(
|
|||
OSErr err = noErr;
|
||||
long xpiStubDirID = 0;
|
||||
Boolean isDir = false;
|
||||
FSSpec fsRegFile;
|
||||
|
||||
FSpGetDirectoryID(&aXPIStubDir, &xpiStubDirID, &isDir);
|
||||
err = FSMakeFSSpec(aXPIStubDir.vRefNum, xpiStubDirID, COMPONENT_REG, &fsRegFile);
|
||||
if (err!=noErr)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsfsRegFile = fsRegFile;
|
||||
nsfsDirectory = aXPIStubDir;
|
||||
rv = NS_InitXPCOM(&gServiceMgr, &nsfsRegFile, &nsfsDirectory);
|
||||
rv = NS_InitXPCOM(&gServiceMgr, &nsfsDirectory);
|
||||
#elif defined(XP_PC)
|
||||
char componentPath[_MAX_PATH];
|
||||
|
||||
getcwd(componentPath, _MAX_PATH);
|
||||
nsfsDirectory = componentPath;
|
||||
nsfsRegFile = componentPath;
|
||||
nsfsDirectory += "\\components";
|
||||
nsfsRegFile += "\\";
|
||||
nsfsRegFile += COMPONENT_REG;
|
||||
nsfsDirectory = componentPath;
|
||||
|
||||
rv = NS_InitXPCOM(&gServiceMgr, &nsfsRegFile, &nsfsDirectory);
|
||||
rv = NS_InitXPCOM(&gServiceMgr, &nsfsDirectory);
|
||||
#elif defined(XP_UNIX)
|
||||
nsfsDirectory = aProgramDir;
|
||||
nsfsRegFile = aProgramDir;
|
||||
nsfsRegFile += "/";
|
||||
nsfsRegFile += COMPONENT_REG;
|
||||
nsfsDirectory = aProgramDir;
|
||||
|
||||
rv = NS_InitXPCOM(&gServiceMgr, &nsfsRegFile, &nsfsDirectory);
|
||||
rv = NS_InitXPCOM(&gServiceMgr, &nsfsDirectory);
|
||||
#else
|
||||
rv = NS_InitXPCOM(&gServiceMgr, NULL, NULL);
|
||||
rv = NS_InitXPCOM(&gServiceMgr, NULL);
|
||||
#endif
|
||||
|
||||
if (!NS_SUCCEEDED(rv))
|
||||
|
|
Загрузка…
Ссылка в новой задаче