diff --git a/components/geckoport/Components/GeckoInit.pas b/components/geckoport/Components/GeckoInit.pas index e0087a4f4..b0adb2481 100644 --- a/components/geckoport/Components/GeckoInit.pas +++ b/components/geckoport/Components/GeckoInit.pas @@ -2,7 +2,7 @@ unit GeckoInit; interface -procedure GeckoComponentsStartup; +procedure GeckoComponentsStartup(XPComPath: string = ''); procedure GeckoComponentsShutdown; implementation @@ -14,7 +14,7 @@ uses var sInitCount: Integer = 0; -procedure GeckoComponentsStartup(); +procedure GeckoComponentsStartup(XPComPath: string = ''); var rv: nsresult; @@ -26,7 +26,7 @@ begin Exit; end; - rv := XRE_Startup('1.9', True, '2.0', False); + rv := XRE_Startup('1.9', True, '2.0', False, XPComPath); if NS_FAILED(rv) then begin diff --git a/components/geckoport/nsXRE.pas b/components/geckoport/nsXRE.pas index 172f0eb84..e386f1536 100755 --- a/components/geckoport/nsXRE.pas +++ b/components/geckoport/nsXRE.pas @@ -54,14 +54,16 @@ function XRE_UnloadGRE(): nsresult; function XRE_FindAndLoadGRE(const lowerVer: PAnsiChar; lowerInclusive: PRBool; const upperVer: PAnsiChar; - upperInclusive: PRBool): nsresult; + upperInclusive: PRBool; + XPComPath: string = ''): nsresult; function XRE_GetLoadedGREPath(GREPath: PAnsiChar; GREPathLen: Cardinal): nsresult; function XRE_Startup(const lowerVer: PAnsiChar; lowerInclusive: PRBool; const upperVer: PAnsiChar; - upperInclusive: PRBool): nsresult; + upperInclusive: PRBool; + XPComPath: string = ''): nsresult; function XRE_Shutdown(): nsresult; function XRE_main(argc: integer; @@ -265,11 +267,7 @@ begin end; lastSlash^ := #0; NS_StrLCopy(xulPath, xpcomPath, MAX_PATH); -{$IFDEF MSWINDOWS} - NS_StrLCat(xulPath, '\' + libxul, MAX_PATH); -{$ELSE} - NS_StrLCat(xulPath, '/' + libxul, MAX_PATH); -{$ENDIF} + NS_StrLCat(xulPath, DirectorySeparator + libxul, MAX_PATH); Result := XPCOMGlueStartup(GREPath); if NS_FAILED(Result) then @@ -318,15 +316,28 @@ end; function XRE_FindAndLoadGRE(const lowerVer: PAnsiChar; lowerInclusive: PRBool; const upperVer: PAnsiChar; - upperInclusive: PRBool): nsresult; + upperInclusive: PRBool; + XPComPath: string = ''): nsresult; var grePath: array[0..MAX_PATH] of AnsiChar; begin - Result := XRE_FindGRE(lowerVer, lowerInclusive, - upperVer, upperInclusive, - grePath, MAX_PATH); - if NS_FAILED(Result) then + if XPComPath='' then + begin + Result := XRE_FindGRE(lowerVer, lowerInclusive, + upperVer, upperInclusive, + grePath, MAX_PATH); + if NS_FAILED(Result) then + Exit; + end + else if FileExists(XPComPath) then + begin + NS_StrLCopy(GREPath, pchar(XPComPath), length(XPComPath)); + end + else + begin + result := NS_ERROR_FILE_ACCESS_DENIED; Exit; + end; Result := XRE_LoadGRE(grePath); end; @@ -346,7 +357,8 @@ end; function XRE_Startup(const lowerVer: PAnsiChar; lowerInclusive: PRBool; const upperVer: PAnsiChar; - upperInclusive: PRBool): nsresult; + upperInclusive: PRBool; + XPComPath: string = ''): nsresult; var grePath: array[0..MAX_PATH] of AnsiChar; xulDir: nsILocalFile; @@ -356,7 +368,8 @@ var appDir: nsILocalFile; begin Result := XRE_FindAndLoadGRE(lowerVer, lowerInclusive, - upperVer, upperInclusive); + upperVer, upperInclusive, + XPComPath); if NS_FAILED(Result) then Exit;