Bug 1328653 - Merging all the various *OriginAttributes to just one, r=huseby

This commit is contained in:
Andrea Marchesini 2017-01-12 17:38:48 +01:00
parent 265b3a3710
commit 359ae91eac
152 changed files with 605 additions and 756 deletions

View file

@ -881,8 +881,8 @@ FeedWriter.prototype = {
.QueryInterface(Ci.nsIDocShell); .QueryInterface(Ci.nsIDocShell);
let chan = docShell.currentDocumentChannel; let chan = docShell.currentDocumentChannel;
// We probably need to call InheritFromDocShellToDoc for this, but right now // We probably need to call Inherit() for this, but right now we can't call
// we can't call it from JS. // it from JS.
let attrs = docShell.getOriginAttributes(); let attrs = docShell.getOriginAttributes();
let ssm = Services.scriptSecurityManager; let ssm = Services.scriptSecurityManager;
let nullPrincipal = ssm.createNullPrincipal(attrs); let nullPrincipal = ssm.createNullPrincipal(attrs);

View file

@ -15,7 +15,6 @@
#include "nsIEffectiveTLDService.h" #include "nsIEffectiveTLDService.h"
#include "nsIObjectInputStream.h" #include "nsIObjectInputStream.h"
#include "nsIObjectOutputStream.h" #include "nsIObjectOutputStream.h"
#include "nsIScriptSecurityManager.h"
#include "nsPrincipal.h" #include "nsPrincipal.h"
#include "nsNetUtil.h" #include "nsNetUtil.h"
@ -35,13 +34,13 @@ namespace mozilla {
using dom::URLParams; using dom::URLParams;
void void
PrincipalOriginAttributes::InheritFromDocShellToDoc(const DocShellOriginAttributes& aAttrs, OriginAttributes::Inherit(const OriginAttributes& aAttrs)
const nsIURI* aURI)
{ {
mAppId = aAttrs.mAppId; mAppId = aAttrs.mAppId;
mInIsolatedMozBrowser = aAttrs.mInIsolatedMozBrowser; mInIsolatedMozBrowser = aAttrs.mInIsolatedMozBrowser;
// addonId is computed from the principal URI and never propagated StripAttributes(STRIP_ADDON_ID);
mUserContextId = aAttrs.mUserContextId; mUserContextId = aAttrs.mUserContextId;
mPrivateBrowsingId = aAttrs.mPrivateBrowsingId; mPrivateBrowsingId = aAttrs.mPrivateBrowsingId;
@ -49,70 +48,16 @@ PrincipalOriginAttributes::InheritFromDocShellToDoc(const DocShellOriginAttribut
} }
void void
PrincipalOriginAttributes::InheritFromNecko(const NeckoOriginAttributes& aAttrs) OriginAttributes::SetFirstPartyDomain(const bool aIsTopLevelDocument,
nsIURI* aURI)
{ {
mAppId = aAttrs.mAppId;
mInIsolatedMozBrowser = aAttrs.mInIsolatedMozBrowser;
// addonId is computed from the principal URI and never propagated
mUserContextId = aAttrs.mUserContextId;
mPrivateBrowsingId = aAttrs.mPrivateBrowsingId;
mFirstPartyDomain = aAttrs.mFirstPartyDomain;
}
void
PrincipalOriginAttributes::StripUserContextIdAndFirstPartyDomain()
{
mUserContextId = nsIScriptSecurityManager::DEFAULT_USER_CONTEXT_ID;
mFirstPartyDomain.Truncate();
}
void
DocShellOriginAttributes::InheritFromDocToChildDocShell(const PrincipalOriginAttributes& aAttrs)
{
mAppId = aAttrs.mAppId;
mInIsolatedMozBrowser = aAttrs.mInIsolatedMozBrowser;
// addonId is computed from the principal URI and never propagated
mUserContextId = aAttrs.mUserContextId;
mPrivateBrowsingId = aAttrs.mPrivateBrowsingId;
mFirstPartyDomain = aAttrs.mFirstPartyDomain;
}
void
NeckoOriginAttributes::InheritFromDocToNecko(const PrincipalOriginAttributes& aAttrs)
{
mAppId = aAttrs.mAppId;
mInIsolatedMozBrowser = aAttrs.mInIsolatedMozBrowser;
// addonId is computed from the principal URI and never propagated
mUserContextId = aAttrs.mUserContextId;
mPrivateBrowsingId = aAttrs.mPrivateBrowsingId;
mFirstPartyDomain = aAttrs.mFirstPartyDomain;
}
void
NeckoOriginAttributes::InheritFromDocShellToNecko(const DocShellOriginAttributes& aAttrs,
const bool aIsTopLevelDocument,
nsIURI* aURI)
{
mAppId = aAttrs.mAppId;
mInIsolatedMozBrowser = aAttrs.mInIsolatedMozBrowser;
// addonId is computed from the principal URI and never propagated
mUserContextId = aAttrs.mUserContextId;
mPrivateBrowsingId = aAttrs.mPrivateBrowsingId;
bool isFirstPartyEnabled = IsFirstPartyEnabled(); bool isFirstPartyEnabled = IsFirstPartyEnabled();
// When the pref is on, we also compute the firstPartyDomain attribute // When the pref is on, we also compute the firstPartyDomain attribute
// if this is for top-level document. // if this is for top-level document.
if (isFirstPartyEnabled && aIsTopLevelDocument) { if (isFirstPartyEnabled && aIsTopLevelDocument) {
nsCOMPtr<nsIEffectiveTLDService> tldService = do_GetService(NS_EFFECTIVETLDSERVICE_CONTRACTID); nsCOMPtr<nsIEffectiveTLDService> tldService =
do_GetService(NS_EFFECTIVETLDSERVICE_CONTRACTID);
MOZ_ASSERT(tldService); MOZ_ASSERT(tldService);
if (!tldService) { if (!tldService) {
return; return;
@ -121,8 +66,6 @@ NeckoOriginAttributes::InheritFromDocShellToNecko(const DocShellOriginAttributes
nsAutoCString baseDomain; nsAutoCString baseDomain;
tldService->GetBaseDomain(aURI, 0, baseDomain); tldService->GetBaseDomain(aURI, 0, baseDomain);
mFirstPartyDomain = NS_ConvertUTF8toUTF16(baseDomain); mFirstPartyDomain = NS_ConvertUTF8toUTF16(baseDomain);
} else {
mFirstPartyDomain = aAttrs.mFirstPartyDomain;
} }
} }
@ -326,17 +269,6 @@ OriginAttributes::SyncAttributesWithPrivateBrowsing(bool aInPrivateBrowsing)
mPrivateBrowsingId = aInPrivateBrowsing ? 1 : 0; mPrivateBrowsingId = aInPrivateBrowsing ? 1 : 0;
} }
void
OriginAttributes::SetFromGenericAttributes(const GenericOriginAttributes& aAttrs)
{
mAppId = aAttrs.mAppId;
mInIsolatedMozBrowser = aAttrs.mInIsolatedMozBrowser;
mAddonId = aAttrs.mAddonId;
mUserContextId = aAttrs.mUserContextId;
mPrivateBrowsingId = aAttrs.mPrivateBrowsingId;
mFirstPartyDomain = aAttrs.mFirstPartyDomain;
}
/* static */ /* static */
bool bool
OriginAttributes::IsFirstPartyEnabled() OriginAttributes::IsFirstPartyEnabled()
@ -357,7 +289,7 @@ bool
OriginAttributes::IsPrivateBrowsing(const nsACString& aOrigin) OriginAttributes::IsPrivateBrowsing(const nsACString& aOrigin)
{ {
nsAutoCString dummy; nsAutoCString dummy;
PrincipalOriginAttributes attrs; OriginAttributes attrs;
if (NS_WARN_IF(!attrs.PopulateFromOrigin(aOrigin, dummy))) { if (NS_WARN_IF(!attrs.PopulateFromOrigin(aOrigin, dummy))) {
return false; return false;
} }
@ -684,7 +616,7 @@ BasePrincipal::AddonHasPermission(const nsAString& aPerm)
} }
already_AddRefed<BasePrincipal> already_AddRefed<BasePrincipal>
BasePrincipal::CreateCodebasePrincipal(nsIURI* aURI, const PrincipalOriginAttributes& aAttrs) BasePrincipal::CreateCodebasePrincipal(nsIURI* aURI, const OriginAttributes& aAttrs)
{ {
// If the URI is supposed to inherit the security context of whoever loads it, // If the URI is supposed to inherit the security context of whoever loads it,
// we shouldn't make a codebase principal for it. // we shouldn't make a codebase principal for it.
@ -724,7 +656,7 @@ BasePrincipal::CreateCodebasePrincipal(const nsACString& aOrigin)
"CreateCodebasePrincipal does not support nsNullPrincipal"); "CreateCodebasePrincipal does not support nsNullPrincipal");
nsAutoCString originNoSuffix; nsAutoCString originNoSuffix;
mozilla::PrincipalOriginAttributes attrs; mozilla::OriginAttributes attrs;
if (!attrs.PopulateFromOrigin(aOrigin, originNoSuffix)) { if (!attrs.PopulateFromOrigin(aOrigin, originNoSuffix)) {
return nullptr; return nullptr;
} }
@ -739,8 +671,9 @@ BasePrincipal::CreateCodebasePrincipal(const nsACString& aOrigin)
already_AddRefed<BasePrincipal> already_AddRefed<BasePrincipal>
BasePrincipal::CloneStrippingUserContextIdAndFirstPartyDomain() BasePrincipal::CloneStrippingUserContextIdAndFirstPartyDomain()
{ {
PrincipalOriginAttributes attrs = OriginAttributesRef(); OriginAttributes attrs = OriginAttributesRef();
attrs.StripUserContextIdAndFirstPartyDomain(); attrs.StripAttributes(OriginAttributes::STRIP_USER_CONTEXT_ID |
OriginAttributes::STRIP_FIRST_PARTY_DOMAIN);
nsAutoCString originNoSuffix; nsAutoCString originNoSuffix;
nsresult rv = GetOriginNoSuffix(originNoSuffix); nsresult rv = GetOriginNoSuffix(originNoSuffix);

View file

@ -11,6 +11,7 @@
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/dom/ChromeUtilsBinding.h" #include "mozilla/dom/ChromeUtilsBinding.h"
#include "nsIScriptSecurityManager.h"
class nsIContentSecurityPolicy; class nsIContentSecurityPolicy;
class nsIObjectOutputStream; class nsIObjectOutputStream;
@ -21,13 +22,50 @@ class nsExpandedPrincipal;
namespace mozilla { namespace mozilla {
class GenericOriginAttributes;
// Base OriginAttributes class. This has several subclass flavors, and is not // Base OriginAttributes class. This has several subclass flavors, and is not
// directly constructable itself. // directly constructable itself.
class OriginAttributes : public dom::OriginAttributesDictionary class OriginAttributes : public dom::OriginAttributesDictionary
{ {
public: public:
OriginAttributes() {}
OriginAttributes(uint32_t aAppId, bool aInIsolatedMozBrowser)
{
mAppId = aAppId;
mInIsolatedMozBrowser = aInIsolatedMozBrowser;
}
explicit OriginAttributes(const OriginAttributesDictionary& aOther)
: OriginAttributesDictionary(aOther)
{}
// This method 'clones' the OriginAttributes ignoring the addonId value becaue
// this is computed from the principal URI and never propagated.
void Inherit(const OriginAttributes& aAttrs);
void SetFirstPartyDomain(const bool aIsTopLevelDocument, nsIURI* aURI);
enum {
STRIP_FIRST_PARTY_DOMAIN = 0x01,
STRIP_ADDON_ID = 0x02,
STRIP_USER_CONTEXT_ID = 0x04,
};
inline void StripAttributes(uint32_t aFlags)
{
if (aFlags & STRIP_FIRST_PARTY_DOMAIN) {
mFirstPartyDomain.Truncate();
}
if (aFlags & STRIP_ADDON_ID) {
mAddonId.Truncate();
}
if (aFlags & STRIP_USER_CONTEXT_ID) {
mUserContextId = nsIScriptSecurityManager::DEFAULT_USER_CONTEXT_ID;
}
}
bool operator==(const OriginAttributes& aOther) const bool operator==(const OriginAttributes& aOther) const
{ {
return mAppId == aOther.mAppId && return mAppId == aOther.mAppId &&
@ -37,6 +75,7 @@ public:
mPrivateBrowsingId == aOther.mPrivateBrowsingId && mPrivateBrowsingId == aOther.mPrivateBrowsingId &&
mFirstPartyDomain == aOther.mFirstPartyDomain; mFirstPartyDomain == aOther.mFirstPartyDomain;
} }
bool operator!=(const OriginAttributes& aOther) const bool operator!=(const OriginAttributes& aOther) const
{ {
return !(*this == aOther); return !(*this == aOther);
@ -61,105 +100,12 @@ public:
// flags. Once all other flags are removed, this can be removed too. // flags. Once all other flags are removed, this can be removed too.
void SyncAttributesWithPrivateBrowsing(bool aInPrivateBrowsing); void SyncAttributesWithPrivateBrowsing(bool aInPrivateBrowsing);
void SetFromGenericAttributes(const GenericOriginAttributes& aAttrs);
// check if "privacy.firstparty.isolate" is enabled. // check if "privacy.firstparty.isolate" is enabled.
static bool IsFirstPartyEnabled(); static bool IsFirstPartyEnabled();
// returns true if the originAttributes suffix has mPrivateBrowsingId value // returns true if the originAttributes suffix has mPrivateBrowsingId value
// different than 0. // different than 0.
static bool IsPrivateBrowsing(const nsACString& aOrigin); static bool IsPrivateBrowsing(const nsACString& aOrigin);
protected:
OriginAttributes() {}
explicit OriginAttributes(const OriginAttributesDictionary& aOther)
: OriginAttributesDictionary(aOther) {}
};
class PrincipalOriginAttributes;
class DocShellOriginAttributes;
class NeckoOriginAttributes;
// Various classes in Gecko contain OriginAttributes members, and those
// OriginAttributes get propagated to other classes according to certain rules.
// For example, the OriginAttributes on the docshell affect the OriginAttributes
// for the principal of a document loaded inside it, whose OriginAttributes in
// turn affect those of network loads and child docshells. To codify and
// centralize these rules, we introduce separate subclasses for the different
// flavors, and a variety of InheritFrom* methods to implement the transfer
// behavior.
// For OriginAttributes stored on principals.
class PrincipalOriginAttributes : public OriginAttributes
{
public:
PrincipalOriginAttributes() {}
PrincipalOriginAttributes(uint32_t aAppId, bool aInIsolatedMozBrowser)
{
mAppId = aAppId;
mInIsolatedMozBrowser = aInIsolatedMozBrowser;
}
// Inheriting OriginAttributes from docshell to document when user navigates.
//
// @param aAttrs Origin Attributes of the docshell.
// @param aURI The URI of the document.
void InheritFromDocShellToDoc(const DocShellOriginAttributes& aAttrs,
const nsIURI* aURI);
// Inherit OriginAttributes from Necko.
void InheritFromNecko(const NeckoOriginAttributes& aAttrs);
void StripUserContextIdAndFirstPartyDomain();
};
// For OriginAttributes stored on docshells / loadcontexts / browsing contexts.
class DocShellOriginAttributes : public OriginAttributes
{
public:
DocShellOriginAttributes() {}
DocShellOriginAttributes(uint32_t aAppId, bool aInIsolatedMozBrowser)
{
mAppId = aAppId;
mInIsolatedMozBrowser = aInIsolatedMozBrowser;
}
// Inheriting OriginAttributes from document to child docshell when an
// <iframe> is created.
//
// @param aAttrs Origin Attributes of the document.
void
InheritFromDocToChildDocShell(const PrincipalOriginAttributes& aAttrs);
};
// For OriginAttributes stored on Necko.
class NeckoOriginAttributes : public OriginAttributes
{
public:
NeckoOriginAttributes() {}
explicit NeckoOriginAttributes(bool aInIsolatedMozBrowser)
{
mInIsolatedMozBrowser = aInIsolatedMozBrowser;
}
// Inheriting OriginAttributes from document to necko when a network request
// is made.
void InheritFromDocToNecko(const PrincipalOriginAttributes& aAttrs);
// Inheriting OriginAttributes from a docshell when loading a top-level
// document.
void InheritFromDocShellToNecko(const DocShellOriginAttributes& aAttrs,
const bool aIsTopLevelDocument = false,
nsIURI* aURI = nullptr);
};
// For operating on OriginAttributes not associated with any data structure.
class GenericOriginAttributes : public OriginAttributes
{
public:
GenericOriginAttributes() {}
explicit GenericOriginAttributes(const OriginAttributesDictionary& aOther)
: OriginAttributes(aOther) {}
}; };
class OriginAttributesPattern : public dom::OriginAttributesPatternDictionary class OriginAttributesPattern : public dom::OriginAttributesPatternDictionary
@ -294,10 +240,10 @@ public:
static BasePrincipal* Cast(nsIPrincipal* aPrin) { return static_cast<BasePrincipal*>(aPrin); } static BasePrincipal* Cast(nsIPrincipal* aPrin) { return static_cast<BasePrincipal*>(aPrin); }
static already_AddRefed<BasePrincipal> static already_AddRefed<BasePrincipal>
CreateCodebasePrincipal(nsIURI* aURI, const PrincipalOriginAttributes& aAttrs); CreateCodebasePrincipal(nsIURI* aURI, const OriginAttributes& aAttrs);
static already_AddRefed<BasePrincipal> CreateCodebasePrincipal(const nsACString& aOrigin); static already_AddRefed<BasePrincipal> CreateCodebasePrincipal(const nsACString& aOrigin);
const PrincipalOriginAttributes& OriginAttributesRef() override { return mOriginAttributes; } const OriginAttributes& OriginAttributesRef() override { return mOriginAttributes; }
uint32_t AppId() const { return mOriginAttributes.mAppId; } uint32_t AppId() const { return mOriginAttributes.mAppId; }
uint32_t UserContextId() const { return mOriginAttributes.mUserContextId; } uint32_t UserContextId() const { return mOriginAttributes.mUserContextId; }
uint32_t PrivateBrowsingId() const { return mOriginAttributes.mPrivateBrowsingId; } uint32_t PrivateBrowsingId() const { return mOriginAttributes.mPrivateBrowsingId; }
@ -334,7 +280,7 @@ protected:
nsCOMPtr<nsIContentSecurityPolicy> mCSP; nsCOMPtr<nsIContentSecurityPolicy> mCSP;
nsCOMPtr<nsIContentSecurityPolicy> mPreloadCSP; nsCOMPtr<nsIContentSecurityPolicy> mPreloadCSP;
PrincipalOriginAttributes mOriginAttributes; OriginAttributes mOriginAttributes;
}; };
} // namespace mozilla } // namespace mozilla

View file

@ -12,7 +12,7 @@ struct JSPrincipals;
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsTArray.h" #include "nsTArray.h"
namespace mozilla { namespace mozilla {
class PrincipalOriginAttributes; class OriginAttributes;
} }
%} %}
@ -23,7 +23,7 @@ interface nsIDOMDocument;
[ptr] native JSContext(JSContext); [ptr] native JSContext(JSContext);
[ptr] native JSPrincipals(JSPrincipals); [ptr] native JSPrincipals(JSPrincipals);
[ptr] native PrincipalArray(nsTArray<nsCOMPtr<nsIPrincipal> >); [ptr] native PrincipalArray(nsTArray<nsCOMPtr<nsIPrincipal> >);
[ref] native const_PrincipalOriginAttributes(const mozilla::PrincipalOriginAttributes); [ref] native const_OriginAttributes(const mozilla::OriginAttributes);
[scriptable, builtinclass, uuid(3da7b133-f1a0-4de9-a2bc-5c49014c1077)] [scriptable, builtinclass, uuid(3da7b133-f1a0-4de9-a2bc-5c49014c1077)]
interface nsIPrincipal : nsISerializable interface nsIPrincipal : nsISerializable
@ -198,7 +198,7 @@ interface nsIPrincipal : nsISerializable
readonly attribute jsval originAttributes; readonly attribute jsval originAttributes;
[noscript, notxpcom, nostdcall, binaryname(OriginAttributesRef)] [noscript, notxpcom, nostdcall, binaryname(OriginAttributesRef)]
const_PrincipalOriginAttributes OriginAttributesRef(); const_OriginAttributes OriginAttributesRef();
/** /**
* A canonical representation of the origin for this principal. This * A canonical representation of the origin for this principal. This

View file

@ -126,7 +126,7 @@ nsJSPrincipals::ReadPrincipals(JSContext* aCx, JSStructuredCloneReader* aReader,
static bool static bool
ReadSuffixAndSpec(JSStructuredCloneReader* aReader, ReadSuffixAndSpec(JSStructuredCloneReader* aReader,
PrincipalOriginAttributes& aAttrs, OriginAttributes& aAttrs,
nsACString& aSpec) nsACString& aSpec)
{ {
uint32_t suffixLength, specLength; uint32_t suffixLength, specLength;
@ -160,7 +160,7 @@ ReadPrincipalInfo(JSStructuredCloneReader* aReader,
if (aTag == SCTAG_DOM_SYSTEM_PRINCIPAL) { if (aTag == SCTAG_DOM_SYSTEM_PRINCIPAL) {
aInfo = SystemPrincipalInfo(); aInfo = SystemPrincipalInfo();
} else if (aTag == SCTAG_DOM_NULL_PRINCIPAL) { } else if (aTag == SCTAG_DOM_NULL_PRINCIPAL) {
PrincipalOriginAttributes attrs; OriginAttributes attrs;
nsAutoCString spec; nsAutoCString spec;
if (!ReadSuffixAndSpec(aReader, attrs, spec)) { if (!ReadSuffixAndSpec(aReader, attrs, spec)) {
return false; return false;
@ -189,7 +189,7 @@ ReadPrincipalInfo(JSStructuredCloneReader* aReader,
aInfo = expanded; aInfo = expanded;
} else if (aTag == SCTAG_DOM_CONTENT_PRINCIPAL) { } else if (aTag == SCTAG_DOM_CONTENT_PRINCIPAL) {
PrincipalOriginAttributes attrs; OriginAttributes attrs;
nsAutoCString spec; nsAutoCString spec;
if (!ReadSuffixAndSpec(aReader, attrs, spec)) { if (!ReadSuffixAndSpec(aReader, attrs, spec)) {
return false; return false;
@ -237,7 +237,7 @@ nsJSPrincipals::ReadKnownPrincipalType(JSContext* aCx,
static bool static bool
WriteSuffixAndSpec(JSStructuredCloneWriter* aWriter, WriteSuffixAndSpec(JSStructuredCloneWriter* aWriter,
const PrincipalOriginAttributes& aAttrs, const OriginAttributes& aAttrs,
const nsCString& aSpec) const nsCString& aSpec)
{ {
nsAutoCString suffix; nsAutoCString suffix;

View file

@ -48,8 +48,8 @@ nsNullPrincipal::CreateWithInheritedAttributes(nsIPrincipal* aInheritFrom)
/* static */ already_AddRefed<nsNullPrincipal> /* static */ already_AddRefed<nsNullPrincipal>
nsNullPrincipal::CreateWithInheritedAttributes(nsIDocShell* aDocShell) nsNullPrincipal::CreateWithInheritedAttributes(nsIDocShell* aDocShell)
{ {
PrincipalOriginAttributes attrs; OriginAttributes attrs;
attrs.InheritFromDocShellToDoc(nsDocShell::Cast(aDocShell)->GetOriginAttributes(), nullptr); attrs.Inherit(nsDocShell::Cast(aDocShell)->GetOriginAttributes());
RefPtr<nsNullPrincipal> nullPrin = new nsNullPrincipal(); RefPtr<nsNullPrincipal> nullPrin = new nsNullPrincipal();
nsresult rv = nullPrin->Init(attrs); nsresult rv = nullPrin->Init(attrs);
@ -58,8 +58,7 @@ nsNullPrincipal::CreateWithInheritedAttributes(nsIDocShell* aDocShell)
} }
/* static */ already_AddRefed<nsNullPrincipal> /* static */ already_AddRefed<nsNullPrincipal>
nsNullPrincipal::Create(const PrincipalOriginAttributes& aOriginAttributes, nsNullPrincipal::Create(const OriginAttributes& aOriginAttributes, nsIURI* aURI)
nsIURI* aURI)
{ {
RefPtr<nsNullPrincipal> nullPrin = new nsNullPrincipal(); RefPtr<nsNullPrincipal> nullPrin = new nsNullPrincipal();
nsresult rv = nullPrin->Init(aOriginAttributes, aURI); nsresult rv = nullPrin->Init(aOriginAttributes, aURI);
@ -69,8 +68,7 @@ nsNullPrincipal::Create(const PrincipalOriginAttributes& aOriginAttributes,
} }
nsresult nsresult
nsNullPrincipal::Init(const PrincipalOriginAttributes& aOriginAttributes, nsNullPrincipal::Init(const OriginAttributes& aOriginAttributes, nsIURI* aURI)
nsIURI* aURI)
{ {
mOriginAttributes = aOriginAttributes; mOriginAttributes = aOriginAttributes;

View file

@ -53,10 +53,10 @@ public:
static already_AddRefed<nsNullPrincipal> CreateWithInheritedAttributes(nsIDocShell* aDocShell); static already_AddRefed<nsNullPrincipal> CreateWithInheritedAttributes(nsIDocShell* aDocShell);
static already_AddRefed<nsNullPrincipal> static already_AddRefed<nsNullPrincipal>
Create(const mozilla::PrincipalOriginAttributes& aOriginAttributes = mozilla::PrincipalOriginAttributes(), Create(const mozilla::OriginAttributes& aOriginAttributes = mozilla::OriginAttributes(),
nsIURI* aURI = nullptr); nsIURI* aURI = nullptr);
nsresult Init(const mozilla::PrincipalOriginAttributes& aOriginAttributes = mozilla::PrincipalOriginAttributes(), nsresult Init(const mozilla::OriginAttributes& aOriginAttributes = mozilla::OriginAttributes(),
nsIURI* aURI = nullptr); nsIURI* aURI = nullptr);
virtual nsresult GetScriptLocation(nsACString &aStr) override; virtual nsresult GetScriptLocation(nsACString &aStr) override;

View file

@ -82,7 +82,7 @@ nsPrincipal::~nsPrincipal()
} }
nsresult nsresult
nsPrincipal::Init(nsIURI *aCodebase, const PrincipalOriginAttributes& aOriginAttributes) nsPrincipal::Init(nsIURI *aCodebase, const OriginAttributes& aOriginAttributes)
{ {
NS_ENSURE_STATE(!mInitialized); NS_ENSURE_STATE(!mInitialized);
NS_ENSURE_ARG(aCodebase); NS_ENSURE_ARG(aCodebase);
@ -404,7 +404,7 @@ nsPrincipal::Read(nsIObjectInputStream* aStream)
rv = aStream->ReadCString(suffix); rv = aStream->ReadCString(suffix);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
PrincipalOriginAttributes attrs; OriginAttributes attrs;
bool ok = attrs.PopulateFromSuffix(suffix); bool ok = attrs.PopulateFromSuffix(suffix);
NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE); NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
@ -688,7 +688,7 @@ struct OriginComparator
}; };
nsExpandedPrincipal::nsExpandedPrincipal(nsTArray<nsCOMPtr<nsIPrincipal>> &aWhiteList, nsExpandedPrincipal::nsExpandedPrincipal(nsTArray<nsCOMPtr<nsIPrincipal>> &aWhiteList,
const PrincipalOriginAttributes& aAttrs) const OriginAttributes& aAttrs)
{ {
// We force the principals to be sorted by origin so that nsExpandedPrincipal // We force the principals to be sorted by origin so that nsExpandedPrincipal
// origins can have a canonical form. // origins can have a canonical form.

View file

@ -32,7 +32,8 @@ public:
nsPrincipal(); nsPrincipal();
// Init() must be called before the principal is in a usable state. // Init() must be called before the principal is in a usable state.
nsresult Init(nsIURI* aCodebase, const mozilla::PrincipalOriginAttributes& aOriginAttributes); nsresult Init(nsIURI* aCodebase,
const mozilla::OriginAttributes& aOriginAttributes);
virtual nsresult GetScriptLocation(nsACString& aStr) override; virtual nsresult GetScriptLocation(nsACString& aStr) override;
void SetURI(nsIURI* aURI); void SetURI(nsIURI* aURI);
@ -63,7 +64,7 @@ class nsExpandedPrincipal : public nsIExpandedPrincipal, public mozilla::BasePri
{ {
public: public:
nsExpandedPrincipal(nsTArray<nsCOMPtr<nsIPrincipal>> &aWhiteList, nsExpandedPrincipal(nsTArray<nsCOMPtr<nsIPrincipal>> &aWhiteList,
const mozilla::PrincipalOriginAttributes& aAttrs); const mozilla::OriginAttributes& aAttrs);
NS_DECL_NSIEXPANDEDPRINCIPAL NS_DECL_NSIEXPANDEDPRINCIPAL
NS_DECL_NSISERIALIZABLE NS_DECL_NSISERIALIZABLE

View file

@ -298,11 +298,10 @@ nsScriptSecurityManager::GetChannelResultPrincipal(nsIChannel* aChannel,
prin = prin =
nsNullPrincipal::CreateWithInheritedAttributes(loadInfo->LoadingPrincipal()); nsNullPrincipal::CreateWithInheritedAttributes(loadInfo->LoadingPrincipal());
} else { } else {
NeckoOriginAttributes nAttrs; OriginAttributes attrs;
loadInfo->GetOriginAttributes(&nAttrs); loadInfo->GetOriginAttributes(&attrs);
PrincipalOriginAttributes pAttrs; attrs.StripAttributes(OriginAttributes::STRIP_ADDON_ID);
pAttrs.InheritFromNecko(nAttrs); prin = nsNullPrincipal::Create(attrs);
prin = nsNullPrincipal::Create(pAttrs);
} }
prin.forget(aPrincipal); prin.forget(aPrincipal);
return NS_OK; return NS_OK;
@ -356,7 +355,7 @@ nsScriptSecurityManager::GetChannelResultPrincipal(nsIChannel* aChannel,
} }
nsresult nsresult
nsScriptSecurityManager::MaybeSetAddonIdFromURI(PrincipalOriginAttributes& aAttrs, nsIURI* aURI) nsScriptSecurityManager::MaybeSetAddonIdFromURI(OriginAttributes& aAttrs, nsIURI* aURI)
{ {
nsAutoCString scheme; nsAutoCString scheme;
nsresult rv = aURI->GetScheme(scheme); nsresult rv = aURI->GetScheme(scheme);
@ -400,11 +399,11 @@ nsScriptSecurityManager::GetChannelURIPrincipal(nsIChannel* aChannel,
// loadInfo will be set from nsDocShell::DoURILoad. // loadInfo will be set from nsDocShell::DoURILoad.
// For subresource loading, the origin attributes of the loadInfo is from // For subresource loading, the origin attributes of the loadInfo is from
// its loadingPrincipal. // its loadingPrincipal.
PrincipalOriginAttributes attrs; OriginAttributes attrs;
// For addons loadInfo might be null. // For addons loadInfo might be null.
if (loadInfo) { if (loadInfo) {
attrs.InheritFromNecko(loadInfo->GetOriginAttributes()); attrs.Inherit(loadInfo->GetOriginAttributes());
} }
rv = MaybeSetAddonIdFromURI(attrs, uri); rv = MaybeSetAddonIdFromURI(attrs, uri);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@ -1070,7 +1069,7 @@ NS_IMETHODIMP
nsScriptSecurityManager::GetNoAppCodebasePrincipal(nsIURI* aURI, nsScriptSecurityManager::GetNoAppCodebasePrincipal(nsIURI* aURI,
nsIPrincipal** aPrincipal) nsIPrincipal** aPrincipal)
{ {
PrincipalOriginAttributes attrs(NO_APP_ID, false); OriginAttributes attrs;
nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(aURI, attrs); nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
prin.forget(aPrincipal); prin.forget(aPrincipal);
return *aPrincipal ? NS_OK : NS_ERROR_FAILURE; return *aPrincipal ? NS_OK : NS_ERROR_FAILURE;
@ -1087,7 +1086,7 @@ NS_IMETHODIMP
nsScriptSecurityManager::CreateCodebasePrincipal(nsIURI* aURI, JS::Handle<JS::Value> aOriginAttributes, nsScriptSecurityManager::CreateCodebasePrincipal(nsIURI* aURI, JS::Handle<JS::Value> aOriginAttributes,
JSContext* aCx, nsIPrincipal** aPrincipal) JSContext* aCx, nsIPrincipal** aPrincipal)
{ {
PrincipalOriginAttributes attrs; OriginAttributes attrs;
if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) { if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) {
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
@ -1117,7 +1116,7 @@ NS_IMETHODIMP
nsScriptSecurityManager::CreateNullPrincipal(JS::Handle<JS::Value> aOriginAttributes, nsScriptSecurityManager::CreateNullPrincipal(JS::Handle<JS::Value> aOriginAttributes,
JSContext* aCx, nsIPrincipal** aPrincipal) JSContext* aCx, nsIPrincipal** aPrincipal)
{ {
PrincipalOriginAttributes attrs; OriginAttributes attrs;
if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) { if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) {
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
@ -1135,7 +1134,7 @@ nsScriptSecurityManager::GetAppCodebasePrincipal(nsIURI* aURI,
NS_ENSURE_TRUE(aAppId != nsIScriptSecurityManager::UNKNOWN_APP_ID, NS_ENSURE_TRUE(aAppId != nsIScriptSecurityManager::UNKNOWN_APP_ID,
NS_ERROR_INVALID_ARG); NS_ERROR_INVALID_ARG);
PrincipalOriginAttributes attrs(aAppId, aInIsolatedMozBrowser); OriginAttributes attrs(aAppId, aInIsolatedMozBrowser);
nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(aURI, attrs); nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
prin.forget(aPrincipal); prin.forget(aPrincipal);
return *aPrincipal ? NS_OK : NS_ERROR_FAILURE; return *aPrincipal ? NS_OK : NS_ERROR_FAILURE;
@ -1148,12 +1147,12 @@ nsScriptSecurityManager::
nsIPrincipal** aPrincipal) nsIPrincipal** aPrincipal)
{ {
NS_ENSURE_STATE(aLoadContext); NS_ENSURE_STATE(aLoadContext);
DocShellOriginAttributes docShellAttrs; OriginAttributes docShellAttrs;
bool result = aLoadContext->GetOriginAttributes(docShellAttrs);; bool result = aLoadContext->GetOriginAttributes(docShellAttrs);;
NS_ENSURE_TRUE(result, NS_ERROR_FAILURE); NS_ENSURE_TRUE(result, NS_ERROR_FAILURE);
PrincipalOriginAttributes attrs; OriginAttributes attrs;
attrs.InheritFromDocShellToDoc(docShellAttrs, aURI); attrs.Inherit(docShellAttrs);
nsresult rv = MaybeSetAddonIdFromURI(attrs, aURI); nsresult rv = MaybeSetAddonIdFromURI(attrs, aURI);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@ -1167,8 +1166,8 @@ nsScriptSecurityManager::GetDocShellCodebasePrincipal(nsIURI* aURI,
nsIDocShell* aDocShell, nsIDocShell* aDocShell,
nsIPrincipal** aPrincipal) nsIPrincipal** aPrincipal)
{ {
PrincipalOriginAttributes attrs; OriginAttributes attrs;
attrs.InheritFromDocShellToDoc(nsDocShell::Cast(aDocShell)->GetOriginAttributes(), aURI); attrs.Inherit(nsDocShell::Cast(aDocShell)->GetOriginAttributes());
nsresult rv = MaybeSetAddonIdFromURI(attrs, aURI); nsresult rv = MaybeSetAddonIdFromURI(attrs, aURI);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);

View file

@ -27,7 +27,7 @@ class nsIStringBundle;
class nsSystemPrincipal; class nsSystemPrincipal;
namespace mozilla { namespace mozilla {
class PrincipalOriginAttributes; class OriginAttributes;
} // namespace mozilla } // namespace mozilla
///////////////////////////// /////////////////////////////
@ -112,7 +112,7 @@ private:
AddSitesToFileURIWhitelist(const nsCString& aSiteList); AddSitesToFileURIWhitelist(const nsCString& aSiteList);
// If aURI is a moz-extension:// URI, set mAddonId to the associated addon. // If aURI is a moz-extension:// URI, set mAddonId to the associated addon.
nsresult MaybeSetAddonIdFromURI(mozilla::PrincipalOriginAttributes& aAttrs, nsIURI* aURI); nsresult MaybeSetAddonIdFromURI(mozilla::OriginAttributes& aAttrs, nsIURI* aURI);
nsresult GetChannelResultPrincipal(nsIChannel* aChannel, nsresult GetChannelResultPrincipal(nsIChannel* aChannel,
nsIPrincipal** aPrincipal, nsIPrincipal** aPrincipal,

View file

@ -4,35 +4,35 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "mozilla/BasePrincipal.h" #include "mozilla/BasePrincipal.h"
using mozilla::PrincipalOriginAttributes; using mozilla::OriginAttributes;
static void static void
TestSuffix(const PrincipalOriginAttributes& attrs) TestSuffix(const OriginAttributes& attrs)
{ {
nsAutoCString suffix; nsAutoCString suffix;
attrs.CreateSuffix(suffix); attrs.CreateSuffix(suffix);
PrincipalOriginAttributes attrsFromSuffix; OriginAttributes attrsFromSuffix;
bool success = attrsFromSuffix.PopulateFromSuffix(suffix); bool success = attrsFromSuffix.PopulateFromSuffix(suffix);
EXPECT_TRUE(success); EXPECT_TRUE(success);
EXPECT_EQ(attrs, attrsFromSuffix); EXPECT_EQ(attrs, attrsFromSuffix);
} }
TEST(PrincipalOriginAttributes, Suffix_default) TEST(OriginAttributes, Suffix_default)
{ {
PrincipalOriginAttributes attrs; OriginAttributes attrs;
TestSuffix(attrs); TestSuffix(attrs);
} }
TEST(PrincipalOriginAttributes, Suffix_appId_inIsolatedMozBrowser) TEST(OriginAttributes, Suffix_appId_inIsolatedMozBrowser)
{ {
PrincipalOriginAttributes attrs(1, true); OriginAttributes attrs(1, true);
TestSuffix(attrs); TestSuffix(attrs);
} }
TEST(PrincipalOriginAttributes, Suffix_maxAppId_inIsolatedMozBrowser) TEST(OriginAttributes, Suffix_maxAppId_inIsolatedMozBrowser)
{ {
PrincipalOriginAttributes attrs(4294967295, true); OriginAttributes attrs(4294967295, true);
TestSuffix(attrs); TestSuffix(attrs);
} }

View file

@ -13,7 +13,7 @@
#include "xpcpublic.h" #include "xpcpublic.h"
bool bool
nsILoadContext::GetOriginAttributes(mozilla::DocShellOriginAttributes& aAttrs) nsILoadContext::GetOriginAttributes(mozilla::OriginAttributes& aAttrs)
{ {
mozilla::dom::AutoJSAPI jsapi; mozilla::dom::AutoJSAPI jsapi;
bool ok = jsapi.Init(xpc::PrivilegedJunkScope()); bool ok = jsapi.Init(xpc::PrivilegedJunkScope());
@ -29,7 +29,7 @@ nsILoadContext::GetOriginAttributes(mozilla::DocShellOriginAttributes& aAttrs)
MOZ_ASSERT(nsContentUtils::IsSystemPrincipal(nsContentUtils::ObjectPrincipal(obj))); MOZ_ASSERT(nsContentUtils::IsSystemPrincipal(nsContentUtils::ObjectPrincipal(obj)));
JSAutoCompartment ac(jsapi.cx(), obj); JSAutoCompartment ac(jsapi.cx(), obj);
mozilla::DocShellOriginAttributes attrs; mozilla::OriginAttributes attrs;
ok = attrs.Init(jsapi.cx(), v); ok = attrs.Init(jsapi.cx(), v);
NS_ENSURE_TRUE(ok, false); NS_ENSURE_TRUE(ok, false);
aAttrs = attrs; aAttrs = attrs;
@ -50,8 +50,7 @@ LoadContext::LoadContext(nsIPrincipal* aPrincipal,
, mIsNotNull(true) , mIsNotNull(true)
#endif #endif
{ {
PrincipalOriginAttributes poa = aPrincipal->OriginAttributesRef(); mOriginAttributes.Inherit(aPrincipal->OriginAttributesRef());
mOriginAttributes.InheritFromDocToChildDocShell(poa);
if (!aOptionalBase) { if (!aOptionalBase) {
return; return;
} }

View file

@ -40,7 +40,7 @@ public:
// provided by child process. // provided by child process.
LoadContext(const IPC::SerializedLoadContext& aToCopy, LoadContext(const IPC::SerializedLoadContext& aToCopy,
dom::Element* aTopFrameElement, dom::Element* aTopFrameElement,
DocShellOriginAttributes& aAttrs) OriginAttributes& aAttrs)
: mTopFrameElement(do_GetWeakReference(aTopFrameElement)) : mTopFrameElement(do_GetWeakReference(aTopFrameElement))
, mNestedFrameId(0) , mNestedFrameId(0)
, mIsContent(aToCopy.mIsContent) , mIsContent(aToCopy.mIsContent)
@ -56,7 +56,7 @@ public:
// provided by child process. // provided by child process.
LoadContext(const IPC::SerializedLoadContext& aToCopy, LoadContext(const IPC::SerializedLoadContext& aToCopy,
uint64_t aNestedFrameId, uint64_t aNestedFrameId,
DocShellOriginAttributes& aAttrs) OriginAttributes& aAttrs)
: mTopFrameElement(nullptr) : mTopFrameElement(nullptr)
, mNestedFrameId(aNestedFrameId) , mNestedFrameId(aNestedFrameId)
, mIsContent(aToCopy.mIsContent) , mIsContent(aToCopy.mIsContent)
@ -72,7 +72,7 @@ public:
bool aIsContent, bool aIsContent,
bool aUsePrivateBrowsing, bool aUsePrivateBrowsing,
bool aUseRemoteTabs, bool aUseRemoteTabs,
const DocShellOriginAttributes& aAttrs) const OriginAttributes& aAttrs)
: mTopFrameElement(do_GetWeakReference(aTopFrameElement)) : mTopFrameElement(do_GetWeakReference(aTopFrameElement))
, mNestedFrameId(0) , mNestedFrameId(0)
, mIsContent(aIsContent) , mIsContent(aIsContent)
@ -86,7 +86,7 @@ public:
} }
// Constructor taking reserved origin attributes. // Constructor taking reserved origin attributes.
explicit LoadContext(DocShellOriginAttributes& aAttrs) explicit LoadContext(OriginAttributes& aAttrs)
: mTopFrameElement(nullptr) : mTopFrameElement(nullptr)
, mNestedFrameId(0) , mNestedFrameId(0)
, mIsContent(false) , mIsContent(false)
@ -110,7 +110,7 @@ private:
uint64_t mNestedFrameId; uint64_t mNestedFrameId;
bool mIsContent; bool mIsContent;
bool mUseRemoteTabs; bool mUseRemoteTabs;
DocShellOriginAttributes mOriginAttributes; OriginAttributes mOriginAttributes;
#ifdef DEBUG #ifdef DEBUG
bool mIsNotNull; bool mIsNotNull;
#endif #endif

View file

@ -52,7 +52,7 @@ public:
bool mIsPrivateBitValid; bool mIsPrivateBitValid;
bool mIsContent; bool mIsContent;
bool mUseRemoteTabs; bool mUseRemoteTabs;
mozilla::DocShellOriginAttributes mOriginAttributes; mozilla::OriginAttributes mOriginAttributes;
}; };
// Function to serialize over IPDL // Function to serialize over IPDL

View file

@ -3556,9 +3556,9 @@ nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem,
aTargetItem->GetSameTypeRootTreeItem(getter_AddRefs(targetRoot)); aTargetItem->GetSameTypeRootTreeItem(getter_AddRefs(targetRoot));
nsCOMPtr<nsIDocShell> targetRootDS = do_QueryInterface(targetRoot); nsCOMPtr<nsIDocShell> targetRootDS = do_QueryInterface(targetRoot);
DocShellOriginAttributes targetOA = OriginAttributes targetOA =
static_cast<nsDocShell*>(targetDS.get())->GetOriginAttributes(); static_cast<nsDocShell*>(targetDS.get())->GetOriginAttributes();
DocShellOriginAttributes accessingOA = OriginAttributes accessingOA =
static_cast<nsDocShell*>(accessingDS.get())->GetOriginAttributes(); static_cast<nsDocShell*>(accessingDS.get())->GetOriginAttributes();
// When the first party isolation is on, the top-level docShell may not have // When the first party isolation is on, the top-level docShell may not have
@ -9673,8 +9673,8 @@ nsresult
nsDocShell::CreatePrincipalFromReferrer(nsIURI* aReferrer, nsDocShell::CreatePrincipalFromReferrer(nsIURI* aReferrer,
nsIPrincipal** aResult) nsIPrincipal** aResult)
{ {
PrincipalOriginAttributes attrs; OriginAttributes attrs;
attrs.InheritFromDocShellToDoc(mOriginAttributes, aReferrer); attrs.Inherit(mOriginAttributes);
nsCOMPtr<nsIPrincipal> prin = nsCOMPtr<nsIPrincipal> prin =
BasePrincipal::CreateCodebasePrincipal(aReferrer, attrs); BasePrincipal::CreateCodebasePrincipal(aReferrer, attrs);
prin.forget(aResult); prin.forget(aResult);
@ -10898,12 +10898,14 @@ nsDocShell::DoURILoad(nsIURI* aURI,
// We have to do this in case our OriginAttributes are different from the // We have to do this in case our OriginAttributes are different from the
// OriginAttributes of the parent document. Or in case there isn't a // OriginAttributes of the parent document. Or in case there isn't a
// parent document. // parent document.
NeckoOriginAttributes neckoAttrs;
bool isTopLevelDoc = aContentPolicyType == nsIContentPolicy::TYPE_DOCUMENT && bool isTopLevelDoc = aContentPolicyType == nsIContentPolicy::TYPE_DOCUMENT &&
mItemType == typeContent && mItemType == typeContent &&
!GetIsMozBrowser(); !GetIsMozBrowser();
neckoAttrs.InheritFromDocShellToNecko(GetOriginAttributes(), isTopLevelDoc, aURI);
rv = loadInfo->SetOriginAttributes(neckoAttrs); OriginAttributes attrs;
attrs.Inherit(GetOriginAttributes());
attrs.SetFirstPartyDomain(isTopLevelDoc, aURI);
rv = loadInfo->SetOriginAttributes(attrs);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }
@ -12286,11 +12288,10 @@ nsDocShell::AddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel,
loadInfo->LoadingPrincipal()); loadInfo->LoadingPrincipal());
} else { } else {
// get the OriginAttributes // get the OriginAttributes
NeckoOriginAttributes nAttrs; OriginAttributes attrs;
loadInfo->GetOriginAttributes(&nAttrs); loadInfo->GetOriginAttributes(&attrs);
PrincipalOriginAttributes pAttrs; attrs.StripAttributes(OriginAttributes::STRIP_ADDON_ID);
pAttrs.InheritFromNecko(nAttrs); principalToInherit = nsNullPrincipal::Create(attrs);
principalToInherit = nsNullPrincipal::Create(pAttrs);
} }
} else { } else {
principalToInherit = loadInfo->PrincipalToInherit(); principalToInherit = loadInfo->PrincipalToInherit();
@ -14375,7 +14376,7 @@ nsDocShell::CanSetOriginAttributes()
} }
nsresult nsresult
nsDocShell::SetOriginAttributes(const DocShellOriginAttributes& aAttrs) nsDocShell::SetOriginAttributes(const OriginAttributes& aAttrs)
{ {
if (!CanSetOriginAttributes()) { if (!CanSetOriginAttributes()) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -14413,7 +14414,7 @@ nsDocShell::SetOriginAttributesBeforeLoading(JS::Handle<JS::Value> aOriginAttrib
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
DocShellOriginAttributes attrs; OriginAttributes attrs;
if (!aOriginAttributes.isObject() || !attrs.Init(cx, aOriginAttributes)) { if (!aOriginAttributes.isObject() || !attrs.Init(cx, aOriginAttributes)) {
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
@ -14425,7 +14426,7 @@ NS_IMETHODIMP
nsDocShell::SetOriginAttributes(JS::Handle<JS::Value> aOriginAttributes, nsDocShell::SetOriginAttributes(JS::Handle<JS::Value> aOriginAttributes,
JSContext* aCx) JSContext* aCx)
{ {
DocShellOriginAttributes attrs; OriginAttributes attrs;
if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) { if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) {
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
@ -14605,8 +14606,8 @@ nsDocShell::ShouldPrepareForIntercept(nsIURI* aURI, bool aIsNonSubresourceReques
} }
if (aIsNonSubresourceRequest) { if (aIsNonSubresourceRequest) {
PrincipalOriginAttributes attrs; OriginAttributes attrs;
attrs.InheritFromDocShellToDoc(mOriginAttributes, aURI); attrs.Inherit(mOriginAttributes);
nsCOMPtr<nsIPrincipal> principal = nsCOMPtr<nsIPrincipal> principal =
BasePrincipal::CreateCodebasePrincipal(aURI, attrs); BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
*aShouldIntercept = swm->IsAvailable(principal, aURI); *aShouldIntercept = swm->IsAvailable(principal, aURI);
@ -14657,12 +14658,8 @@ nsDocShell::ChannelIntercepted(nsIInterceptedChannel* aChannel)
bool isReload = mLoadType & LOAD_CMD_RELOAD; bool isReload = mLoadType & LOAD_CMD_RELOAD;
nsCOMPtr<nsIURI> uri; OriginAttributes attrs;
rv = channel->GetURI(getter_AddRefs(uri)); attrs.Inherit(mOriginAttributes);
NS_ENSURE_SUCCESS(rv, rv);
PrincipalOriginAttributes attrs;
attrs.InheritFromDocShellToDoc(mOriginAttributes, uri);
ErrorResult error; ErrorResult error;
swm->DispatchFetchEvent(attrs, doc, mInterceptedDocumentId, aChannel, swm->DispatchFetchEvent(attrs, doc, mInterceptedDocumentId, aChannel,

View file

@ -277,13 +277,13 @@ private:
bool CanSetOriginAttributes(); bool CanSetOriginAttributes();
public: public:
const mozilla::DocShellOriginAttributes& const mozilla::OriginAttributes&
GetOriginAttributes() GetOriginAttributes()
{ {
return mOriginAttributes; return mOriginAttributes;
} }
nsresult SetOriginAttributes(const mozilla::DocShellOriginAttributes& aAttrs); nsresult SetOriginAttributes(const mozilla::OriginAttributes& aAttrs);
void GetInterceptedDocumentId(nsAString& aId) void GetInterceptedDocumentId(nsAString& aId)
{ {
@ -1041,7 +1041,7 @@ private:
nsTObserverArray<nsWeakPtr> mScrollObservers; nsTObserverArray<nsWeakPtr> mScrollObservers;
nsCString mOriginalUriString; nsCString mOriginalUriString;
nsWeakPtr mOpener; nsWeakPtr mOpener;
mozilla::DocShellOriginAttributes mOriginAttributes; mozilla::OriginAttributes mOriginAttributes;
// A depth count of how many times NotifyRunToCompletionStart // A depth count of how many times NotifyRunToCompletionStart
// has been called without a matching NotifyRunToCompletionStop. // has been called without a matching NotifyRunToCompletionStop.

View file

@ -11,7 +11,7 @@ interface nsIDOMElement;
%{C++ %{C++
#ifdef MOZILLA_INTERNAL_API #ifdef MOZILLA_INTERNAL_API
#include "mozilla/BasePrincipal.h" // for DocShellOriginAttributes #include "mozilla/BasePrincipal.h" // for OriginAttributes
#endif #endif
%} %}
@ -127,7 +127,7 @@ interface nsILoadContext : nsISupports
* *
* Defined in LoadContext.cpp * Defined in LoadContext.cpp
*/ */
bool GetOriginAttributes(mozilla::DocShellOriginAttributes& aAttrs); bool GetOriginAttributes(mozilla::OriginAttributes& aAttrs);
#endif #endif
%} %}

View file

@ -132,7 +132,7 @@ ChromeUtils::OriginAttributesToSuffix(dom::GlobalObject& aGlobal,
nsCString& aSuffix) nsCString& aSuffix)
{ {
GenericOriginAttributes attrs(aAttrs); OriginAttributes attrs(aAttrs);
attrs.CreateSuffix(aSuffix); attrs.CreateSuffix(aSuffix);
} }
@ -141,7 +141,7 @@ ChromeUtils::OriginAttributesMatchPattern(dom::GlobalObject& aGlobal,
const dom::OriginAttributesDictionary& aAttrs, const dom::OriginAttributesDictionary& aAttrs,
const dom::OriginAttributesPatternDictionary& aPattern) const dom::OriginAttributesPatternDictionary& aPattern)
{ {
GenericOriginAttributes attrs(aAttrs); OriginAttributes attrs(aAttrs);
OriginAttributesPattern pattern(aPattern); OriginAttributesPattern pattern(aPattern);
return pattern.Matches(attrs); return pattern.Matches(attrs);
} }
@ -152,7 +152,7 @@ ChromeUtils::CreateOriginAttributesFromOrigin(dom::GlobalObject& aGlobal,
dom::OriginAttributesDictionary& aAttrs, dom::OriginAttributesDictionary& aAttrs,
ErrorResult& aRv) ErrorResult& aRv)
{ {
GenericOriginAttributes attrs; OriginAttributes attrs;
nsAutoCString suffix; nsAutoCString suffix;
if (!attrs.PopulateFromOrigin(NS_ConvertUTF16toUTF8(aOrigin), suffix)) { if (!attrs.PopulateFromOrigin(NS_ConvertUTF16toUTF8(aOrigin), suffix)) {
aRv.Throw(NS_ERROR_FAILURE); aRv.Throw(NS_ERROR_FAILURE);

View file

@ -350,7 +350,7 @@ DOMParser::Init(nsIPrincipal* principal, nsIURI* documentURI,
0, 0,
documentURI); documentURI);
PrincipalOriginAttributes attrs; OriginAttributes attrs;
mPrincipal = BasePrincipal::CreateCodebasePrincipal(mDocumentURI, attrs); mPrincipal = BasePrincipal::CreateCodebasePrincipal(mDocumentURI, attrs);
NS_ENSURE_TRUE(mPrincipal, NS_ERROR_FAILURE); NS_ENSURE_TRUE(mPrincipal, NS_ERROR_FAILURE);
mOriginalPrincipal = mPrincipal; mOriginalPrincipal = mPrincipal;

View file

@ -3145,11 +3145,11 @@ nsContentUtils::CanLoadImage(nsIURI* aURI, nsISupports* aContext,
} }
// static // static
mozilla::PrincipalOriginAttributes mozilla::OriginAttributes
nsContentUtils::GetOriginAttributes(nsIDocument* aDocument) nsContentUtils::GetOriginAttributes(nsIDocument* aDocument)
{ {
if (!aDocument) { if (!aDocument) {
return mozilla::PrincipalOriginAttributes(); return mozilla::OriginAttributes();
} }
nsCOMPtr<nsILoadGroup> loadGroup = aDocument->GetDocumentLoadGroup(); nsCOMPtr<nsILoadGroup> loadGroup = aDocument->GetDocumentLoadGroup();
@ -3157,30 +3157,28 @@ nsContentUtils::GetOriginAttributes(nsIDocument* aDocument)
return GetOriginAttributes(loadGroup); return GetOriginAttributes(loadGroup);
} }
mozilla::PrincipalOriginAttributes attrs; mozilla::OriginAttributes attrs;
mozilla::NeckoOriginAttributes nattrs;
nsCOMPtr<nsIChannel> channel = aDocument->GetChannel(); nsCOMPtr<nsIChannel> channel = aDocument->GetChannel();
if (channel && NS_GetOriginAttributes(channel, nattrs)) { if (channel && NS_GetOriginAttributes(channel, attrs)) {
attrs.InheritFromNecko(nattrs); attrs.StripAttributes(OriginAttributes::STRIP_ADDON_ID);
} }
return attrs; return attrs;
} }
// static // static
mozilla::PrincipalOriginAttributes mozilla::OriginAttributes
nsContentUtils::GetOriginAttributes(nsILoadGroup* aLoadGroup) nsContentUtils::GetOriginAttributes(nsILoadGroup* aLoadGroup)
{ {
if (!aLoadGroup) { if (!aLoadGroup) {
return mozilla::PrincipalOriginAttributes(); return mozilla::OriginAttributes();
} }
mozilla::PrincipalOriginAttributes attrs; mozilla::OriginAttributes attrs;
mozilla::DocShellOriginAttributes dsattrs;
nsCOMPtr<nsIInterfaceRequestor> callbacks; nsCOMPtr<nsIInterfaceRequestor> callbacks;
aLoadGroup->GetNotificationCallbacks(getter_AddRefs(callbacks)); aLoadGroup->GetNotificationCallbacks(getter_AddRefs(callbacks));
if (callbacks) { if (callbacks) {
nsCOMPtr<nsILoadContext> loadContext = do_GetInterface(callbacks); nsCOMPtr<nsILoadContext> loadContext = do_GetInterface(callbacks);
if (loadContext && loadContext->GetOriginAttributes(dsattrs)) { if (loadContext && loadContext->GetOriginAttributes(attrs)) {
attrs.InheritFromDocShellToDoc(dsattrs, nullptr); attrs.StripAttributes(OriginAttributes::STRIP_ADDON_ID);
} }
} }
return attrs; return attrs;

View file

@ -805,13 +805,13 @@ public:
/** /**
* Returns origin attributes of the document. * Returns origin attributes of the document.
**/ **/
static mozilla::PrincipalOriginAttributes static mozilla::OriginAttributes
GetOriginAttributes(nsIDocument* aDoc); GetOriginAttributes(nsIDocument* aDoc);
/** /**
* Returns origin attributes of the load group. * Returns origin attributes of the load group.
**/ **/
static mozilla::PrincipalOriginAttributes static mozilla::OriginAttributes
GetOriginAttributes(nsILoadGroup* aLoadGroup); GetOriginAttributes(nsILoadGroup* aLoadGroup);
/** /**

View file

@ -1361,12 +1361,12 @@ nsFrameLoader::SwapWithOtherRemoteLoader(nsFrameLoader* aOther,
// This is the reason why now we must retrieve the correct value from the // This is the reason why now we must retrieve the correct value from the
// usercontextid attribute before comparing our originAttributes with the // usercontextid attribute before comparing our originAttributes with the
// other one. // other one.
DocShellOriginAttributes ourOriginAttributes = OriginAttributes ourOriginAttributes =
mRemoteBrowser->OriginAttributesRef(); mRemoteBrowser->OriginAttributesRef();
rv = PopulateUserContextIdFromAttribute(ourOriginAttributes); rv = PopulateUserContextIdFromAttribute(ourOriginAttributes);
NS_ENSURE_SUCCESS(rv,rv); NS_ENSURE_SUCCESS(rv,rv);
DocShellOriginAttributes otherOriginAttributes = OriginAttributes otherOriginAttributes =
aOther->mRemoteBrowser->OriginAttributesRef(); aOther->mRemoteBrowser->OriginAttributesRef();
rv = aOther->PopulateUserContextIdFromAttribute(otherOriginAttributes); rv = aOther->PopulateUserContextIdFromAttribute(otherOriginAttributes);
NS_ENSURE_SUCCESS(rv,rv); NS_ENSURE_SUCCESS(rv,rv);
@ -1759,12 +1759,12 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
// This is the reason why now we must retrieve the correct value from the // This is the reason why now we must retrieve the correct value from the
// usercontextid attribute before comparing our originAttributes with the // usercontextid attribute before comparing our originAttributes with the
// other one. // other one.
DocShellOriginAttributes ourOriginAttributes = OriginAttributes ourOriginAttributes =
ourDocshell->GetOriginAttributes(); ourDocshell->GetOriginAttributes();
rv = PopulateUserContextIdFromAttribute(ourOriginAttributes); rv = PopulateUserContextIdFromAttribute(ourOriginAttributes);
NS_ENSURE_SUCCESS(rv,rv); NS_ENSURE_SUCCESS(rv,rv);
DocShellOriginAttributes otherOriginAttributes = OriginAttributes otherOriginAttributes =
otherDocshell->GetOriginAttributes(); otherDocshell->GetOriginAttributes();
rv = aOther->PopulateUserContextIdFromAttribute(otherOriginAttributes); rv = aOther->PopulateUserContextIdFromAttribute(otherOriginAttributes);
NS_ENSURE_SUCCESS(rv,rv); NS_ENSURE_SUCCESS(rv,rv);
@ -2406,7 +2406,7 @@ nsFrameLoader::MaybeCreateDocShell()
} }
} }
DocShellOriginAttributes attrs; OriginAttributes attrs;
if (docShell->ItemType() == mDocShell->ItemType()) { if (docShell->ItemType() == mDocShell->ItemType()) {
attrs = nsDocShell::Cast(docShell)->GetOriginAttributes(); attrs = nsDocShell::Cast(docShell)->GetOriginAttributes();
} }
@ -2421,7 +2421,7 @@ nsFrameLoader::MaybeCreateDocShell()
if (parentType == nsIDocShellTreeItem::typeContent && if (parentType == nsIDocShellTreeItem::typeContent &&
!nsContentUtils::IsSystemPrincipal(doc->NodePrincipal()) && !nsContentUtils::IsSystemPrincipal(doc->NodePrincipal()) &&
!OwnerIsMozBrowserFrame()) { !OwnerIsMozBrowserFrame()) {
PrincipalOriginAttributes poa = doc->NodePrincipal()->OriginAttributesRef(); OriginAttributes oa = doc->NodePrincipal()->OriginAttributesRef();
// Assert on the firstPartyDomain from top-level docshell should be empty // Assert on the firstPartyDomain from top-level docshell should be empty
if (mIsTopLevelContent) { if (mIsTopLevelContent) {
@ -2429,18 +2429,18 @@ nsFrameLoader::MaybeCreateDocShell()
"top-level docshell shouldn't have firstPartyDomain attribute."); "top-level docshell shouldn't have firstPartyDomain attribute.");
} }
// So far we want to make sure InheritFromDocToChildDocShell doesn't override // So far we want to make sure Inherit doesn't override any other origin
// any other origin attribute than firstPartyDomain. // attribute than firstPartyDomain.
MOZ_ASSERT(attrs.mAppId == poa.mAppId, MOZ_ASSERT(attrs.mAppId == oa.mAppId,
"docshell and document should have the same appId attribute."); "docshell and document should have the same appId attribute.");
MOZ_ASSERT(attrs.mUserContextId == poa.mUserContextId, MOZ_ASSERT(attrs.mUserContextId == oa.mUserContextId,
"docshell and document should have the same userContextId attribute."); "docshell and document should have the same userContextId attribute.");
MOZ_ASSERT(attrs.mInIsolatedMozBrowser == poa.mInIsolatedMozBrowser, MOZ_ASSERT(attrs.mInIsolatedMozBrowser == oa.mInIsolatedMozBrowser,
"docshell and document should have the same inIsolatedMozBrowser attribute."); "docshell and document should have the same inIsolatedMozBrowser attribute.");
MOZ_ASSERT(attrs.mPrivateBrowsingId == poa.mPrivateBrowsingId, MOZ_ASSERT(attrs.mPrivateBrowsingId == oa.mPrivateBrowsingId,
"docshell and document should have the same privateBrowsingId attribute."); "docshell and document should have the same privateBrowsingId attribute.");
attrs.InheritFromDocToChildDocShell(poa); attrs.Inherit(oa);
} }
if (OwnerIsMozBrowserFrame()) { if (OwnerIsMozBrowserFrame()) {
@ -3592,7 +3592,7 @@ nsresult
nsFrameLoader::GetNewTabContext(MutableTabContext* aTabContext, nsFrameLoader::GetNewTabContext(MutableTabContext* aTabContext,
nsIURI* aURI) nsIURI* aURI)
{ {
DocShellOriginAttributes attrs; OriginAttributes attrs;
attrs.mInIsolatedMozBrowser = OwnerIsIsolatedMozBrowserFrame(); attrs.mInIsolatedMozBrowser = OwnerIsIsolatedMozBrowserFrame();
nsresult rv; nsresult rv;
@ -3641,7 +3641,7 @@ nsFrameLoader::GetNewTabContext(MutableTabContext* aTabContext,
} }
nsresult nsresult
nsFrameLoader::PopulateUserContextIdFromAttribute(DocShellOriginAttributes& aAttr) nsFrameLoader::PopulateUserContextIdFromAttribute(OriginAttributes& aAttr)
{ {
if (aAttr.mUserContextId == if (aAttr.mUserContextId ==
nsIScriptSecurityManager::DEFAULT_USER_CONTEXT_ID) { nsIScriptSecurityManager::DEFAULT_USER_CONTEXT_ID) {

View file

@ -39,7 +39,7 @@ class nsIDocShellTreeOwner;
namespace mozilla { namespace mozilla {
class DocShellOriginAttributes; class OriginAttributes;
namespace dom { namespace dom {
class ContentParent; class ContentParent;
@ -308,7 +308,7 @@ private:
void MaybeUpdatePrimaryTabParent(TabParentChange aChange); void MaybeUpdatePrimaryTabParent(TabParentChange aChange);
nsresult nsresult
PopulateUserContextIdFromAttribute(mozilla::DocShellOriginAttributes& aAttr); PopulateUserContextIdFromAttribute(mozilla::OriginAttributes& aAttr);
// Swap ourselves with the frameloader aOther, and notify chrome code with // Swap ourselves with the frameloader aOther, and notify chrome code with
// a BrowserChangedProcess event. // a BrowserChangedProcess event.

View file

@ -275,7 +275,7 @@ using namespace mozilla;
using namespace mozilla::dom; using namespace mozilla::dom;
using namespace mozilla::dom::ipc; using namespace mozilla::dom::ipc;
using mozilla::BasePrincipal; using mozilla::BasePrincipal;
using mozilla::PrincipalOriginAttributes; using mozilla::OriginAttributes;
using mozilla::TimeStamp; using mozilla::TimeStamp;
using mozilla::TimeDuration; using mozilla::TimeDuration;
using mozilla::dom::cache::CacheStorage; using mozilla::dom::cache::CacheStorage;
@ -2436,7 +2436,7 @@ nsGlobalWindow::ComputeIsSecureContext(nsIDocument* aDocument)
// IsOriginPotentiallyTrustworthy doesn't care about origin attributes so // IsOriginPotentiallyTrustworthy doesn't care about origin attributes so
// it doesn't actually matter what we use here, but reusing the document // it doesn't actually matter what we use here, but reusing the document
// principal's attributes is convenient. // principal's attributes is convenient.
const PrincipalOriginAttributes& attrs = principal->OriginAttributesRef(); const OriginAttributes& attrs = principal->OriginAttributesRef();
// CreateCodebasePrincipal correctly gets a useful principal for blob: and // CreateCodebasePrincipal correctly gets a useful principal for blob: and
// other URI_INHERITS_SECURITY_CONTEXT URIs. // other URI_INHERITS_SECURITY_CONTEXT URIs.
principal = BasePrincipal::CreateCodebasePrincipal(uri, attrs); principal = BasePrincipal::CreateCodebasePrincipal(uri, attrs);
@ -8486,7 +8486,7 @@ nsGlobalWindow::PostMessageMozOuter(JSContext* aCx, JS::Handle<JS::Value> aMessa
return; return;
} }
PrincipalOriginAttributes attrs = aSubjectPrincipal.OriginAttributesRef(); OriginAttributes attrs = aSubjectPrincipal.OriginAttributesRef();
if (aSubjectPrincipal.GetIsSystemPrincipal()) { if (aSubjectPrincipal.GetIsSystemPrincipal()) {
auto principal = BasePrincipal::Cast(GetPrincipal()); auto principal = BasePrincipal::Cast(GetPrincipal());

View file

@ -10,7 +10,7 @@
NS_IMPL_ISUPPORTS(nsOpenURIInFrameParams, nsIOpenURIInFrameParams) NS_IMPL_ISUPPORTS(nsOpenURIInFrameParams, nsIOpenURIInFrameParams)
nsOpenURIInFrameParams::nsOpenURIInFrameParams(const mozilla::DocShellOriginAttributes& aOriginAttributes) nsOpenURIInFrameParams::nsOpenURIInFrameParams(const mozilla::OriginAttributes& aOriginAttributes)
: mOpenerOriginAttributes(aOriginAttributes) : mOpenerOriginAttributes(aOriginAttributes)
, mIsPrivate(false) , mIsPrivate(false)
{ {

View file

@ -9,7 +9,7 @@
#include "nsString.h" #include "nsString.h"
namespace mozilla { namespace mozilla {
class DocShellOriginAttributes; class OriginAttributes;
} }
class nsOpenURIInFrameParams final : public nsIOpenURIInFrameParams class nsOpenURIInFrameParams final : public nsIOpenURIInFrameParams
@ -18,12 +18,12 @@ public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSIOPENURIINFRAMEPARAMS NS_DECL_NSIOPENURIINFRAMEPARAMS
explicit nsOpenURIInFrameParams(const mozilla::DocShellOriginAttributes& aOriginAttributes); explicit nsOpenURIInFrameParams(const mozilla::OriginAttributes& aOriginAttributes);
private: private:
~nsOpenURIInFrameParams(); ~nsOpenURIInFrameParams();
mozilla::DocShellOriginAttributes mOpenerOriginAttributes; mozilla::OriginAttributes mOpenerOriginAttributes;
nsString mReferrer; nsString mReferrer;
bool mIsPrivate; bool mIsPrivate;
}; };

View file

@ -1975,7 +1975,7 @@ ReadResponse(mozIStorageConnection* aConn, EntryId aEntryId,
aSavedResponseOut->mValue.principalInfo() = void_t(); aSavedResponseOut->mValue.principalInfo() = void_t();
if (!serializedInfo.IsEmpty()) { if (!serializedInfo.IsEmpty()) {
nsAutoCString originNoSuffix; nsAutoCString originNoSuffix;
PrincipalOriginAttributes attrs; OriginAttributes attrs;
if (!attrs.PopulateFromOrigin(serializedInfo, originNoSuffix)) { if (!attrs.PopulateFromOrigin(serializedInfo, originNoSuffix)) {
NS_WARNING("Something went wrong parsing a serialized principal!"); NS_WARNING("Something went wrong parsing a serialized principal!");
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;

View file

@ -152,7 +152,7 @@ public:
} }
void void
SetOriginAttributes(const PrincipalOriginAttributes& aOriginAttributes) SetOriginAttributes(const OriginAttributes& aOriginAttributes)
{ {
mOriginAttributes = aOriginAttributes; mOriginAttributes = aOriginAttributes;
} }
@ -248,7 +248,7 @@ public:
uint64_t mInnerIDNumber; uint64_t mInnerIDNumber;
nsString mInnerIDString; nsString mInnerIDString;
PrincipalOriginAttributes mOriginAttributes; OriginAttributes mOriginAttributes;
nsString mMethodString; nsString mMethodString;
@ -1201,7 +1201,7 @@ Console::MethodInternal(JSContext* aCx, MethodName aMethodName,
return; return;
} }
PrincipalOriginAttributes oa; OriginAttributes oa;
if (mWindow) { if (mWindow) {
// Save the principal's OriginAttributes in the console event data // Save the principal's OriginAttributes in the console event data

View file

@ -667,7 +667,7 @@ ContentChild::ProvideWindow(mozIDOMWindowProxy* aParent,
static nsresult static nsresult
GetWindowParamsFromParent(mozIDOMWindowProxy* aParent, GetWindowParamsFromParent(mozIDOMWindowProxy* aParent,
nsACString& aBaseURIString, float* aFullZoom, nsACString& aBaseURIString, float* aFullZoom,
DocShellOriginAttributes& aOriginAttributes) OriginAttributes& aOriginAttributes)
{ {
*aFullZoom = 1.0f; *aFullZoom = 1.0f;
auto* opener = nsPIDOMWindowOuter::From(aParent); auto* opener = nsPIDOMWindowOuter::From(aParent);
@ -734,7 +734,7 @@ ContentChild::ProvideWindowCommon(TabChild* aTabOpener,
if (NS_SUCCEEDED(rv) && !shouldLoad) { if (NS_SUCCEEDED(rv) && !shouldLoad) {
nsAutoCString baseURIString; nsAutoCString baseURIString;
float fullZoom; float fullZoom;
DocShellOriginAttributes originAttributes; OriginAttributes originAttributes;
rv = GetWindowParamsFromParent(aParent, baseURIString, &fullZoom, rv = GetWindowParamsFromParent(aParent, baseURIString, &fullZoom,
originAttributes); originAttributes);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
@ -834,7 +834,7 @@ ContentChild::ProvideWindowCommon(TabChild* aTabOpener,
} else { } else {
nsAutoCString baseURIString; nsAutoCString baseURIString;
float fullZoom; float fullZoom;
DocShellOriginAttributes originAttributes; OriginAttributes originAttributes;
rv = GetWindowParamsFromParent(aParent, baseURIString, &fullZoom, rv = GetWindowParamsFromParent(aParent, baseURIString, &fullZoom,
originAttributes); originAttributes);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
@ -2324,7 +2324,7 @@ ContentChild::RecvAddPermission(const IPC::Permission& permission)
// note we do not need to force mUserContextId to the default here because // note we do not need to force mUserContextId to the default here because
// the permission manager does that internally. // the permission manager does that internally.
nsAutoCString originNoSuffix; nsAutoCString originNoSuffix;
PrincipalOriginAttributes attrs; OriginAttributes attrs;
bool success = attrs.PopulateFromOrigin(permission.origin, originNoSuffix); bool success = attrs.PopulateFromOrigin(permission.origin, originNoSuffix);
NS_ENSURE_TRUE(success, IPC_FAIL_NO_REASON(this)); NS_ENSURE_TRUE(success, IPC_FAIL_NO_REASON(this));

View file

@ -4177,7 +4177,7 @@ ContentParent::CommonCreateWindow(PBrowserParent* aThisTab,
nsIURI* aURIToLoad, nsIURI* aURIToLoad,
const nsCString& aFeatures, const nsCString& aFeatures,
const nsCString& aBaseURI, const nsCString& aBaseURI,
const DocShellOriginAttributes& aOpenerOriginAttributes, const OriginAttributes& aOpenerOriginAttributes,
const float& aFullZoom, const float& aFullZoom,
nsresult& aResult, nsresult& aResult,
nsCOMPtr<nsITabParent>& aNewTabParent, nsCOMPtr<nsITabParent>& aNewTabParent,
@ -4301,7 +4301,7 @@ ContentParent::RecvCreateWindow(PBrowserParent* aThisTab,
const bool& aSizeSpecified, const bool& aSizeSpecified,
const nsCString& aFeatures, const nsCString& aFeatures,
const nsCString& aBaseURI, const nsCString& aBaseURI,
const DocShellOriginAttributes& aOpenerOriginAttributes, const OriginAttributes& aOpenerOriginAttributes,
const float& aFullZoom, const float& aFullZoom,
nsresult* aResult, nsresult* aResult,
bool* aWindowIsNew, bool* aWindowIsNew,
@ -4368,7 +4368,7 @@ ContentParent::RecvCreateWindowInDifferentProcess(
const URIParams& aURIToLoad, const URIParams& aURIToLoad,
const nsCString& aFeatures, const nsCString& aFeatures,
const nsCString& aBaseURI, const nsCString& aBaseURI,
const DocShellOriginAttributes& aOpenerOriginAttributes, const OriginAttributes& aOpenerOriginAttributes,
const float& aFullZoom) const float& aFullZoom)
{ {
nsCOMPtr<nsITabParent> newRemoteTab; nsCOMPtr<nsITabParent> newRemoteTab;

View file

@ -500,7 +500,7 @@ public:
const bool& aSizeSpecified, const bool& aSizeSpecified,
const nsCString& aFeatures, const nsCString& aFeatures,
const nsCString& aBaseURI, const nsCString& aBaseURI,
const DocShellOriginAttributes& aOpenerOriginAttributes, const OriginAttributes& aOpenerOriginAttributes,
const float& aFullZoom, const float& aFullZoom,
nsresult* aResult, nsresult* aResult,
bool* aWindowIsNew, bool* aWindowIsNew,
@ -518,7 +518,7 @@ public:
const URIParams& aURIToLoad, const URIParams& aURIToLoad,
const nsCString& aFeatures, const nsCString& aFeatures,
const nsCString& aBaseURI, const nsCString& aBaseURI,
const DocShellOriginAttributes& aOpenerOriginAttributes, const OriginAttributes& aOpenerOriginAttributes,
const float& aFullZoom) override; const float& aFullZoom) override;
static bool AllocateLayerTreeId(TabParent* aTabParent, uint64_t* aId); static bool AllocateLayerTreeId(TabParent* aTabParent, uint64_t* aId);
@ -613,7 +613,7 @@ private:
nsIURI* aURIToLoad, nsIURI* aURIToLoad,
const nsCString& aFeatures, const nsCString& aFeatures,
const nsCString& aBaseURI, const nsCString& aBaseURI,
const DocShellOriginAttributes& aOpenerOriginAttributes, const OriginAttributes& aOpenerOriginAttributes,
const float& aFullZoom, const float& aFullZoom,
nsresult& aResult, nsresult& aResult,
nsCOMPtr<nsITabParent>& aNewTabParent, nsCOMPtr<nsITabParent>& aNewTabParent,

View file

@ -90,7 +90,7 @@ using struct LookAndFeelInt from "mozilla/widget/WidgetMessageUtils.h";
using class mozilla::dom::MessagePort from "mozilla/dom/MessagePort.h"; using class mozilla::dom::MessagePort from "mozilla/dom/MessagePort.h";
using class mozilla::dom::ipc::StructuredCloneData from "mozilla/dom/ipc/StructuredCloneData.h"; using class mozilla::dom::ipc::StructuredCloneData from "mozilla/dom/ipc/StructuredCloneData.h";
using mozilla::DataStorageType from "ipc/DataStorageIPCUtils.h"; using mozilla::DataStorageType from "ipc/DataStorageIPCUtils.h";
using mozilla::DocShellOriginAttributes from "mozilla/ipc/BackgroundUtils.h"; using mozilla::OriginAttributes from "mozilla/ipc/BackgroundUtils.h";
using struct mozilla::layers::TextureFactoryIdentifier from "mozilla/layers/CompositorTypes.h"; using struct mozilla::layers::TextureFactoryIdentifier from "mozilla/layers/CompositorTypes.h";
using struct mozilla::dom::FlyWebPublishOptions from "mozilla/dom/FlyWebPublishOptionsIPCSerializer.h"; using struct mozilla::dom::FlyWebPublishOptions from "mozilla/dom/FlyWebPublishOptionsIPCSerializer.h";
using mozilla::Telemetry::Accumulation from "mozilla/TelemetryComms.h"; using mozilla::Telemetry::Accumulation from "mozilla/TelemetryComms.h";
@ -1066,7 +1066,7 @@ parent:
bool aSizeSpecified, bool aSizeSpecified,
nsCString aFeatures, nsCString aFeatures,
nsCString aBaseURI, nsCString aBaseURI,
DocShellOriginAttributes aOpenerOriginAttributes, OriginAttributes aOpenerOriginAttributes,
float aFullZoom) float aFullZoom)
returns (nsresult rv, returns (nsresult rv,
bool windowOpened, bool windowOpened,
@ -1084,7 +1084,7 @@ parent:
URIParams aURIToLoad, URIParams aURIToLoad,
nsCString aFeatures, nsCString aFeatures,
nsCString aBaseURI, nsCString aBaseURI,
DocShellOriginAttributes aOpenerOriginAttributes, OriginAttributes aOpenerOriginAttributes,
float aFullZoom); float aFullZoom);
sync GetDeviceStorageLocation(nsString type) sync GetDeviceStorageLocation(nsString type)

View file

@ -8,7 +8,7 @@ include protocol PBrowser;
include PBrowserOrId; include PBrowserOrId;
using UIStateChangeType from "nsPIDOMWindow.h"; using UIStateChangeType from "nsPIDOMWindow.h";
using mozilla::DocShellOriginAttributes from "mozilla/ipc/BackgroundUtils.h"; using mozilla::OriginAttributes from "mozilla/ipc/BackgroundUtils.h";
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
@ -37,7 +37,7 @@ struct PopupIPCTabContext
struct FrameIPCTabContext struct FrameIPCTabContext
{ {
// The originAttributes dictionary. // The originAttributes dictionary.
DocShellOriginAttributes originAttributes; OriginAttributes originAttributes;
// Whether this is a mozbrowser frame. <iframe mozbrowser mozapp> and // Whether this is a mozbrowser frame. <iframe mozbrowser mozapp> and
// <xul:browser> are not considered to be mozbrowser frames. // <xul:browser> are not considered to be mozbrowser frames.

View file

@ -1200,7 +1200,7 @@ TabChild::ApplyShowInfo(const ShowInfo& aInfo)
NS_LITERAL_CSTRING("mozprivatebrowsing"), NS_LITERAL_CSTRING("mozprivatebrowsing"),
nullptr); nullptr);
} else { } else {
DocShellOriginAttributes attrs(nsDocShell::Cast(docShell)->GetOriginAttributes()); OriginAttributes attrs(nsDocShell::Cast(docShell)->GetOriginAttributes());
attrs.SyncAttributesWithPrivateBrowsing(true); attrs.SyncAttributesWithPrivateBrowsing(true);
nsDocShell::Cast(docShell)->SetOriginAttributes(attrs); nsDocShell::Cast(docShell)->SetOriginAttributes(attrs);
} }

View file

@ -80,7 +80,7 @@ TabContext::UpdateTabContextAfterSwap(const TabContext& aContext)
return true; return true;
} }
const DocShellOriginAttributes& const OriginAttributes&
TabContext::OriginAttributesRef() const TabContext::OriginAttributesRef() const
{ {
return mOriginAttributes; return mOriginAttributes;
@ -109,7 +109,7 @@ TabContext::SetTabContext(bool aIsMozBrowserElement,
bool aIsPrerendered, bool aIsPrerendered,
UIStateChangeType aShowAccelerators, UIStateChangeType aShowAccelerators,
UIStateChangeType aShowFocusRings, UIStateChangeType aShowFocusRings,
const DocShellOriginAttributes& aOriginAttributes, const OriginAttributes& aOriginAttributes,
const nsAString& aPresentationURL) const nsAString& aPresentationURL)
{ {
NS_ENSURE_FALSE(mInitialized, false); NS_ENSURE_FALSE(mInitialized, false);
@ -143,7 +143,7 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
{ {
bool isMozBrowserElement = false; bool isMozBrowserElement = false;
bool isPrerendered = false; bool isPrerendered = false;
DocShellOriginAttributes originAttributes; OriginAttributes originAttributes;
nsAutoString presentationURL; nsAutoString presentationURL;
UIStateChangeType showAccelerators = UIStateChangeType_NoChange; UIStateChangeType showAccelerators = UIStateChangeType_NoChange;
UIStateChangeType showFocusRings = UIStateChangeType_NoChange; UIStateChangeType showFocusRings = UIStateChangeType_NoChange;

View file

@ -64,11 +64,11 @@ public:
bool IsMozBrowser() const; bool IsMozBrowser() const;
/** /**
* OriginAttributesRef() returns the DocShellOriginAttributes of this frame to * OriginAttributesRef() returns the OriginAttributes of this frame to
* the caller. This is used to store any attribute associated with the frame's * the caller. This is used to store any attribute associated with the frame's
* docshell. * docshell.
*/ */
const DocShellOriginAttributes& OriginAttributesRef() const; const OriginAttributes& OriginAttributesRef() const;
/** /**
* Returns the presentation URL associated with the tab if this tab is * Returns the presentation URL associated with the tab if this tab is
@ -105,7 +105,7 @@ protected:
bool aIsPrerendered, bool aIsPrerendered,
UIStateChangeType aShowAccelerators, UIStateChangeType aShowAccelerators,
UIStateChangeType aShowFocusRings, UIStateChangeType aShowFocusRings,
const DocShellOriginAttributes& aOriginAttributes, const OriginAttributes& aOriginAttributes,
const nsAString& aPresentationURL); const nsAString& aPresentationURL);
/** /**
@ -139,9 +139,9 @@ private:
bool mIsMozBrowserElement; bool mIsMozBrowserElement;
/** /**
* DocShellOriginAttributes of the top level tab docShell * OriginAttributes of the top level tab docShell
*/ */
DocShellOriginAttributes mOriginAttributes; OriginAttributes mOriginAttributes;
/** /**
* The requested presentation URL. * The requested presentation URL.
@ -173,7 +173,7 @@ public:
bool aIsPrerendered, bool aIsPrerendered,
UIStateChangeType aShowAccelerators, UIStateChangeType aShowAccelerators,
UIStateChangeType aShowFocusRings, UIStateChangeType aShowFocusRings,
const DocShellOriginAttributes& aOriginAttributes, const OriginAttributes& aOriginAttributes,
const nsAString& aPresentationURL = EmptyString()) const nsAString& aPresentationURL = EmptyString())
{ {
return TabContext::SetTabContext(aIsMozBrowserElement, return TabContext::SetTabContext(aIsMozBrowserElement,

View file

@ -1590,7 +1590,7 @@ MatchOrigin(nsIFile* aPath,
nsresult rv; nsresult rv;
nsCString str; nsCString str;
nsCString originNoSuffix; nsCString originNoSuffix;
mozilla::PrincipalOriginAttributes originAttributes; mozilla::OriginAttributes originAttributes;
rv = ReadFromFile(aPath, NS_LITERAL_CSTRING("origin"), str, MaxDomainLength); rv = ReadFromFile(aPath, NS_LITERAL_CSTRING("origin"), str, MaxDomainLength);
if (!originAttributes.PopulateFromOrigin(str, originNoSuffix)) { if (!originAttributes.PopulateFromOrigin(str, originNoSuffix)) {
@ -1603,7 +1603,7 @@ MatchOrigin(nsIFile* aPath,
return true; return true;
} }
mozilla::PrincipalOriginAttributes topLevelOriginAttributes; mozilla::OriginAttributes topLevelOriginAttributes;
rv = ReadFromFile(aPath, NS_LITERAL_CSTRING("topLevelOrigin"), str, MaxDomainLength); rv = ReadFromFile(aPath, NS_LITERAL_CSTRING("topLevelOrigin"), str, MaxDomainLength);
if (!topLevelOriginAttributes.PopulateFromOrigin(str, originNoSuffix)) { if (!topLevelOriginAttributes.PopulateFromOrigin(str, originNoSuffix)) {
// Fails on paring the originAttributes, treat this as a non-match. // Fails on paring the originAttributes, treat this as a non-match.

View file

@ -470,7 +470,7 @@ GetNodeId(const nsAString& aOrigin,
UniquePtr<GetNodeIdCallback> callback(new TestGetNodeIdCallback(nodeId, UniquePtr<GetNodeIdCallback> callback(new TestGetNodeIdCallback(nodeId,
result)); result));
PrincipalOriginAttributes attrs; OriginAttributes attrs;
attrs.mPrivateBrowsingId = aInPBMode ? 1 : 0; attrs.mPrivateBrowsingId = aInPBMode ? 1 : 0;
nsAutoCString suffix; nsAutoCString suffix;

View file

@ -640,7 +640,7 @@ static nsresult
GetPrincipalFromOrigin(const nsACString& aOrigin, nsIPrincipal** aPrincipal) GetPrincipalFromOrigin(const nsACString& aOrigin, nsIPrincipal** aPrincipal)
{ {
nsAutoCString originNoSuffix; nsAutoCString originNoSuffix;
mozilla::PrincipalOriginAttributes attrs; mozilla::OriginAttributes attrs;
if (!attrs.PopulateFromOrigin(aOrigin, originNoSuffix)) { if (!attrs.PopulateFromOrigin(aOrigin, originNoSuffix)) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }

View file

@ -814,7 +814,7 @@ nsDOMOfflineResourceList::CacheKeys()
nsAutoCString originSuffix; nsAutoCString originSuffix;
if (loadContext) { if (loadContext) {
mozilla::DocShellOriginAttributes oa; mozilla::OriginAttributes oa;
bool ok = loadContext->GetOriginAttributes(oa); bool ok = loadContext->GetOriginAttributes(oa);
NS_ENSURE_TRUE(ok, NS_ERROR_UNEXPECTED); NS_ENSURE_TRUE(ok, NS_ERROR_UNEXPECTED);

View file

@ -561,7 +561,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL,
// bypass ContentPolicy checks which should still be enforced. // bypass ContentPolicy checks which should still be enforced.
nsCOMPtr<nsIPrincipal> triggeringPrincipal; nsCOMPtr<nsIPrincipal> triggeringPrincipal;
if (!aDoCheckLoadURIChecks) { if (!aDoCheckLoadURIChecks) {
mozilla::PrincipalOriginAttributes attrs = mozilla::OriginAttributes attrs =
BasePrincipal::Cast(content->NodePrincipal())->OriginAttributesRef(); BasePrincipal::Cast(content->NodePrincipal())->OriginAttributesRef();
triggeringPrincipal = BasePrincipal::CreateCodebasePrincipal(uri, attrs); triggeringPrincipal = BasePrincipal::CreateCodebasePrincipal(uri, attrs);
} }

View file

@ -532,7 +532,7 @@ PresentationRequest::IsPrioriAuthenticatedURL(const nsAString& aUrl)
return true; return true;
} }
PrincipalOriginAttributes attrs; OriginAttributes attrs;
nsCOMPtr<nsIPrincipal> principal = nsCOMPtr<nsIPrincipal> principal =
BasePrincipal::CreateCodebasePrincipal(uri, attrs); BasePrincipal::CreateCodebasePrincipal(uri, attrs);
if (NS_WARN_IF(!principal)) { if (NS_WARN_IF(!principal)) {

View file

@ -1362,7 +1362,7 @@ struct StorageDirectoryHelper::OriginProps
nsCOMPtr<nsIFile> mDirectory; nsCOMPtr<nsIFile> mDirectory;
nsCString mSpec; nsCString mSpec;
PrincipalOriginAttributes mAttrs; OriginAttributes mAttrs;
int64_t mTimestamp; int64_t mTimestamp;
nsCString mSuffix; nsCString mSuffix;
nsCString mGroup; nsCString mGroup;
@ -1415,7 +1415,7 @@ class MOZ_STACK_CLASS OriginParser final
}; };
const nsCString mOrigin; const nsCString mOrigin;
const PrincipalOriginAttributes mOriginAttributes; const OriginAttributes mOriginAttributes;
Tokenizer mTokenizer; Tokenizer mTokenizer;
uint32_t mAppId; uint32_t mAppId;
@ -1433,7 +1433,7 @@ class MOZ_STACK_CLASS OriginParser final
public: public:
OriginParser(const nsACString& aOrigin, OriginParser(const nsACString& aOrigin,
const PrincipalOriginAttributes& aOriginAttributes) const OriginAttributes& aOriginAttributes)
: mOrigin(aOrigin) : mOrigin(aOrigin)
, mOriginAttributes(aOriginAttributes) , mOriginAttributes(aOriginAttributes)
, mTokenizer(aOrigin, '+') , mTokenizer(aOrigin, '+')
@ -1449,10 +1449,10 @@ public:
static bool static bool
ParseOrigin(const nsACString& aOrigin, ParseOrigin(const nsACString& aOrigin,
nsCString& aSpec, nsCString& aSpec,
PrincipalOriginAttributes* aAttrs); OriginAttributes* aAttrs);
bool bool
Parse(nsACString& aSpec, PrincipalOriginAttributes* aAttrs); Parse(nsACString& aSpec, OriginAttributes* aAttrs);
private: private:
void void
@ -1875,7 +1875,7 @@ CreateDirectoryMetadata(nsIFile* aDirectory, int64_t aTimestamp,
{ {
AssertIsOnIOThread(); AssertIsOnIOThread();
PrincipalOriginAttributes groupAttributes; OriginAttributes groupAttributes;
nsCString groupNoSuffix; nsCString groupNoSuffix;
bool ok = groupAttributes.PopulateFromOrigin(aGroup, groupNoSuffix); bool ok = groupAttributes.PopulateFromOrigin(aGroup, groupNoSuffix);
@ -1890,7 +1890,7 @@ CreateDirectoryMetadata(nsIFile* aDirectory, int64_t aTimestamp,
nsCString group = groupPrefix + groupNoSuffix; nsCString group = groupPrefix + groupNoSuffix;
PrincipalOriginAttributes originAttributes; OriginAttributes originAttributes;
nsCString originNoSuffix; nsCString originNoSuffix;
ok = originAttributes.PopulateFromOrigin(aOrigin, originNoSuffix); ok = originAttributes.PopulateFromOrigin(aOrigin, originNoSuffix);
@ -4567,7 +4567,7 @@ QuotaManager::EnsureOriginIsInitialized(PersistenceType aPersistenceType,
if (!leafName.EqualsLiteral(kChromeOrigin)) { if (!leafName.EqualsLiteral(kChromeOrigin)) {
nsCString spec; nsCString spec;
PrincipalOriginAttributes attrs; OriginAttributes attrs;
bool result = OriginParser::ParseOrigin(NS_ConvertUTF16toUTF8(leafName), bool result = OriginParser::ParseOrigin(NS_ConvertUTF16toUTF8(leafName),
spec, &attrs); spec, &attrs);
if (NS_WARN_IF(!result)) { if (NS_WARN_IF(!result)) {
@ -6547,7 +6547,7 @@ StorageDirectoryHelper::AddOriginDirectory(nsIFile* aDirectory,
originProps->mType = OriginProps::eChrome; originProps->mType = OriginProps::eChrome;
} else { } else {
nsCString spec; nsCString spec;
PrincipalOriginAttributes attrs; OriginAttributes attrs;
bool result = OriginParser::ParseOrigin(NS_ConvertUTF16toUTF8(leafName), bool result = OriginParser::ParseOrigin(NS_ConvertUTF16toUTF8(leafName),
spec, &attrs); spec, &attrs);
if (NS_WARN_IF(!result)) { if (NS_WARN_IF(!result)) {
@ -6685,12 +6685,12 @@ StorageDirectoryHelper::Run()
bool bool
OriginParser::ParseOrigin(const nsACString& aOrigin, OriginParser::ParseOrigin(const nsACString& aOrigin,
nsCString& aSpec, nsCString& aSpec,
PrincipalOriginAttributes* aAttrs) OriginAttributes* aAttrs)
{ {
MOZ_ASSERT(!aOrigin.IsEmpty()); MOZ_ASSERT(!aOrigin.IsEmpty());
MOZ_ASSERT(aAttrs); MOZ_ASSERT(aAttrs);
PrincipalOriginAttributes originAttributes; OriginAttributes originAttributes;
nsCString originNoSuffix; nsCString originNoSuffix;
bool ok = originAttributes.PopulateFromOrigin(aOrigin, originNoSuffix); bool ok = originAttributes.PopulateFromOrigin(aOrigin, originNoSuffix);
@ -6703,7 +6703,7 @@ OriginParser::ParseOrigin(const nsACString& aOrigin,
} }
bool bool
OriginParser::Parse(nsACString& aSpec, PrincipalOriginAttributes* aAttrs) OriginParser::Parse(nsACString& aSpec, OriginAttributes* aAttrs)
{ {
MOZ_ASSERT(aAttrs); MOZ_ASSERT(aAttrs);
@ -6742,7 +6742,7 @@ OriginParser::Parse(nsACString& aSpec, PrincipalOriginAttributes* aAttrs)
} else { } else {
MOZ_ASSERT(mOriginAttributes.mAppId == kNoAppId); MOZ_ASSERT(mOriginAttributes.mAppId == kNoAppId);
*aAttrs = PrincipalOriginAttributes(mAppId, mInIsolatedMozBrowser); *aAttrs = OriginAttributes(mAppId, mInIsolatedMozBrowser);
} }
nsAutoCString spec(mSchema); nsAutoCString spec(mSchema);

View file

@ -28,7 +28,7 @@ private:
struct OriginAndAttributes struct OriginAndAttributes
{ {
nsCString mOrigin; nsCString mOrigin;
PrincipalOriginAttributes mAttributes; OriginAttributes mAttributes;
OriginAndAttributes(const OriginAndAttributes& aOther) OriginAndAttributes(const OriginAndAttributes& aOther)
: mOrigin(aOther.mOrigin) : mOrigin(aOther.mOrigin)

View file

@ -54,7 +54,7 @@ Scheme0Scope(StorageCacheBridge* aCache)
nsCString suffix = aCache->OriginSuffix(); nsCString suffix = aCache->OriginSuffix();
PrincipalOriginAttributes oa; OriginAttributes oa;
if (!suffix.IsEmpty()) { if (!suffix.IsEmpty()) {
DebugOnly<bool> success = oa.PopulateFromSuffix(suffix); DebugOnly<bool> success = oa.PopulateFromSuffix(suffix);
MOZ_ASSERT(success); MOZ_ASSERT(success);
@ -768,7 +768,7 @@ OriginAttrsPatternMatchSQLFunction::OnFunctionCall(
rv = aFunctionArguments->GetUTF8String(0, suffix); rv = aFunctionArguments->GetUTF8String(0, suffix);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
PrincipalOriginAttributes oa; OriginAttributes oa;
bool success = oa.PopulateFromSuffix(suffix); bool success = oa.PopulateFromSuffix(suffix);
NS_ENSURE_TRUE(success, NS_ERROR_FAILURE); NS_ENSURE_TRUE(success, NS_ERROR_FAILURE);
bool result = mPattern.Matches(oa); bool result = mPattern.Matches(oa);
@ -1208,7 +1208,7 @@ namespace {
bool OriginPatternMatches(const nsACString& aOriginSuffix, bool OriginPatternMatches(const nsACString& aOriginSuffix,
const OriginAttributesPattern& aPattern) const OriginAttributesPattern& aPattern)
{ {
PrincipalOriginAttributes oa; OriginAttributes oa;
DebugOnly<bool> rv = oa.PopulateFromSuffix(aOriginSuffix); DebugOnly<bool> rv = oa.PopulateFromSuffix(aOriginSuffix);
MOZ_ASSERT(rv); MOZ_ASSERT(rv);
return aPattern.Matches(oa); return aPattern.Matches(oa);

View file

@ -135,7 +135,7 @@ public:
} }
} }
} else { } else {
PrincipalOriginAttributes attrs(appId, inIsolatedMozBrowser); OriginAttributes attrs(appId, inIsolatedMozBrowser);
attrs.CreateSuffix(suffix); attrs.CreateSuffix(suffix);
} }

View file

@ -485,7 +485,7 @@ StorageManagerBase::ClearCaches(uint32_t aUnloadFlags,
const nsACString& aOriginScope) const nsACString& aOriginScope)
{ {
for (auto iter1 = mCaches.Iter(); !iter1.Done(); iter1.Next()) { for (auto iter1 = mCaches.Iter(); !iter1.Done(); iter1.Next()) {
PrincipalOriginAttributes oa; OriginAttributes oa;
DebugOnly<bool> rv = oa.PopulateFromSuffix(iter1.Key()); DebugOnly<bool> rv = oa.PopulateFromSuffix(iter1.Key());
MOZ_ASSERT(rv); MOZ_ASSERT(rv);
if (!aPattern.Matches(oa)) { if (!aPattern.Matches(oa)) {

View file

@ -7,7 +7,7 @@ include protocol PBackground;
include PBackgroundSharedTypes; include PBackgroundSharedTypes;
include ServiceWorkerRegistrarTypes; include ServiceWorkerRegistrarTypes;
using mozilla::PrincipalOriginAttributes from "mozilla/ipc/BackgroundUtils.h"; using mozilla::OriginAttributes from "mozilla/ipc/BackgroundUtils.h";
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
@ -21,7 +21,7 @@ parent:
async Unregister(PrincipalInfo principalInfo, nsString scope); async Unregister(PrincipalInfo principalInfo, nsString scope);
async PropagateSoftUpdate(PrincipalOriginAttributes originAttributes, async PropagateSoftUpdate(OriginAttributes originAttributes,
nsString scope); nsString scope);
async PropagateUnregister(PrincipalInfo principalInfo, nsString scope); async PropagateUnregister(PrincipalInfo principalInfo, nsString scope);
@ -33,7 +33,7 @@ parent:
child: child:
async NotifyRegister(ServiceWorkerRegistrationData data); async NotifyRegister(ServiceWorkerRegistrationData data);
async NotifySoftUpdate(PrincipalOriginAttributes originAttributes, nsString scope); async NotifySoftUpdate(OriginAttributes originAttributes, nsString scope);
async NotifyUnregister(PrincipalInfo principalInfo, nsString scope); async NotifyUnregister(PrincipalInfo principalInfo, nsString scope);
async NotifyRemove(nsCString host); async NotifyRemove(nsCString host);
async NotifyRemoveAll(); async NotifyRemoveAll();

View file

@ -252,7 +252,7 @@ GetWorkerPref(const nsACString& aPref,
void void
GenerateSharedWorkerKey(const nsACString& aScriptSpec, GenerateSharedWorkerKey(const nsACString& aScriptSpec,
const nsACString& aName, const nsACString& aName,
const PrincipalOriginAttributes& aAttrs, const OriginAttributes& aAttrs,
nsCString& aKey) nsCString& aKey)
{ {
nsAutoCString suffix; nsAutoCString suffix;

View file

@ -417,7 +417,7 @@ private:
nsTArray<RefPtr<CacheScriptLoader>> mLoaders; nsTArray<RefPtr<CacheScriptLoader>> mLoaders;
nsString mCacheName; nsString mCacheName;
PrincipalOriginAttributes mOriginAttributes; OriginAttributes mOriginAttributes;
}; };
NS_IMPL_ISUPPORTS0(CacheCreator) NS_IMPL_ISUPPORTS0(CacheCreator)

View file

@ -32,7 +32,7 @@ private:
const nsString mCacheName; const nsString mCacheName;
const nsLoadFlags mLoadFlags; const nsLoadFlags mLoadFlags;
ServiceWorkerState mState; ServiceWorkerState mState;
PrincipalOriginAttributes mOriginAttributes; OriginAttributes mOriginAttributes;
// This id is shared with WorkerPrivate to match requests issued by service // This id is shared with WorkerPrivate to match requests issued by service
// workers to their corresponding serviceWorkerInfo. // workers to their corresponding serviceWorkerInfo.
@ -113,7 +113,7 @@ public:
return mState; return mState;
} }
const PrincipalOriginAttributes& const OriginAttributes&
GetOriginAttributes() const GetOriginAttributes() const
{ {
return mOriginAttributes; return mOriginAttributes;

View file

@ -321,7 +321,7 @@ namespace {
class PropagateSoftUpdateRunnable final : public Runnable class PropagateSoftUpdateRunnable final : public Runnable
{ {
public: public:
PropagateSoftUpdateRunnable(const PrincipalOriginAttributes& aOriginAttributes, PropagateSoftUpdateRunnable(const OriginAttributes& aOriginAttributes,
const nsAString& aScope) const nsAString& aScope)
: mOriginAttributes(aOriginAttributes) : mOriginAttributes(aOriginAttributes)
, mScope(aScope) , mScope(aScope)
@ -342,7 +342,7 @@ private:
~PropagateSoftUpdateRunnable() ~PropagateSoftUpdateRunnable()
{} {}
const PrincipalOriginAttributes mOriginAttributes; const OriginAttributes mOriginAttributes;
const nsString mScope; const nsString mScope;
}; };
@ -928,7 +928,7 @@ ServiceWorkerManager::SendPushEvent(const nsACString& aOriginAttributes,
const nsAString& aMessageId, const nsAString& aMessageId,
const Maybe<nsTArray<uint8_t>>& aData) const Maybe<nsTArray<uint8_t>>& aData)
{ {
PrincipalOriginAttributes attrs; OriginAttributes attrs;
if (!attrs.PopulateFromSuffix(aOriginAttributes)) { if (!attrs.PopulateFromSuffix(aOriginAttributes)) {
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
@ -950,7 +950,7 @@ NS_IMETHODIMP
ServiceWorkerManager::SendPushSubscriptionChangeEvent(const nsACString& aOriginAttributes, ServiceWorkerManager::SendPushSubscriptionChangeEvent(const nsACString& aOriginAttributes,
const nsACString& aScope) const nsACString& aScope)
{ {
PrincipalOriginAttributes attrs; OriginAttributes attrs;
if (!attrs.PopulateFromSuffix(aOriginAttributes)) { if (!attrs.PopulateFromSuffix(aOriginAttributes)) {
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
@ -976,7 +976,7 @@ ServiceWorkerManager::SendNotificationEvent(const nsAString& aEventName,
const nsAString& aData, const nsAString& aData,
const nsAString& aBehavior) const nsAString& aBehavior)
{ {
PrincipalOriginAttributes attrs; OriginAttributes attrs;
if (!attrs.PopulateFromSuffix(aOriginSuffix)) { if (!attrs.PopulateFromSuffix(aOriginSuffix)) {
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
@ -1136,7 +1136,7 @@ ServiceWorkerManager::CheckReadyPromise(nsPIDOMWindowInner* aWindow,
} }
ServiceWorkerInfo* ServiceWorkerInfo*
ServiceWorkerManager::GetActiveWorkerInfoForScope(const PrincipalOriginAttributes& aOriginAttributes, ServiceWorkerManager::GetActiveWorkerInfoForScope(const OriginAttributes& aOriginAttributes,
const nsACString& aScope) const nsACString& aScope)
{ {
AssertIsOnMainThread(); AssertIsOnMainThread();
@ -2339,7 +2339,7 @@ public:
} // anonymous namespace } // anonymous namespace
void void
ServiceWorkerManager::DispatchFetchEvent(const PrincipalOriginAttributes& aOriginAttributes, ServiceWorkerManager::DispatchFetchEvent(const OriginAttributes& aOriginAttributes,
nsIDocument* aDoc, nsIDocument* aDoc,
const nsAString& aDocumentIdForTopLevelNavigation, const nsAString& aDocumentIdForTopLevelNavigation,
nsIInterceptedChannel* aChannel, nsIInterceptedChannel* aChannel,
@ -2613,7 +2613,7 @@ ServiceWorkerManager::NotifyServiceWorkerRegistrationRemoved(ServiceWorkerRegist
} }
void void
ServiceWorkerManager::SoftUpdate(const PrincipalOriginAttributes& aOriginAttributes, ServiceWorkerManager::SoftUpdate(const OriginAttributes& aOriginAttributes,
const nsACString& aScope) const nsACString& aScope)
{ {
AssertIsOnMainThread(); AssertIsOnMainThread();
@ -3594,7 +3594,7 @@ ServiceWorkerManager::PropagateSoftUpdate(JS::Handle<JS::Value> aOriginAttribute
{ {
AssertIsOnMainThread(); AssertIsOnMainThread();
PrincipalOriginAttributes attrs; OriginAttributes attrs;
if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) { if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) {
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
@ -3604,7 +3604,7 @@ ServiceWorkerManager::PropagateSoftUpdate(JS::Handle<JS::Value> aOriginAttribute
} }
void void
ServiceWorkerManager::PropagateSoftUpdate(const PrincipalOriginAttributes& aOriginAttributes, ServiceWorkerManager::PropagateSoftUpdate(const OriginAttributes& aOriginAttributes,
const nsAString& aScope) const nsAString& aScope)
{ {
AssertIsOnMainThread(); AssertIsOnMainThread();
@ -3920,7 +3920,7 @@ ServiceWorkerManager::UpdateTimerFired(nsIPrincipal* aPrincipal,
return; return;
} }
PrincipalOriginAttributes attrs = aPrincipal->OriginAttributesRef(); OriginAttributes attrs = aPrincipal->OriginAttributesRef();
SoftUpdate(attrs, aScope); SoftUpdate(attrs, aScope);
} }

View file

@ -37,7 +37,7 @@ class nsIConsoleReportCollector;
namespace mozilla { namespace mozilla {
class PrincipalOriginAttributes; class OriginAttributes;
namespace dom { namespace dom {
@ -150,7 +150,7 @@ public:
nsIPrincipal* aPrincipal); nsIPrincipal* aPrincipal);
void void
DispatchFetchEvent(const PrincipalOriginAttributes& aOriginAttributes, DispatchFetchEvent(const OriginAttributes& aOriginAttributes,
nsIDocument* aDoc, nsIDocument* aDoc,
const nsAString& aDocumentIdForTopLevelNavigation, const nsAString& aDocumentIdForTopLevelNavigation,
nsIInterceptedChannel* aChannel, nsIInterceptedChannel* aChannel,
@ -164,11 +164,11 @@ public:
ServiceWorkerUpdateFinishCallback* aCallback); ServiceWorkerUpdateFinishCallback* aCallback);
void void
SoftUpdate(const PrincipalOriginAttributes& aOriginAttributes, SoftUpdate(const OriginAttributes& aOriginAttributes,
const nsACString& aScope); const nsACString& aScope);
void void
PropagateSoftUpdate(const PrincipalOriginAttributes& aOriginAttributes, PropagateSoftUpdate(const OriginAttributes& aOriginAttributes,
const nsAString& aScope); const nsAString& aScope);
void void
@ -358,7 +358,7 @@ private:
nsISupports** aServiceWorker); nsISupports** aServiceWorker);
ServiceWorkerInfo* ServiceWorkerInfo*
GetActiveWorkerInfoForScope(const PrincipalOriginAttributes& aOriginAttributes, GetActiveWorkerInfoForScope(const OriginAttributes& aOriginAttributes,
const nsACString& aScope); const nsACString& aScope);
ServiceWorkerInfo* ServiceWorkerInfo*

View file

@ -32,7 +32,7 @@ ServiceWorkerManagerChild::RecvNotifyRegister(
mozilla::ipc::IPCResult mozilla::ipc::IPCResult
ServiceWorkerManagerChild::RecvNotifySoftUpdate( ServiceWorkerManagerChild::RecvNotifySoftUpdate(
const PrincipalOriginAttributes& aOriginAttributes, const OriginAttributes& aOriginAttributes,
const nsString& aScope) const nsString& aScope)
{ {
if (mShuttingDown) { if (mShuttingDown) {

View file

@ -12,7 +12,7 @@
namespace mozilla { namespace mozilla {
class PrincipalOriginAttributes; class OriginAttributes;
namespace ipc { namespace ipc {
class BackgroundChildImpl; class BackgroundChildImpl;
@ -36,7 +36,7 @@ public:
virtual mozilla::ipc::IPCResult RecvNotifyRegister(const ServiceWorkerRegistrationData& aData) virtual mozilla::ipc::IPCResult RecvNotifyRegister(const ServiceWorkerRegistrationData& aData)
override; override;
virtual mozilla::ipc::IPCResult RecvNotifySoftUpdate(const PrincipalOriginAttributes& aOriginAttributes, virtual mozilla::ipc::IPCResult RecvNotifySoftUpdate(const OriginAttributes& aOriginAttributes,
const nsString& aScope) override; const nsString& aScope) override;
virtual mozilla::ipc::IPCResult RecvNotifyUnregister(const PrincipalInfo& aPrincipalInfo, virtual mozilla::ipc::IPCResult RecvNotifyUnregister(const PrincipalInfo& aPrincipalInfo,

View file

@ -231,7 +231,7 @@ ServiceWorkerManagerParent::RecvUnregister(const PrincipalInfo& aPrincipalInfo,
} }
mozilla::ipc::IPCResult mozilla::ipc::IPCResult
ServiceWorkerManagerParent::RecvPropagateSoftUpdate(const PrincipalOriginAttributes& aOriginAttributes, ServiceWorkerManagerParent::RecvPropagateSoftUpdate(const OriginAttributes& aOriginAttributes,
const nsString& aScope) const nsString& aScope)
{ {
AssertIsOnBackgroundThread(); AssertIsOnBackgroundThread();

View file

@ -11,7 +11,7 @@
namespace mozilla { namespace mozilla {
class PrincipalOriginAttributes; class OriginAttributes;
namespace ipc { namespace ipc {
class BackgroundParentImpl; class BackgroundParentImpl;
@ -44,7 +44,7 @@ private:
virtual mozilla::ipc::IPCResult RecvUnregister(const PrincipalInfo& aPrincipalInfo, virtual mozilla::ipc::IPCResult RecvUnregister(const PrincipalInfo& aPrincipalInfo,
const nsString& aScope) override; const nsString& aScope) override;
virtual mozilla::ipc::IPCResult RecvPropagateSoftUpdate(const PrincipalOriginAttributes& aOriginAttributes, virtual mozilla::ipc::IPCResult RecvPropagateSoftUpdate(const OriginAttributes& aOriginAttributes,
const nsString& aScope) override; const nsString& aScope) override;
virtual mozilla::ipc::IPCResult RecvPropagateUnregister(const PrincipalInfo& aPrincipalInfo, virtual mozilla::ipc::IPCResult RecvPropagateUnregister(const PrincipalInfo& aPrincipalInfo,

View file

@ -113,7 +113,7 @@ ServiceWorkerManagerService::PropagateRegistration(
void void
ServiceWorkerManagerService::PropagateSoftUpdate( ServiceWorkerManagerService::PropagateSoftUpdate(
uint64_t aParentID, uint64_t aParentID,
const PrincipalOriginAttributes& aOriginAttributes, const OriginAttributes& aOriginAttributes,
const nsAString& aScope) const nsAString& aScope)
{ {
AssertIsOnBackgroundThread(); AssertIsOnBackgroundThread();

View file

@ -13,7 +13,7 @@
namespace mozilla { namespace mozilla {
class PrincipalOriginAttributes; class OriginAttributes;
namespace ipc { namespace ipc {
class PrincipalInfo; class PrincipalInfo;
@ -42,7 +42,7 @@ public:
ServiceWorkerRegistrationData& aData); ServiceWorkerRegistrationData& aData);
void PropagateSoftUpdate(uint64_t aParentID, void PropagateSoftUpdate(uint64_t aParentID,
const PrincipalOriginAttributes& aOriginAttributes, const OriginAttributes& aOriginAttributes,
const nsAString& aScope); const nsAString& aScope);
void PropagateUnregister(uint64_t aParentID, void PropagateUnregister(uint64_t aParentID,

View file

@ -341,7 +341,7 @@ ServiceWorkerRegistrar::ReadData()
nsAutoCString suffix; nsAutoCString suffix;
GET_LINE(suffix); GET_LINE(suffix);
PrincipalOriginAttributes attrs; OriginAttributes attrs;
if (!attrs.PopulateFromSuffix(suffix)) { if (!attrs.PopulateFromSuffix(suffix)) {
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
@ -382,7 +382,7 @@ ServiceWorkerRegistrar::ReadData()
nsAutoCString suffix; nsAutoCString suffix;
GET_LINE(suffix); GET_LINE(suffix);
PrincipalOriginAttributes attrs; OriginAttributes attrs;
if (!attrs.PopulateFromSuffix(suffix)) { if (!attrs.PopulateFromSuffix(suffix)) {
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
@ -415,7 +415,7 @@ ServiceWorkerRegistrar::ReadData()
nsAutoCString suffix; nsAutoCString suffix;
GET_LINE(suffix); GET_LINE(suffix);
PrincipalOriginAttributes attrs; OriginAttributes attrs;
if (!attrs.PopulateFromSuffix(suffix)) { if (!attrs.PopulateFromSuffix(suffix)) {
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
@ -442,7 +442,7 @@ ServiceWorkerRegistrar::ReadData()
nsAutoCString suffix; nsAutoCString suffix;
GET_LINE(suffix); GET_LINE(suffix);
PrincipalOriginAttributes attrs; OriginAttributes attrs;
if (!attrs.PopulateFromSuffix(suffix)) { if (!attrs.PopulateFromSuffix(suffix)) {
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
@ -472,7 +472,7 @@ ServiceWorkerRegistrar::ReadData()
nsAutoCString suffix; nsAutoCString suffix;
GET_LINE(suffix); GET_LINE(suffix);
PrincipalOriginAttributes attrs; OriginAttributes attrs;
if (!attrs.PopulateFromSuffix(suffix)) { if (!attrs.PopulateFromSuffix(suffix)) {
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }

View file

@ -4463,7 +4463,7 @@ WorkerPrivate::GetLoadInfo(JSContext* aCx, nsPIDOMWindowInner* aWindow,
loadInfo.mFromWindow = false; loadInfo.mFromWindow = false;
loadInfo.mWindowID = UINT64_MAX; loadInfo.mWindowID = UINT64_MAX;
loadInfo.mStorageAllowed = true; loadInfo.mStorageAllowed = true;
loadInfo.mOriginAttributes = PrincipalOriginAttributes(); loadInfo.mOriginAttributes = OriginAttributes();
} }
MOZ_ASSERT(loadInfo.mPrincipal); MOZ_ASSERT(loadInfo.mPrincipal);

View file

@ -789,7 +789,7 @@ public:
return mLoadInfo.mStorageAllowed; return mLoadInfo.mStorageAllowed;
} }
const PrincipalOriginAttributes& const OriginAttributes&
GetOriginAttributes() const GetOriginAttributes() const
{ {
return mLoadInfo.mOriginAttributes; return mLoadInfo.mOriginAttributes;

View file

@ -271,7 +271,7 @@ struct WorkerLoadInfo
bool mPrincipalIsSystem; bool mPrincipalIsSystem;
bool mStorageAllowed; bool mStorageAllowed;
bool mServiceWorkersTestingInWindow; bool mServiceWorkersTestingInWindow;
PrincipalOriginAttributes mOriginAttributes; OriginAttributes mOriginAttributes;
WorkerLoadInfo(); WorkerLoadInfo();
~WorkerLoadInfo(); ~WorkerLoadInfo();

View file

@ -239,7 +239,7 @@ TEST(ServiceWorkerRegistrar, TestWriteData)
nsAutoCString spec; nsAutoCString spec;
spec.AppendPrintf("spec write %d", i); spec.AppendPrintf("spec write %d", i);
reg.principal() = reg.principal() =
mozilla::ipc::ContentPrincipalInfo(mozilla::PrincipalOriginAttributes(i, i % 2), spec); mozilla::ipc::ContentPrincipalInfo(mozilla::OriginAttributes(i, i % 2), spec);
swr->TestRegisterServiceWorker(reg); swr->TestRegisterServiceWorker(reg);
} }
@ -262,7 +262,7 @@ TEST(ServiceWorkerRegistrar, TestWriteData)
ASSERT_EQ(data[i].principal().type(), mozilla::ipc::PrincipalInfo::TContentPrincipalInfo); ASSERT_EQ(data[i].principal().type(), mozilla::ipc::PrincipalInfo::TContentPrincipalInfo);
const mozilla::ipc::ContentPrincipalInfo& cInfo = data[i].principal(); const mozilla::ipc::ContentPrincipalInfo& cInfo = data[i].principal();
mozilla::PrincipalOriginAttributes attrs(i, i % 2); mozilla::OriginAttributes attrs(i, i % 2);
nsAutoCString suffix, expectSuffix; nsAutoCString suffix, expectSuffix;
attrs.CreateSuffix(expectSuffix); attrs.CreateSuffix(expectSuffix);
cInfo.attrs().CreateSuffix(suffix); cInfo.attrs().CreateSuffix(suffix);
@ -593,7 +593,7 @@ TEST(ServiceWorkerRegistrar, TestDedupeWrite)
nsAutoCString spec; nsAutoCString spec;
spec.AppendPrintf("spec write dedupe/%d", i); spec.AppendPrintf("spec write dedupe/%d", i);
reg.principal() = reg.principal() =
mozilla::ipc::ContentPrincipalInfo(mozilla::PrincipalOriginAttributes(0, false), spec); mozilla::ipc::ContentPrincipalInfo(mozilla::OriginAttributes(0, false), spec);
swr->TestRegisterServiceWorker(reg); swr->TestRegisterServiceWorker(reg);
} }
@ -614,7 +614,7 @@ TEST(ServiceWorkerRegistrar, TestDedupeWrite)
ASSERT_EQ(data[0].principal().type(), mozilla::ipc::PrincipalInfo::TContentPrincipalInfo); ASSERT_EQ(data[0].principal().type(), mozilla::ipc::PrincipalInfo::TContentPrincipalInfo);
const mozilla::ipc::ContentPrincipalInfo& cInfo = data[0].principal(); const mozilla::ipc::ContentPrincipalInfo& cInfo = data[0].principal();
mozilla::PrincipalOriginAttributes attrs(0, false); mozilla::OriginAttributes attrs(0, false);
nsAutoCString suffix, expectSuffix; nsAutoCString suffix, expectSuffix;
attrs.CreateSuffix(expectSuffix); attrs.CreateSuffix(expectSuffix);
cInfo.attrs().CreateSuffix(suffix); cInfo.attrs().CreateSuffix(suffix);

View file

@ -1613,13 +1613,11 @@ XMLHttpRequestMainThread::SetOriginAttributes(const OriginAttributesDictionary&
{ {
MOZ_ASSERT((mState == State::opened) && !mFlagSend); MOZ_ASSERT((mState == State::opened) && !mFlagSend);
GenericOriginAttributes attrs(aAttrs); OriginAttributes attrs(aAttrs);
NeckoOriginAttributes neckoAttrs;
neckoAttrs.SetFromGenericAttributes(attrs);
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->GetLoadInfo(); nsCOMPtr<nsILoadInfo> loadInfo = mChannel->GetLoadInfo();
MOZ_ASSERT(loadInfo); MOZ_ASSERT(loadInfo);
loadInfo->SetOriginAttributes(neckoAttrs); loadInfo->SetOriginAttributes(attrs);
} }
void void

View file

@ -414,7 +414,7 @@ txCompileObserver::loadURI(const nsAString& aUri,
rv = NS_NewURI(getter_AddRefs(referrerUri), aReferrerUri); rv = NS_NewURI(getter_AddRefs(referrerUri), aReferrerUri);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
PrincipalOriginAttributes attrs; OriginAttributes attrs;
nsCOMPtr<nsIPrincipal> referrerPrincipal = nsCOMPtr<nsIPrincipal> referrerPrincipal =
BasePrincipal::CreateCodebasePrincipal(referrerUri, attrs); BasePrincipal::CreateCodebasePrincipal(referrerUri, attrs);
NS_ENSURE_TRUE(referrerPrincipal, NS_ERROR_FAILURE); NS_ENSURE_TRUE(referrerPrincipal, NS_ERROR_FAILURE);
@ -619,7 +619,7 @@ txSyncCompileObserver::loadURI(const nsAString& aUri,
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIPrincipal> referrerPrincipal = nsCOMPtr<nsIPrincipal> referrerPrincipal =
BasePrincipal::CreateCodebasePrincipal(referrerUri, PrincipalOriginAttributes()); BasePrincipal::CreateCodebasePrincipal(referrerUri, OriginAttributes());
NS_ENSURE_TRUE(referrerPrincipal, NS_ERROR_FAILURE); NS_ENSURE_TRUE(referrerPrincipal, NS_ERROR_FAILURE);
// This is probably called by js, a loadGroup for the channel doesn't // This is probably called by js, a loadGroup for the channel doesn't

View file

@ -15,11 +15,11 @@ interface nsIWeakReference;
%{C++ %{C++
namespace mozilla { namespace mozilla {
class DocShellOriginAttributes; class OriginAttributes;
} }
%} %}
[ref] native const_OriginAttributesRef(const mozilla::DocShellOriginAttributes); [ref] native const_OriginAttributesRef(const mozilla::OriginAttributes);
/** /**
* The nsIWebBrowser interface is implemented by web browser objects. * The nsIWebBrowser interface is implemented by web browser objects.

View file

@ -390,7 +390,7 @@ nsWebBrowser::SetIsActive(bool aIsActive)
} }
void void
nsWebBrowser::SetOriginAttributes(const DocShellOriginAttributes& aAttrs) nsWebBrowser::SetOriginAttributes(const OriginAttributes& aAttrs)
{ {
mOriginAttributes = aAttrs; mOriginAttributes = aAttrs;
} }

View file

@ -133,7 +133,7 @@ protected:
nsCOMPtr<nsIWebNavigation> mDocShellAsNav; nsCOMPtr<nsIWebNavigation> mDocShellAsNav;
nsCOMPtr<nsIScrollable> mDocShellAsScrollable; nsCOMPtr<nsIScrollable> mDocShellAsScrollable;
nsCOMPtr<nsITextScroll> mDocShellAsTextScroll; nsCOMPtr<nsITextScroll> mDocShellAsTextScroll;
mozilla::DocShellOriginAttributes mOriginAttributes; mozilla::OriginAttributes mOriginAttributes;
nsCOMPtr<nsIWidget> mInternalWidget; nsCOMPtr<nsIWidget> mInternalWidget;
nsCOMPtr<nsIWindowWatcher> mWWatch; nsCOMPtr<nsIWindowWatcher> mWWatch;

View file

@ -1103,8 +1103,8 @@ nsWindowWatcher::OpenWindowInternal(mozIDOMWindowProxy* aParent,
if (subjectPrincipal && if (subjectPrincipal &&
!nsContentUtils::IsSystemOrExpandedPrincipal(subjectPrincipal) && !nsContentUtils::IsSystemOrExpandedPrincipal(subjectPrincipal) &&
docShell->ItemType() != nsIDocShellTreeItem::typeChrome) { docShell->ItemType() != nsIDocShellTreeItem::typeChrome) {
DocShellOriginAttributes attrs; OriginAttributes attrs;
attrs.InheritFromDocToChildDocShell(subjectPrincipal->OriginAttributesRef()); attrs.Inherit(subjectPrincipal->OriginAttributesRef());
isPrivateBrowsingWindow = !!attrs.mPrivateBrowsingId; isPrivateBrowsingWindow = !!attrs.mPrivateBrowsingId;
docShell->SetOriginAttributes(attrs); docShell->SetOriginAttributes(attrs);
} else { } else {

View file

@ -110,8 +110,8 @@ nsPermission::Matches(nsIPrincipal* aPrincipal, bool aExactHost, bool* aMatches)
} }
// Compare their OriginAttributes // Compare their OriginAttributes
const mozilla::PrincipalOriginAttributes& theirAttrs = principal->OriginAttributesRef(); const mozilla::OriginAttributes& theirAttrs = principal->OriginAttributesRef();
const mozilla::PrincipalOriginAttributes& ourAttrs = mPrincipal->OriginAttributesRef(); const mozilla::OriginAttributes& ourAttrs = mPrincipal->OriginAttributesRef();
if (theirAttrs != ourAttrs) { if (theirAttrs != ourAttrs) {
return NS_OK; return NS_OK;
@ -193,7 +193,7 @@ nsPermission::MatchesURI(nsIURI* aURI, bool aExactHost, bool* aMatches)
{ {
NS_ENSURE_ARG_POINTER(aURI); NS_ENSURE_ARG_POINTER(aURI);
mozilla::PrincipalOriginAttributes attrs; mozilla::OriginAttributes attrs;
nsCOMPtr<nsIPrincipal> principal = mozilla::BasePrincipal::CreateCodebasePrincipal(aURI, attrs); nsCOMPtr<nsIPrincipal> principal = mozilla::BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE); NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE);

View file

@ -111,7 +111,7 @@ GetOriginFromPrincipal(nsIPrincipal* aPrincipal, nsACString& aOrigin)
rv = aPrincipal->GetOriginSuffix(suffix); rv = aPrincipal->GetOriginSuffix(suffix);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
mozilla::PrincipalOriginAttributes attrs; mozilla::OriginAttributes attrs;
if (!attrs.PopulateFromSuffix(suffix)) { if (!attrs.PopulateFromSuffix(suffix)) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -121,7 +121,8 @@ GetOriginFromPrincipal(nsIPrincipal* aPrincipal, nsACString& aOrigin)
attrs.mPrivateBrowsingId = 0; attrs.mPrivateBrowsingId = 0;
// Disable userContext and firstParty isolation for permissions. // Disable userContext and firstParty isolation for permissions.
attrs.StripUserContextIdAndFirstPartyDomain(); attrs.StripAttributes(mozilla::OriginAttributes::STRIP_USER_CONTEXT_ID |
mozilla::OriginAttributes::STRIP_FIRST_PARTY_DOMAIN);
attrs.CreateSuffix(suffix); attrs.CreateSuffix(suffix);
aOrigin.Append(suffix); aOrigin.Append(suffix);
@ -132,13 +133,14 @@ nsresult
GetPrincipalFromOrigin(const nsACString& aOrigin, nsIPrincipal** aPrincipal) GetPrincipalFromOrigin(const nsACString& aOrigin, nsIPrincipal** aPrincipal)
{ {
nsAutoCString originNoSuffix; nsAutoCString originNoSuffix;
mozilla::PrincipalOriginAttributes attrs; mozilla::OriginAttributes attrs;
if (!attrs.PopulateFromOrigin(aOrigin, originNoSuffix)) { if (!attrs.PopulateFromOrigin(aOrigin, originNoSuffix)) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
// Disable userContext and firstParty isolation for permissions. // Disable userContext and firstParty isolation for permissions.
attrs.StripUserContextIdAndFirstPartyDomain(); attrs.StripAttributes(mozilla::OriginAttributes::STRIP_USER_CONTEXT_ID |
mozilla::OriginAttributes::STRIP_FIRST_PARTY_DOMAIN);
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewURI(getter_AddRefs(uri), originNoSuffix); nsresult rv = NS_NewURI(getter_AddRefs(uri), originNoSuffix);
@ -152,7 +154,7 @@ GetPrincipalFromOrigin(const nsACString& aOrigin, nsIPrincipal** aPrincipal)
nsresult nsresult
GetPrincipal(nsIURI* aURI, uint32_t aAppId, bool aIsInIsolatedMozBrowserElement, nsIPrincipal** aPrincipal) GetPrincipal(nsIURI* aURI, uint32_t aAppId, bool aIsInIsolatedMozBrowserElement, nsIPrincipal** aPrincipal)
{ {
mozilla::PrincipalOriginAttributes attrs(aAppId, aIsInIsolatedMozBrowserElement); mozilla::OriginAttributes attrs(aAppId, aIsInIsolatedMozBrowserElement);
nsCOMPtr<nsIPrincipal> principal = mozilla::BasePrincipal::CreateCodebasePrincipal(aURI, attrs); nsCOMPtr<nsIPrincipal> principal = mozilla::BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE); NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE);
@ -163,7 +165,7 @@ GetPrincipal(nsIURI* aURI, uint32_t aAppId, bool aIsInIsolatedMozBrowserElement,
nsresult nsresult
GetPrincipal(nsIURI* aURI, nsIPrincipal** aPrincipal) GetPrincipal(nsIURI* aURI, nsIPrincipal** aPrincipal)
{ {
mozilla::PrincipalOriginAttributes attrs; mozilla::OriginAttributes attrs;
nsCOMPtr<nsIPrincipal> principal = mozilla::BasePrincipal::CreateCodebasePrincipal(aURI, attrs); nsCOMPtr<nsIPrincipal> principal = mozilla::BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE); NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE);
@ -2208,10 +2210,11 @@ nsPermissionManager::GetPermissionHashKey(nsIPrincipal* aPrincipal,
} }
// Copy the attributes over // Copy the attributes over
mozilla::PrincipalOriginAttributes attrs = aPrincipal->OriginAttributesRef(); mozilla::OriginAttributes attrs = aPrincipal->OriginAttributesRef();
// Disable userContext and firstParty isolation for permissions. // Disable userContext and firstParty isolation for permissions.
attrs.StripUserContextIdAndFirstPartyDomain(); attrs.StripAttributes(mozilla::OriginAttributes::STRIP_USER_CONTEXT_ID |
mozilla::OriginAttributes::STRIP_FIRST_PARTY_DOMAIN);
nsCOMPtr<nsIPrincipal> principal = nsCOMPtr<nsIPrincipal> principal =
mozilla::BasePrincipal::CreateCodebasePrincipal(newURI, attrs); mozilla::BasePrincipal::CreateCodebasePrincipal(newURI, attrs);

View file

@ -46,7 +46,7 @@ BlobSerial(ImageURL* aURI)
} }
ImageCacheKey::ImageCacheKey(nsIURI* aURI, ImageCacheKey::ImageCacheKey(nsIURI* aURI,
const PrincipalOriginAttributes& aAttrs, const OriginAttributes& aAttrs,
nsIDocument* aDocument, nsIDocument* aDocument,
nsresult& aRv) nsresult& aRv)
: mURI(new ImageURL(aURI, aRv)) : mURI(new ImageURL(aURI, aRv))
@ -66,7 +66,7 @@ ImageCacheKey::ImageCacheKey(nsIURI* aURI,
} }
ImageCacheKey::ImageCacheKey(ImageURL* aURI, ImageCacheKey::ImageCacheKey(ImageURL* aURI,
const PrincipalOriginAttributes& aAttrs, const OriginAttributes& aAttrs,
nsIDocument* aDocument) nsIDocument* aDocument)
: mURI(aURI) : mURI(aURI)
, mOriginAttributes(aAttrs) , mOriginAttributes(aAttrs)
@ -131,7 +131,7 @@ ImageCacheKey::Spec() const
/* static */ uint32_t /* static */ uint32_t
ImageCacheKey::ComputeHash(ImageURL* aURI, ImageCacheKey::ComputeHash(ImageURL* aURI,
const Maybe<uint64_t>& aBlobSerial, const Maybe<uint64_t>& aBlobSerial,
const PrincipalOriginAttributes& aAttrs, const OriginAttributes& aAttrs,
void* aControlledDocument) void* aControlledDocument)
{ {
// Since we frequently call Hash() several times in a row on the same // Since we frequently call Hash() several times in a row on the same

View file

@ -33,9 +33,9 @@ class ImageURL;
class ImageCacheKey final class ImageCacheKey final
{ {
public: public:
ImageCacheKey(nsIURI* aURI, const PrincipalOriginAttributes& aAttrs, ImageCacheKey(nsIURI* aURI, const OriginAttributes& aAttrs,
nsIDocument* aDocument, nsresult& aRv); nsIDocument* aDocument, nsresult& aRv);
ImageCacheKey(ImageURL* aURI, const PrincipalOriginAttributes& aAttrs, ImageCacheKey(ImageURL* aURI, const OriginAttributes& aAttrs,
nsIDocument* aDocument); nsIDocument* aDocument);
ImageCacheKey(const ImageCacheKey& aOther); ImageCacheKey(const ImageCacheKey& aOther);
@ -57,13 +57,13 @@ public:
private: private:
static uint32_t ComputeHash(ImageURL* aURI, static uint32_t ComputeHash(ImageURL* aURI,
const Maybe<uint64_t>& aBlobSerial, const Maybe<uint64_t>& aBlobSerial,
const PrincipalOriginAttributes& aAttrs, const OriginAttributes& aAttrs,
void* aControlledDocument); void* aControlledDocument);
static void* GetControlledDocumentToken(nsIDocument* aDocument); static void* GetControlledDocumentToken(nsIDocument* aDocument);
RefPtr<ImageURL> mURI; RefPtr<ImageURL> mURI;
Maybe<uint64_t> mBlobSerial; Maybe<uint64_t> mBlobSerial;
PrincipalOriginAttributes mOriginAttributes; OriginAttributes mOriginAttributes;
void* mControlledDocument; void* mControlledDocument;
uint32_t mHash; uint32_t mHash;
bool mIsChrome; bool mIsChrome;

View file

@ -752,11 +752,11 @@ NewImageChannel(nsIChannel** aResult,
// If this is a favicon loading, we will use the originAttributes from the // If this is a favicon loading, we will use the originAttributes from the
// loadingPrincipal as the channel's originAttributes. This allows the favicon // loadingPrincipal as the channel's originAttributes. This allows the favicon
// loading from XUL will use the correct originAttributes. // loading from XUL will use the correct originAttributes.
NeckoOriginAttributes neckoAttrs; OriginAttributes attrs;
neckoAttrs.InheritFromDocToNecko(aLoadingPrincipal->OriginAttributesRef()); attrs.Inherit(aLoadingPrincipal->OriginAttributesRef());
nsCOMPtr<nsILoadInfo> loadInfo = (*aResult)->GetLoadInfo(); nsCOMPtr<nsILoadInfo> loadInfo = (*aResult)->GetLoadInfo();
rv = loadInfo->SetOriginAttributes(neckoAttrs); rv = loadInfo->SetOriginAttributes(attrs);
} }
} else { } else {
// either we are loading something inside a document, in which case // either we are loading something inside a document, in which case
@ -781,14 +781,14 @@ NewImageChannel(nsIChannel** aResult,
// Use the OriginAttributes from the loading principal, if one is available, // Use the OriginAttributes from the loading principal, if one is available,
// and adjust the private browsing ID based on what kind of load the caller // and adjust the private browsing ID based on what kind of load the caller
// has asked us to perform. // has asked us to perform.
NeckoOriginAttributes neckoAttrs; OriginAttributes attrs;
if (aLoadingPrincipal) { if (aLoadingPrincipal) {
neckoAttrs.InheritFromDocToNecko(aLoadingPrincipal->OriginAttributesRef()); attrs.Inherit(aLoadingPrincipal->OriginAttributesRef());
} }
neckoAttrs.mPrivateBrowsingId = aRespectPrivacy ? 1 : 0; attrs.mPrivateBrowsingId = aRespectPrivacy ? 1 : 0;
nsCOMPtr<nsILoadInfo> loadInfo = (*aResult)->GetLoadInfo(); nsCOMPtr<nsILoadInfo> loadInfo = (*aResult)->GetLoadInfo();
rv = loadInfo->SetOriginAttributes(neckoAttrs); rv = loadInfo->SetOriginAttributes(attrs);
} }
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
@ -1348,7 +1348,7 @@ imgLoader::FindEntryProperties(nsIURI* uri,
nsCOMPtr<nsIDocument> doc = do_QueryInterface(aDOMDoc); nsCOMPtr<nsIDocument> doc = do_QueryInterface(aDOMDoc);
PrincipalOriginAttributes attrs; OriginAttributes attrs;
if (doc) { if (doc) {
nsCOMPtr<nsIPrincipal> principal = doc->NodePrincipal(); nsCOMPtr<nsIPrincipal> principal = doc->NodePrincipal();
if (principal) { if (principal) {
@ -2111,7 +2111,7 @@ imgLoader::LoadImage(nsIURI* aURI,
// XXX For now ignore aCacheKey. We will need it in the future // XXX For now ignore aCacheKey. We will need it in the future
// for correctly dealing with image load requests that are a result // for correctly dealing with image load requests that are a result
// of post data. // of post data.
PrincipalOriginAttributes attrs; OriginAttributes attrs;
if (aLoadingPrincipal) { if (aLoadingPrincipal) {
attrs = aLoadingPrincipal->OriginAttributesRef(); attrs = aLoadingPrincipal->OriginAttributesRef();
} }
@ -2323,9 +2323,9 @@ imgLoader::LoadImageWithChannel(nsIChannel* channel,
NS_ENSURE_TRUE(channel, NS_ERROR_FAILURE); NS_ENSURE_TRUE(channel, NS_ERROR_FAILURE);
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo(); nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
PrincipalOriginAttributes attrs; OriginAttributes attrs;
if (loadInfo) { if (loadInfo) {
attrs.InheritFromNecko(loadInfo->GetOriginAttributes()); attrs.Inherit(loadInfo->GetOriginAttributes());
} }
nsresult rv; nsresult rv;

View file

@ -83,7 +83,7 @@ PrincipalInfoToPrincipal(const PrincipalInfo& aPrincipalInfo,
return nullptr; return nullptr;
} }
PrincipalOriginAttributes attrs; OriginAttributes attrs;
if (info.attrs().mAppId != nsIScriptSecurityManager::UNKNOWN_APP_ID) { if (info.attrs().mAppId != nsIScriptSecurityManager::UNKNOWN_APP_ID) {
attrs = info.attrs(); attrs = info.attrs();
} }

View file

@ -41,20 +41,8 @@ struct OriginAttributesParamTraits
} // namespace detail } // namespace detail
template<> template<>
struct ParamTraits<mozilla::PrincipalOriginAttributes> struct ParamTraits<mozilla::OriginAttributes>
: public detail::OriginAttributesParamTraits<mozilla::PrincipalOriginAttributes> {}; : public detail::OriginAttributesParamTraits<mozilla::OriginAttributes> {};
template<>
struct ParamTraits<mozilla::DocShellOriginAttributes>
: public detail::OriginAttributesParamTraits<mozilla::DocShellOriginAttributes> {};
template<>
struct ParamTraits<mozilla::NeckoOriginAttributes>
: public detail::OriginAttributesParamTraits<mozilla::NeckoOriginAttributes> {};
template<>
struct ParamTraits<mozilla::GenericOriginAttributes>
: public detail::OriginAttributesParamTraits<mozilla::GenericOriginAttributes> {};
} // namespace IPC } // namespace IPC

View file

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
using mozilla::PrincipalOriginAttributes from "mozilla/ipc/BackgroundUtils.h"; using mozilla::OriginAttributes from "mozilla/ipc/BackgroundUtils.h";
using struct mozilla::void_t from "ipc/IPCMessageUtils.h"; using struct mozilla::void_t from "ipc/IPCMessageUtils.h";
namespace mozilla { namespace mozilla {
@ -10,7 +10,7 @@ namespace ipc {
struct ContentPrincipalInfo struct ContentPrincipalInfo
{ {
PrincipalOriginAttributes attrs; OriginAttributes attrs;
nsCString spec; nsCString spec;
}; };
@ -19,13 +19,13 @@ struct SystemPrincipalInfo
struct NullPrincipalInfo struct NullPrincipalInfo
{ {
PrincipalOriginAttributes attrs; OriginAttributes attrs;
nsCString spec; nsCString spec;
}; };
struct ExpandedPrincipalInfo struct ExpandedPrincipalInfo
{ {
PrincipalOriginAttributes attrs; OriginAttributes attrs;
PrincipalInfo[] whitelist; PrincipalInfo[] whitelist;
}; };

View file

@ -1247,7 +1247,7 @@ nsXPCComponents_utils_Sandbox::Construct(nsIXPConnectWrappedNative* wrapper, JSC
* we use the related Codebase Principal for the sandbox. * we use the related Codebase Principal for the sandbox.
*/ */
bool bool
ParsePrincipal(JSContext* cx, HandleString codebase, const PrincipalOriginAttributes& aAttrs, ParsePrincipal(JSContext* cx, HandleString codebase, const OriginAttributes& aAttrs,
nsIPrincipal** principal) nsIPrincipal** principal)
{ {
MOZ_ASSERT(principal); MOZ_ASSERT(principal);
@ -1331,7 +1331,7 @@ GetExpandedPrincipal(JSContext* cx, HandleObject arrayObj,
// strings, then we will use a default OriginAttribute. // strings, then we will use a default OriginAttribute.
// Otherwise, we will use the origin attributes of the passed object(s). If // Otherwise, we will use the origin attributes of the passed object(s). If
// more than one object is specified, we ensure that the OAs match. // more than one object is specified, we ensure that the OAs match.
Maybe<PrincipalOriginAttributes> attrs; Maybe<OriginAttributes> attrs;
if (options.originAttributes) { if (options.originAttributes) {
attrs.emplace(); attrs.emplace();
JS::RootedValue val(cx, JS::ObjectValue(*options.originAttributes)); JS::RootedValue val(cx, JS::ObjectValue(*options.originAttributes));
@ -1376,7 +1376,7 @@ GetExpandedPrincipal(JSContext* cx, HandleObject arrayObj,
NS_ENSURE_TRUE(principal, false); NS_ENSURE_TRUE(principal, false);
if (!options.originAttributes) { if (!options.originAttributes) {
const PrincipalOriginAttributes prinAttrs = const OriginAttributes prinAttrs =
principal->OriginAttributesRef(); principal->OriginAttributesRef();
if (attrs.isNothing()) { if (attrs.isNothing()) {
attrs.emplace(prinAttrs); attrs.emplace(prinAttrs);
@ -1751,7 +1751,7 @@ nsXPCComponents_utils_Sandbox::CallOrConstruct(nsIXPConnectWrappedNative* wrappe
if (args[0].isString()) { if (args[0].isString()) {
RootedString str(cx, args[0].toString()); RootedString str(cx, args[0].toString());
PrincipalOriginAttributes attrs; OriginAttributes attrs;
if (options.originAttributes) { if (options.originAttributes) {
JS::RootedValue val(cx, JS::ObjectValue(*options.originAttributes)); JS::RootedValue val(cx, JS::ObjectValue(*options.originAttributes));
if (!attrs.Init(cx, val)) { if (!attrs.Init(cx, val)) {

View file

@ -18,7 +18,8 @@ namespace net {
NS_IMPL_ISUPPORTS(LoadContextInfo, nsILoadContextInfo) NS_IMPL_ISUPPORTS(LoadContextInfo, nsILoadContextInfo)
LoadContextInfo::LoadContextInfo(bool aIsAnonymous, NeckoOriginAttributes aOriginAttributes) LoadContextInfo::LoadContextInfo(bool aIsAnonymous,
OriginAttributes aOriginAttributes)
: mIsAnonymous(aIsAnonymous) : mIsAnonymous(aIsAnonymous)
, mOriginAttributes(aOriginAttributes) , mOriginAttributes(aOriginAttributes)
{ {
@ -40,7 +41,7 @@ NS_IMETHODIMP LoadContextInfo::GetIsAnonymous(bool *aIsAnonymous)
return NS_OK; return NS_OK;
} }
NeckoOriginAttributes const* LoadContextInfo::OriginAttributesPtr() OriginAttributes const* LoadContextInfo::OriginAttributesPtr()
{ {
return &mOriginAttributes; return &mOriginAttributes;
} }
@ -60,14 +61,15 @@ NS_IMPL_ISUPPORTS(LoadContextInfoFactory, nsILoadContextInfoFactory)
NS_IMETHODIMP LoadContextInfoFactory::GetDefault(nsILoadContextInfo * *aDefault) NS_IMETHODIMP LoadContextInfoFactory::GetDefault(nsILoadContextInfo * *aDefault)
{ {
nsCOMPtr<nsILoadContextInfo> info = GetLoadContextInfo(false, NeckoOriginAttributes()); nsCOMPtr<nsILoadContextInfo> info =
GetLoadContextInfo(false, OriginAttributes());
info.forget(aDefault); info.forget(aDefault);
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP LoadContextInfoFactory::GetPrivate(nsILoadContextInfo * *aPrivate) NS_IMETHODIMP LoadContextInfoFactory::GetPrivate(nsILoadContextInfo * *aPrivate)
{ {
NeckoOriginAttributes attrs; OriginAttributes attrs;
attrs.SyncAttributesWithPrivateBrowsing(true); attrs.SyncAttributesWithPrivateBrowsing(true);
nsCOMPtr<nsILoadContextInfo> info = GetLoadContextInfo(false, attrs); nsCOMPtr<nsILoadContextInfo> info = GetLoadContextInfo(false, attrs);
info.forget(aPrivate); info.forget(aPrivate);
@ -76,7 +78,8 @@ NS_IMETHODIMP LoadContextInfoFactory::GetPrivate(nsILoadContextInfo * *aPrivate)
NS_IMETHODIMP LoadContextInfoFactory::GetAnonymous(nsILoadContextInfo * *aAnonymous) NS_IMETHODIMP LoadContextInfoFactory::GetAnonymous(nsILoadContextInfo * *aAnonymous)
{ {
nsCOMPtr<nsILoadContextInfo> info = GetLoadContextInfo(true, NeckoOriginAttributes()); nsCOMPtr<nsILoadContextInfo> info =
GetLoadContextInfo(true, OriginAttributes());
info.forget(aAnonymous); info.forget(aAnonymous);
return NS_OK; return NS_OK;
} }
@ -85,7 +88,7 @@ NS_IMETHODIMP LoadContextInfoFactory::Custom(bool aAnonymous,
JS::HandleValue aOriginAttributes, JSContext *cx, JS::HandleValue aOriginAttributes, JSContext *cx,
nsILoadContextInfo * *_retval) nsILoadContextInfo * *_retval)
{ {
NeckoOriginAttributes attrs; OriginAttributes attrs;
bool status = attrs.Init(cx, aOriginAttributes); bool status = attrs.Init(cx, aOriginAttributes);
NS_ENSURE_TRUE(status, NS_ERROR_FAILURE); NS_ENSURE_TRUE(status, NS_ERROR_FAILURE);
@ -126,7 +129,7 @@ GetLoadContextInfo(nsIChannel * aChannel)
anon = !!(loadFlags & nsIChannel::LOAD_ANONYMOUS); anon = !!(loadFlags & nsIChannel::LOAD_ANONYMOUS);
} }
NeckoOriginAttributes oa; OriginAttributes oa;
NS_GetOriginAttributes(aChannel, oa); NS_GetOriginAttributes(aChannel, oa);
MOZ_ASSERT(pb == (oa.mPrivateBrowsingId > 0)); MOZ_ASSERT(pb == (oa.mPrivateBrowsingId > 0));
@ -137,18 +140,16 @@ LoadContextInfo *
GetLoadContextInfo(nsILoadContext *aLoadContext, bool aIsAnonymous) GetLoadContextInfo(nsILoadContext *aLoadContext, bool aIsAnonymous)
{ {
if (!aLoadContext) { if (!aLoadContext) {
return new LoadContextInfo(aIsAnonymous, NeckoOriginAttributes(false)); return new LoadContextInfo(aIsAnonymous, OriginAttributes());
} }
DebugOnly<bool> pb = aLoadContext->UsePrivateBrowsing(); DebugOnly<bool> pb = aLoadContext->UsePrivateBrowsing();
DocShellOriginAttributes doa; OriginAttributes oa;
aLoadContext->GetOriginAttributes(doa); aLoadContext->GetOriginAttributes(oa);
MOZ_ASSERT(pb == (doa.mPrivateBrowsingId > 0)); oa.StripAttributes(OriginAttributes::STRIP_ADDON_ID);
NeckoOriginAttributes noa; MOZ_ASSERT(pb == (oa.mPrivateBrowsingId > 0));
noa.InheritFromDocShellToNecko(doa); return new LoadContextInfo(aIsAnonymous, oa);
return new LoadContextInfo(aIsAnonymous, noa);
} }
LoadContextInfo* LoadContextInfo*
@ -170,10 +171,9 @@ GetLoadContextInfo(nsILoadContextInfo *aInfo)
LoadContextInfo * LoadContextInfo *
GetLoadContextInfo(bool const aIsAnonymous, GetLoadContextInfo(bool const aIsAnonymous,
NeckoOriginAttributes const &aOriginAttributes) OriginAttributes const &aOriginAttributes)
{ {
return new LoadContextInfo(aIsAnonymous, return new LoadContextInfo(aIsAnonymous, aOriginAttributes);
aOriginAttributes);
} }
} // namespace net } // namespace net

View file

@ -19,14 +19,14 @@ public:
NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSILOADCONTEXTINFO NS_DECL_NSILOADCONTEXTINFO
LoadContextInfo(bool aIsAnonymous, NeckoOriginAttributes aOriginAttributes); LoadContextInfo(bool aIsAnonymous, OriginAttributes aOriginAttributes);
private: private:
virtual ~LoadContextInfo(); virtual ~LoadContextInfo();
protected: protected:
bool mIsAnonymous : 1; bool mIsAnonymous : 1;
NeckoOriginAttributes mOriginAttributes; OriginAttributes mOriginAttributes;
}; };
class LoadContextInfoFactory : public nsILoadContextInfoFactory class LoadContextInfoFactory : public nsILoadContextInfoFactory
@ -53,7 +53,7 @@ GetLoadContextInfo(nsILoadContextInfo *aInfo);
LoadContextInfo* LoadContextInfo*
GetLoadContextInfo(bool const aIsAnonymous, GetLoadContextInfo(bool const aIsAnonymous,
NeckoOriginAttributes const &aOriginAttributes); OriginAttributes const &aOriginAttributes);
} // namespace net } // namespace net
} // namespace mozilla } // namespace mozilla

View file

@ -29,11 +29,10 @@ namespace mozilla {
namespace net { namespace net {
static void static void
InheritOriginAttributes(nsIPrincipal* aLoadingPrincipal, NeckoOriginAttributes& aAttrs) InheritOriginAttributes(nsIPrincipal* aLoadingPrincipal,
OriginAttributes& aAttrs)
{ {
const PrincipalOriginAttributes attrs = aAttrs.Inherit(aLoadingPrincipal->OriginAttributesRef());
aLoadingPrincipal->OriginAttributesRef();
aAttrs.InheritFromDocToNecko(attrs);
} }
LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal, LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
@ -262,7 +261,7 @@ LoadInfo::LoadInfo(nsPIDOMWindowOuter* aOuterWindow,
// get the docshell from the outerwindow, and then get the originattributes // get the docshell from the outerwindow, and then get the originattributes
nsCOMPtr<nsIDocShell> docShell = aOuterWindow->GetDocShell(); nsCOMPtr<nsIDocShell> docShell = aOuterWindow->GetDocShell();
MOZ_ASSERT(docShell); MOZ_ASSERT(docShell);
const DocShellOriginAttributes attrs = const OriginAttributes attrs =
nsDocShell::Cast(docShell)->GetOriginAttributes(); nsDocShell::Cast(docShell)->GetOriginAttributes();
if (docShell->ItemType() == nsIDocShellTreeItem::typeChrome) { if (docShell->ItemType() == nsIDocShellTreeItem::typeChrome) {
@ -270,7 +269,7 @@ LoadInfo::LoadInfo(nsPIDOMWindowOuter* aOuterWindow,
"chrome docshell shouldn't have mPrivateBrowsingId set."); "chrome docshell shouldn't have mPrivateBrowsingId set.");
} }
mOriginAttributes.InheritFromDocShellToNecko(attrs); mOriginAttributes.Inherit(attrs);
} }
LoadInfo::LoadInfo(const LoadInfo& rhs) LoadInfo::LoadInfo(const LoadInfo& rhs)
@ -321,7 +320,7 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
bool aEnforceSecurity, bool aEnforceSecurity,
bool aInitialSecurityCheckDone, bool aInitialSecurityCheckDone,
bool aIsThirdPartyContext, bool aIsThirdPartyContext,
const NeckoOriginAttributes& aOriginAttributes, const OriginAttributes& aOriginAttributes,
nsTArray<nsCOMPtr<nsIPrincipal>>& aRedirectChainIncludingInternalRedirects, nsTArray<nsCOMPtr<nsIPrincipal>>& aRedirectChainIncludingInternalRedirects,
nsTArray<nsCOMPtr<nsIPrincipal>>& aRedirectChain, nsTArray<nsCOMPtr<nsIPrincipal>>& aRedirectChain,
const nsTArray<nsCString>& aCorsUnsafeHeaders, const nsTArray<nsCString>& aCorsUnsafeHeaders,
@ -699,9 +698,9 @@ LoadInfo::ResetPrincipalsToNullPrincipal()
{ {
// take the originAttributes from the LoadInfo and create // take the originAttributes from the LoadInfo and create
// a new NullPrincipal using those origin attributes. // a new NullPrincipal using those origin attributes.
PrincipalOriginAttributes pAttrs; OriginAttributes attrs;
pAttrs.InheritFromNecko(mOriginAttributes); attrs.Inherit(mOriginAttributes);
nsCOMPtr<nsIPrincipal> newNullPrincipal = nsNullPrincipal::Create(pAttrs); nsCOMPtr<nsIPrincipal> newNullPrincipal = nsNullPrincipal::Create(attrs);
MOZ_ASSERT(mInternalContentPolicyType != nsIContentPolicy::TYPE_DOCUMENT || MOZ_ASSERT(mInternalContentPolicyType != nsIContentPolicy::TYPE_DOCUMENT ||
!mLoadingPrincipal, !mLoadingPrincipal,
@ -726,7 +725,7 @@ NS_IMETHODIMP
LoadInfo::SetScriptableOriginAttributes(JSContext* aCx, LoadInfo::SetScriptableOriginAttributes(JSContext* aCx,
JS::Handle<JS::Value> aOriginAttributes) JS::Handle<JS::Value> aOriginAttributes)
{ {
NeckoOriginAttributes attrs; OriginAttributes attrs;
if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) { if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) {
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
@ -736,7 +735,7 @@ LoadInfo::SetScriptableOriginAttributes(JSContext* aCx,
} }
nsresult nsresult
LoadInfo::GetOriginAttributes(mozilla::NeckoOriginAttributes* aOriginAttributes) LoadInfo::GetOriginAttributes(mozilla::OriginAttributes* aOriginAttributes)
{ {
NS_ENSURE_ARG(aOriginAttributes); NS_ENSURE_ARG(aOriginAttributes);
*aOriginAttributes = mOriginAttributes; *aOriginAttributes = mOriginAttributes;
@ -744,7 +743,7 @@ LoadInfo::GetOriginAttributes(mozilla::NeckoOriginAttributes* aOriginAttributes)
} }
nsresult nsresult
LoadInfo::SetOriginAttributes(const mozilla::NeckoOriginAttributes& aOriginAttributes) LoadInfo::SetOriginAttributes(const mozilla::OriginAttributes& aOriginAttributes)
{ {
mOriginAttributes = aOriginAttributes; mOriginAttributes = aOriginAttributes;
return NS_OK; return NS_OK;

View file

@ -101,7 +101,7 @@ private:
bool aEnforceSecurity, bool aEnforceSecurity,
bool aInitialSecurityCheckDone, bool aInitialSecurityCheckDone,
bool aIsThirdPartyRequest, bool aIsThirdPartyRequest,
const NeckoOriginAttributes& aOriginAttributes, const OriginAttributes& aOriginAttributes,
nsTArray<nsCOMPtr<nsIPrincipal>>& aRedirectChainIncludingInternalRedirects, nsTArray<nsCOMPtr<nsIPrincipal>>& aRedirectChainIncludingInternalRedirects,
nsTArray<nsCOMPtr<nsIPrincipal>>& aRedirectChain, nsTArray<nsCOMPtr<nsIPrincipal>>& aRedirectChain,
const nsTArray<nsCString>& aUnsafeHeaders, const nsTArray<nsCString>& aUnsafeHeaders,
@ -145,7 +145,7 @@ private:
bool mEnforceSecurity; bool mEnforceSecurity;
bool mInitialSecurityCheckDone; bool mInitialSecurityCheckDone;
bool mIsThirdPartyContext; bool mIsThirdPartyContext;
NeckoOriginAttributes mOriginAttributes; OriginAttributes mOriginAttributes;
nsTArray<nsCOMPtr<nsIPrincipal>> mRedirectChainIncludingInternalRedirects; nsTArray<nsCOMPtr<nsIPrincipal>> mRedirectChainIncludingInternalRedirects;
nsTArray<nsCOMPtr<nsIPrincipal>> mRedirectChain; nsTArray<nsCOMPtr<nsIPrincipal>> mRedirectChain;
nsTArray<nsCString> mCorsUnsafeHeaders; nsTArray<nsCString> mCorsUnsafeHeaders;

View file

@ -593,7 +593,7 @@ Predictor::Init()
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
RefPtr<LoadContextInfo> lci = RefPtr<LoadContextInfo> lci =
new LoadContextInfo(false, NeckoOriginAttributes()); new LoadContextInfo(false, OriginAttributes());
rv = cacheStorageService->DiskCacheStorage(lci, false, rv = cacheStorageService->DiskCacheStorage(lci, false,
getter_AddRefs(mCacheDiskStorage)); getter_AddRefs(mCacheDiskStorage));

View file

@ -84,7 +84,7 @@ public:
nsCOMPtr<nsILoadInfo> loadInfo; nsCOMPtr<nsILoadInfo> loadInfo;
Unused << channel->GetLoadInfo(getter_AddRefs(loadInfo)); Unused << channel->GetLoadInfo(getter_AddRefs(loadInfo));
if (loadInfo) { if (loadInfo) {
NeckoOriginAttributes attrs = loadInfo->GetOriginAttributes(); OriginAttributes attrs = loadInfo->GetOriginAttributes();
mPrivateBrowsing = attrs.mPrivateBrowsingId > 0; mPrivateBrowsing = attrs.mPrivateBrowsingId > 0;
} }
} }

View file

@ -8,7 +8,7 @@
%{ C++ %{ C++
#include "mozilla/BasePrincipal.h" #include "mozilla/BasePrincipal.h"
%} %}
native OriginAttributesNativePtr(const mozilla::NeckoOriginAttributes*); native OriginAttributesNativePtr(const mozilla::OriginAttributes*);
interface nsILoadContext; interface nsILoadContext;
interface nsIDOMWindow; interface nsIDOMWindow;
@ -37,7 +37,7 @@ interface nsILoadContextInfo : nsISupports
readonly attribute boolean isAnonymous; readonly attribute boolean isAnonymous;
/** /**
* NeckoOriginAttributes hiding all the security context attributes * OriginAttributes hiding all the security context attributes
*/ */
[implicit_jscontext] [implicit_jscontext]
readonly attribute jsval originAttributes; readonly attribute jsval originAttributes;
@ -71,7 +71,7 @@ interface nsILoadContextInfo : nsISupports
}; };
/** /**
* Since NeckoOriginAttributes struct limits the implementation of * Since OriginAttributes struct limits the implementation of
* nsILoadContextInfo (that needs to be thread safe) to C++, * nsILoadContextInfo (that needs to be thread safe) to C++,
* we need a scriptable factory to create instances of that * we need a scriptable factory to create instances of that
* interface from JS. * interface from JS.

View file

@ -20,8 +20,8 @@ class nsCString;
%} %}
[ref] native const_nsIPrincipalArray(const nsTArray<nsCOMPtr<nsIPrincipal>>); [ref] native const_nsIPrincipalArray(const nsTArray<nsCOMPtr<nsIPrincipal>>);
native NeckoOriginAttributes(mozilla::NeckoOriginAttributes); native OriginAttributes(mozilla::OriginAttributes);
[ref] native const_OriginAttributesRef(const mozilla::NeckoOriginAttributes); [ref] native const_OriginAttributesRef(const mozilla::OriginAttributes);
[ref] native StringArrayRef(const nsTArray<nsCString>); [ref] native StringArrayRef(const nsTArray<nsCString>);
typedef unsigned long nsSecurityFlags; typedef unsigned long nsSecurityFlags;
@ -534,7 +534,7 @@ interface nsILoadInfo : nsISupports
void resetPrincipalsToNullPrincipal(); void resetPrincipalsToNullPrincipal();
/** /**
* Customized NeckoOriginAttributes within LoadInfo to allow overwriting of the * Customized OriginAttributes within LoadInfo to allow overwriting of the
* default originAttributes from the loadingPrincipal. * default originAttributes from the loadingPrincipal.
* *
* In chrome side, originAttributes.privateBrowsingId will always be 0 even if * In chrome side, originAttributes.privateBrowsingId will always be 0 even if
@ -546,15 +546,15 @@ interface nsILoadInfo : nsISupports
attribute jsval originAttributes; attribute jsval originAttributes;
[noscript, nostdcall, binaryname(GetOriginAttributes)] [noscript, nostdcall, binaryname(GetOriginAttributes)]
NeckoOriginAttributes binaryGetOriginAttributes(); OriginAttributes binaryGetOriginAttributes();
[noscript, nostdcall, binaryname(SetOriginAttributes)] [noscript, nostdcall, binaryname(SetOriginAttributes)]
void binarySetOriginAttributes(in const_OriginAttributesRef aOriginAttrs); void binarySetOriginAttributes(in const_OriginAttributesRef aOriginAttrs);
%{ C++ %{ C++
inline mozilla::NeckoOriginAttributes GetOriginAttributes() inline mozilla::OriginAttributes GetOriginAttributes()
{ {
mozilla::NeckoOriginAttributes result; mozilla::OriginAttributes result;
mozilla::DebugOnly<nsresult> rv = GetOriginAttributes(&result); mozilla::DebugOnly<nsresult> rv = GetOriginAttributes(&result);
MOZ_ASSERT(NS_SUCCEEDED(rv)); MOZ_ASSERT(NS_SUCCEEDED(rv));
return result; return result;

View file

@ -18,8 +18,8 @@ union NetAddr;
%} %}
native NetAddr(mozilla::net::NetAddr); native NetAddr(mozilla::net::NetAddr);
[ptr] native NetAddrPtr(mozilla::net::NetAddr); [ptr] native NetAddrPtr(mozilla::net::NetAddr);
native NeckoOriginAttributes(mozilla::NeckoOriginAttributes); native OriginAttributes(mozilla::OriginAttributes);
[ref] native const_OriginAttributesRef(const mozilla::NeckoOriginAttributes); [ref] native const_OriginAttributesRef(const mozilla::OriginAttributes);
/** /**
* nsISocketTransport * nsISocketTransport
@ -58,7 +58,7 @@ interface nsISocketTransport : nsITransport
attribute jsval originAttributes; attribute jsval originAttributes;
[noscript, nostdcall, binaryname(GetOriginAttributes)] [noscript, nostdcall, binaryname(GetOriginAttributes)]
NeckoOriginAttributes binaryGetOriginAttributes(); OriginAttributes binaryGetOriginAttributes();
[noscript, nostdcall, binaryname(SetOriginAttributes)] [noscript, nostdcall, binaryname(SetOriginAttributes)]
void binarySetOriginAttributes(in const_OriginAttributesRef aOriginAttrs); void binarySetOriginAttributes(in const_OriginAttributesRef aOriginAttrs);

View file

@ -1249,7 +1249,7 @@ NS_UsePrivateBrowsing(nsIChannel *channel)
bool bool
NS_GetOriginAttributes(nsIChannel *aChannel, NS_GetOriginAttributes(nsIChannel *aChannel,
mozilla::NeckoOriginAttributes &aAttributes) mozilla::OriginAttributes &aAttributes)
{ {
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo(); nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
if (!loadInfo) { if (!loadInfo) {
@ -2346,7 +2346,7 @@ NS_CompareLoadInfoAndLoadContext(nsIChannel *aChannel)
} }
OriginAttributes originAttrsLoadInfo = loadInfo->GetOriginAttributes(); OriginAttributes originAttrsLoadInfo = loadInfo->GetOriginAttributes();
DocShellOriginAttributes originAttrsLoadContext; OriginAttributes originAttrsLoadContext;
loadContext->GetOriginAttributes(originAttrsLoadContext); loadContext->GetOriginAttributes(originAttrsLoadContext);
LOG(("NS_CompareLoadInfoAndLoadContext - loadInfo: %d, %d, %d; " LOG(("NS_CompareLoadInfoAndLoadContext - loadInfo: %d, %d, %d; "

View file

@ -48,7 +48,7 @@ class nsIIncrementalStreamLoaderObserver;
class nsIUnicharStreamLoader; class nsIUnicharStreamLoader;
class nsIUnicharStreamLoaderObserver; class nsIUnicharStreamLoaderObserver;
namespace mozilla { class NeckoOriginAttributes; } namespace mozilla { class OriginAttributes; }
template <class> class nsCOMPtr; template <class> class nsCOMPtr;
template <typename> struct already_AddRefed; template <typename> struct already_AddRefed;
@ -657,10 +657,10 @@ NS_QueryNotificationCallbacks(nsIInterfaceRequestor *callbacks,
bool NS_UsePrivateBrowsing(nsIChannel *channel); bool NS_UsePrivateBrowsing(nsIChannel *channel);
/** /**
* Extract the NeckoOriginAttributes from the channel's triggering principal. * Extract the OriginAttributes from the channel's triggering principal.
*/ */
bool NS_GetOriginAttributes(nsIChannel *aChannel, bool NS_GetOriginAttributes(nsIChannel *aChannel,
mozilla::NeckoOriginAttributes &aAttributes); mozilla::OriginAttributes &aAttributes);
/** /**
* Returns true if the channel has visited any cross-origin URLs on any * Returns true if the channel has visited any cross-origin URLs on any

View file

@ -2422,7 +2422,7 @@ nsSocketTransport::SetScriptableOriginAttributes(JSContext* aCx,
MutexAutoLock lock(mLock); MutexAutoLock lock(mLock);
NS_ENSURE_FALSE(mFD.IsInitialized(), NS_ERROR_FAILURE); NS_ENSURE_FALSE(mFD.IsInitialized(), NS_ERROR_FAILURE);
NeckoOriginAttributes attrs; OriginAttributes attrs;
if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) { if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) {
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
@ -2432,7 +2432,7 @@ nsSocketTransport::SetScriptableOriginAttributes(JSContext* aCx,
} }
nsresult nsresult
nsSocketTransport::GetOriginAttributes(NeckoOriginAttributes* aOriginAttributes) nsSocketTransport::GetOriginAttributes(OriginAttributes* aOriginAttributes)
{ {
NS_ENSURE_ARG(aOriginAttributes); NS_ENSURE_ARG(aOriginAttributes);
*aOriginAttributes = mOriginAttributes; *aOriginAttributes = mOriginAttributes;
@ -2440,7 +2440,7 @@ nsSocketTransport::GetOriginAttributes(NeckoOriginAttributes* aOriginAttributes)
} }
nsresult nsresult
nsSocketTransport::SetOriginAttributes(const NeckoOriginAttributes& aOriginAttributes) nsSocketTransport::SetOriginAttributes(const OriginAttributes& aOriginAttributes)
{ {
MutexAutoLock lock(mLock); MutexAutoLock lock(mLock);
NS_ENSURE_FALSE(mFD.IsInitialized(), NS_ERROR_FAILURE); NS_ENSURE_FALSE(mFD.IsInitialized(), NS_ERROR_FAILURE);

View file

@ -91,7 +91,7 @@ public:
uint64_t ByteCount() { return mByteCount; } uint64_t ByteCount() { return mByteCount; }
// called by the socket transport on the socket thread... // called by the socket transport on the socket thread...
void OnSocketReady(nsresult condition); void OnSocketReady(nsresult condition);
private: private:
static nsresult WriteFromSegments(nsIInputStream *, void *, static nsresult WriteFromSegments(nsIInputStream *, void *,
@ -309,8 +309,8 @@ private:
// "privacy.firstparty.isolate" is enabled. Setting this is the only way to // "privacy.firstparty.isolate" is enabled. Setting this is the only way to
// carry origin attributes down to NSPR layers which are final consumers. // carry origin attributes down to NSPR layers which are final consumers.
// It must be set before the socket transport is built. // It must be set before the socket transport is built.
NeckoOriginAttributes mOriginAttributes; OriginAttributes mOriginAttributes;
uint16_t SocketPort() { return (!mProxyHost.IsEmpty() && !mProxyTransparent) ? mProxyPort : mPort; } uint16_t SocketPort() { return (!mProxyHost.IsEmpty() && !mProxyTransparent) ? mProxyPort : mPort; }
const nsCString &SocketHost() { return (!mProxyHost.IsEmpty() && !mProxyTransparent) ? mProxyHost : mHost; } const nsCString &SocketHost() { return (!mProxyHost.IsEmpty() && !mProxyTransparent) ? mProxyHost : mHost; }
@ -351,7 +351,7 @@ private:
void SendStatus(nsresult status); void SendStatus(nsresult status);
nsresult ResolveHost(); nsresult ResolveHost();
nsresult BuildSocket(PRFileDesc *&, bool &, bool &); nsresult BuildSocket(PRFileDesc *&, bool &, bool &);
nsresult InitiateSocket(); nsresult InitiateSocket();
bool RecoverFromError(); bool RecoverFromError();

View file

@ -53,7 +53,7 @@
using namespace mozilla; using namespace mozilla;
using namespace mozilla::storage; using namespace mozilla::storage;
using mozilla::NeckoOriginAttributes; using mozilla::OriginAttributes;
static const char OFFLINE_CACHE_DEVICE_ID[] = { "offline" }; static const char OFFLINE_CACHE_DEVICE_ID[] = { "offline" };
@ -2523,7 +2523,7 @@ OriginMatch::OnFunctionCall(mozIStorageValueArray* aFunctionArguments, nsIVarian
nsDependentCSubstring suffix(groupId.BeginReading() + hash, groupId.Length() - hash); nsDependentCSubstring suffix(groupId.BeginReading() + hash, groupId.Length() - hash);
mozilla::NeckoOriginAttributes oa; mozilla::OriginAttributes oa;
bool ok = oa.PopulateFromSuffix(suffix); bool ok = oa.PopulateFromSuffix(suffix);
NS_ENSURE_TRUE(ok, NS_ERROR_UNEXPECTED); NS_ENSURE_TRUE(ok, NS_ERROR_UNEXPECTED);

View file

@ -147,7 +147,7 @@ public:
nsresult SyncReadMetadata(nsIFile *aFile); nsresult SyncReadMetadata(nsIFile *aFile);
bool IsAnonymous() const { return mAnonymous; } bool IsAnonymous() const { return mAnonymous; }
mozilla::NeckoOriginAttributes const & OriginAttributes() const { return mOriginAttributes; } mozilla::OriginAttributes const & OriginAttributes() const { return mOriginAttributes; }
bool Pinned() const { return !!(mMetaHdr.mFlags & kCacheEntryIsPinned); } bool Pinned() const { return !!(mMetaHdr.mFlags & kCacheEntryIsPinned); }
const char * GetElement(const char *aKey); const char * GetElement(const char *aKey);
@ -215,7 +215,7 @@ private:
bool mAnonymous : 1; bool mAnonymous : 1;
bool mAllocExactSize : 1; bool mAllocExactSize : 1;
bool mFirstRead : 1; bool mFirstRead : 1;
mozilla::NeckoOriginAttributes mOriginAttributes; mozilla::OriginAttributes mOriginAttributes;
mozilla::TimeStamp mReadStart; mozilla::TimeStamp mReadStart;
nsCOMPtr<CacheFileMetadataListener> mListener; nsCOMPtr<CacheFileMetadataListener> mListener;
}; };

View file

@ -34,8 +34,6 @@ class KeyParser : protected Tokenizer
public: public:
explicit KeyParser(nsACString const& aInput) explicit KeyParser(nsACString const& aInput)
: Tokenizer(aInput) : Tokenizer(aInput)
// Initialize attributes to their default values
, originAttribs(false)
, isAnonymous(false) , isAnonymous(false)
// Initialize the cache key to a zero length by default // Initialize the cache key to a zero length by default
, lastTag(0) , lastTag(0)
@ -44,7 +42,7 @@ public:
private: private:
// Results // Results
NeckoOriginAttributes originAttribs; OriginAttributes originAttribs;
bool isAnonymous; bool isAnonymous;
nsCString idEnhance; nsCString idEnhance;
nsDependentCSubstring cacheKey; nsDependentCSubstring cacheKey;
@ -212,7 +210,7 @@ AppendKeyPrefix(nsILoadContextInfo* aInfo, nsACString &_retval)
* Keep the attributes list sorted according their ASCII code. * Keep the attributes list sorted according their ASCII code.
*/ */
NeckoOriginAttributes const *oa = aInfo->OriginAttributesPtr(); OriginAttributes const *oa = aInfo->OriginAttributesPtr();
nsAutoCString suffix; nsAutoCString suffix;
oa->CreateSuffix(suffix); oa->CreateSuffix(suffix);
if (!suffix.IsEmpty()) { if (!suffix.IsEmpty()) {

View file

@ -410,7 +410,7 @@ namespace CacheStorageEvictHelper {
nsresult ClearStorage(bool const aPrivate, nsresult ClearStorage(bool const aPrivate,
bool const aAnonymous, bool const aAnonymous,
NeckoOriginAttributes &aOa) OriginAttributes &aOa)
{ {
nsresult rv; nsresult rv;
@ -436,7 +436,7 @@ nsresult ClearStorage(bool const aPrivate,
return NS_OK; return NS_OK;
} }
nsresult Run(NeckoOriginAttributes &aOa) nsresult Run(OriginAttributes &aOa)
{ {
nsresult rv; nsresult rv;
@ -553,9 +553,9 @@ CacheObserver::Observe(nsISupports* aSubject,
} }
if (!strcmp(aTopic, "clear-origin-attributes-data")) { if (!strcmp(aTopic, "clear-origin-attributes-data")) {
NeckoOriginAttributes oa; OriginAttributes oa;
if (!oa.Init(nsDependentString(aData))) { if (!oa.Init(nsDependentString(aData))) {
NS_ERROR("Could not parse NeckoOriginAttributes JSON in clear-origin-attributes-data notification"); NS_ERROR("Could not parse OriginAttributes JSON in clear-origin-attributes-data notification");
return NS_OK; return NS_OK;
} }

View file

@ -524,7 +524,7 @@ GetCacheSessionNameForStoragePolicy(
nsCSubstring const &scheme, nsCSubstring const &scheme,
nsCacheStoragePolicy storagePolicy, nsCacheStoragePolicy storagePolicy,
bool isPrivate, bool isPrivate,
NeckoOriginAttributes const *originAttribs, OriginAttributes const *originAttribs,
nsACString& sessionName) nsACString& sessionName)
{ {
MOZ_ASSERT(!isPrivate || storagePolicy == nsICache::STORE_IN_MEMORY); MOZ_ASSERT(!isPrivate || storagePolicy == nsICache::STORE_IN_MEMORY);

View file

@ -124,7 +124,7 @@ CookieServiceChild::GetCookieStringInternal(nsIURI *aHostURI,
URIParams uriParams; URIParams uriParams;
SerializeURI(aHostURI, uriParams); SerializeURI(aHostURI, uriParams);
mozilla::NeckoOriginAttributes attrs; mozilla::OriginAttributes attrs;
if (aChannel) { if (aChannel) {
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo(); nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
if (loadInfo) { if (loadInfo) {
@ -171,7 +171,7 @@ CookieServiceChild::SetCookieStringInternal(nsIURI *aHostURI,
URIParams uriParams; URIParams uriParams;
SerializeURI(aHostURI, uriParams); SerializeURI(aHostURI, uriParams);
mozilla::NeckoOriginAttributes attrs; mozilla::OriginAttributes attrs;
if (aChannel) { if (aChannel) {
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo(); nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
if (loadInfo) { if (loadInfo) {

View file

@ -18,8 +18,7 @@
using namespace mozilla::ipc; using namespace mozilla::ipc;
using mozilla::BasePrincipal; using mozilla::BasePrincipal;
using mozilla::NeckoOriginAttributes; using mozilla::OriginAttributes;
using mozilla::PrincipalOriginAttributes;
using mozilla::dom::PContentParent; using mozilla::dom::PContentParent;
using mozilla::net::NeckoParent; using mozilla::net::NeckoParent;
@ -28,11 +27,11 @@ namespace {
// Ignore failures from this function, as they only affect whether we do or // Ignore failures from this function, as they only affect whether we do or
// don't show a dialog box in private browsing mode if the user sets a pref. // don't show a dialog box in private browsing mode if the user sets a pref.
void void
CreateDummyChannel(nsIURI* aHostURI, NeckoOriginAttributes& aAttrs, bool aIsPrivate, CreateDummyChannel(nsIURI* aHostURI, OriginAttributes& aAttrs, bool aIsPrivate,
nsIChannel** aChannel) nsIChannel** aChannel)
{ {
PrincipalOriginAttributes attrs; OriginAttributes attrs;
attrs.InheritFromNecko(aAttrs); attrs.Inherit(aAttrs);
nsCOMPtr<nsIPrincipal> principal = nsCOMPtr<nsIPrincipal> principal =
BasePrincipal::CreateCodebasePrincipal(aHostURI, attrs); BasePrincipal::CreateCodebasePrincipal(aHostURI, attrs);
@ -94,7 +93,7 @@ mozilla::ipc::IPCResult
CookieServiceParent::RecvGetCookieString(const URIParams& aHost, CookieServiceParent::RecvGetCookieString(const URIParams& aHost,
const bool& aIsForeign, const bool& aIsForeign,
const bool& aFromHttp, const bool& aFromHttp,
const NeckoOriginAttributes& aAttrs, const OriginAttributes& aAttrs,
nsCString* aResult) nsCString* aResult)
{ {
if (!mCookieService) if (!mCookieService)
@ -118,7 +117,7 @@ CookieServiceParent::RecvSetCookieString(const URIParams& aHost,
const nsCString& aCookieString, const nsCString& aCookieString,
const nsCString& aServerTime, const nsCString& aServerTime,
const bool& aFromHttp, const bool& aFromHttp,
const NeckoOriginAttributes& aAttrs) const OriginAttributes& aAttrs)
{ {
if (!mCookieService) if (!mCookieService)
return IPC_OK(); return IPC_OK();
@ -139,7 +138,7 @@ CookieServiceParent::RecvSetCookieString(const URIParams& aHost,
// with aIsForeign before we have to worry about nsCookiePermission trying // with aIsForeign before we have to worry about nsCookiePermission trying
// to use the channel to inspect it. // to use the channel to inspect it.
nsCOMPtr<nsIChannel> dummyChannel; nsCOMPtr<nsIChannel> dummyChannel;
CreateDummyChannel(hostURI, const_cast<NeckoOriginAttributes&>(aAttrs), CreateDummyChannel(hostURI, const_cast<OriginAttributes&>(aAttrs),
isPrivate, getter_AddRefs(dummyChannel)); isPrivate, getter_AddRefs(dummyChannel));
// NB: dummyChannel could be null if something failed in CreateDummyChannel. // NB: dummyChannel could be null if something failed in CreateDummyChannel.

Some files were not shown because too many files have changed in this diff Show more