2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* The privileged system principal. */
|
|
|
|
|
|
|
|
#include "nscore.h"
|
|
|
|
#include "nsSystemPrincipal.h"
|
|
|
|
#include "nsIComponentManager.h"
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIURL.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsXPIDLString.h"
|
|
|
|
#include "nsReadableUtils.h"
|
|
|
|
#include "nsCRT.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsIClassInfoImpl.h"
|
2012-07-19 22:44:03 -07:00
|
|
|
#include "nsIScriptSecurityManager.h"
|
2013-07-11 13:21:45 -07:00
|
|
|
#include "pratom.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-04-02 17:16:25 -07:00
|
|
|
NS_IMPL_CLASSINFO(nsSystemPrincipal, nullptr,
|
2010-06-22 09:59:57 -07:00
|
|
|
nsIClassInfo::SINGLETON | nsIClassInfo::MAIN_THREAD_ONLY,
|
|
|
|
NS_SYSTEMPRINCIPAL_CID)
|
2014-04-27 00:06:00 -07:00
|
|
|
NS_IMPL_QUERY_INTERFACE_CI(nsSystemPrincipal,
|
|
|
|
nsIPrincipal,
|
|
|
|
nsISerializable)
|
|
|
|
NS_IMPL_CI_INTERFACE_GETTER(nsSystemPrincipal,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIPrincipal,
|
|
|
|
nsISerializable)
|
|
|
|
|
2015-05-16 01:07:10 -07:00
|
|
|
#define SYSTEM_PRINCIPAL_SPEC "[System Principal]"
|
2012-03-09 01:48:50 -08:00
|
|
|
|
|
|
|
void
|
|
|
|
nsSystemPrincipal::GetScriptLocation(nsACString &aStr)
|
|
|
|
{
|
2015-05-16 01:07:10 -07:00
|
|
|
aStr.AssignLiteral(SYSTEM_PRINCIPAL_SPEC);
|
2012-03-09 01:48:50 -08:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
///////////////////////////////////////
|
|
|
|
// Methods implementing nsIPrincipal //
|
|
|
|
///////////////////////////////////////
|
|
|
|
|
2008-02-26 19:45:29 -08:00
|
|
|
NS_IMETHODIMP
|
2012-08-20 11:34:33 -07:00
|
|
|
nsSystemPrincipal::CheckMayLoad(nsIURI* uri, bool aReport, bool aAllowIfInheritsPrincipal)
|
2008-02-26 19:45:29 -08:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsSystemPrincipal::GetHashValue(uint32_t *result)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
*result = NS_PTR_TO_INT32(this);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSystemPrincipal::GetURI(nsIURI** aURI)
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
*aURI = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-05-14 16:50:44 -07:00
|
|
|
nsresult
|
|
|
|
nsSystemPrincipal::GetOriginInternal(nsACString& aOrigin)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2015-05-12 15:08:20 -07:00
|
|
|
aOrigin.AssignLiteral(SYSTEM_PRINCIPAL_SPEC);
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-01-22 13:38:21 -08:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSystemPrincipal::GetCsp(nsIContentSecurityPolicy** aCsp)
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
*aCsp = nullptr;
|
2010-01-22 13:38:21 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSystemPrincipal::SetCsp(nsIContentSecurityPolicy* aCsp)
|
|
|
|
{
|
|
|
|
// CSP on a null principal makes no sense
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSystemPrincipal::GetDomain(nsIURI** aDomain)
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
*aDomain = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSystemPrincipal::SetDomain(nsIURI* aDomain)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-01-08 13:53:32 -08:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSystemPrincipal::GetBaseDomain(nsACString& aBaseDomain)
|
|
|
|
{
|
|
|
|
// No base domain for chrome.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//////////////////////////////////////////
|
|
|
|
// Methods implementing nsISerializable //
|
|
|
|
//////////////////////////////////////////
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSystemPrincipal::Read(nsIObjectInputStream* aStream)
|
|
|
|
{
|
|
|
|
// no-op: CID is sufficient to identify the mSystemPrincipal singleton
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSystemPrincipal::Write(nsIObjectOutputStream* aStream)
|
|
|
|
{
|
|
|
|
// no-op: CID is sufficient to identify the mSystemPrincipal singleton
|
|
|
|
return NS_OK;
|
|
|
|
}
|