Init the system principal singleton when we init the security manager -- no

need for lazy init here.  Bug 327176, r=mrbkap, sr=dveditz
This commit is contained in:
bzbarsky%mit.edu 2006-04-02 21:10:23 +00:00
Родитель 25ab5fffef
Коммит 40f15bd48c
1 изменённых файлов: 10 добавлений и 14 удалений

Просмотреть файл

@ -1698,19 +1698,6 @@ nsScriptSecurityManager::doGetSubjectPrincipal(nsresult* rv)
NS_IMETHODIMP
nsScriptSecurityManager::GetSystemPrincipal(nsIPrincipal **result)
{
if (!mSystemPrincipal)
{
nsRefPtr<nsSystemPrincipal> system = new nsSystemPrincipal();
if (!system)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv = system->Init();
if (NS_FAILED(rv))
return rv;
mSystemPrincipal = system;
}
NS_ADDREF(*result = mSystemPrincipal);
return NS_OK;
@ -3039,6 +3026,15 @@ nsresult nsScriptSecurityManager::Init()
rv = bundleService->CreateBundle("chrome://global/locale/security/caps.properties", &sStrBundle);
NS_ENSURE_SUCCESS(rv, rv);
// Create our system principal singleton
nsRefPtr<nsSystemPrincipal> system = new nsSystemPrincipal();
NS_ENSURE_TRUE(system, NS_ERROR_OUT_OF_MEMORY);
rv = system->Init();
NS_ENSURE_SUCCESS(rv, rv);
mSystemPrincipal = system;
//-- Register security check callback in the JS engine
// Currently this is used to control access to function.caller
nsCOMPtr<nsIJSRuntimeService> runtimeService =
@ -3133,7 +3129,7 @@ nsScriptSecurityManager::SystemPrincipalSingletonConstructor()
{
nsIPrincipal *sysprin = nsnull;
if (gScriptSecMan)
gScriptSecMan->GetSystemPrincipal(&sysprin);
sysprin = gScriptSecMan->mSystemPrincipal;
return NS_STATIC_CAST(nsSystemPrincipal*, sysprin);
}