Skip to content

Commit 13be6d7

Browse files
author
edburns%acm.org
committed
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.
1 parent 7fe9af6 commit 13be6d7

File tree

25 files changed

+127
-122
lines changed

25 files changed

+127
-122
lines changed

embedding/browser/activex/src/control/MozillaBrowser.cpp

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ static const tstring c_szHelpKey = _T("Software\\Microsoft\\Windows\\CurrentVers
5454

5555
#define MOZ_CONTROL_REG_KEY _T("Software\\Mozilla\\")
5656
#define MOZ_CONTROL_REG_VALUE_DIR _T("Dir")
57-
#define MOZ_CONTROL_REG_VALUE_COMPONENT_PATH _T("ComponentPath")
58-
#define MOZ_CONTROL_REG_VALUE_COMPONENT_FILE _T("ComponentFile")
57+
#define MOZ_CONTROL_REG_VALUE_BIN_DIRECTORY_PATH _T("BinDirectoryPath")
5958

6059
BOOL CMozillaBrowser::m_bRegistryInitialized = FALSE;
6160

@@ -107,8 +106,7 @@ CMozillaBrowser::CMozillaBrowser()
107106
m_UserKey.Create(HKEY_CURRENT_USER, MOZ_CONTROL_REG_KEY);
108107

109108
// Component path and file
110-
m_pComponentPath = NULL;
111-
m_pComponentFile = NULL;
109+
m_pBinDirPath = NULL;
112110

113111
// Initialise the web shell
114112
InitWebShell();
@@ -566,26 +564,21 @@ static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
566564
HRESULT CMozillaBrowser::InitWebShell()
567565
{
568566
// Initialise XPCOM
569-
TCHAR szComponentPath[MAX_PATH];
570-
TCHAR szComponentFile[MAX_PATH];
571-
DWORD dwComponentPath = sizeof(szComponentPath) / sizeof(szComponentPath[0]);
572-
DWORD dwComponentFile = sizeof(szComponentFile) / sizeof(szComponentFile[0]);
567+
TCHAR szBinDirPath[MAX_PATH];
568+
DWORD dwBinDirPath = sizeof(szBinDirPath) / sizeof(szBinDirPath[0]);
573569

574-
memset(szComponentPath, 0, sizeof(szComponentPath));
575-
memset(szComponentFile, 0, sizeof(szComponentFile));
576-
if (m_SystemKey.QueryValue(szComponentPath, MOZ_CONTROL_REG_VALUE_COMPONENT_PATH, &dwComponentPath) == ERROR_SUCCESS &&
577-
m_SystemKey.QueryValue(szComponentFile, MOZ_CONTROL_REG_VALUE_COMPONENT_FILE, &dwComponentFile) == ERROR_SUCCESS)
570+
memset(szBinDirPath, 0, sizeof(szBinDirPath));
571+
if (m_SystemKey.QueryValue(szBinDirPath, MOZ_CONTROL_REG_VALUE_BIN_DIRECTORY_PATH, &dwBinDirPath) == ERROR_SUCCESS)
578572
{
579573
USES_CONVERSION;
580574

581-
m_pComponentPath = new nsFileSpec(T2A(szComponentPath));
582-
m_pComponentFile = new nsFileSpec(T2A(szComponentFile));
575+
m_pBinDirPath = new nsFileSpec(T2A(szBinDirPath));
583576

584-
NS_InitXPCOM(&m_pIServiceManager, m_pComponentFile, m_pComponentPath);
577+
NS_InitXPCOM(&m_pIServiceManager, m_pBinDirPath);
585578
}
586579
else
587580
{
588-
NS_InitXPCOM(&m_pIServiceManager, nsnull, nsnull);
581+
NS_InitXPCOM(&m_pIServiceManager, nsnull);
589582
}
590583

591584
// Register components
@@ -622,15 +615,10 @@ HRESULT CMozillaBrowser::TermWebShell()
622615
NS_ShutdownXPCOM(m_pIServiceManager);
623616
m_pIServiceManager = nsnull;
624617

625-
if (m_pComponentPath)
618+
if (m_pBinDirPath)
626619
{
627-
delete m_pComponentPath;
628-
m_pComponentPath = NULL;
629-
}
630-
if (m_pComponentFile)
631-
{
632-
delete m_pComponentFile;
633-
m_pComponentFile = NULL;
620+
delete m_pBinDirPath;
621+
m_pBinDirPath = NULL;
634622
}
635623

636624
return S_OK;
@@ -2790,4 +2778,4 @@ HRESULT _stdcall CMozillaBrowser::EditCommandHandler(CMozillaBrowser *pThis, con
27902778
{
27912779
pThis->OnEditorCommand(nCmdID);
27922780
return S_OK;
2793-
}
2781+
}

embedding/browser/activex/src/control/MozillaBrowser.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,8 @@ END_OLECOMMAND_TABLE()
326326
// List of registered browser helper objects
327327
ObjectList m_cBrowserHelperList;
328328

329-
// Pointer to the component folder
330-
nsFileSpec *m_pComponentPath;
331-
// Pointer to the component file
332-
nsFileSpec *m_pComponentFile;
329+
// Pointer to the bin directory
330+
nsFileSpec *m_pBinDirPath;
333331

334332
virtual HRESULT CreateWebShell();
335333
virtual HRESULT InitWebShell();

js/src/xpconnect/shell/xpcshell.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ main(int argc, char **argv)
643643
gErrFile = stderr;
644644
gOutFile = stdout;
645645

646-
rv = NS_InitXPCOM(NULL, NULL, NULL);
646+
rv = NS_InitXPCOM(NULL, NULL);
647647
NS_ASSERTION( NS_SUCCEEDED(rv), "NS_InitXPCOM failed" );
648648

649649
SetupRegistry();

netwerk/protocol/res/src/nsResProtocolHandler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ nsResProtocolHandler::Init()
5858
return NS_ERROR_OUT_OF_MEMORY;
5959

6060
// set up initial mappings
61-
rv = SetSpecialDir("ProgramDir", nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
61+
rv = SetSpecialDir("ProgramDir", nsSpecialSystemDirectory::Moz_BinDirectory);
6262
if (NS_FAILED(rv)) return rv;
6363

6464
// make "res:///" == "resource:/"
65-
rv = SetSpecialDir("", nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
65+
rv = SetSpecialDir("", nsSpecialSystemDirectory::Moz_BinDirectory);
6666
if (NS_FAILED(rv)) return rv;
6767

6868
rv = SetSpecialDir("CurrentDir", nsSpecialSystemDirectory::OS_CurrentWorkingDirectory);

webshell/embed/ActiveX/MozillaBrowser.cpp

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ static const tstring c_szHelpKey = _T("Software\\Microsoft\\Windows\\CurrentVers
5454

5555
#define MOZ_CONTROL_REG_KEY _T("Software\\Mozilla\\")
5656
#define MOZ_CONTROL_REG_VALUE_DIR _T("Dir")
57-
#define MOZ_CONTROL_REG_VALUE_COMPONENT_PATH _T("ComponentPath")
58-
#define MOZ_CONTROL_REG_VALUE_COMPONENT_FILE _T("ComponentFile")
57+
#define MOZ_CONTROL_REG_VALUE_BIN_DIRECTORY_PATH _T("BinDirectoryPath")
5958

6059
BOOL CMozillaBrowser::m_bRegistryInitialized = FALSE;
6160

@@ -107,8 +106,7 @@ CMozillaBrowser::CMozillaBrowser()
107106
m_UserKey.Create(HKEY_CURRENT_USER, MOZ_CONTROL_REG_KEY);
108107

109108
// Component path and file
110-
m_pComponentPath = NULL;
111-
m_pComponentFile = NULL;
109+
m_pBinDirPath = NULL;
112110

113111
// Initialise the web shell
114112
InitWebShell();
@@ -566,26 +564,21 @@ static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
566564
HRESULT CMozillaBrowser::InitWebShell()
567565
{
568566
// Initialise XPCOM
569-
TCHAR szComponentPath[MAX_PATH];
570-
TCHAR szComponentFile[MAX_PATH];
571-
DWORD dwComponentPath = sizeof(szComponentPath) / sizeof(szComponentPath[0]);
572-
DWORD dwComponentFile = sizeof(szComponentFile) / sizeof(szComponentFile[0]);
567+
TCHAR szBinDirPath[MAX_PATH];
568+
DWORD dwBinDirPath = sizeof(szBinDirPath) / sizeof(szBinDirPath[0]);
573569

574-
memset(szComponentPath, 0, sizeof(szComponentPath));
575-
memset(szComponentFile, 0, sizeof(szComponentFile));
576-
if (m_SystemKey.QueryValue(szComponentPath, MOZ_CONTROL_REG_VALUE_COMPONENT_PATH, &dwComponentPath) == ERROR_SUCCESS &&
577-
m_SystemKey.QueryValue(szComponentFile, MOZ_CONTROL_REG_VALUE_COMPONENT_FILE, &dwComponentFile) == ERROR_SUCCESS)
570+
memset(szBinDirPath, 0, sizeof(szBinDirPath));
571+
if (m_SystemKey.QueryValue(szBinDirPath, MOZ_CONTROL_REG_VALUE_BIN_DIRECTORY_PATH, &dwBinDirPath) == ERROR_SUCCESS)
578572
{
579573
USES_CONVERSION;
580574

581-
m_pComponentPath = new nsFileSpec(T2A(szComponentPath));
582-
m_pComponentFile = new nsFileSpec(T2A(szComponentFile));
575+
m_pBinDirPath = new nsFileSpec(T2A(szBinDirPath));
583576

584-
NS_InitXPCOM(&m_pIServiceManager, m_pComponentFile, m_pComponentPath);
577+
NS_InitXPCOM(&m_pIServiceManager, m_pBinDirPath);
585578
}
586579
else
587580
{
588-
NS_InitXPCOM(&m_pIServiceManager, nsnull, nsnull);
581+
NS_InitXPCOM(&m_pIServiceManager, nsnull);
589582
}
590583

591584
// Register components
@@ -622,15 +615,10 @@ HRESULT CMozillaBrowser::TermWebShell()
622615
NS_ShutdownXPCOM(m_pIServiceManager);
623616
m_pIServiceManager = nsnull;
624617

625-
if (m_pComponentPath)
618+
if (m_pBinDirPath)
626619
{
627-
delete m_pComponentPath;
628-
m_pComponentPath = NULL;
629-
}
630-
if (m_pComponentFile)
631-
{
632-
delete m_pComponentFile;
633-
m_pComponentFile = NULL;
620+
delete m_pBinDirPath;
621+
m_pBinDirPath = NULL;
634622
}
635623

636624
return S_OK;
@@ -2790,4 +2778,4 @@ HRESULT _stdcall CMozillaBrowser::EditCommandHandler(CMozillaBrowser *pThis, con
27902778
{
27912779
pThis->OnEditorCommand(nCmdID);
27922780
return S_OK;
2793-
}
2781+
}

webshell/embed/ActiveX/MozillaBrowser.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,8 @@ END_OLECOMMAND_TABLE()
326326
// List of registered browser helper objects
327327
ObjectList m_cBrowserHelperList;
328328

329-
// Pointer to the component folder
330-
nsFileSpec *m_pComponentPath;
331-
// Pointer to the component file
332-
nsFileSpec *m_pComponentFile;
329+
// Pointer to the bin directory
330+
nsFileSpec *m_pBinDirPath;
333331

334332
virtual HRESULT CreateWebShell();
335333
virtual HRESULT InitWebShell();

webshell/tests/viewer/nsMacMain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ int main(int argc, char **argv)
394394
NS_ASSERTION((err==noErr), "AEInstallEventHandler failed");
395395

396396
// Start up XPCOM?
397-
nsresult rv = NS_InitXPCOM(nsnull, nsnull, nsnull);
397+
nsresult rv = NS_InitXPCOM(nsnull, nsnull);
398398
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_InitXPCOM failed");
399399

400400
// Hack to get il_ss set so it doesn't fail in xpcompat.c

webshell/tests/viewer/nsPhMain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ int main(int argc, char **argv)
170170
signal(SIGABRT, abnormal_exit_handler);
171171

172172
// Initialize XPCOM
173-
nsresult rv = NS_InitXPCOM(nsnull, nsnull, nsnull);
173+
nsresult rv = NS_InitXPCOM(nsnull, nsnull);
174174
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_InitXPCOM failed");
175175
if (NS_SUCCEEDED(rv)) {
176176
// The toolkit service in mozilla will look in the environment

webshell/tests/viewer/nsWinMain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ nsNativeBrowserWindow::DispatchMenuItem(PRInt32 aID)
129129
int main(int argc, char **argv)
130130
{
131131
nsresult rv;
132-
rv = NS_InitXPCOM(nsnull, nsnull, nsnull);
132+
rv = NS_InitXPCOM(nsnull, nsnull);
133133
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_InitXPCOM failed");
134134
nsViewerApp* app = new nsNativeViewerApp();
135135
NS_ADDREF(app);

webshell/tests/viewer/unix/gtk/nsGtkMain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ int main(int argc, char **argv)
152152
#endif // CRAWL_STACK_ON_SIGSEGV
153153

154154
// Initialize XPCOM
155-
nsresult rv = NS_InitXPCOM(nsnull, nsnull, nsnull);
155+
nsresult rv = NS_InitXPCOM(nsnull, nsnull);
156156
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_InitXPCOM failed");
157157
if (NS_SUCCEEDED(rv)) {
158158
// The toolkit service in mozilla will look in the environment

xpcom/build/nsXPComInit.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ extern nsIServiceManager* gServiceManager;
172172
extern PRBool gShuttingDown;
173173

174174
nsresult NS_COM NS_InitXPCOM(nsIServiceManager* *result,
175-
nsFileSpec *registryFile, nsFileSpec *componentDir)
175+
nsFileSpec *binDirectory)
176176
{
177177
nsresult rv = NS_OK;
178178

@@ -205,15 +205,10 @@ nsresult NS_COM NS_InitXPCOM(nsIServiceManager* *result,
205205
NS_ADDREF(compMgr);
206206

207207
// Set the registry file
208-
if (registryFile && registryFile->IsFile())
208+
if (binDirectory && binDirectory->IsDirectory())
209209
{
210-
nsSpecialSystemDirectory::Set(nsSpecialSystemDirectory::XPCOM_CurrentProcessComponentRegistry,
211-
registryFile);
212-
}
213-
if (componentDir && componentDir->IsDirectory())
214-
{
215-
nsSpecialSystemDirectory::Set(nsSpecialSystemDirectory::XPCOM_CurrentProcessComponentDirectory,
216-
componentDir);
210+
nsSpecialSystemDirectory::Set(nsSpecialSystemDirectory::Moz_BinDirectory,
211+
binDirectory);
217212
}
218213
rv = compMgr->Init();
219214
if (NS_FAILED(rv))

xpcom/components/nsComponentManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2251,7 +2251,7 @@ NS_GetGlobalComponentManager(nsIComponentManager* *result)
22512251
if (nsComponentManagerImpl::gComponentManager == NULL)
22522252
{
22532253
// XPCOM needs initialization.
2254-
rv = NS_InitXPCOM(NULL, NULL, NULL);
2254+
rv = NS_InitXPCOM(NULL, NULL);
22552255
}
22562256

22572257
if (NS_SUCCEEDED(rv))

xpcom/components/nsIServiceManager.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,12 +332,12 @@ NS_NewServiceManager(nsIServiceManager* *result);
332332
// before any call can be made to XPCOM. Currently we are coping with this
333333
// not being called and internally initializing XPCOM if not already.
334334
//
335-
// registryFileName is the absolute path to the registry file. This
336-
// file will be checked for existence. If it does not exist, it
337-
// will use the current process directory name, and tack on "component.reg"
335+
336+
// binDirectory is the absolute path to the mozilla bin directory.
337+
// directory must contain a "components" directory and a component.reg file.
338338

339339
extern NS_COM nsresult
340-
NS_InitXPCOM(nsIServiceManager* *result, nsFileSpec* registryFile, nsFileSpec* componentDir);
340+
NS_InitXPCOM(nsIServiceManager* *result, nsFileSpec* binDirectory);
341341

342342
extern NS_COM nsresult
343343
NS_ShutdownXPCOM(nsIServiceManager* servMgr);

xpcom/components/nsServiceManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ nsServiceManager::GetGlobalServiceManager(nsIServiceManager* *result)
473473
nsresult rv = NS_OK;
474474
if (gServiceManager == NULL) {
475475
// XPCOM not initialized yet. Let us do initialization of our module.
476-
rv = NS_InitXPCOM(NULL, NULL, NULL);
476+
rv = NS_InitXPCOM(NULL, NULL);
477477
}
478478
// No ADDREF as we are advicing no release of this.
479479
if (NS_SUCCEEDED(rv))

0 commit comments

Comments
 (0)