зеркало из https://github.com/mozilla/gecko-dev.git
allow install wizard to override program directory
This commit is contained in:
Родитель
9e851343f5
Коммит
daae3f07cc
|
@ -37,6 +37,7 @@
|
|||
|
||||
#include "nsISoftwareUpdate.h"
|
||||
#include "nsSoftwareUpdateIIDs.h"
|
||||
#include "nsPvtIXPIStubHook.h"
|
||||
|
||||
#include "plstr.h"
|
||||
|
||||
|
@ -75,6 +76,9 @@ PR_PUBLIC_API(nsresult) XPI_Init(
|
|||
nsCOMPtr<nsIFileSpec> nsIfsDirectory;
|
||||
nsFileSpec nsfsDirectory;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Initialize XPCOM and AutoRegister() its components
|
||||
//--------------------------------------------------------------------
|
||||
rv = NS_InitXPCOM(&gServiceMgr);
|
||||
if (!NS_SUCCEEDED(rv))
|
||||
return rv;
|
||||
|
@ -107,15 +111,45 @@ PR_PUBLIC_API(nsresult) XPI_Init(
|
|||
#else
|
||||
rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, 0);
|
||||
#endif
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
|
||||
if (!NS_SUCCEEDED(rv))
|
||||
return rv;
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Get the SoftwareUpdate (XPInstall) service.
|
||||
//
|
||||
// Since AppShell is not started by XPIStub the XPI service is never
|
||||
// registered with the service manager. We keep a local pointer to it
|
||||
// so it stays alive througout.
|
||||
//--------------------------------------------------------------------
|
||||
rv = nsComponentManager::CreateInstance(kSoftwareUpdateCID,
|
||||
nsnull,
|
||||
nsISoftwareUpdate::GetIID(),
|
||||
(void**) &gXPI);
|
||||
if (!NS_SUCCEEDED(rv))
|
||||
return rv;
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Override XPInstall's natural assumption that the current executable
|
||||
// is Mozilla. Use the given directory as the "Program" folder.
|
||||
//--------------------------------------------------------------------
|
||||
nsCOMPtr<nsPvtIXPIStubHook> hook = do_QueryInterface(gXPI);
|
||||
nsFileSpec dirSpec( aDir );
|
||||
nsCOMPtr<nsIFileSpec> iDirSpec;
|
||||
|
||||
NS_NewFileSpecWithSpec( dirSpec, getter_AddRefs(iDirSpec) );
|
||||
|
||||
if (hook && iDirSpec)
|
||||
hook->SetProgramDirectory( iDirSpec );
|
||||
else
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Save the install wizard's callbacks as a nsIXPINotifer for later
|
||||
//--------------------------------------------------------------------
|
||||
nsStubNotifier* stub = new nsStubNotifier( startCB, progressCB, finalCB );
|
||||
if (!stub)
|
||||
{
|
||||
|
@ -126,9 +160,6 @@ PR_PUBLIC_API(nsresult) XPI_Init(
|
|||
{
|
||||
rv = stub->QueryInterface(nsIXPINotifier::GetIID(), (void**)&gNotifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче