зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1343933 - Renaming Principal classes - part 4 - ContentPrincipal, r=qdot
--HG-- rename : caps/nsPrincipal.cpp => caps/ContentPrincipal.cpp rename : caps/nsPrincipal.h => caps/ContentPrincipal.h
This commit is contained in:
Родитель
f91cb666bb
Коммит
507c00cb9f
|
@ -16,7 +16,7 @@
|
|||
#include "nsIObjectInputStream.h"
|
||||
#include "nsIObjectOutputStream.h"
|
||||
|
||||
#include "nsPrincipal.h"
|
||||
#include "ContentPrincipal.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIURIWithPrincipal.h"
|
||||
#include "NullPrincipal.h"
|
||||
|
@ -661,7 +661,7 @@ BasePrincipal::CreateCodebasePrincipal(nsIURI* aURI, const OriginAttributes& aAt
|
|||
}
|
||||
|
||||
// Mint a codebase principal.
|
||||
RefPtr<nsPrincipal> codebase = new nsPrincipal();
|
||||
RefPtr<ContentPrincipal> codebase = new ContentPrincipal();
|
||||
rv = codebase->Init(aURI, aAttrs);
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
return codebase.forget();
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* 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/. */
|
||||
|
||||
#include "nsPrincipal.h"
|
||||
#include "ContentPrincipal.h"
|
||||
|
||||
#include "mozIThirdPartyUtil.h"
|
||||
#include "nscore.h"
|
||||
|
@ -19,6 +19,8 @@
|
|||
#include "nsJSPrincipals.h"
|
||||
#include "nsIEffectiveTLDService.h"
|
||||
#include "nsIClassInfoImpl.h"
|
||||
#include "nsIObjectInputStream.h"
|
||||
#include "nsIObjectOutputStream.h"
|
||||
#include "nsIProtocolHandler.h"
|
||||
#include "nsError.h"
|
||||
#include "nsIContentSecurityPolicy.h"
|
||||
|
@ -58,25 +60,25 @@ GetAddonPolicyService(nsresult* aRv)
|
|||
return addonPolicyService;
|
||||
}
|
||||
|
||||
NS_IMPL_CLASSINFO(nsPrincipal, nullptr, nsIClassInfo::MAIN_THREAD_ONLY,
|
||||
NS_IMPL_CLASSINFO(ContentPrincipal, nullptr, nsIClassInfo::MAIN_THREAD_ONLY,
|
||||
NS_PRINCIPAL_CID)
|
||||
NS_IMPL_QUERY_INTERFACE_CI(nsPrincipal,
|
||||
NS_IMPL_QUERY_INTERFACE_CI(ContentPrincipal,
|
||||
nsIPrincipal,
|
||||
nsISerializable)
|
||||
NS_IMPL_CI_INTERFACE_GETTER(nsPrincipal,
|
||||
NS_IMPL_CI_INTERFACE_GETTER(ContentPrincipal,
|
||||
nsIPrincipal,
|
||||
nsISerializable)
|
||||
|
||||
// Called at startup:
|
||||
/* static */ void
|
||||
nsPrincipal::InitializeStatics()
|
||||
ContentPrincipal::InitializeStatics()
|
||||
{
|
||||
Preferences::AddBoolVarCache(&gCodeBasePrincipalSupport,
|
||||
"signed.applets.codebase_principal_support",
|
||||
false);
|
||||
}
|
||||
|
||||
nsPrincipal::nsPrincipal()
|
||||
ContentPrincipal::ContentPrincipal()
|
||||
: BasePrincipal(eCodebasePrincipal)
|
||||
, mCodebaseImmutable(false)
|
||||
, mDomainImmutable(false)
|
||||
|
@ -84,7 +86,7 @@ nsPrincipal::nsPrincipal()
|
|||
{
|
||||
}
|
||||
|
||||
nsPrincipal::~nsPrincipal()
|
||||
ContentPrincipal::~ContentPrincipal()
|
||||
{
|
||||
// let's clear the principal within the csp to avoid a tangling pointer
|
||||
if (mCSP) {
|
||||
|
@ -93,7 +95,8 @@ nsPrincipal::~nsPrincipal()
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsPrincipal::Init(nsIURI *aCodebase, const OriginAttributes& aOriginAttributes)
|
||||
ContentPrincipal::Init(nsIURI *aCodebase,
|
||||
const OriginAttributes& aOriginAttributes)
|
||||
{
|
||||
NS_ENSURE_STATE(!mInitialized);
|
||||
NS_ENSURE_ARG(aCodebase);
|
||||
|
@ -123,13 +126,13 @@ nsPrincipal::Init(nsIURI *aCodebase, const OriginAttributes& aOriginAttributes)
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsPrincipal::GetScriptLocation(nsACString &aStr)
|
||||
ContentPrincipal::GetScriptLocation(nsACString &aStr)
|
||||
{
|
||||
return mCodebase->GetSpec(aStr);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPrincipal::GetOriginInternal(nsACString& aOrigin)
|
||||
ContentPrincipal::GetOriginInternal(nsACString& aOrigin)
|
||||
{
|
||||
if (!mCodebase) {
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -249,12 +252,12 @@ nsPrincipal::GetOriginInternal(nsACString& aOrigin)
|
|||
}
|
||||
|
||||
bool
|
||||
nsPrincipal::SubsumesInternal(nsIPrincipal* aOther,
|
||||
BasePrincipal::DocumentDomainConsideration aConsideration)
|
||||
ContentPrincipal::SubsumesInternal(nsIPrincipal* aOther,
|
||||
BasePrincipal::DocumentDomainConsideration aConsideration)
|
||||
{
|
||||
MOZ_ASSERT(aOther);
|
||||
|
||||
// For nsPrincipal, Subsumes is equivalent to Equals.
|
||||
// For ContentPrincipal, Subsumes is equivalent to Equals.
|
||||
if (aOther == this) {
|
||||
return true;
|
||||
}
|
||||
|
@ -286,7 +289,7 @@ nsPrincipal::SubsumesInternal(nsIPrincipal* aOther,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrincipal::GetURI(nsIURI** aURI)
|
||||
ContentPrincipal::GetURI(nsIURI** aURI)
|
||||
{
|
||||
if (mCodebaseImmutable) {
|
||||
NS_ADDREF(*aURI = mCodebase);
|
||||
|
@ -302,7 +305,7 @@ nsPrincipal::GetURI(nsIURI** aURI)
|
|||
}
|
||||
|
||||
bool
|
||||
nsPrincipal::MayLoadInternal(nsIURI* aURI)
|
||||
ContentPrincipal::MayLoadInternal(nsIURI* aURI)
|
||||
{
|
||||
// See if aURI is something like a Blob URI that is actually associated with
|
||||
// a principal.
|
||||
|
@ -338,7 +341,7 @@ nsPrincipal::MayLoadInternal(nsIURI* aURI)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrincipal::GetHashValue(uint32_t* aValue)
|
||||
ContentPrincipal::GetHashValue(uint32_t* aValue)
|
||||
{
|
||||
NS_PRECONDITION(mCodebase, "Need a codebase");
|
||||
|
||||
|
@ -347,7 +350,7 @@ nsPrincipal::GetHashValue(uint32_t* aValue)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrincipal::GetDomain(nsIURI** aDomain)
|
||||
ContentPrincipal::GetDomain(nsIURI** aDomain)
|
||||
{
|
||||
if (!mDomain) {
|
||||
*aDomain = nullptr;
|
||||
|
@ -363,7 +366,7 @@ nsPrincipal::GetDomain(nsIURI** aDomain)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrincipal::SetDomain(nsIURI* aDomain)
|
||||
ContentPrincipal::SetDomain(nsIURI* aDomain)
|
||||
{
|
||||
mDomain = NS_TryToMakeImmutable(aDomain);
|
||||
mDomainImmutable = URIIsImmutable(mDomain);
|
||||
|
@ -384,7 +387,7 @@ nsPrincipal::SetDomain(nsIURI* aDomain)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrincipal::GetBaseDomain(nsACString& aBaseDomain)
|
||||
ContentPrincipal::GetBaseDomain(nsACString& aBaseDomain)
|
||||
{
|
||||
// For a file URI, we return the file path.
|
||||
if (NS_URIIsLocalFile(mCodebase)) {
|
||||
|
@ -419,7 +422,7 @@ nsPrincipal::GetBaseDomain(nsACString& aBaseDomain)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrincipal::GetAddonId(nsAString& aAddonId)
|
||||
ContentPrincipal::GetAddonId(nsAString& aAddonId)
|
||||
{
|
||||
if (mAddonIdCache.isSome()) {
|
||||
aAddonId.Assign(mAddonIdCache.ref());
|
||||
|
@ -448,7 +451,7 @@ nsPrincipal::GetAddonId(nsAString& aAddonId)
|
|||
};
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrincipal::Read(nsIObjectInputStream* aStream)
|
||||
ContentPrincipal::Read(nsIObjectInputStream* aStream)
|
||||
{
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
nsCOMPtr<nsIURI> codebase;
|
||||
|
@ -494,7 +497,7 @@ nsPrincipal::Read(nsIObjectInputStream* aStream)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrincipal::Write(nsIObjectOutputStream* aStream)
|
||||
ContentPrincipal::Write(nsIObjectOutputStream* aStream)
|
||||
{
|
||||
NS_ENSURE_STATE(mCodebase);
|
||||
nsresult rv = NS_WriteOptionalCompoundObject(aStream, mCodebase, NS_GET_IID(nsIURI),
|
|
@ -3,8 +3,8 @@
|
|||
* 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/. */
|
||||
|
||||
#ifndef nsPrincipal_h__
|
||||
#define nsPrincipal_h__
|
||||
#ifndef ContentPrincipal_h
|
||||
#define ContentPrincipal_h
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsJSPrincipals.h"
|
||||
|
@ -15,7 +15,7 @@
|
|||
#include "nsScriptSecurityManager.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
|
||||
class nsPrincipal final : public mozilla::BasePrincipal
|
||||
class ContentPrincipal final : public mozilla::BasePrincipal
|
||||
{
|
||||
public:
|
||||
NS_DECL_NSISERIALIZABLE
|
||||
|
@ -29,7 +29,7 @@ public:
|
|||
bool IsCodebasePrincipal() const override { return true; }
|
||||
nsresult GetOriginInternal(nsACString& aOrigin) override;
|
||||
|
||||
nsPrincipal();
|
||||
ContentPrincipal();
|
||||
|
||||
// Init() must be called before the principal is in a usable state.
|
||||
nsresult Init(nsIURI* aCodebase,
|
||||
|
@ -50,9 +50,10 @@ public:
|
|||
bool mInitialized;
|
||||
|
||||
protected:
|
||||
virtual ~nsPrincipal();
|
||||
virtual ~ContentPrincipal();
|
||||
|
||||
bool SubsumesInternal(nsIPrincipal* aOther, DocumentDomainConsideration aConsideration) override;
|
||||
bool SubsumesInternal(nsIPrincipal* aOther,
|
||||
DocumentDomainConsideration aConsideration) override;
|
||||
bool MayLoadInternal(nsIURI* aURI) override;
|
||||
|
||||
private:
|
||||
|
@ -64,4 +65,4 @@ private:
|
|||
{ 0x653e0e4d, 0x3ee4, 0x45fa, \
|
||||
{ 0xb2, 0x72, 0x97, 0xc2, 0x0b, 0xc0, 0x1e, 0xb8 } }
|
||||
|
||||
#endif // nsPrincipal_h__
|
||||
#endif // ContentPrincipal_h
|
|
@ -21,7 +21,7 @@
|
|||
#include "nsNetCID.h"
|
||||
#include "nsError.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsPrincipal.h"
|
||||
#include "ContentPrincipal.h"
|
||||
#include "nsScriptSecurityManager.h"
|
||||
#include "pratom.h"
|
||||
|
||||
|
@ -188,7 +188,7 @@ NullPrincipal::Read(nsIObjectInputStream* aStream)
|
|||
{
|
||||
// Note - NullPrincipal use NS_GENERIC_FACTORY_CONSTRUCTOR_INIT, which means
|
||||
// that the Init() method has already been invoked by the time we deserialize.
|
||||
// This is in contrast to nsPrincipal, which uses NS_GENERIC_FACTORY_CONSTRUCTOR,
|
||||
// This is in contrast to ContentPrincipal, which uses NS_GENERIC_FACTORY_CONSTRUCTOR,
|
||||
// in which case ::Read needs to invoke Init().
|
||||
|
||||
nsAutoCString spec;
|
||||
|
|
|
@ -40,10 +40,10 @@ SOURCES += [
|
|||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'ContentPrincipal.cpp',
|
||||
'DomainPolicy.cpp',
|
||||
'ExpandedPrincipal.cpp',
|
||||
'nsJSPrincipals.cpp',
|
||||
'nsPrincipal.cpp',
|
||||
'nsScriptSecurityManager.cpp',
|
||||
'NullPrincipal.cpp',
|
||||
'NullPrincipalURI.cpp',
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "nsJSPrincipals.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "SystemPrincipal.h"
|
||||
#include "nsPrincipal.h"
|
||||
#include "NullPrincipal.h"
|
||||
#include "DomainPolicy.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
|
|
@ -98,7 +98,7 @@
|
|||
#include "mozilla/dom/Promise.h"
|
||||
#include "mozilla/dom/PromiseNativeHandler.h"
|
||||
|
||||
#include "nsPrincipal.h"
|
||||
#include "ContentPrincipal.h"
|
||||
|
||||
#ifdef XP_WIN
|
||||
#include "mozilla/plugins/PPluginWidgetParent.h"
|
||||
|
|
|
@ -58,7 +58,6 @@
|
|||
#include "nsIDOMWindowUtils.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsILoadInfo.h"
|
||||
#include "nsPrincipal.h"
|
||||
#include "nsIPromptFactory.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
|
@ -69,6 +68,7 @@
|
|||
#include "nsViewManager.h"
|
||||
#include "nsVariant.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsNetUtil.h"
|
||||
#ifndef XP_WIN
|
||||
#include "nsJARProtocolHandler.h"
|
||||
#endif
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include "nsIIDNService.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsPrincipal.h"
|
||||
#include "nsICryptoHash.h"
|
||||
#include "nsICryptoHMAC.h"
|
||||
#include "nsIKeyModule.h"
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "nsIScriptError.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsContentPolicyUtils.h"
|
||||
#include "nsPrincipal.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
#include "mozilla/ipc/PBackgroundSharedTypes.h"
|
||||
#include "mozilla/net/NeckoChannelParams.h"
|
||||
#include "ExpandedPrincipal.h"
|
||||
#include "nsPrincipal.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "mozilla/LoadInfo.h"
|
||||
#include "ContentPrincipal.h"
|
||||
#include "NullPrincipal.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsString.h"
|
||||
|
|
|
@ -131,7 +131,7 @@ using mozilla::dom::AudioChannelAgent;
|
|||
#include "nsTextServicesCID.h"
|
||||
|
||||
#include "nsScriptSecurityManager.h"
|
||||
#include "nsPrincipal.h"
|
||||
#include "ContentPrincipal.h"
|
||||
#include "SystemPrincipal.h"
|
||||
#include "NullPrincipal.h"
|
||||
#include "nsNetCID.h"
|
||||
|
@ -590,7 +590,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsCSPContext)
|
|||
NS_GENERIC_FACTORY_CONSTRUCTOR(CSPService)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMixedContentBlocker)
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrincipal)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(ContentPrincipal)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(SystemPrincipal,
|
||||
nsScriptSecurityManager::SystemPrincipalSingletonConstructor)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(NullPrincipal, Init)
|
||||
|
@ -1027,7 +1027,7 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
|
|||
{ &kNS_PARENTPROCESSMESSAGEMANAGER_CID, false, nullptr, CreateParentMessageManager },
|
||||
{ &kNS_CHILDPROCESSMESSAGEMANAGER_CID, false, nullptr, CreateChildMessageManager },
|
||||
{ &kNS_SCRIPTSECURITYMANAGER_CID, false, nullptr, Construct_nsIScriptSecurityManager },
|
||||
{ &kNS_PRINCIPAL_CID, false, nullptr, nsPrincipalConstructor },
|
||||
{ &kNS_PRINCIPAL_CID, false, nullptr, ContentPrincipalConstructor },
|
||||
{ &kNS_SYSTEMPRINCIPAL_CID, false, nullptr, SystemPrincipalConstructor },
|
||||
{ &kNS_NULLPRINCIPAL_CID, false, nullptr, NullPrincipalConstructor },
|
||||
{ &kNS_DEVICE_SENSORS_CID, false, nullptr, nsDeviceSensorsConstructor },
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "nsImageFrame.h"
|
||||
#include "nsLayoutStylesheetCache.h"
|
||||
#include "mozilla/RuleProcessorCache.h"
|
||||
#include "nsPrincipal.h"
|
||||
#include "ContentPrincipal.h"
|
||||
#include "nsRange.h"
|
||||
#include "nsRegion.h"
|
||||
#include "nsRepeatService.h"
|
||||
|
@ -270,7 +270,7 @@ nsLayoutStatics::Initialize()
|
|||
nsLayoutUtils::Initialize();
|
||||
nsIPresShell::InitializeStatics();
|
||||
TouchManager::InitializeStatics();
|
||||
nsPrincipal::InitializeStatics();
|
||||
ContentPrincipal::InitializeStatics();
|
||||
|
||||
nsCORSListenerProxy::Startup();
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
* old (pre-gecko6) nsIURI IID and swap in the current IID instead, in order
|
||||
* for sessionstore to work after an upgrade. If this IID is revved further,
|
||||
* we will need to add additional checks there for all intermediate IIDs, until
|
||||
* nsPrincipal is fixed to serialize its URIs as nsISupports (bug 662693).
|
||||
* ContentPrincipal is fixed to serialize its URIs as nsISupports (bug 662693).
|
||||
*/
|
||||
[scriptable, uuid(92073a54-6d78-4f30-913a-b871813208c6)]
|
||||
interface nsIURI : nsISupports
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include "SerializedLoadContext.h"
|
||||
#include "nsAuthInformationHolder.h"
|
||||
#include "nsIAuthPromptCallback.h"
|
||||
#include "nsPrincipal.h"
|
||||
#include "ContentPrincipal.h"
|
||||
#include "nsINetworkPredictor.h"
|
||||
#include "nsINetworkPredictorVerifier.h"
|
||||
#include "nsISpeculativeConnect.h"
|
||||
|
|
|
@ -274,9 +274,10 @@ class Permissions(object):
|
|||
permission_type = 2
|
||||
|
||||
if using_origin:
|
||||
# This is a crude approximation of the origin generation logic from
|
||||
# nsPrincipal and nsStandardURL. It should suffice for the permissions
|
||||
# which the test runners will want to insert into the system.
|
||||
# This is a crude approximation of the origin generation
|
||||
# logic from ContentPrincipal and nsStandardURL. It should
|
||||
# suffice for the permissions which the test runners will
|
||||
# want to insert into the system.
|
||||
origin = location.scheme + "://" + location.host
|
||||
if (location.scheme != 'http' or location.port != '80') and \
|
||||
(location.scheme != 'https' or location.port != '443'):
|
||||
|
|
|
@ -763,7 +763,7 @@ NS_IMETHODIMP nsContentTreeOwner::SetTitle(const char16_t* aTitle)
|
|||
//
|
||||
// location bar is turned off, find the browser location
|
||||
//
|
||||
// use the document's nsPrincipal to find the true owner
|
||||
// use the document's ContentPrincipal to find the true owner
|
||||
// in case of javascript: or data: documents
|
||||
//
|
||||
nsCOMPtr<nsIDocShellTreeItem> dsitem;
|
||||
|
|
Загрузка…
Ссылка в новой задаче