mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
Revert "Bug 1209162 - Create OriginAttributes subtypes. IGNORE IDL r=sicking."
This commit is contained in:
+16
-64
@@ -28,74 +28,26 @@ namespace mozilla {
|
||||
|
||||
using dom::URLParams;
|
||||
|
||||
void
|
||||
PrincipalOriginAttributes::InheritFromDocShellToDoc(const DocShellOriginAttributes& aAttrs,
|
||||
const nsIURI* aURI)
|
||||
void OriginAttributes::InheritFromDocShellParent(const OriginAttributes& aParent)
|
||||
{
|
||||
mAppId = aAttrs.mAppId;
|
||||
mInBrowser = aAttrs.mInBrowser;
|
||||
|
||||
// addonId is computed from the principal URI and never propagated
|
||||
mUserContextId = aAttrs.mUserContextId;
|
||||
|
||||
// TODO:
|
||||
// Bug 1225349 - PrincipalOriginAttributes should inherit mSignedPkg
|
||||
// accordingly by URI
|
||||
mSignedPkg = aAttrs.mSignedPkg;
|
||||
mAppId = aParent.mAppId;
|
||||
mInBrowser = aParent.mInBrowser;
|
||||
mUserContextId = aParent.mUserContextId;
|
||||
mSignedPkg = aParent.mSignedPkg;
|
||||
}
|
||||
|
||||
void
|
||||
PrincipalOriginAttributes::InheritFromNecko(const NeckoOriginAttributes& aAttrs)
|
||||
bool OriginAttributes::CopyFromLoadContext(nsILoadContext* aLoadContext)
|
||||
{
|
||||
mAppId = aAttrs.mAppId;
|
||||
mInBrowser = aAttrs.mInBrowser;
|
||||
OriginAttributes attrs;
|
||||
bool result = aLoadContext->GetOriginAttributes(attrs);
|
||||
NS_ENSURE_TRUE(result, false);
|
||||
|
||||
// addonId is computed from the principal URI and never propagated
|
||||
mUserContextId = aAttrs.mUserContextId;
|
||||
mSignedPkg = aAttrs.mSignedPkg;
|
||||
}
|
||||
|
||||
void
|
||||
DocShellOriginAttributes::InheritFromDocToChildDocShell(const PrincipalOriginAttributes& aAttrs)
|
||||
{
|
||||
mAppId = aAttrs.mAppId;
|
||||
mInBrowser = aAttrs.mInBrowser;
|
||||
|
||||
// addonId is computed from the principal URI and never propagated
|
||||
mUserContextId = aAttrs.mUserContextId;
|
||||
|
||||
// TODO:
|
||||
// Bug 1225353 - DocShell/NeckoOriginAttributes should inherit
|
||||
// mSignedPkg accordingly by mSignedPkgInBrowser
|
||||
mSignedPkg = aAttrs.mSignedPkg;
|
||||
}
|
||||
|
||||
void
|
||||
NeckoOriginAttributes::InheritFromDocToNecko(const PrincipalOriginAttributes& aAttrs)
|
||||
{
|
||||
mAppId = aAttrs.mAppId;
|
||||
mInBrowser = aAttrs.mInBrowser;
|
||||
|
||||
// addonId is computed from the principal URI and never propagated
|
||||
mUserContextId = aAttrs.mUserContextId;
|
||||
|
||||
// TODO:
|
||||
// Bug 1225353 - DocShell/NeckoOriginAttributes should inherit
|
||||
// mSignedPkg accordingly by mSignedPkgInBrowser
|
||||
}
|
||||
|
||||
void
|
||||
NeckoOriginAttributes::InheritFromDocShellToNecko(const DocShellOriginAttributes& aAttrs)
|
||||
{
|
||||
mAppId = aAttrs.mAppId;
|
||||
mInBrowser = aAttrs.mInBrowser;
|
||||
|
||||
// addonId is computed from the principal URI and never propagated
|
||||
mUserContextId = aAttrs.mUserContextId;
|
||||
|
||||
// TODO:
|
||||
// Bug 1225353 - DocShell/NeckoOriginAttributes should inherit
|
||||
// mSignedPkg accordingly by mSignedPkgInBrowser
|
||||
mAppId = attrs.mAppId;
|
||||
mInBrowser = attrs.mInBrowser;
|
||||
mAddonId = attrs.mAddonId;
|
||||
mUserContextId = attrs.mUserContextId;
|
||||
mSignedPkg = attrs.mSignedPkg;
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -490,7 +442,7 @@ BasePrincipal::GetUnknownAppId(bool* aUnknownAppId)
|
||||
}
|
||||
|
||||
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,
|
||||
// we shouldn't make a codebase principal for it.
|
||||
|
||||
+35
-92
@@ -14,19 +14,26 @@
|
||||
#include "mozilla/dom/ChromeUtilsBinding.h"
|
||||
|
||||
class nsIContentSecurityPolicy;
|
||||
class nsILoadContext;
|
||||
class nsIObjectOutputStream;
|
||||
class nsIObjectInputStream;
|
||||
class nsIURI;
|
||||
|
||||
class nsExpandedPrincipal;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
// Base OriginAttributes class. This has several subclass flavors, and is not
|
||||
// directly constructable itself.
|
||||
class OriginAttributes : public dom::OriginAttributesDictionary
|
||||
{
|
||||
public:
|
||||
OriginAttributes() {}
|
||||
OriginAttributes(uint32_t aAppId, bool aInBrowser)
|
||||
{
|
||||
mAppId = aAppId;
|
||||
mInBrowser = aInBrowser;
|
||||
}
|
||||
explicit OriginAttributes(const OriginAttributesDictionary& aOther)
|
||||
: OriginAttributesDictionary(aOther) {}
|
||||
|
||||
bool operator==(const OriginAttributes& aOther) const
|
||||
{
|
||||
return mAppId == aOther.mAppId &&
|
||||
@@ -40,6 +47,28 @@ public:
|
||||
return !(*this == aOther);
|
||||
}
|
||||
|
||||
// The docshell often influences the origin attributes of content loaded
|
||||
// inside of it, and in some cases also influences the origin attributes of
|
||||
// content loaded in child docshells. We say that a given attribute "lives on
|
||||
// the docshell" to indicate that this attribute is specified by the docshell
|
||||
// (if any) associated with a given content document.
|
||||
//
|
||||
// In practice, this usually means that we need to store a copy of those
|
||||
// attributes on each docshell, or provide methods on the docshell to compute
|
||||
// them on-demand.
|
||||
// We could track each of these attributes individually, but since the
|
||||
// majority of the existing origin attributes currently live on the docshell,
|
||||
// it's cleaner to simply store an entire OriginAttributes struct on each
|
||||
// docshell, and selectively copy them to child docshells and content
|
||||
// principals in a manner that implements our desired semantics.
|
||||
//
|
||||
// This method is used to propagate attributes from parent to child
|
||||
// docshells.
|
||||
void InheritFromDocShellParent(const OriginAttributes& aParent);
|
||||
|
||||
// Copy from the origin attributes of the nsILoadContext.
|
||||
bool CopyFromLoadContext(nsILoadContext* aLoadContext);
|
||||
|
||||
// Serializes/Deserializes non-default values into the suffix format, i.e.
|
||||
// |!key1=value1&key2=value2|. If there are no non-default attributes, this
|
||||
// returns an empty string.
|
||||
@@ -50,92 +79,6 @@ public:
|
||||
// |uri!key1=value1&key2=value2| and returns the uri without the suffix.
|
||||
bool PopulateFromOrigin(const nsACString& aOrigin,
|
||||
nsACString& aOriginNoSuffix);
|
||||
|
||||
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 aInBrowser)
|
||||
{
|
||||
mAppId = aAppId;
|
||||
mInBrowser = aInBrowser;
|
||||
}
|
||||
|
||||
// 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);
|
||||
};
|
||||
|
||||
// For OriginAttributes stored on docshells / loadcontexts / browsing contexts.
|
||||
class DocShellOriginAttributes : public OriginAttributes
|
||||
{
|
||||
public:
|
||||
DocShellOriginAttributes() {}
|
||||
DocShellOriginAttributes(uint32_t aAppId, bool aInBrowser)
|
||||
{
|
||||
mAppId = aAppId;
|
||||
mInBrowser = aInBrowser;
|
||||
}
|
||||
|
||||
// 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() {}
|
||||
NeckoOriginAttributes(uint32_t aAppId, bool aInBrowser)
|
||||
{
|
||||
mAppId = aAppId;
|
||||
mInBrowser = aInBrowser;
|
||||
}
|
||||
|
||||
// Inheriting OriginAttributes from document to necko when a network request
|
||||
// is made.
|
||||
void InheritFromDocToNecko(const PrincipalOriginAttributes& aAttrs);
|
||||
|
||||
void InheritFromDocShellToNecko(const DocShellOriginAttributes& aAttrs);
|
||||
};
|
||||
|
||||
// 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
|
||||
@@ -224,9 +167,9 @@ public:
|
||||
|
||||
static BasePrincipal* Cast(nsIPrincipal* aPrin) { return static_cast<BasePrincipal*>(aPrin); }
|
||||
static already_AddRefed<BasePrincipal>
|
||||
CreateCodebasePrincipal(nsIURI* aURI, const PrincipalOriginAttributes& aAttrs);
|
||||
CreateCodebasePrincipal(nsIURI* aURI, const OriginAttributes& aAttrs);
|
||||
|
||||
const PrincipalOriginAttributes& OriginAttributesRef() { return mOriginAttributes; }
|
||||
const OriginAttributes& OriginAttributesRef() { return mOriginAttributes; }
|
||||
uint32_t AppId() const { return mOriginAttributes.mAppId; }
|
||||
uint32_t UserContextId() const { return mOriginAttributes.mUserContextId; }
|
||||
bool IsInBrowserElement() const { return mOriginAttributes.mInBrowser; }
|
||||
@@ -258,7 +201,7 @@ protected:
|
||||
|
||||
nsCOMPtr<nsIContentSecurityPolicy> mCSP;
|
||||
nsCOMPtr<nsIContentSecurityPolicy> mPreloadCSP;
|
||||
PrincipalOriginAttributes mOriginAttributes;
|
||||
OriginAttributes mOriginAttributes;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
@@ -160,7 +160,7 @@ nsJSPrincipals::ReadKnownPrincipalType(JSContext* aCx,
|
||||
return false;
|
||||
}
|
||||
|
||||
PrincipalOriginAttributes attrs;
|
||||
OriginAttributes attrs;
|
||||
attrs.PopulateFromSuffix(suffix);
|
||||
info = ContentPrincipalInfo(attrs, spec);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ nsNullPrincipal::CreateWithInheritedAttributes(nsIPrincipal* aInheritFrom)
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<nsNullPrincipal>
|
||||
nsNullPrincipal::Create(const PrincipalOriginAttributes& aOriginAttributes)
|
||||
nsNullPrincipal::Create(const OriginAttributes& aOriginAttributes)
|
||||
{
|
||||
RefPtr<nsNullPrincipal> nullPrin = new nsNullPrincipal();
|
||||
nsresult rv = nullPrin->Init(aOriginAttributes);
|
||||
@@ -54,7 +54,7 @@ nsNullPrincipal::Create(const PrincipalOriginAttributes& aOriginAttributes)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNullPrincipal::Init(const PrincipalOriginAttributes& aOriginAttributes)
|
||||
nsNullPrincipal::Init(const OriginAttributes& aOriginAttributes)
|
||||
{
|
||||
mOriginAttributes = aOriginAttributes;
|
||||
|
||||
|
||||
@@ -52,9 +52,9 @@ public:
|
||||
|
||||
// Returns null on failure.
|
||||
static already_AddRefed<nsNullPrincipal>
|
||||
Create(const mozilla::PrincipalOriginAttributes& aOriginAttributes = mozilla::PrincipalOriginAttributes());
|
||||
Create(const mozilla::OriginAttributes& aOriginAttributes = mozilla::OriginAttributes());
|
||||
|
||||
nsresult Init(const mozilla::PrincipalOriginAttributes& aOriginAttributes = mozilla::PrincipalOriginAttributes());
|
||||
nsresult Init(const mozilla::OriginAttributes& aOriginAttributes = mozilla::OriginAttributes());
|
||||
|
||||
virtual void GetScriptLocation(nsACString &aStr) override;
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ nsPrincipal::~nsPrincipal()
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPrincipal::Init(nsIURI *aCodebase, const PrincipalOriginAttributes& aOriginAttributes)
|
||||
nsPrincipal::Init(nsIURI *aCodebase, const OriginAttributes& aOriginAttributes)
|
||||
{
|
||||
NS_ENSURE_STATE(!mInitialized);
|
||||
NS_ENSURE_ARG(aCodebase);
|
||||
@@ -391,7 +391,7 @@ nsPrincipal::Read(nsIObjectInputStream* aStream)
|
||||
rv = aStream->ReadCString(suffix);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PrincipalOriginAttributes attrs;
|
||||
OriginAttributes attrs;
|
||||
bool ok = attrs.PopulateFromSuffix(suffix);
|
||||
NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
|
||||
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ public:
|
||||
nsPrincipal();
|
||||
|
||||
// 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 void GetScriptLocation(nsACString& aStr) override;
|
||||
void SetURI(nsIURI* aURI);
|
||||
|
||||
@@ -290,7 +290,7 @@ nsScriptSecurityManager::AppStatusForPrincipal(nsIPrincipal *aPrin)
|
||||
// The app could contain a cross-origin iframe - make sure that the content
|
||||
// is actually same-origin with the app.
|
||||
MOZ_ASSERT(inMozBrowser == false, "Checked this above");
|
||||
PrincipalOriginAttributes attrs(appId, false);
|
||||
OriginAttributes attrs(appId, false);
|
||||
nsCOMPtr<nsIPrincipal> appPrin = BasePrincipal::CreateCodebasePrincipal(appURI, attrs);
|
||||
NS_ENSURE_TRUE(appPrin, nsIPrincipal::APP_STATUS_NOT_INSTALLED);
|
||||
return aPrin->Equals(appPrin) ? status
|
||||
@@ -361,7 +361,7 @@ nsScriptSecurityManager::GetChannelResultPrincipal(nsIChannel* aChannel,
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsScriptSecurityManager::MaybeSetAddonIdFromURI(PrincipalOriginAttributes& aAttrs, nsIURI* aURI)
|
||||
nsScriptSecurityManager::MaybeSetAddonIdFromURI(OriginAttributes& aAttrs, nsIURI* aURI)
|
||||
{
|
||||
nsAutoCString scheme;
|
||||
nsresult rv = aURI->GetScheme(scheme);
|
||||
@@ -404,8 +404,7 @@ nsScriptSecurityManager::GetChannelURIPrincipal(nsIChannel* aChannel,
|
||||
return GetLoadContextCodebasePrincipal(uri, loadContext, aPrincipal);
|
||||
}
|
||||
|
||||
//TODO: Bug 1211590. inherit Origin Attributes from LoadInfo.
|
||||
PrincipalOriginAttributes attrs(UNKNOWN_APP_ID, false);
|
||||
OriginAttributes attrs(UNKNOWN_APP_ID, false);
|
||||
rv = MaybeSetAddonIdFromURI(attrs, uri);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(uri, attrs);
|
||||
@@ -761,6 +760,16 @@ nsScriptSecurityManager::CheckLoadURIWithPrincipal(nsIPrincipal* aPrincipal,
|
||||
// Exception for linking to moz-icon://
|
||||
return NS_OK;
|
||||
}
|
||||
#ifdef MOZ_XULRUNNER
|
||||
else if ((sourceScheme.LowerCaseEqualsLiteral("about") ||
|
||||
sourceScheme.LowerCaseEqualsLiteral("jar") ||
|
||||
sourceScheme.LowerCaseEqualsLiteral("file")) &&
|
||||
targetScheme.LowerCaseEqualsLiteral("chrome"))
|
||||
{
|
||||
// Exception for linking from about:, jar:, and file:// to chrome:// for XULRunner only
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
// If the schemes don't match, the policy is specified by the protocol
|
||||
// flags on the target URI. Note that the order of policy checks here is
|
||||
@@ -1018,7 +1027,7 @@ NS_IMETHODIMP
|
||||
nsScriptSecurityManager::GetSimpleCodebasePrincipal(nsIURI* aURI,
|
||||
nsIPrincipal** aPrincipal)
|
||||
{
|
||||
PrincipalOriginAttributes attrs(UNKNOWN_APP_ID, false);
|
||||
OriginAttributes attrs(UNKNOWN_APP_ID, false);
|
||||
nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
|
||||
prin.forget(aPrincipal);
|
||||
return *aPrincipal ? NS_OK : NS_ERROR_FAILURE;
|
||||
@@ -1028,7 +1037,7 @@ NS_IMETHODIMP
|
||||
nsScriptSecurityManager::GetNoAppCodebasePrincipal(nsIURI* aURI,
|
||||
nsIPrincipal** aPrincipal)
|
||||
{
|
||||
PrincipalOriginAttributes attrs(NO_APP_ID, false);
|
||||
OriginAttributes attrs(NO_APP_ID, false);
|
||||
nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
|
||||
prin.forget(aPrincipal);
|
||||
return *aPrincipal ? NS_OK : NS_ERROR_FAILURE;
|
||||
@@ -1045,7 +1054,7 @@ NS_IMETHODIMP
|
||||
nsScriptSecurityManager::CreateCodebasePrincipal(nsIURI* aURI, JS::Handle<JS::Value> aOriginAttributes,
|
||||
JSContext* aCx, nsIPrincipal** aPrincipal)
|
||||
{
|
||||
PrincipalOriginAttributes attrs;
|
||||
OriginAttributes attrs;
|
||||
if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
@@ -1058,7 +1067,7 @@ NS_IMETHODIMP
|
||||
nsScriptSecurityManager::CreateNullPrincipal(JS::Handle<JS::Value> aOriginAttributes,
|
||||
JSContext* aCx, nsIPrincipal** aPrincipal)
|
||||
{
|
||||
PrincipalOriginAttributes attrs;
|
||||
OriginAttributes attrs;
|
||||
if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
@@ -1092,7 +1101,7 @@ nsScriptSecurityManager::GetAppCodebasePrincipal(nsIURI* aURI,
|
||||
NS_ENSURE_TRUE(aAppId != nsIScriptSecurityManager::UNKNOWN_APP_ID,
|
||||
NS_ERROR_INVALID_ARG);
|
||||
|
||||
PrincipalOriginAttributes attrs(aAppId, aInMozBrowser);
|
||||
OriginAttributes attrs(aAppId, aInMozBrowser);
|
||||
nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
|
||||
prin.forget(aPrincipal);
|
||||
return *aPrincipal ? NS_OK : NS_ERROR_FAILURE;
|
||||
@@ -1104,13 +1113,10 @@ nsScriptSecurityManager::
|
||||
nsILoadContext* aLoadContext,
|
||||
nsIPrincipal** aPrincipal)
|
||||
{
|
||||
DocShellOriginAttributes docShellAttrs;
|
||||
bool result = aLoadContext->GetOriginAttributes(docShellAttrs);;
|
||||
OriginAttributes attrs;
|
||||
bool result = attrs.CopyFromLoadContext(aLoadContext);
|
||||
NS_ENSURE_TRUE(result, NS_ERROR_FAILURE);
|
||||
|
||||
PrincipalOriginAttributes attrs;
|
||||
attrs.InheritFromDocShellToDoc(docShellAttrs, aURI);
|
||||
|
||||
nsresult rv = MaybeSetAddonIdFromURI(attrs, aURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
|
||||
@@ -1123,8 +1129,10 @@ nsScriptSecurityManager::GetDocShellCodebasePrincipal(nsIURI* aURI,
|
||||
nsIDocShell* aDocShell,
|
||||
nsIPrincipal** aPrincipal)
|
||||
{
|
||||
PrincipalOriginAttributes attrs;
|
||||
attrs.InheritFromDocShellToDoc(nsDocShell::Cast(aDocShell)->GetOriginAttributes(), aURI);
|
||||
OriginAttributes attrs;
|
||||
nsDocShell* docShell= nsDocShell::Cast(aDocShell);
|
||||
bool result = attrs.CopyFromLoadContext(docShell);
|
||||
NS_ENSURE_TRUE(result, NS_ERROR_FAILURE);
|
||||
|
||||
nsresult rv = MaybeSetAddonIdFromURI(attrs, aURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@@ -28,7 +28,7 @@ class nsIStringBundle;
|
||||
class nsSystemPrincipal;
|
||||
|
||||
namespace mozilla {
|
||||
class PrincipalOriginAttributes;
|
||||
class OriginAttributes;
|
||||
} // namespace mozilla
|
||||
|
||||
/////////////////////////////
|
||||
@@ -121,7 +121,7 @@ private:
|
||||
AddSitesToFileURIWhitelist(const nsCString& aSiteList);
|
||||
|
||||
// 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);
|
||||
|
||||
nsCOMPtr<nsIPrincipal> mSystemPrincipal;
|
||||
bool mPrefInitialized;
|
||||
|
||||
@@ -4,34 +4,34 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
|
||||
using mozilla::PrincipalOriginAttributes;
|
||||
using mozilla::OriginAttributes;
|
||||
|
||||
static void
|
||||
TestSuffix(const PrincipalOriginAttributes& attrs)
|
||||
TestSuffix(const OriginAttributes& attrs)
|
||||
{
|
||||
nsAutoCString suffix;
|
||||
attrs.CreateSuffix(suffix);
|
||||
|
||||
PrincipalOriginAttributes attrsFromSuffix;
|
||||
OriginAttributes attrsFromSuffix;
|
||||
attrsFromSuffix.PopulateFromSuffix(suffix);
|
||||
|
||||
EXPECT_EQ(attrs, attrsFromSuffix);
|
||||
}
|
||||
|
||||
TEST(PrincipalOriginAttributes, Suffix_default)
|
||||
TEST(OriginAttributes, Suffix_default)
|
||||
{
|
||||
PrincipalOriginAttributes attrs;
|
||||
OriginAttributes attrs;
|
||||
TestSuffix(attrs);
|
||||
}
|
||||
|
||||
TEST(PrincipalOriginAttributes, Suffix_appId_inBrowser)
|
||||
TEST(OriginAttributes, Suffix_appId_inBrowser)
|
||||
{
|
||||
PrincipalOriginAttributes attrs(1, true);
|
||||
OriginAttributes attrs(1, true);
|
||||
TestSuffix(attrs);
|
||||
}
|
||||
|
||||
TEST(PrincipalOriginAttributes, Suffix_maxAppId_inBrowser)
|
||||
TEST(OriginAttributes, Suffix_maxAppId_inBrowser)
|
||||
{
|
||||
PrincipalOriginAttributes attrs(4294967295, true);
|
||||
OriginAttributes attrs(4294967295, true);
|
||||
TestSuffix(attrs);
|
||||
}
|
||||
|
||||
@@ -23,8 +23,7 @@ LoadContext::LoadContext(nsIPrincipal* aPrincipal,
|
||||
, mIsNotNull(true)
|
||||
#endif
|
||||
{
|
||||
PrincipalOriginAttributes poa = BasePrincipal::Cast(aPrincipal)->OriginAttributesRef();
|
||||
mOriginAttributes = DocShellOriginAttributes(poa.mAppId, poa.mInBrowser);
|
||||
mOriginAttributes = BasePrincipal::Cast(aPrincipal)->OriginAttributesRef();
|
||||
|
||||
if (!aOptionalBase) {
|
||||
return;
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
// by child process.
|
||||
LoadContext(const IPC::SerializedLoadContext& aToCopy,
|
||||
dom::Element* aTopFrameElement,
|
||||
DocShellOriginAttributes& aAttrs)
|
||||
OriginAttributes& aAttrs)
|
||||
: mTopFrameElement(do_GetWeakReference(aTopFrameElement))
|
||||
, mNestedFrameId(0)
|
||||
, mIsContent(aToCopy.mIsContent)
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
// by child process.
|
||||
LoadContext(const IPC::SerializedLoadContext& aToCopy,
|
||||
uint64_t aNestedFrameId,
|
||||
DocShellOriginAttributes& aAttrs)
|
||||
OriginAttributes& aAttrs)
|
||||
: mTopFrameElement(nullptr)
|
||||
, mNestedFrameId(aNestedFrameId)
|
||||
, mIsContent(aToCopy.mIsContent)
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
bool aIsContent,
|
||||
bool aUsePrivateBrowsing,
|
||||
bool aUseRemoteTabs,
|
||||
const DocShellOriginAttributes& aAttrs)
|
||||
const OriginAttributes& aAttrs)
|
||||
: mTopFrameElement(do_GetWeakReference(aTopFrameElement))
|
||||
, mNestedFrameId(0)
|
||||
, mIsContent(aIsContent)
|
||||
@@ -117,7 +117,7 @@ private:
|
||||
bool mIsContent;
|
||||
bool mUsePrivateBrowsing;
|
||||
bool mUseRemoteTabs;
|
||||
DocShellOriginAttributes mOriginAttributes;
|
||||
OriginAttributes mOriginAttributes;
|
||||
#ifdef DEBUG
|
||||
bool mIsNotNull;
|
||||
#endif
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
bool mIsContent;
|
||||
bool mUsePrivateBrowsing;
|
||||
bool mUseRemoteTabs;
|
||||
mozilla::DocShellOriginAttributes mOriginAttributes;
|
||||
mozilla::OriginAttributes mOriginAttributes;
|
||||
};
|
||||
|
||||
// Function to serialize over IPDL
|
||||
|
||||
@@ -9446,8 +9446,7 @@ nsresult
|
||||
nsDocShell::CreatePrincipalFromReferrer(nsIURI* aReferrer,
|
||||
nsIPrincipal** aResult)
|
||||
{
|
||||
PrincipalOriginAttributes attrs;
|
||||
attrs.InheritFromDocShellToDoc(GetOriginAttributes(), aReferrer);
|
||||
OriginAttributes attrs = GetOriginAttributes();
|
||||
nsCOMPtr<nsIPrincipal> prin =
|
||||
BasePrincipal::CreateCodebasePrincipal(aReferrer, attrs);
|
||||
prin.forget(aResult);
|
||||
@@ -13891,19 +13890,13 @@ nsDocShell::GetAppId(uint32_t* aAppId)
|
||||
return parent->GetAppId(aAppId);
|
||||
}
|
||||
|
||||
DocShellOriginAttributes
|
||||
OriginAttributes
|
||||
nsDocShell::GetOriginAttributes()
|
||||
{
|
||||
DocShellOriginAttributes attrs;
|
||||
OriginAttributes attrs;
|
||||
RefPtr<nsDocShell> parent = GetParentDocshell();
|
||||
if (parent) {
|
||||
nsCOMPtr<nsIPrincipal> parentPrin = parent->GetDocument()->NodePrincipal();
|
||||
PrincipalOriginAttributes poa = BasePrincipal::Cast(parentPrin)->OriginAttributesRef();
|
||||
attrs.InheritFromDocToChildDocShell(poa);
|
||||
} else {
|
||||
// This is the topmost docshell, so we get the mSignedPkg attribute if it is
|
||||
// set before.
|
||||
attrs.mSignedPkg = mSignedPkg;
|
||||
attrs.InheritFromDocShellParent(parent->GetOriginAttributes());
|
||||
}
|
||||
|
||||
if (mOwnOrContainingAppId != nsIScriptSecurityManager::UNKNOWN_APP_ID) {
|
||||
@@ -13914,6 +13907,9 @@ nsDocShell::GetOriginAttributes()
|
||||
attrs.mInBrowser = true;
|
||||
}
|
||||
|
||||
// Bug 1209162 will address the inheritance of each attributes.
|
||||
attrs.mSignedPkg = mSignedPkg;
|
||||
|
||||
return attrs;
|
||||
}
|
||||
|
||||
@@ -13923,7 +13919,8 @@ nsDocShell::GetOriginAttributes(JS::MutableHandle<JS::Value> aVal)
|
||||
JSContext* cx = nsContentUtils::GetCurrentJSContext();
|
||||
MOZ_ASSERT(cx);
|
||||
|
||||
bool ok = ToJSValue(cx, GetOriginAttributes(), aVal);
|
||||
OriginAttributes attrs = GetOriginAttributes();
|
||||
bool ok = ToJSValue(cx, attrs, aVal);
|
||||
NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -14122,8 +14119,7 @@ nsDocShell::ShouldPrepareForIntercept(nsIURI* aURI, bool aIsNonSubresourceReques
|
||||
}
|
||||
|
||||
if (aIsNonSubresourceRequest) {
|
||||
PrincipalOriginAttributes attrs;
|
||||
attrs.InheritFromDocShellToDoc(GetOriginAttributes(), aURI);
|
||||
OriginAttributes attrs(GetAppId(), GetIsInBrowserElement());
|
||||
*aShouldIntercept = swm->IsAvailable(attrs, aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -14219,12 +14215,7 @@ nsDocShell::ChannelIntercepted(nsIInterceptedChannel* aChannel,
|
||||
|
||||
bool isReload = mLoadType & LOAD_CMD_RELOAD;
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = channel->GetURI(getter_AddRefs(uri));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PrincipalOriginAttributes attrs;
|
||||
attrs.InheritFromDocShellToDoc(GetOriginAttributes(), uri);
|
||||
OriginAttributes attrs(GetAppId(), GetIsInBrowserElement());
|
||||
|
||||
ErrorResult error;
|
||||
nsCOMPtr<nsIRunnable> runnable =
|
||||
|
||||
@@ -274,7 +274,7 @@ public:
|
||||
}
|
||||
bool InFrameSwap();
|
||||
|
||||
mozilla::DocShellOriginAttributes GetOriginAttributes();
|
||||
mozilla::OriginAttributes GetOriginAttributes();
|
||||
|
||||
void GetInterceptedDocumentId(nsAString& aId)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ interface nsIDOMElement;
|
||||
|
||||
%{C++
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
#include "mozilla/BasePrincipal.h" // for DocShellOriginAttributes
|
||||
#include "mozilla/BasePrincipal.h" // for OriginAttributes
|
||||
#include "mozilla/dom/ScriptSettings.h" // for AutoJSAPI
|
||||
#include "xpcpublic.h" // for PrivilegedJunkScope
|
||||
#include "nsContentUtils.h" // for IsSystemPrincipal
|
||||
@@ -140,7 +140,7 @@ interface nsILoadContext : nsISupports
|
||||
/**
|
||||
* The C++ getter for origin attributes.
|
||||
*/
|
||||
bool GetOriginAttributes(mozilla::DocShellOriginAttributes& aAttrs)
|
||||
bool GetOriginAttributes(mozilla::OriginAttributes& aAttrs)
|
||||
{
|
||||
mozilla::dom::AutoJSAPI jsapi;
|
||||
bool ok = jsapi.Init(xpc::PrivilegedJunkScope());
|
||||
@@ -156,13 +156,12 @@ interface nsILoadContext : nsISupports
|
||||
MOZ_ASSERT(nsContentUtils::IsSystemPrincipal(nsContentUtils::ObjectPrincipal(obj)));
|
||||
JSAutoCompartment ac(jsapi.cx(), obj);
|
||||
|
||||
mozilla::DocShellOriginAttributes attrs;
|
||||
mozilla::OriginAttributes attrs;
|
||||
ok = attrs.Init(jsapi.cx(), v);
|
||||
NS_ENSURE_TRUE(ok, false);
|
||||
aAttrs = attrs;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
%}
|
||||
};
|
||||
|
||||
@@ -56,7 +56,7 @@ ChromeUtils::OriginAttributesToSuffix(dom::GlobalObject& aGlobal,
|
||||
nsCString& aSuffix)
|
||||
|
||||
{
|
||||
GenericOriginAttributes attrs(aAttrs);
|
||||
OriginAttributes attrs(aAttrs);
|
||||
attrs.CreateSuffix(aSuffix);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ ChromeUtils::OriginAttributesMatchPattern(dom::GlobalObject& aGlobal,
|
||||
const dom::OriginAttributesDictionary& aAttrs,
|
||||
const dom::OriginAttributesPatternDictionary& aPattern)
|
||||
{
|
||||
GenericOriginAttributes attrs(aAttrs);
|
||||
OriginAttributes attrs(aAttrs);
|
||||
OriginAttributesPattern pattern(aPattern);
|
||||
return pattern.Matches(attrs);
|
||||
}
|
||||
|
||||
+14
-13
@@ -280,10 +280,18 @@ nsFrameLoader::LoadURI(nsIURI* aURI)
|
||||
NS_IMETHODIMP
|
||||
nsFrameLoader::SwitchProcessAndLoadURI(nsIURI* aURI, const nsACString& aPackageId)
|
||||
{
|
||||
nsCOMPtr<nsIURI> URIToLoad = aURI;
|
||||
RefPtr<TabParent> tp = nullptr;
|
||||
|
||||
nsCString signedPkgOrigin;
|
||||
if (!aPackageId.IsEmpty()) {
|
||||
// Only when aPackageId is not empty would signed package origin
|
||||
// be meaningful.
|
||||
nsPrincipal::GetOriginForURI(aURI, signedPkgOrigin);
|
||||
}
|
||||
|
||||
MutableTabContext context;
|
||||
nsresult rv = GetNewTabContext(&context, aURI, aPackageId);
|
||||
nsresult rv = GetNewTabContext(&context, signedPkgOrigin, aPackageId);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<Element> ownerElement = mOwnerContent;
|
||||
@@ -297,7 +305,7 @@ nsFrameLoader::SwitchProcessAndLoadURI(nsIURI* aURI, const nsACString& aPackageI
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
LoadURI(aURI);
|
||||
LoadURI(URIToLoad);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -3007,21 +3015,14 @@ nsFrameLoader::MaybeUpdatePrimaryTabParent(TabParentChange aChange)
|
||||
|
||||
nsresult
|
||||
nsFrameLoader::GetNewTabContext(MutableTabContext* aTabContext,
|
||||
nsIURI* aURI,
|
||||
const nsACString& aSignedPkgOriginNoSuffix,
|
||||
const nsACString& aPackageId)
|
||||
{
|
||||
nsCOMPtr<mozIApplication> ownApp = GetOwnApp();
|
||||
nsCOMPtr<mozIApplication> containingApp = GetContainingApp();
|
||||
DocShellOriginAttributes attrs;
|
||||
OriginAttributes attrs = OriginAttributes();
|
||||
attrs.mInBrowser = OwnerIsBrowserFrame();
|
||||
|
||||
nsCString signedPkgOrigin;
|
||||
if (!aPackageId.IsEmpty()) {
|
||||
// Only when aPackageId is not empty would signed package origin
|
||||
// be meaningful.
|
||||
nsPrincipal::GetOriginForURI(aURI, signedPkgOrigin);
|
||||
}
|
||||
|
||||
// Get the AppId from ownApp
|
||||
uint32_t appId = nsIScriptSecurityManager::NO_APP_ID;
|
||||
if (ownApp) {
|
||||
@@ -3038,8 +3039,8 @@ nsFrameLoader::GetNewTabContext(MutableTabContext* aTabContext,
|
||||
// Populate packageId to signedPkg.
|
||||
attrs.mSignedPkg = NS_ConvertUTF8toUTF16(aPackageId);
|
||||
|
||||
bool tabContextUpdated =
|
||||
aTabContext->SetTabContext(ownApp, containingApp, attrs, signedPkgOrigin);
|
||||
bool tabContextUpdated = aTabContext->SetTabContext(ownApp, containingApp,
|
||||
attrs, aSignedPkgOriginNoSuffix);
|
||||
NS_ENSURE_STATE(tabContextUpdated);
|
||||
|
||||
return NS_OK;
|
||||
|
||||
@@ -317,7 +317,7 @@ private:
|
||||
void InitializeBrowserAPI();
|
||||
|
||||
nsresult GetNewTabContext(mozilla::dom::MutableTabContext* aTabContext,
|
||||
nsIURI* aURI = nullptr,
|
||||
const nsACString& aSignedPkgNoSuffix = EmptyCString(),
|
||||
const nsACString& aPackageId = EmptyCString());
|
||||
|
||||
enum TabParentChange {
|
||||
|
||||
@@ -263,7 +263,7 @@ using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::dom::ipc;
|
||||
using mozilla::BasePrincipal;
|
||||
using mozilla::PrincipalOriginAttributes;
|
||||
using mozilla::OriginAttributes;
|
||||
using mozilla::TimeStamp;
|
||||
using mozilla::TimeDuration;
|
||||
using mozilla::dom::cache::CacheStorage;
|
||||
@@ -8364,7 +8364,7 @@ nsGlobalWindow::PostMessageMozOuter(JSContext* aCx, JS::Handle<JS::Value> aMessa
|
||||
nsCOMPtr<nsIPrincipal> principal = nsContentUtils::SubjectPrincipal();
|
||||
MOZ_ASSERT(principal);
|
||||
|
||||
PrincipalOriginAttributes attrs = BasePrincipal::Cast(principal)->OriginAttributesRef();
|
||||
OriginAttributes attrs = BasePrincipal::Cast(principal)->OriginAttributesRef();
|
||||
// Create a nsIPrincipal inheriting the app/browser attributes from the
|
||||
// caller.
|
||||
providedPrincipal = BasePrincipal::CreateCodebasePrincipal(originURI, attrs);
|
||||
|
||||
Vendored
+1
-1
@@ -1933,7 +1933,7 @@ ReadResponse(mozIStorageConnection* aConn, EntryId aEntryId,
|
||||
aSavedResponseOut->mValue.principalInfo() = void_t();
|
||||
if (!serializedInfo.IsEmpty()) {
|
||||
nsAutoCString originNoSuffix;
|
||||
PrincipalOriginAttributes attrs;
|
||||
OriginAttributes attrs;
|
||||
if (!attrs.PopulateFromOrigin(serializedInfo, originNoSuffix)) {
|
||||
NS_WARNING("Something went wrong parsing a serialized principal!");
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
}
|
||||
|
||||
using mozilla::BasePrincipal;
|
||||
using mozilla::PrincipalOriginAttributes;
|
||||
using mozilla::OriginAttributes;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@@ -211,7 +211,7 @@ ResetPermission(uint32_t aAppId, const nsAString& aOriginURL,
|
||||
return rv;
|
||||
}
|
||||
|
||||
PrincipalOriginAttributes attrs(aAppId, false);
|
||||
OriginAttributes attrs(aAppId, false);
|
||||
nsCOMPtr<nsIPrincipal> principal =
|
||||
BasePrincipal::CreateCodebasePrincipal(uri, attrs);
|
||||
NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE);
|
||||
|
||||
@@ -154,7 +154,7 @@ AssertAppProcess(TabContext& aContext,
|
||||
AssertAppProcessType aType,
|
||||
const char* aCapability)
|
||||
{
|
||||
const mozilla::DocShellOriginAttributes& attr = aContext.OriginAttributesRef();
|
||||
const mozilla::OriginAttributes& attr = aContext.OriginAttributesRef();
|
||||
nsCString suffix;
|
||||
attr.CreateSuffix(suffix);
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ TabContext::SetTabContext(const TabContext& aContext)
|
||||
return true;
|
||||
}
|
||||
|
||||
const DocShellOriginAttributes&
|
||||
const OriginAttributes&
|
||||
TabContext::OriginAttributesRef() const
|
||||
{
|
||||
return mOriginAttributes;
|
||||
@@ -167,7 +167,7 @@ TabContext::SignedPkgOriginNoSuffix() const
|
||||
bool
|
||||
TabContext::SetTabContext(mozIApplication* aOwnApp,
|
||||
mozIApplication* aAppFrameOwnerApp,
|
||||
const DocShellOriginAttributes& aOriginAttributes,
|
||||
const OriginAttributes& aOriginAttributes,
|
||||
const nsACString& aSignedPkgOriginNoSuffix)
|
||||
{
|
||||
NS_ENSURE_FALSE(mInitialized, false);
|
||||
@@ -228,7 +228,7 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
|
||||
: mInvalidReason(nullptr)
|
||||
{
|
||||
uint32_t containingAppId = NO_APP_ID;
|
||||
DocShellOriginAttributes originAttributes;
|
||||
OriginAttributes originAttributes = OriginAttributes();
|
||||
nsAutoCString originSuffix;
|
||||
nsAutoCString signedPkgOriginNoSuffix;
|
||||
|
||||
@@ -269,6 +269,9 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
|
||||
//
|
||||
// Otherwise, we're a new app window and we inherit from our
|
||||
// opener app.
|
||||
|
||||
// FIXME bug 1212250 - use InheritFromDocToChildDocshell instead
|
||||
// of copying attributes directly.
|
||||
originAttributes = context->mOriginAttributes;
|
||||
if (ipcContext.isBrowserElement()) {
|
||||
containingAppId = context->OwnOrContainingAppId();
|
||||
|
||||
@@ -104,11 +104,11 @@ public:
|
||||
bool HasOwnOrContainingApp() const;
|
||||
|
||||
/**
|
||||
* OriginAttributesRef() returns the DocShellOriginAttributes of this frame to the
|
||||
* OriginAttributesRef() returns the OriginAttributes of this frame to the
|
||||
* caller. This is used to store any attribute associated with the frame's
|
||||
* docshell, such as the AppId.
|
||||
*/
|
||||
const DocShellOriginAttributes& OriginAttributesRef() const;
|
||||
const OriginAttributes& OriginAttributesRef() const;
|
||||
|
||||
/**
|
||||
* Returns the origin associated with the tab (w/o suffix) if this tab owns
|
||||
@@ -142,7 +142,7 @@ protected:
|
||||
*/
|
||||
bool SetTabContext(mozIApplication* aOwnApp,
|
||||
mozIApplication* aAppFrameOwnerApp,
|
||||
const DocShellOriginAttributes& aOriginAttributes,
|
||||
const OriginAttributes& aOriginAttributes,
|
||||
const nsACString& aSignedPkgOriginNoSuffix);
|
||||
|
||||
private:
|
||||
@@ -170,9 +170,9 @@ private:
|
||||
uint32_t mContainingAppId;
|
||||
|
||||
/**
|
||||
* DocShellOriginAttributes of the top level tab docShell
|
||||
* OriginAttributes of the top level tab docShell
|
||||
*/
|
||||
DocShellOriginAttributes mOriginAttributes;
|
||||
OriginAttributes mOriginAttributes;
|
||||
|
||||
/**
|
||||
* The signed package origin without suffix. Since the signed packaged
|
||||
@@ -198,7 +198,7 @@ public:
|
||||
|
||||
bool SetTabContext(mozIApplication* aOwnApp,
|
||||
mozIApplication* aAppFrameOwnerApp,
|
||||
const DocShellOriginAttributes& aOriginAttributes,
|
||||
const OriginAttributes& aOriginAttributes,
|
||||
const nsACString& aSignedPkgOriginNoSuffix = EmptyCString())
|
||||
{
|
||||
return TabContext::SetTabContext(aOwnApp,
|
||||
|
||||
@@ -5261,7 +5261,7 @@ StorageDirectoryHelper::RunOnMainThread()
|
||||
rv = secMan->GetSimpleCodebasePrincipal(uri,
|
||||
getter_AddRefs(principal));
|
||||
} else {
|
||||
PrincipalOriginAttributes attrs(originProps.mAppId, originProps.mInMozBrowser);
|
||||
OriginAttributes attrs(originProps.mAppId, originProps.mInMozBrowser);
|
||||
principal = BasePrincipal::CreateCodebasePrincipal(uri, attrs);
|
||||
rv = principal ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ interface ChromeUtils : ThreadSafeChromeUtils {
|
||||
* IMPORTANT: If you add any members here, you need to do the following:
|
||||
* (1) Add them to both dictionaries.
|
||||
* (2) Update the methods on mozilla::OriginAttributes, including equality,
|
||||
* serialization, deserialization, and inheritance.
|
||||
* serialization, and deserialization.
|
||||
* (3) Update the methods on mozilla::OriginAttributesPattern, including matching.
|
||||
*/
|
||||
dictionary OriginAttributesDictionary {
|
||||
|
||||
@@ -7,7 +7,7 @@ include protocol PBackground;
|
||||
include PBackgroundSharedTypes;
|
||||
include ServiceWorkerRegistrarTypes;
|
||||
|
||||
using mozilla::PrincipalOriginAttributes from "mozilla/ipc/BackgroundUtils.h";
|
||||
using mozilla::OriginAttributes from "mozilla/ipc/BackgroundUtils.h";
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@@ -21,7 +21,7 @@ parent:
|
||||
|
||||
Unregister(PrincipalInfo principalInfo, nsString scope);
|
||||
|
||||
PropagateSoftUpdate(PrincipalOriginAttributes originAttributes,
|
||||
PropagateSoftUpdate(OriginAttributes originAttributes,
|
||||
nsString scope);
|
||||
PropagateUnregister(PrincipalInfo principalInfo, nsString scope);
|
||||
|
||||
@@ -33,7 +33,7 @@ parent:
|
||||
|
||||
child:
|
||||
NotifyRegister(ServiceWorkerRegistrationData data);
|
||||
NotifySoftUpdate(PrincipalOriginAttributes originAttributes, nsString scope);
|
||||
NotifySoftUpdate(OriginAttributes originAttributes, nsString scope);
|
||||
NotifyUnregister(PrincipalInfo principalInfo, nsString scope);
|
||||
NotifyRemove(nsCString host);
|
||||
NotifyRemoveAll();
|
||||
|
||||
@@ -779,7 +779,7 @@ GetRequiredScopeStringPrefix(nsIURI* aScriptURI, nsACString& aPrefix,
|
||||
class PropagateSoftUpdateRunnable final : public nsRunnable
|
||||
{
|
||||
public:
|
||||
PropagateSoftUpdateRunnable(const PrincipalOriginAttributes& aOriginAttributes,
|
||||
PropagateSoftUpdateRunnable(const OriginAttributes& aOriginAttributes,
|
||||
const nsAString& aScope)
|
||||
: mOriginAttributes(aOriginAttributes)
|
||||
, mScope(aScope)
|
||||
@@ -800,7 +800,7 @@ private:
|
||||
~PropagateSoftUpdateRunnable()
|
||||
{}
|
||||
|
||||
const PrincipalOriginAttributes mOriginAttributes;
|
||||
const OriginAttributes mOriginAttributes;
|
||||
const nsString mScope;
|
||||
};
|
||||
|
||||
@@ -2056,7 +2056,7 @@ ServiceWorkerManager::SendPushEvent(const nsACString& aOriginAttributes,
|
||||
#ifdef MOZ_SIMPLEPUSH
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
#else
|
||||
PrincipalOriginAttributes attrs;
|
||||
OriginAttributes attrs;
|
||||
if (!attrs.PopulateFromSuffix(aOriginAttributes)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
@@ -2089,7 +2089,7 @@ ServiceWorkerManager::SendPushSubscriptionChangeEvent(const nsACString& aOriginA
|
||||
#ifdef MOZ_SIMPLEPUSH
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
#else
|
||||
PrincipalOriginAttributes attrs;
|
||||
OriginAttributes attrs;
|
||||
if (!attrs.PopulateFromSuffix(aOriginAttributes)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
@@ -2115,7 +2115,7 @@ ServiceWorkerManager::SendNotificationClickEvent(const nsACString& aOriginSuffix
|
||||
const nsAString& aData,
|
||||
const nsAString& aBehavior)
|
||||
{
|
||||
PrincipalOriginAttributes attrs;
|
||||
OriginAttributes attrs;
|
||||
if (!attrs.PopulateFromSuffix(aOriginSuffix)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
@@ -2239,8 +2239,8 @@ ServiceWorkerManager::CheckReadyPromise(nsPIDOMWindow* aWindow,
|
||||
}
|
||||
|
||||
ServiceWorkerInfo*
|
||||
ServiceWorkerManager::GetActiveWorkerInfoForScope(const PrincipalOriginAttributes& aOriginAttributes,
|
||||
const nsACString& aScope)
|
||||
ServiceWorkerManager::GetActiveWorkerInfoForScope(const OriginAttributes& aOriginAttributes,
|
||||
const nsACString& aScope)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
|
||||
@@ -2846,7 +2846,7 @@ ServiceWorkerManager::GetServiceWorkerRegistrationInfo(nsIPrincipal* aPrincipal,
|
||||
}
|
||||
|
||||
already_AddRefed<ServiceWorkerRegistrationInfo>
|
||||
ServiceWorkerManager::GetServiceWorkerRegistrationInfo(const PrincipalOriginAttributes& aOriginAttributes,
|
||||
ServiceWorkerManager::GetServiceWorkerRegistrationInfo(const OriginAttributes& aOriginAttributes,
|
||||
nsIURI* aURI)
|
||||
{
|
||||
MOZ_ASSERT(aURI);
|
||||
@@ -3335,7 +3335,7 @@ public:
|
||||
} // anonymous namespace
|
||||
|
||||
already_AddRefed<nsIRunnable>
|
||||
ServiceWorkerManager::PrepareFetchEvent(const PrincipalOriginAttributes& aOriginAttributes,
|
||||
ServiceWorkerManager::PrepareFetchEvent(const OriginAttributes& aOriginAttributes,
|
||||
nsIDocument* aDoc,
|
||||
const nsAString& aDocumentIdForTopLevelNavigation,
|
||||
nsIInterceptedChannel* aChannel,
|
||||
@@ -3430,7 +3430,7 @@ ServiceWorkerManager::DispatchPreparedFetchEvent(nsIInterceptedChannel* aChannel
|
||||
}
|
||||
|
||||
bool
|
||||
ServiceWorkerManager::IsAvailable(const PrincipalOriginAttributes& aOriginAttributes,
|
||||
ServiceWorkerManager::IsAvailable(const OriginAttributes& aOriginAttributes,
|
||||
nsIURI* aURI)
|
||||
{
|
||||
MOZ_ASSERT(aURI);
|
||||
@@ -4209,7 +4209,7 @@ ServiceWorkerManager::PropagateRemoveAll()
|
||||
}
|
||||
|
||||
void
|
||||
ServiceWorkerManager::RemoveAllRegistrations(PrincipalOriginAttributes* aParams)
|
||||
ServiceWorkerManager::RemoveAllRegistrations(OriginAttributes* aParams)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
|
||||
@@ -4442,7 +4442,7 @@ ServiceWorkerManager::Observe(nsISupports* aSubject,
|
||||
|
||||
if (strcmp(aTopic, CLEAR_ORIGIN_DATA) == 0) {
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
PrincipalOriginAttributes attrs;
|
||||
OriginAttributes attrs;
|
||||
MOZ_ALWAYS_TRUE(attrs.Init(nsAutoString(aData)));
|
||||
|
||||
RemoveAllRegistrations(&attrs);
|
||||
@@ -4485,7 +4485,7 @@ ServiceWorkerManager::PropagateSoftUpdate(JS::Handle<JS::Value> aOriginAttribute
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
|
||||
PrincipalOriginAttributes attrs;
|
||||
OriginAttributes attrs;
|
||||
if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
@@ -4495,7 +4495,7 @@ ServiceWorkerManager::PropagateSoftUpdate(JS::Handle<JS::Value> aOriginAttribute
|
||||
}
|
||||
|
||||
void
|
||||
ServiceWorkerManager::PropagateSoftUpdate(const PrincipalOriginAttributes& aOriginAttributes,
|
||||
ServiceWorkerManager::PropagateSoftUpdate(const OriginAttributes& aOriginAttributes,
|
||||
const nsAString& aScope)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
|
||||
@@ -36,7 +36,7 @@ class mozIApplicationClearPrivateDataParams;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class PrincipalOriginAttributes;
|
||||
class OriginAttributes;
|
||||
|
||||
namespace dom {
|
||||
|
||||
@@ -353,13 +353,13 @@ public:
|
||||
nsClassHashtable<nsCStringHashKey, InterceptionList> mNavigationInterceptions;
|
||||
|
||||
bool
|
||||
IsAvailable(const PrincipalOriginAttributes& aOriginAttributes, nsIURI* aURI);
|
||||
IsAvailable(const OriginAttributes& aOriginAttributes, nsIURI* aURI);
|
||||
|
||||
bool
|
||||
IsControlled(nsIDocument* aDocument, ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<nsIRunnable>
|
||||
PrepareFetchEvent(const PrincipalOriginAttributes& aOriginAttributes,
|
||||
PrepareFetchEvent(const OriginAttributes& aOriginAttributes,
|
||||
nsIDocument* aDoc,
|
||||
const nsAString& aDocumentIdForTopLevelNavigation,
|
||||
nsIInterceptedChannel* aChannel,
|
||||
@@ -382,7 +382,7 @@ public:
|
||||
const nsACString& aScope);
|
||||
|
||||
void
|
||||
PropagateSoftUpdate(const PrincipalOriginAttributes& aOriginAttributes,
|
||||
PropagateSoftUpdate(const OriginAttributes& aOriginAttributes,
|
||||
const nsAString& aScope);
|
||||
|
||||
void
|
||||
@@ -515,7 +515,7 @@ private:
|
||||
nsISupports** aServiceWorker);
|
||||
|
||||
ServiceWorkerInfo*
|
||||
GetActiveWorkerInfoForScope(const PrincipalOriginAttributes& aOriginAttributes,
|
||||
GetActiveWorkerInfoForScope(const OriginAttributes& aOriginAttributes,
|
||||
const nsACString& aScope);
|
||||
|
||||
ServiceWorkerInfo*
|
||||
@@ -546,7 +546,7 @@ private:
|
||||
GetServiceWorkerRegistrationInfo(nsIPrincipal* aPrincipal, nsIURI* aURI);
|
||||
|
||||
already_AddRefed<ServiceWorkerRegistrationInfo>
|
||||
GetServiceWorkerRegistrationInfo(const PrincipalOriginAttributes& aOriginAttributes,
|
||||
GetServiceWorkerRegistrationInfo(const OriginAttributes& aOriginAttributes,
|
||||
nsIURI* aURI);
|
||||
|
||||
already_AddRefed<ServiceWorkerRegistrationInfo>
|
||||
@@ -629,7 +629,7 @@ private:
|
||||
// Removes all service worker registrations that matches the given
|
||||
// mozIApplicationClearPrivateDataParams.
|
||||
void
|
||||
RemoveAllRegistrations(PrincipalOriginAttributes* aParams);
|
||||
RemoveAllRegistrations(OriginAttributes* aParams);
|
||||
|
||||
RefPtr<ServiceWorkerManagerChild> mActor;
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ ServiceWorkerManagerChild::RecvNotifyRegister(
|
||||
|
||||
bool
|
||||
ServiceWorkerManagerChild::RecvNotifySoftUpdate(
|
||||
const PrincipalOriginAttributes& aOriginAttributes,
|
||||
const OriginAttributes& aOriginAttributes,
|
||||
const nsString& aScope)
|
||||
{
|
||||
if (mShuttingDown) {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class PrincipalOriginAttributes;
|
||||
class OriginAttributes;
|
||||
|
||||
namespace ipc {
|
||||
class BackgroundChildImpl;
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
virtual bool RecvNotifyRegister(const ServiceWorkerRegistrationData& aData)
|
||||
override;
|
||||
|
||||
virtual bool RecvNotifySoftUpdate(const PrincipalOriginAttributes& aOriginAttributes,
|
||||
virtual bool RecvNotifySoftUpdate(const OriginAttributes& aOriginAttributes,
|
||||
const nsString& aScope) override;
|
||||
|
||||
virtual bool RecvNotifyUnregister(const PrincipalInfo& aPrincipalInfo,
|
||||
|
||||
@@ -232,7 +232,7 @@ ServiceWorkerManagerParent::RecvUnregister(const PrincipalInfo& aPrincipalInfo,
|
||||
}
|
||||
|
||||
bool
|
||||
ServiceWorkerManagerParent::RecvPropagateSoftUpdate(const PrincipalOriginAttributes& aOriginAttributes,
|
||||
ServiceWorkerManagerParent::RecvPropagateSoftUpdate(const OriginAttributes& aOriginAttributes,
|
||||
const nsString& aScope)
|
||||
{
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class PrincipalOriginAttributes;
|
||||
class OriginAttributes;
|
||||
|
||||
namespace ipc {
|
||||
class BackgroundParentImpl;
|
||||
@@ -42,7 +42,7 @@ private:
|
||||
virtual bool RecvUnregister(const PrincipalInfo& aPrincipalInfo,
|
||||
const nsString& aScope) override;
|
||||
|
||||
virtual bool RecvPropagateSoftUpdate(const PrincipalOriginAttributes& aOriginAttributes,
|
||||
virtual bool RecvPropagateSoftUpdate(const OriginAttributes& aOriginAttributes,
|
||||
const nsString& aScope) override;
|
||||
|
||||
virtual bool RecvPropagateUnregister(const PrincipalInfo& aPrincipalInfo,
|
||||
|
||||
@@ -111,7 +111,7 @@ ServiceWorkerManagerService::PropagateRegistration(
|
||||
void
|
||||
ServiceWorkerManagerService::PropagateSoftUpdate(
|
||||
uint64_t aParentID,
|
||||
const PrincipalOriginAttributes& aOriginAttributes,
|
||||
const OriginAttributes& aOriginAttributes,
|
||||
const nsAString& aScope)
|
||||
{
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class PrincipalOriginAttributes;
|
||||
class OriginAttributes;
|
||||
|
||||
namespace ipc {
|
||||
class PrincipalInfo;
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
ServiceWorkerRegistrationData& aData);
|
||||
|
||||
void PropagateSoftUpdate(uint64_t aParentID,
|
||||
const PrincipalOriginAttributes& aOriginAttributes,
|
||||
const OriginAttributes& aOriginAttributes,
|
||||
const nsAString& aScope);
|
||||
|
||||
void PropagateUnregister(uint64_t aParentID,
|
||||
|
||||
@@ -230,7 +230,7 @@ public:
|
||||
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
||||
MOZ_ASSERT(swm);
|
||||
|
||||
PrincipalOriginAttributes attrs =
|
||||
OriginAttributes attrs =
|
||||
mozilla::BasePrincipal::Cast(mRegistration->mPrincipal)->OriginAttributesRef();
|
||||
|
||||
swm->PropagateSoftUpdate(attrs,
|
||||
|
||||
@@ -326,7 +326,7 @@ ServiceWorkerRegistrar::ReadData()
|
||||
nsAutoCString suffix;
|
||||
GET_LINE(suffix);
|
||||
|
||||
PrincipalOriginAttributes attrs;
|
||||
OriginAttributes attrs;
|
||||
if (!attrs.PopulateFromSuffix(suffix)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ TEST(ServiceWorkerRegistrar, TestWriteData)
|
||||
|
||||
nsAutoCString spec;
|
||||
spec.AppendPrintf("spec write %d", i);
|
||||
d->principal() = mozilla::ipc::ContentPrincipalInfo(mozilla::PrincipalOriginAttributes(i, i % 2), spec);
|
||||
d->principal() = mozilla::ipc::ContentPrincipalInfo(mozilla::OriginAttributes(i, i % 2), spec);
|
||||
d->scope().AppendPrintf("scope write %d", i);
|
||||
d->scriptSpec().AppendPrintf("scriptSpec write %d", i);
|
||||
d->currentWorkerURL().AppendPrintf("currentWorkerURL write %d", i);
|
||||
@@ -245,7 +245,8 @@ TEST(ServiceWorkerRegistrar, TestWriteData)
|
||||
ASSERT_EQ(data[i].principal().type(), mozilla::ipc::PrincipalInfo::TContentPrincipalInfo);
|
||||
const mozilla::ipc::ContentPrincipalInfo& cInfo = data[i].principal();
|
||||
|
||||
mozilla::PrincipalOriginAttributes attrs(i, i % 2);
|
||||
ASSERT_EQ((uint32_t)i, cInfo.appId());
|
||||
mozilla::OriginAttributes attrs(i, i % 2);
|
||||
nsAutoCString suffix, expectSuffix;
|
||||
attrs.CreateSuffix(expectSuffix);
|
||||
cInfo.attrs().CreateSuffix(suffix);
|
||||
|
||||
@@ -122,7 +122,7 @@ GetPrincipal(const nsACString& aHost, uint32_t aAppId, bool aIsInBrowserElement,
|
||||
}
|
||||
|
||||
// TODO: Bug 1165267 - Use OriginAttributes for nsCookieService
|
||||
mozilla::PrincipalOriginAttributes attrs(aAppId, aIsInBrowserElement);
|
||||
mozilla::OriginAttributes attrs(aAppId, aIsInBrowserElement);
|
||||
nsCOMPtr<nsIPrincipal> principal = mozilla::BasePrincipal::CreateCodebasePrincipal(uri, attrs);
|
||||
NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE);
|
||||
|
||||
|
||||
@@ -16,11 +16,10 @@ class nsIPrincipal;
|
||||
|
||||
namespace IPC {
|
||||
|
||||
namespace detail {
|
||||
template<class ParamType>
|
||||
struct OriginAttributesParamTraits
|
||||
template<>
|
||||
struct ParamTraits<mozilla::OriginAttributes>
|
||||
{
|
||||
typedef ParamType paramType;
|
||||
typedef mozilla::OriginAttributes paramType;
|
||||
|
||||
static void Write(Message* aMsg, const paramType& aParam)
|
||||
{
|
||||
@@ -36,23 +35,6 @@ struct OriginAttributesParamTraits
|
||||
aResult->PopulateFromSuffix(suffix);
|
||||
}
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
template<>
|
||||
struct ParamTraits<mozilla::PrincipalOriginAttributes>
|
||||
: public detail::OriginAttributesParamTraits<mozilla::PrincipalOriginAttributes> {};
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
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";
|
||||
|
||||
namespace mozilla {
|
||||
@@ -10,7 +10,7 @@ namespace ipc {
|
||||
|
||||
struct ContentPrincipalInfo
|
||||
{
|
||||
PrincipalOriginAttributes attrs;
|
||||
OriginAttributes attrs;
|
||||
nsCString spec;
|
||||
};
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace net {
|
||||
|
||||
NS_IMPL_ISUPPORTS(LoadContextInfo, nsILoadContextInfo)
|
||||
|
||||
LoadContextInfo::LoadContextInfo(bool aIsPrivate, bool aIsAnonymous, NeckoOriginAttributes aOriginAttributes)
|
||||
LoadContextInfo::LoadContextInfo(bool aIsPrivate, bool aIsAnonymous, OriginAttributes aOriginAttributes)
|
||||
: mIsPrivate(aIsPrivate)
|
||||
, mIsAnonymous(aIsAnonymous)
|
||||
, mOriginAttributes(aOriginAttributes)
|
||||
@@ -38,7 +38,7 @@ NS_IMETHODIMP LoadContextInfo::GetIsAnonymous(bool *aIsAnonymous)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NeckoOriginAttributes const* LoadContextInfo::OriginAttributesPtr()
|
||||
OriginAttributes const* LoadContextInfo::OriginAttributesPtr()
|
||||
{
|
||||
return &mOriginAttributes;
|
||||
}
|
||||
@@ -58,21 +58,21 @@ NS_IMPL_ISUPPORTS(LoadContextInfoFactory, nsILoadContextInfoFactory)
|
||||
|
||||
NS_IMETHODIMP LoadContextInfoFactory::GetDefault(nsILoadContextInfo * *aDefault)
|
||||
{
|
||||
nsCOMPtr<nsILoadContextInfo> info = GetLoadContextInfo(false, false, NeckoOriginAttributes());
|
||||
nsCOMPtr<nsILoadContextInfo> info = GetLoadContextInfo(false, false, OriginAttributes());
|
||||
info.forget(aDefault);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP LoadContextInfoFactory::GetPrivate(nsILoadContextInfo * *aPrivate)
|
||||
{
|
||||
nsCOMPtr<nsILoadContextInfo> info = GetLoadContextInfo(true, false, NeckoOriginAttributes());
|
||||
nsCOMPtr<nsILoadContextInfo> info = GetLoadContextInfo(true, false, OriginAttributes());
|
||||
info.forget(aPrivate);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP LoadContextInfoFactory::GetAnonymous(nsILoadContextInfo * *aAnonymous)
|
||||
{
|
||||
nsCOMPtr<nsILoadContextInfo> info = GetLoadContextInfo(false, true, NeckoOriginAttributes());
|
||||
nsCOMPtr<nsILoadContextInfo> info = GetLoadContextInfo(false, true, OriginAttributes());
|
||||
info.forget(aAnonymous);
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -81,7 +81,7 @@ NS_IMETHODIMP LoadContextInfoFactory::Custom(bool aPrivate, bool aAnonymous,
|
||||
JS::HandleValue aOriginAttributes, JSContext *cx,
|
||||
nsILoadContextInfo * *_retval)
|
||||
{
|
||||
NeckoOriginAttributes attrs;
|
||||
OriginAttributes attrs;
|
||||
bool status = attrs.Init(cx, aOriginAttributes);
|
||||
NS_ENSURE_TRUE(status, NS_ERROR_FAILURE);
|
||||
|
||||
@@ -122,7 +122,7 @@ GetLoadContextInfo(nsIChannel * aChannel)
|
||||
anon = !!(loadFlags & nsIChannel::LOAD_ANONYMOUS);
|
||||
}
|
||||
|
||||
NeckoOriginAttributes oa;
|
||||
OriginAttributes oa;
|
||||
NS_GetOriginAttributes(aChannel, oa);
|
||||
|
||||
return new LoadContextInfo(pb, anon, oa);
|
||||
@@ -133,17 +133,14 @@ GetLoadContextInfo(nsILoadContext *aLoadContext, bool aIsAnonymous)
|
||||
{
|
||||
if (!aLoadContext) {
|
||||
return new LoadContextInfo(false, aIsAnonymous,
|
||||
NeckoOriginAttributes(nsILoadContextInfo::NO_APP_ID, false));
|
||||
OriginAttributes(nsILoadContextInfo::NO_APP_ID, false));
|
||||
}
|
||||
|
||||
bool pb = aLoadContext->UsePrivateBrowsing();
|
||||
DocShellOriginAttributes doa;
|
||||
aLoadContext->GetOriginAttributes(doa);
|
||||
OriginAttributes oa;
|
||||
aLoadContext->GetOriginAttributes(oa);
|
||||
|
||||
NeckoOriginAttributes noa;
|
||||
noa.InheritFromDocShellToNecko(doa);
|
||||
|
||||
return new LoadContextInfo(pb, aIsAnonymous, noa);
|
||||
return new LoadContextInfo(pb, aIsAnonymous, oa);
|
||||
}
|
||||
|
||||
LoadContextInfo*
|
||||
@@ -167,7 +164,7 @@ GetLoadContextInfo(nsILoadContextInfo *aInfo)
|
||||
LoadContextInfo *
|
||||
GetLoadContextInfo(bool const aIsPrivate,
|
||||
bool const aIsAnonymous,
|
||||
NeckoOriginAttributes const &aOriginAttributes)
|
||||
OriginAttributes const &aOriginAttributes)
|
||||
{
|
||||
return new LoadContextInfo(aIsPrivate,
|
||||
aIsAnonymous,
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSILOADCONTEXTINFO
|
||||
|
||||
LoadContextInfo(bool aIsPrivate, bool aIsAnonymous, NeckoOriginAttributes aOriginAttributes);
|
||||
LoadContextInfo(bool aIsPrivate, bool aIsAnonymous, OriginAttributes aOriginAttributes);
|
||||
|
||||
private:
|
||||
virtual ~LoadContextInfo();
|
||||
@@ -27,7 +27,7 @@ private:
|
||||
protected:
|
||||
bool mIsPrivate : 1;
|
||||
bool mIsAnonymous : 1;
|
||||
NeckoOriginAttributes mOriginAttributes;
|
||||
OriginAttributes mOriginAttributes;
|
||||
};
|
||||
|
||||
class LoadContextInfoFactory : public nsILoadContextInfoFactory
|
||||
@@ -55,7 +55,7 @@ GetLoadContextInfo(nsILoadContextInfo *aInfo);
|
||||
LoadContextInfo*
|
||||
GetLoadContextInfo(bool const aIsPrivate,
|
||||
bool const aIsAnonymous,
|
||||
NeckoOriginAttributes const &aOriginAttributes);
|
||||
OriginAttributes const &aOriginAttributes);
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
||||
@@ -89,8 +89,7 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
|
||||
mUpgradeInsecurePreloads = aLoadingContext->OwnerDoc()->GetUpgradeInsecurePreloads();
|
||||
}
|
||||
|
||||
const PrincipalOriginAttributes attrs = BasePrincipal::Cast(mLoadingPrincipal)->OriginAttributesRef();
|
||||
mOriginAttributes.InheritFromDocToNecko(attrs);
|
||||
mOriginAttributes = BasePrincipal::Cast(mLoadingPrincipal)->OriginAttributesRef();
|
||||
}
|
||||
|
||||
LoadInfo::LoadInfo(const LoadInfo& rhs)
|
||||
@@ -128,7 +127,7 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
|
||||
bool aEnforceSecurity,
|
||||
bool aInitialSecurityCheckDone,
|
||||
bool aIsThirdPartyContext,
|
||||
const NeckoOriginAttributes& aOriginAttributes,
|
||||
const OriginAttributes& aOriginAttributes,
|
||||
nsTArray<nsCOMPtr<nsIPrincipal>>& aRedirectChainIncludingInternalRedirects,
|
||||
nsTArray<nsCOMPtr<nsIPrincipal>>& aRedirectChain)
|
||||
: mLoadingPrincipal(aLoadingPrincipal)
|
||||
@@ -417,7 +416,7 @@ NS_IMETHODIMP
|
||||
LoadInfo::SetScriptableOriginAttributes(JSContext* aCx,
|
||||
JS::Handle<JS::Value> aOriginAttributes)
|
||||
{
|
||||
NeckoOriginAttributes attrs;
|
||||
OriginAttributes attrs;
|
||||
if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
@@ -427,7 +426,7 @@ LoadInfo::SetScriptableOriginAttributes(JSContext* aCx,
|
||||
}
|
||||
|
||||
nsresult
|
||||
LoadInfo::GetOriginAttributes(mozilla::NeckoOriginAttributes* aOriginAttributes)
|
||||
LoadInfo::GetOriginAttributes(mozilla::OriginAttributes* aOriginAttributes)
|
||||
{
|
||||
NS_ENSURE_ARG(aOriginAttributes);
|
||||
*aOriginAttributes = mOriginAttributes;
|
||||
@@ -435,7 +434,7 @@ LoadInfo::GetOriginAttributes(mozilla::NeckoOriginAttributes* aOriginAttributes)
|
||||
}
|
||||
|
||||
nsresult
|
||||
LoadInfo::SetOriginAttributes(const mozilla::NeckoOriginAttributes& aOriginAttributes)
|
||||
LoadInfo::SetOriginAttributes(const mozilla::OriginAttributes& aOriginAttributes)
|
||||
{
|
||||
mOriginAttributes = aOriginAttributes;
|
||||
return NS_OK;
|
||||
|
||||
@@ -86,7 +86,7 @@ private:
|
||||
bool aEnforceSecurity,
|
||||
bool aInitialSecurityCheckDone,
|
||||
bool aIsThirdPartyRequest,
|
||||
const NeckoOriginAttributes& aOriginAttributes,
|
||||
const OriginAttributes& aOriginAttributes,
|
||||
nsTArray<nsCOMPtr<nsIPrincipal>>& aRedirectChainIncludingInternalRedirects,
|
||||
nsTArray<nsCOMPtr<nsIPrincipal>>& aRedirectChain);
|
||||
LoadInfo(const LoadInfo& rhs);
|
||||
@@ -121,7 +121,7 @@ private:
|
||||
bool mEnforceSecurity;
|
||||
bool mInitialSecurityCheckDone;
|
||||
bool mIsThirdPartyContext;
|
||||
NeckoOriginAttributes mOriginAttributes;
|
||||
OriginAttributes mOriginAttributes;
|
||||
nsTArray<nsCOMPtr<nsIPrincipal>> mRedirectChainIncludingInternalRedirects;
|
||||
nsTArray<nsCOMPtr<nsIPrincipal>> mRedirectChain;
|
||||
|
||||
|
||||
@@ -581,7 +581,7 @@ Predictor::Init()
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
RefPtr<LoadContextInfo> lci =
|
||||
new LoadContextInfo(false, false, NeckoOriginAttributes());
|
||||
new LoadContextInfo(false, false, OriginAttributes());
|
||||
|
||||
rv = cacheStorageService->DiskCacheStorage(lci, false,
|
||||
getter_AddRefs(mCacheDiskStorage));
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
%{ C++
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
%}
|
||||
native OriginAttributesNativePtr(const mozilla::NeckoOriginAttributes*);
|
||||
native OriginAttributesNativePtr(const mozilla::OriginAttributes*);
|
||||
|
||||
interface nsILoadContext;
|
||||
interface nsIDOMWindow;
|
||||
@@ -37,7 +37,7 @@ interface nsILoadContextInfo : nsISupports
|
||||
readonly attribute boolean isAnonymous;
|
||||
|
||||
/**
|
||||
* NeckoOriginAttributes hiding all the security context attributes
|
||||
* OriginAttributes hiding all the security context attributes
|
||||
*/
|
||||
[implicit_jscontext]
|
||||
readonly attribute jsval originAttributes;
|
||||
@@ -72,7 +72,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++,
|
||||
* we need a scriptable factory to create instances of that
|
||||
* interface from JS.
|
||||
|
||||
@@ -18,8 +18,8 @@ interface nsIPrincipal;
|
||||
%}
|
||||
|
||||
[ref] native const_nsIPrincipalArray(const nsTArray<nsCOMPtr<nsIPrincipal>>);
|
||||
native NeckoOriginAttributes(mozilla::NeckoOriginAttributes);
|
||||
[ref] native const_OriginAttributesRef(const mozilla::NeckoOriginAttributes);
|
||||
native OriginAttributes(mozilla::OriginAttributes);
|
||||
[ref] native const_OriginAttributesRef(const mozilla::OriginAttributes);
|
||||
|
||||
typedef unsigned long nsSecurityFlags;
|
||||
|
||||
@@ -343,22 +343,22 @@ interface nsILoadInfo : nsISupports
|
||||
[infallible] readonly attribute unsigned long long parentOuterWindowID;
|
||||
|
||||
/**
|
||||
* Customized NeckoOriginAttributes within LoadInfo to allow overwriting of the
|
||||
* Customized OriginAttributes within LoadInfo to allow overwriting of the
|
||||
* default originAttributes from the loadingPrincipal.
|
||||
*/
|
||||
[implicit_jscontext, binaryname(ScriptableOriginAttributes)]
|
||||
attribute jsval originAttributes;
|
||||
|
||||
[noscript, nostdcall, binaryname(GetOriginAttributes)]
|
||||
NeckoOriginAttributes binaryGetOriginAttributes();
|
||||
OriginAttributes binaryGetOriginAttributes();
|
||||
|
||||
[noscript, nostdcall, binaryname(SetOriginAttributes)]
|
||||
void binarySetOriginAttributes(in const_OriginAttributesRef aOriginAttrs);
|
||||
|
||||
%{ C++
|
||||
inline mozilla::NeckoOriginAttributes GetOriginAttributes()
|
||||
inline mozilla::OriginAttributes GetOriginAttributes()
|
||||
{
|
||||
mozilla::NeckoOriginAttributes result;
|
||||
mozilla::OriginAttributes result;
|
||||
mozilla::DebugOnly<nsresult> rv = GetOriginAttributes(&result);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
return result;
|
||||
|
||||
@@ -1205,7 +1205,7 @@ NS_UsePrivateBrowsing(nsIChannel *channel)
|
||||
|
||||
bool
|
||||
NS_GetOriginAttributes(nsIChannel *aChannel,
|
||||
mozilla::NeckoOriginAttributes &aAttributes)
|
||||
mozilla::OriginAttributes &aAttributes)
|
||||
{
|
||||
nsCOMPtr<nsILoadContext> loadContext;
|
||||
NS_QueryNotificationCallbacks(aChannel, loadContext);
|
||||
@@ -1213,9 +1213,7 @@ NS_GetOriginAttributes(nsIChannel *aChannel,
|
||||
return false;
|
||||
}
|
||||
|
||||
DocShellOriginAttributes doa;
|
||||
loadContext->GetOriginAttributes(doa);
|
||||
aAttributes.InheritFromDocShellToNecko(doa);
|
||||
loadContext->GetOriginAttributes(aAttributes);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class nsIStreamLoaderObserver;
|
||||
class nsIUnicharStreamLoader;
|
||||
class nsIUnicharStreamLoaderObserver;
|
||||
|
||||
namespace mozilla { class NeckoOriginAttributes; }
|
||||
namespace mozilla { class OriginAttributes; }
|
||||
|
||||
template <class> class nsCOMPtr;
|
||||
template <typename> struct already_AddRefed;
|
||||
@@ -684,10 +684,10 @@ NS_QueryNotificationCallbacks(nsIInterfaceRequestor *callbacks,
|
||||
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,
|
||||
mozilla::NeckoOriginAttributes &aAttributes);
|
||||
mozilla::OriginAttributes &aAttributes);
|
||||
|
||||
// Constants duplicated from nsIScriptSecurityManager so we avoid having necko
|
||||
// know about script security manager.
|
||||
|
||||
+2
-2
@@ -40,7 +40,7 @@ nsApplicationCacheService::BuildGroupID(nsIURI *aManifestURL,
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
mozilla::NeckoOriginAttributes const *oa = aLoadContextInfo
|
||||
mozilla::OriginAttributes const *oa = aLoadContextInfo
|
||||
? aLoadContextInfo->OriginAttributesPtr()
|
||||
: nullptr;
|
||||
|
||||
@@ -57,7 +57,7 @@ nsApplicationCacheService::BuildGroupIDForApp(nsIURI *aManifestURL,
|
||||
bool aIsInBrowser,
|
||||
nsACString &_result)
|
||||
{
|
||||
NeckoOriginAttributes oa;
|
||||
OriginAttributes oa;
|
||||
oa.mAppId = aAppId;
|
||||
oa.mInBrowser = aIsInBrowser;
|
||||
nsresult rv = nsOfflineCacheDevice::BuildApplicationCacheGroupID(
|
||||
|
||||
+6
-6
@@ -47,7 +47,7 @@
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::storage;
|
||||
using mozilla::NeckoOriginAttributes;
|
||||
using mozilla::OriginAttributes;
|
||||
|
||||
static const char OFFLINE_CACHE_DEVICE_ID[] = { "offline" };
|
||||
|
||||
@@ -1302,7 +1302,7 @@ GetGroupForCache(const nsCSubstring &clientID, nsCString &group)
|
||||
}
|
||||
|
||||
void
|
||||
AppendJARIdentifier(nsACString &_result, NeckoOriginAttributes const *aOriginAttributes)
|
||||
AppendJARIdentifier(nsACString &_result, OriginAttributes const *aOriginAttributes)
|
||||
{
|
||||
nsAutoCString suffix;
|
||||
aOriginAttributes->CreateSuffix(suffix);
|
||||
@@ -1314,7 +1314,7 @@ AppendJARIdentifier(nsACString &_result, NeckoOriginAttributes const *aOriginAtt
|
||||
// static
|
||||
nsresult
|
||||
nsOfflineCacheDevice::BuildApplicationCacheGroupID(nsIURI *aManifestURL,
|
||||
NeckoOriginAttributes const *aOriginAttributes,
|
||||
OriginAttributes const *aOriginAttributes,
|
||||
nsACString &_result)
|
||||
{
|
||||
nsCOMPtr<nsIURI> newURI;
|
||||
@@ -2399,11 +2399,11 @@ nsOfflineCacheDevice::DiscardByAppId(int32_t appID, bool browserEntriesOnly)
|
||||
|
||||
jaridsuffix.Append('%');
|
||||
|
||||
// TODO - this method should accept NeckoOriginAttributes* from outside instead.
|
||||
// TODO - this method should accept OriginAttributes* from outside instead.
|
||||
// If passed null, we should then delegate to
|
||||
// nsCacheService::GlobalInstance()->EvictEntriesInternal(nsICache::STORE_OFFLINE);
|
||||
|
||||
NeckoOriginAttributes oa;
|
||||
OriginAttributes oa;
|
||||
oa.mAppId = appID;
|
||||
oa.mInBrowser = browserEntriesOnly;
|
||||
AppendJARIdentifier(jaridsuffix, &oa);
|
||||
@@ -2483,7 +2483,7 @@ nsOfflineCacheDevice::CanUseCache(nsIURI *keyURI,
|
||||
// This is check of extended origin.
|
||||
nsAutoCString demandedGroupID;
|
||||
|
||||
const NeckoOriginAttributes *oa = loadContextInfo
|
||||
const OriginAttributes *oa = loadContextInfo
|
||||
? loadContextInfo->OriginAttributesPtr()
|
||||
: nullptr;
|
||||
rv = BuildApplicationCacheGroupID(groupURI, oa, demandedGroupID);
|
||||
|
||||
Vendored
+2
-2
@@ -25,7 +25,7 @@
|
||||
class nsIURI;
|
||||
class nsOfflineCacheDevice;
|
||||
class mozIStorageService;
|
||||
namespace mozilla { class NeckoOriginAttributes; }
|
||||
namespace mozilla { class OriginAttributes; }
|
||||
|
||||
class nsApplicationCacheNamespace final : public nsIApplicationCacheNamespace
|
||||
{
|
||||
@@ -141,7 +141,7 @@ public:
|
||||
nsresult EvictUnownedEntries(const char *clientID);
|
||||
|
||||
static nsresult BuildApplicationCacheGroupID(nsIURI *aManifestURL,
|
||||
mozilla::NeckoOriginAttributes const *aOriginAttributes,
|
||||
mozilla::OriginAttributes const *aOriginAttributes,
|
||||
nsACString &_result);
|
||||
|
||||
nsresult ActivateCache(const nsCSubstring &group,
|
||||
|
||||
@@ -126,7 +126,7 @@ NS_IMETHODIMP AppCacheStorage::AsyncEvictStorage(nsICacheEntryDoomCallback* aCal
|
||||
if (!mAppCache) {
|
||||
// TODO - bug 1165256, have an API on nsIApplicationCacheService that takes
|
||||
// optional OAs and decides internally what to do.
|
||||
const NeckoOriginAttributes* oa = LoadInfo()->OriginAttributesPtr();
|
||||
const OriginAttributes* oa = LoadInfo()->OriginAttributesPtr();
|
||||
if (oa->mAppId == nsILoadContextInfo::NO_APP_ID && !oa->mInBrowser) {
|
||||
// Clear everything.
|
||||
nsCOMPtr<nsICacheService> serv =
|
||||
|
||||
@@ -146,7 +146,7 @@ public:
|
||||
nsresult SyncReadMetadata(nsIFile *aFile);
|
||||
|
||||
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); }
|
||||
|
||||
const char * GetElement(const char *aKey);
|
||||
@@ -212,7 +212,7 @@ private:
|
||||
bool mIsDirty : 1;
|
||||
bool mAnonymous : 1;
|
||||
bool mAllocExactSize : 1;
|
||||
mozilla::NeckoOriginAttributes mOriginAttributes;
|
||||
mozilla::OriginAttributes mOriginAttributes;
|
||||
uint32_t mAppId;
|
||||
nsCOMPtr<CacheFileMetadataListener> mListener;
|
||||
};
|
||||
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
|
||||
private:
|
||||
// Results
|
||||
NeckoOriginAttributes originAttribs;
|
||||
OriginAttributes originAttribs;
|
||||
bool isPrivate;
|
||||
bool isAnonymous;
|
||||
nsCString idEnhance;
|
||||
@@ -206,7 +206,7 @@ AppendKeyPrefix(nsILoadContextInfo* aInfo, nsACString &_retval)
|
||||
* Keep the attributes list sorted according their ASCII code.
|
||||
*/
|
||||
|
||||
NeckoOriginAttributes const *oa = aInfo->OriginAttributesPtr();
|
||||
OriginAttributes const *oa = aInfo->OriginAttributesPtr();
|
||||
nsAutoCString suffix;
|
||||
oa->CreateSuffix(suffix);
|
||||
if (!suffix.IsEmpty()) {
|
||||
|
||||
@@ -330,7 +330,7 @@ namespace CacheStorageEvictHelper {
|
||||
|
||||
nsresult ClearStorage(bool const aPrivate,
|
||||
bool const aAnonymous,
|
||||
NeckoOriginAttributes const &aOa)
|
||||
OriginAttributes const &aOa)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
@@ -355,7 +355,7 @@ nsresult ClearStorage(bool const aPrivate,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult Run(NeckoOriginAttributes const &aOa)
|
||||
nsresult Run(OriginAttributes const &aOa)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
@@ -450,9 +450,9 @@ CacheObserver::Observe(nsISupports* aSubject,
|
||||
}
|
||||
|
||||
if (!strcmp(aTopic, "clear-origin-data")) {
|
||||
NeckoOriginAttributes oa;
|
||||
OriginAttributes oa;
|
||||
if (!oa.Init(nsDependentString(aData))) {
|
||||
NS_ERROR("Could not parse NeckoOriginAttributes JSON in clear-origin-data notification");
|
||||
NS_ERROR("Could not parse OriginAttributes JSON in clear-origin-data notification");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -527,7 +527,7 @@ GetCacheSessionNameForStoragePolicy(
|
||||
nsCSubstring const &scheme,
|
||||
nsCacheStoragePolicy storagePolicy,
|
||||
bool isPrivate,
|
||||
NeckoOriginAttributes const *originAttribs,
|
||||
OriginAttributes const *originAttribs,
|
||||
nsACString& sessionName)
|
||||
{
|
||||
MOZ_ASSERT(!isPrivate || storagePolicy == nsICache::STORE_IN_MEMORY);
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
|
||||
using namespace mozilla::ipc;
|
||||
using mozilla::BasePrincipal;
|
||||
using mozilla::NeckoOriginAttributes;
|
||||
using mozilla::PrincipalOriginAttributes;
|
||||
using mozilla::OriginAttributes;
|
||||
using mozilla::dom::PContentParent;
|
||||
using mozilla::net::NeckoParent;
|
||||
|
||||
@@ -29,16 +28,13 @@ namespace {
|
||||
// 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.
|
||||
void
|
||||
CreateDummyChannel(nsIURI* aHostURI, NeckoOriginAttributes& aAttrs, bool aIsPrivate,
|
||||
nsIChannel** aChannel)
|
||||
CreateDummyChannel(nsIURI* aHostURI, OriginAttributes &aAttrs, bool aIsPrivate,
|
||||
nsIChannel **aChannel)
|
||||
{
|
||||
MOZ_ASSERT(aAttrs.mAppId != nsIScriptSecurityManager::UNKNOWN_APP_ID);
|
||||
|
||||
PrincipalOriginAttributes attrs;
|
||||
attrs.InheritFromNecko(aAttrs);
|
||||
|
||||
nsCOMPtr<nsIPrincipal> principal =
|
||||
BasePrincipal::CreateCodebasePrincipal(aHostURI, attrs);
|
||||
BasePrincipal::CreateCodebasePrincipal(aHostURI, aAttrs);
|
||||
if (!principal) {
|
||||
return;
|
||||
}
|
||||
@@ -70,15 +66,14 @@ namespace net {
|
||||
MOZ_WARN_UNUSED_RESULT
|
||||
bool
|
||||
CookieServiceParent::GetOriginAttributesFromParams(const IPC::SerializedLoadContext &aLoadContext,
|
||||
NeckoOriginAttributes& aAttrs,
|
||||
OriginAttributes& aAttrs,
|
||||
bool& aIsPrivate)
|
||||
{
|
||||
aIsPrivate = false;
|
||||
|
||||
DocShellOriginAttributes docShellAttrs;
|
||||
const char* error = NeckoParent::GetValidatedAppInfo(aLoadContext,
|
||||
Manager()->Manager(),
|
||||
docShellAttrs);
|
||||
aAttrs);
|
||||
if (error) {
|
||||
NS_WARNING(nsPrintfCString("CookieServiceParent: GetOriginAttributesFromParams: "
|
||||
"FATAL error: %s: KILLING CHILD PROCESS\n",
|
||||
@@ -89,8 +84,6 @@ CookieServiceParent::GetOriginAttributesFromParams(const IPC::SerializedLoadCont
|
||||
if (aLoadContext.IsPrivateBitValid()) {
|
||||
aIsPrivate = aLoadContext.mUsePrivateBrowsing;
|
||||
}
|
||||
|
||||
aAttrs.InheritFromDocShellToNecko(docShellAttrs);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -133,7 +126,7 @@ CookieServiceParent::RecvGetCookieString(const URIParams& aHost,
|
||||
if (!hostURI)
|
||||
return false;
|
||||
|
||||
NeckoOriginAttributes attrs;
|
||||
OriginAttributes attrs;
|
||||
bool isPrivate;
|
||||
bool valid = GetOriginAttributesFromParams(aLoadContext, attrs, isPrivate);
|
||||
if (!valid) {
|
||||
@@ -163,7 +156,7 @@ CookieServiceParent::RecvSetCookieString(const URIParams& aHost,
|
||||
if (!hostURI)
|
||||
return false;
|
||||
|
||||
NeckoOriginAttributes attrs;
|
||||
OriginAttributes attrs;
|
||||
bool isPrivate;
|
||||
bool valid = GetOriginAttributesFromParams(aLoadContext, attrs, isPrivate);
|
||||
if (!valid) {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "SerializedLoadContext.h"
|
||||
|
||||
class nsCookieService;
|
||||
namespace mozilla { class NeckoOriginAttributes; }
|
||||
namespace mozilla { class OriginAttributes; }
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
protected:
|
||||
MOZ_WARN_UNUSED_RESULT bool
|
||||
GetOriginAttributesFromParams(const IPC::SerializedLoadContext &aLoadContext,
|
||||
NeckoOriginAttributes& aAttrs,
|
||||
OriginAttributes& aAttrs,
|
||||
bool& aIsPrivate);
|
||||
|
||||
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
|
||||
|
||||
@@ -60,7 +60,7 @@ using namespace mozilla::net;
|
||||
// on content processes (see bug 777620), change to use the appropriate app
|
||||
// namespace. For now those IDLs aren't supported on child processes.
|
||||
#define DEFAULT_APP_KEY(baseDomain) \
|
||||
nsCookieKey(baseDomain, NeckoOriginAttributes())
|
||||
nsCookieKey(baseDomain, OriginAttributes())
|
||||
|
||||
/******************************************************************************
|
||||
* nsCookieService impl:
|
||||
@@ -572,7 +572,7 @@ public:
|
||||
MOZ_ASSERT(!nsCRT::strcmp(aTopic, TOPIC_CLEAR_ORIGIN_DATA));
|
||||
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
NeckoOriginAttributes attrs;
|
||||
OriginAttributes attrs;
|
||||
MOZ_ALWAYS_TRUE(attrs.Init(nsDependentString(aData)));
|
||||
|
||||
nsCOMPtr<nsICookieManager2> cookieManager
|
||||
@@ -832,7 +832,7 @@ ConvertAppIdToOriginAttrsSQLFunction::OnFunctionCall(
|
||||
|
||||
// Create an originAttributes object by appId and inBrowserElemnt.
|
||||
// Then create the originSuffix string from this object.
|
||||
NeckoOriginAttributes attrs(appId, (inBrowser ? 1 : 0));
|
||||
OriginAttributes attrs(appId, (inBrowser ? 1 : 0));
|
||||
nsAutoCString suffix;
|
||||
attrs.CreateSuffix(suffix);
|
||||
|
||||
@@ -860,7 +860,7 @@ SetAppIdFromOriginAttributesSQLFunction::OnFunctionCall(
|
||||
{
|
||||
nsresult rv;
|
||||
nsAutoCString suffix;
|
||||
NeckoOriginAttributes attrs;
|
||||
OriginAttributes attrs;
|
||||
|
||||
rv = aFunctionArguments->GetUTF8String(0, suffix);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@@ -892,7 +892,7 @@ SetInBrowserFromOriginAttributesSQLFunction::OnFunctionCall(
|
||||
{
|
||||
nsresult rv;
|
||||
nsAutoCString suffix;
|
||||
NeckoOriginAttributes attrs;
|
||||
OriginAttributes attrs;
|
||||
|
||||
rv = aFunctionArguments->GetUTF8String(0, suffix);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@@ -1889,7 +1889,7 @@ nsCookieService::GetCookieStringCommon(nsIURI *aHostURI,
|
||||
mThirdPartyUtil->IsThirdPartyChannel(aChannel, aHostURI, &isForeign);
|
||||
|
||||
// Get originAttributes.
|
||||
NeckoOriginAttributes attrs;
|
||||
OriginAttributes attrs;
|
||||
if (aChannel) {
|
||||
NS_GetOriginAttributes(aChannel, attrs);
|
||||
}
|
||||
@@ -1962,7 +1962,7 @@ nsCookieService::SetCookieStringCommon(nsIURI *aHostURI,
|
||||
mThirdPartyUtil->IsThirdPartyChannel(aChannel, aHostURI, &isForeign);
|
||||
|
||||
// Get originAttributes.
|
||||
NeckoOriginAttributes attrs;
|
||||
OriginAttributes attrs;
|
||||
if (aChannel) {
|
||||
NS_GetOriginAttributes(aChannel, attrs);
|
||||
}
|
||||
@@ -1983,7 +1983,7 @@ nsCookieService::SetCookieStringInternal(nsIURI *aHostURI,
|
||||
nsDependentCString &aCookieHeader,
|
||||
const nsCString &aServerTime,
|
||||
bool aFromHttp,
|
||||
const NeckoOriginAttributes &aOriginAttrs,
|
||||
const OriginAttributes &aOriginAttrs,
|
||||
bool aIsPrivate,
|
||||
nsIChannel *aChannel)
|
||||
{
|
||||
@@ -2294,7 +2294,7 @@ nsCookieService::Add(const nsACString &aHost,
|
||||
|
||||
|
||||
nsresult
|
||||
nsCookieService::Remove(const nsACString& aHost, const NeckoOriginAttributes& aAttrs,
|
||||
nsCookieService::Remove(const nsACString& aHost, const OriginAttributes& aAttrs,
|
||||
const nsACString& aName, const nsACString& aPath,
|
||||
bool aBlocked)
|
||||
{
|
||||
@@ -2352,7 +2352,7 @@ nsCookieService::Remove(const nsACString &aHost,
|
||||
const nsACString &aPath,
|
||||
bool aBlocked)
|
||||
{
|
||||
NeckoOriginAttributes attrs;
|
||||
OriginAttributes attrs;
|
||||
return Remove(aHost, attrs, aName, aPath, aBlocked);
|
||||
}
|
||||
|
||||
@@ -2676,7 +2676,7 @@ nsCookieService::EnsureReadComplete()
|
||||
stmt->GetUTF8String(IDX_BASE_DOMAIN, baseDomain);
|
||||
|
||||
nsAutoCString suffix;
|
||||
NeckoOriginAttributes attrs;
|
||||
OriginAttributes attrs;
|
||||
stmt->GetUTF8String(IDX_ORIGIN_ATTRIBUTES, suffix);
|
||||
attrs.PopulateFromSuffix(suffix);
|
||||
|
||||
@@ -2825,7 +2825,7 @@ nsCookieService::ImportCookies(nsIFile *aCookieFile)
|
||||
continue;
|
||||
|
||||
// pre-existing cookies have appId=0, inBrowser=false set by default
|
||||
// constructor of NeckoOriginAttributes().
|
||||
// constructor of OriginAttributes().
|
||||
nsCookieKey key = DEFAULT_APP_KEY(baseDomain);
|
||||
|
||||
// Create a new nsCookie and assign the data. We don't know the cookie
|
||||
@@ -2916,7 +2916,7 @@ void
|
||||
nsCookieService::GetCookieStringInternal(nsIURI *aHostURI,
|
||||
bool aIsForeign,
|
||||
bool aHttpBound,
|
||||
const NeckoOriginAttributes aOriginAttrs,
|
||||
const OriginAttributes aOriginAttrs,
|
||||
bool aIsPrivate,
|
||||
nsCString &aCookieString)
|
||||
{
|
||||
@@ -4317,7 +4317,7 @@ nsCookieService::RemoveCookiesForApp(uint32_t aAppId, bool aOnlyBrowserElement)
|
||||
//
|
||||
// NOTE: we could make this better by getting nsCookieEntry objects instead
|
||||
// of plain nsICookie.
|
||||
NeckoOriginAttributes attrs(aAppId, true);
|
||||
OriginAttributes attrs(aAppId, true);
|
||||
Remove(host, attrs, name, path, false);
|
||||
if (!aOnlyBrowserElement) {
|
||||
attrs.mInBrowser = false;
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
|
||||
using mozilla::NeckoOriginAttributes;
|
||||
using mozilla::OriginAttributes;
|
||||
|
||||
class nsICookiePermission;
|
||||
class nsIEffectiveTLDService;
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
nsCookieKey()
|
||||
{}
|
||||
|
||||
nsCookieKey(const nsCString &baseDomain, const NeckoOriginAttributes &attrs)
|
||||
nsCookieKey(const nsCString &baseDomain, const OriginAttributes &attrs)
|
||||
: mBaseDomain(baseDomain)
|
||||
, mOriginAttributes(attrs)
|
||||
{}
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
enum { ALLOW_MEMMOVE = true };
|
||||
|
||||
nsCString mBaseDomain;
|
||||
NeckoOriginAttributes mOriginAttributes;
|
||||
OriginAttributes mOriginAttributes;
|
||||
};
|
||||
|
||||
// Inherit from nsCookieKey so this can be stored in nsTHashTable
|
||||
@@ -292,9 +292,9 @@ class nsCookieService final : public nsICookieService
|
||||
nsresult GetBaseDomain(nsIURI *aHostURI, nsCString &aBaseDomain, bool &aRequireHostMatch);
|
||||
nsresult GetBaseDomainFromHost(const nsACString &aHost, nsCString &aBaseDomain);
|
||||
nsresult GetCookieStringCommon(nsIURI *aHostURI, nsIChannel *aChannel, bool aHttpBound, char** aCookie);
|
||||
void GetCookieStringInternal(nsIURI *aHostURI, bool aIsForeign, bool aHttpBound, const NeckoOriginAttributes aOriginAttrs, bool aIsPrivate, nsCString &aCookie);
|
||||
void GetCookieStringInternal(nsIURI *aHostURI, bool aIsForeign, bool aHttpBound, const OriginAttributes aOriginAttrs, bool aIsPrivate, nsCString &aCookie);
|
||||
nsresult SetCookieStringCommon(nsIURI *aHostURI, const char *aCookieHeader, const char *aServerTime, nsIChannel *aChannel, bool aFromHttp);
|
||||
void SetCookieStringInternal(nsIURI *aHostURI, bool aIsForeign, nsDependentCString &aCookieHeader, const nsCString &aServerTime, bool aFromHttp, const NeckoOriginAttributes &aOriginAttrs, bool aIsPrivate, nsIChannel* aChannel);
|
||||
void SetCookieStringInternal(nsIURI *aHostURI, bool aIsForeign, nsDependentCString &aCookieHeader, const nsCString &aServerTime, bool aFromHttp, const OriginAttributes &aOriginAttrs, bool aIsPrivate, nsIChannel* aChannel);
|
||||
bool SetCookieInternal(nsIURI *aHostURI, const nsCookieKey& aKey, bool aRequireHostMatch, CookieStatus aStatus, nsDependentCString &aCookieHeader, int64_t aServerTime, bool aFromHttp, nsIChannel* aChannel);
|
||||
void AddInternal(const nsCookieKey& aKey, nsCookie *aCookie, int64_t aCurrentTimeInUsec, nsIURI *aHostURI, const char *aCookieHeader, bool aFromHttp);
|
||||
void RemoveCookieFromList(const nsListIter &aIter, mozIStorageBindingParamsArray *aParamsArray = nullptr);
|
||||
@@ -320,10 +320,10 @@ class nsCookieService final : public nsICookieService
|
||||
|
||||
/**
|
||||
* This method is a helper that allows calling nsICookieManager::Remove()
|
||||
* with NeckoOriginAttributes parameter.
|
||||
* with OriginAttributes parameter.
|
||||
* NOTE: this could be added to a public interface if we happen to need it.
|
||||
*/
|
||||
nsresult Remove(const nsACString& aHost, const NeckoOriginAttributes& aAttrs,
|
||||
nsresult Remove(const nsACString& aHost, const OriginAttributes& aAttrs,
|
||||
const nsACString& aName, const nsACString& aPath,
|
||||
bool aBlocked);
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ include URIParams;
|
||||
include InputStreamParams;
|
||||
include PBackgroundSharedTypes;
|
||||
|
||||
using mozilla::NeckoOriginAttributes from "mozilla/ipc/BackgroundUtils.h";
|
||||
using struct mozilla::void_t from "ipc/IPCMessageUtils.h";
|
||||
using RequestHeaderTuples from "mozilla/net/PHttpChannelParams.h";
|
||||
using struct nsHttpAtom from "nsHttp.h";
|
||||
@@ -39,7 +38,7 @@ struct LoadInfoArgs
|
||||
bool enforceSecurity;
|
||||
bool initialSecurityCheckDone;
|
||||
bool isInThirdPartyContext;
|
||||
NeckoOriginAttributes originAttributes;
|
||||
OriginAttributes originAttributes;
|
||||
PrincipalInfo[] redirectChainIncludingInternalRedirects;
|
||||
PrincipalInfo[] redirectChain;
|
||||
};
|
||||
|
||||
@@ -45,8 +45,7 @@
|
||||
#include "mozilla/net/OfflineObserver.h"
|
||||
#include "nsISpeculativeConnect.h"
|
||||
|
||||
using mozilla::DocShellOriginAttributes;
|
||||
using mozilla::NeckoOriginAttributes;
|
||||
using mozilla::OriginAttributes;
|
||||
using mozilla::dom::ContentParent;
|
||||
using mozilla::dom::TabContext;
|
||||
using mozilla::dom::TabParent;
|
||||
@@ -112,7 +111,7 @@ PBOverrideStatusFromLoadContext(const SerializedLoadContext& aSerialized)
|
||||
const char*
|
||||
NeckoParent::GetValidatedAppInfo(const SerializedLoadContext& aSerialized,
|
||||
PContentParent* aContent,
|
||||
DocShellOriginAttributes& aAttrs)
|
||||
OriginAttributes& aAttrs)
|
||||
{
|
||||
if (UsingNeckoIPCSecurity()) {
|
||||
if (!aSerialized.IsNotNull()) {
|
||||
@@ -149,7 +148,7 @@ NeckoParent::GetValidatedAppInfo(const SerializedLoadContext& aSerialized,
|
||||
aSerialized.mOriginAttributes.mSignedPkg != tabContext.OriginAttributesRef().mSignedPkg) {
|
||||
continue;
|
||||
}
|
||||
aAttrs = DocShellOriginAttributes(appId, inBrowserElement);
|
||||
aAttrs = OriginAttributes(appId, inBrowserElement);
|
||||
aAttrs.mSignedPkg = tabContext.OriginAttributesRef().mSignedPkg;
|
||||
return nullptr;
|
||||
}
|
||||
@@ -163,7 +162,7 @@ NeckoParent::GetValidatedAppInfo(const SerializedLoadContext& aSerialized,
|
||||
if (aSerialized.IsNotNull()) {
|
||||
aAttrs = aSerialized.mOriginAttributes;
|
||||
} else {
|
||||
aAttrs = DocShellOriginAttributes(NECKO_NO_APP_ID, false);
|
||||
aAttrs = OriginAttributes(NECKO_NO_APP_ID, false);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@@ -177,7 +176,7 @@ NeckoParent::CreateChannelLoadContext(const PBrowserOrId& aBrowser,
|
||||
const SerializedLoadContext& aSerialized,
|
||||
nsCOMPtr<nsILoadContext> &aResult)
|
||||
{
|
||||
DocShellOriginAttributes attrs;
|
||||
OriginAttributes attrs;
|
||||
const char* error = GetValidatedAppInfo(aSerialized, aContent, attrs);
|
||||
if (error) {
|
||||
return error;
|
||||
@@ -890,7 +889,7 @@ NeckoParent::RecvPredPredict(const ipc::OptionalURIParams& aTargetURI,
|
||||
// We only actually care about the loadContext.mPrivateBrowsing, so we'll just
|
||||
// pass dummy params for nestFrameId, and originAttributes.
|
||||
uint64_t nestedFrameId = 0;
|
||||
DocShellOriginAttributes attrs(NECKO_UNKNOWN_APP_ID, false);
|
||||
OriginAttributes attrs(NECKO_UNKNOWN_APP_ID, false);
|
||||
nsCOMPtr<nsILoadContext> loadContext;
|
||||
if (aLoadContext.IsNotNull()) {
|
||||
loadContext = new LoadContext(aLoadContext, nestedFrameId, attrs);
|
||||
@@ -922,7 +921,7 @@ NeckoParent::RecvPredLearn(const ipc::URIParams& aTargetURI,
|
||||
// We only actually care about the loadContext.mPrivateBrowsing, so we'll just
|
||||
// pass dummy params for nestFrameId, and originAttributes;
|
||||
uint64_t nestedFrameId = 0;
|
||||
DocShellOriginAttributes attrs(NECKO_UNKNOWN_APP_ID, false);
|
||||
OriginAttributes attrs(NECKO_UNKNOWN_APP_ID, false);
|
||||
nsCOMPtr<nsILoadContext> loadContext;
|
||||
if (aLoadContext.IsNotNull()) {
|
||||
loadContext = new LoadContext(aLoadContext, nestedFrameId, attrs);
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
static const char *
|
||||
GetValidatedAppInfo(const SerializedLoadContext& aSerialized,
|
||||
PContentParent* aBrowser,
|
||||
mozilla::DocShellOriginAttributes& aAttrs);
|
||||
mozilla::OriginAttributes& aAttrs);
|
||||
|
||||
/*
|
||||
* Creates LoadContext for parent-side of an e10s channel.
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "nsIDocument.h"
|
||||
|
||||
using mozilla::BasePrincipal;
|
||||
using mozilla::OriginAttributes;
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::ipc;
|
||||
|
||||
@@ -562,18 +563,11 @@ HttpChannelParent::DoAsyncOpen( const URIParams& aURI,
|
||||
}
|
||||
|
||||
if (setChooseApplicationCache) {
|
||||
DocShellOriginAttributes docShellAttrs;
|
||||
OriginAttributes attrs;
|
||||
if (mLoadContext) {
|
||||
bool result = mLoadContext->GetOriginAttributes(docShellAttrs);
|
||||
if (!result) {
|
||||
return SendFailedAsyncOpen(NS_ERROR_FAILURE);
|
||||
}
|
||||
attrs.CopyFromLoadContext(mLoadContext);
|
||||
}
|
||||
|
||||
NeckoOriginAttributes neckoAttrs;
|
||||
neckoAttrs.InheritFromDocShellToNecko(docShellAttrs);
|
||||
PrincipalOriginAttributes attrs;
|
||||
attrs.InheritFromNecko(neckoAttrs);
|
||||
nsCOMPtr<nsIPrincipal> principal =
|
||||
BasePrincipal::CreateCodebasePrincipal(uri, attrs);
|
||||
|
||||
|
||||
@@ -897,7 +897,7 @@ static bool
|
||||
AddPackageIdToOrigin(nsACString& aOrigin, const nsACString& aPackageId)
|
||||
{
|
||||
nsAutoCString originNoSuffix;
|
||||
mozilla::NeckoOriginAttributes attrs;
|
||||
mozilla::OriginAttributes attrs;
|
||||
if (!attrs.PopulateFromOrigin(aOrigin, originNoSuffix)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ NS_IMETHODIMP PackagedAppVerifier::Init(nsIPackagedAppVerifierListener* aListene
|
||||
mIsFirstResource = true;
|
||||
mManifest = EmptyCString();
|
||||
|
||||
NeckoOriginAttributes().PopulateFromOrigin(aPackageOrigin, mPackageOrigin);
|
||||
OriginAttributes().PopulateFromOrigin(aPackageOrigin, mPackageOrigin);
|
||||
mBypassVerification = (mPackageOrigin ==
|
||||
Preferences::GetCString("network.http.signed-packages.trusted-origin"));
|
||||
|
||||
|
||||
@@ -292,8 +292,8 @@ RemoveEntriesForPattern(PLHashEntry *entry, int32_t number, void *arg)
|
||||
nsDependentCSubstring oaSuffix;
|
||||
oaSuffix.Rebind(key.BeginReading(), colon);
|
||||
|
||||
// Build the NeckoOriginAttributes object of it...
|
||||
NeckoOriginAttributes oa;
|
||||
// Build the OriginAttributes object of it...
|
||||
OriginAttributes oa;
|
||||
DebugOnly<bool> rv = oa.PopulateFromSuffix(oaSuffix);
|
||||
MOZ_ASSERT(rv);
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace net {
|
||||
static void
|
||||
GetOriginAttributesSuffix(nsIChannel* aChan, nsACString &aSuffix)
|
||||
{
|
||||
NeckoOriginAttributes oa;
|
||||
OriginAttributes oa;
|
||||
|
||||
// Deliberately ignoring the result and going with defaults
|
||||
if (aChan) {
|
||||
|
||||
@@ -87,7 +87,7 @@ protected:
|
||||
nsCString mCharset;
|
||||
int64_t mContentLength;
|
||||
uint32_t mLoadFlags;
|
||||
mozilla::NeckoOriginAttributes mOriginAttributes;
|
||||
mozilla::OriginAttributes mOriginAttributes;
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
nsCOMPtr<nsIURI> mOriginalURI;
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
|
||||
@@ -31,5 +31,3 @@ skip-if = e10s || buildapp != 'browser'
|
||||
skip-if = e10s || buildapp != 'browser'
|
||||
skip-if = buildapp == 'b2g' #no ssl support
|
||||
[test_idn_redirect.html]
|
||||
[test_origin_attributes_conversion.html]
|
||||
skip-if = e10s || buildapp != 'browser'
|
||||
|
||||
@@ -6,12 +6,13 @@ function handleRequest(request, response)
|
||||
{
|
||||
response.setHeader("Content-Type", "application/package", false);
|
||||
response.write(signedPackage);
|
||||
return;
|
||||
}
|
||||
|
||||
// The package content
|
||||
// getData formats it as described at http://www.w3.org/TR/web-packaging/#streamable-package-format
|
||||
var signedPackage = `manifest-signature: MIIF1AYJKoZIhvcNAQcCoIIFxTCCBcECAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3DQEHAaCCA54wggOaMIICgqADAgECAgEEMA0GCSqGSIb3DQEBCwUAMHMxCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEkMCIGA1UEChMbRXhhbXBsZSBUcnVzdGVkIENvcnBvcmF0aW9uMRkwFwYDVQQDExBUcnVzdGVkIFZhbGlkIENBMB4XDTE1MTExOTAzMDEwNVoXDTM1MTExOTAzMDEwNVowdDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MSQwIgYDVQQKExtFeGFtcGxlIFRydXN0ZWQgQ29ycG9yYXRpb24xGjAYBgNVBAMTEVRydXN0ZWQgQ29ycCBDZXJ0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzPback9X7RRxKTc3/5o2vm9Ro6XNiSM9NPsN3djjCIVz50bY0rJkP98zsqpFjnLwqHeJigxyYoqFexRhRLgKrG10CxNl4rxP6CEPENjvj5FfbX/HUZpT/DelNR18F498yD95vSHcSrCc3JrjV3bKA+wgt11E4a0Ba95S1RuwtehZw1+Y4hO8nHpbSGfjD0BpluFY2nDoYAm+aWSrsmLuJsKLO8Xn2I1brZFJUynR3q1ujuDE9EJk1niDLfOeVgXM4AavJS5C0ZBHhAhR2W+K9NN97jpkpmHFqecTwDXB7rEhsyB3185cI7anaaQfHHfH5+4SD+cMDNtYIOSgLO06ZwIDAQABozgwNjAMBgNVHRMBAf8EAjAAMBYGA1UdJQEB/wQMMAoGCCsGAQUFBwMDMA4GA1UdDwEB/wQEAwIHgDANBgkqhkiG9w0BAQsFAAOCAQEAlnVyLz5dPhS0ZhZD6qJOUzSo6nFwMxNX1m0oS37mevtuh0b0o1gmEuMw3mVxiAVkC2vPsoxBL2wLlAkcEdBPxGEqhBmtiBY3F3DgvEkf+/sOY1rnr6O1qLZuBAnPzA1Vnco8Jwf0DYF0PxaRd8yT5XSl5qGpM2DItEldZwuKKaL94UEgIeC2c+Uv/IOyrv+EyftX96vcmRwr8ghPFLQ+36H5nuAKEpDD170EvfWl1zs0dUPiqSI6l+hy5V14gl63Woi34L727+FKx8oatbyZtdvbeeOmenfTLifLomnZdx+3WMLkp3TLlHa5xDLwifvZtBP2d3c6zHp7gdrGU1u2WTGCAf4wggH6AgEBMHgwczELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MSQwIgYDVQQKExtFeGFtcGxlIFRydXN0ZWQgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFRydXN0ZWQgVmFsaWQgQ0ECAQQwCQYFKw4DAhoFAKBdMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTE1MTEyNTAzMDQzMFowIwYJKoZIhvcNAQkEMRYEFD4ut4oKoYdcGzyfQE6ROeazv+uNMA0GCSqGSIb3DQEBAQUABIIBAFG99dKBSOzQmYVn6lHKWERVDtYXbDTIVF957ID8YH9B5unlX/PdludTNbP5dzn8GWQV08tNRgoXQ5sgxjifHunrpaR1WiR6XqvwOCBeA5NB688jxGNxth6zg6fCGFaynsYMX3FlglfIW+AYwyQUclbv+C4UORJpBjvuknOnK+UDBLVSoP9ivL6KhylYna3oFcs0SMsumc/jf/oQW51LzFHpn61TRUqdDgvGhwcjgphMhKj23KwkjwRspU2oIWNRAuhZgqDD5BJlNniCr9X5Hx1dW6tIVISO91CLAryYkGZKRJYekXctCpIvldUkIDeh2tAw5owr0jtsVd6ovFF3bV4=\r
|
||||
--NKWXJUAFXB\r
|
||||
var signedPackage = `manifest-signature: MIIF1AYJKoZIhvcNAQcCoIIFxTCCBcECAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3DQEHAaCCA54wggOaMIICgqADAgECAgEEMA0GCSqGSIb3DQEBCwUAMHMxCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEkMCIGA1UEChMbRXhhbXBsZSBUcnVzdGVkIENvcnBvcmF0aW9uMRkwFwYDVQQDExBUcnVzdGVkIFZhbGlkIENBMB4XDTE1MTExOTAzMDEwNVoXDTM1MTExOTAzMDEwNVowdDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MSQwIgYDVQQKExtFeGFtcGxlIFRydXN0ZWQgQ29ycG9yYXRpb24xGjAYBgNVBAMTEVRydXN0ZWQgQ29ycCBDZXJ0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzPback9X7RRxKTc3/5o2vm9Ro6XNiSM9NPsN3djjCIVz50bY0rJkP98zsqpFjnLwqHeJigxyYoqFexRhRLgKrG10CxNl4rxP6CEPENjvj5FfbX/HUZpT/DelNR18F498yD95vSHcSrCc3JrjV3bKA+wgt11E4a0Ba95S1RuwtehZw1+Y4hO8nHpbSGfjD0BpluFY2nDoYAm+aWSrsmLuJsKLO8Xn2I1brZFJUynR3q1ujuDE9EJk1niDLfOeVgXM4AavJS5C0ZBHhAhR2W+K9NN97jpkpmHFqecTwDXB7rEhsyB3185cI7anaaQfHHfH5+4SD+cMDNtYIOSgLO06ZwIDAQABozgwNjAMBgNVHRMBAf8EAjAAMBYGA1UdJQEB/wQMMAoGCCsGAQUFBwMDMA4GA1UdDwEB/wQEAwIHgDANBgkqhkiG9w0BAQsFAAOCAQEAlnVyLz5dPhS0ZhZD6qJOUzSo6nFwMxNX1m0oS37mevtuh0b0o1gmEuMw3mVxiAVkC2vPsoxBL2wLlAkcEdBPxGEqhBmtiBY3F3DgvEkf+/sOY1rnr6O1qLZuBAnPzA1Vnco8Jwf0DYF0PxaRd8yT5XSl5qGpM2DItEldZwuKKaL94UEgIeC2c+Uv/IOyrv+EyftX96vcmRwr8ghPFLQ+36H5nuAKEpDD170EvfWl1zs0dUPiqSI6l+hy5V14gl63Woi34L727+FKx8oatbyZtdvbeeOmenfTLifLomnZdx+3WMLkp3TLlHa5xDLwifvZtBP2d3c6zHp7gdrGU1u2WTGCAf4wggH6AgEBMHgwczELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MSQwIgYDVQQKExtFeGFtcGxlIFRydXN0ZWQgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFRydXN0ZWQgVmFsaWQgQ0ECAQQwCQYFKw4DAhoFAKBdMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTE1MTExOTA2NTUyOFowIwYJKoZIhvcNAQkEMRYEFENKTXRUkdej+EPd/oKRhz0Cp13zMA0GCSqGSIb3DQEBAQUABIIBAGUh2vVwKqidBo7VEaEtjw3Uh1ElXLRPySu5Mmaw3yHgVhq4jAVnqm2Iwpe+C8d3Jb9Vd98NyvZfXFwu+dHKIEmOk0jQFJeO0kShaaWbK0awz08J9tSUz9WTLzNUAHiYgzNlN7j4S6fQ0d1nxW4+I0GSL6ojAsxWyeUW4QbFfuJe01/WlsVSuUBKwU5a1a7enb10OP84cIdXglm+PpKDyzk+sIyj/hyg57QXjvmLT5+QVGLUk4DmLZUGZKwGLeg4ofwGDqAH6Y+6f5wKo/sQkl7/L0n2wl4TsQwDtS7aE6Uu6uswp/du/OwLY6fpTChVfHqn8t96u/swJmMSvF/eq2g=\r
|
||||
--X3JDIZCX8G\r
|
||||
Content-Location: manifest.webapp\r
|
||||
Content-Type: application/x-web-app-manifest+json\r
|
||||
\r
|
||||
@@ -25,7 +26,7 @@ Content-Type: application/x-web-app-manifest+json\r
|
||||
},
|
||||
{
|
||||
"src": "index.html",
|
||||
"integrity": "Jkvco7U8WOY9s0YREsPouX+DWK7FWlgZwA0iYYSrb7Q="
|
||||
"integrity": "IjQ2S/V9qsC7wW5uv/Niq40M1aivvqH5+1GKRwUnyRg="
|
||||
},
|
||||
{
|
||||
"src": "scripts/script.js",
|
||||
@@ -49,7 +50,7 @@ Content-Type: application/x-web-app-manifest+json\r
|
||||
"package-identifier": "09bc9714-7ab6-4320-9d20-fde4c237522c",
|
||||
"description": "A great app!"
|
||||
}\r
|
||||
--NKWXJUAFXB\r
|
||||
--X3JDIZCX8G\r
|
||||
Content-Location: page2.html\r
|
||||
Content-Type: text/html\r
|
||||
\r
|
||||
@@ -57,25 +58,24 @@ Content-Type: text/html\r
|
||||
page2.html
|
||||
</html>
|
||||
\r
|
||||
--NKWXJUAFXB\r
|
||||
--X3JDIZCX8G\r
|
||||
Content-Location: index.html\r
|
||||
Content-Type: text/html\r
|
||||
\r
|
||||
<html>
|
||||
Last updated: 2015/10/28
|
||||
<iframe id="innerFrame" src="page2.html"></iframe>
|
||||
</html>
|
||||
\r
|
||||
--NKWXJUAFXB\r
|
||||
--X3JDIZCX8G\r
|
||||
Content-Location: scripts/script.js\r
|
||||
Content-Type: text/javascript\r
|
||||
\r
|
||||
// script.js
|
||||
\r
|
||||
--NKWXJUAFXB\r
|
||||
--X3JDIZCX8G\r
|
||||
Content-Location: scripts/library.js\r
|
||||
Content-Type: text/javascript\r
|
||||
\r
|
||||
// library.js
|
||||
\r
|
||||
--NKWXJUAFXB--`;
|
||||
--X3JDIZCX8G--`;
|
||||
|
||||
@@ -1,135 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title> Bug 1209162 - Test Origin Attributes Conversion </title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="application/javascript;version=1.7">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SpecialPowers.pushPrefEnv(
|
||||
{ "set": [["network.http.enable-packaged-apps", true],
|
||||
["network.http.signed-packages.enabled", true],
|
||||
["network.http.signed-packages.trusted-origin", "http://mochi.test:8888"],
|
||||
["dom.mozBrowserFramesEnabled", true]] },
|
||||
() => SpecialPowers.pushPermissions([
|
||||
{ "type": "browser", "allow": 1, "context": document }
|
||||
], function() {
|
||||
runTest();
|
||||
}));
|
||||
|
||||
var Ci = SpecialPowers.Ci;
|
||||
|
||||
function runTest() {
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.setAttribute('mozbrowser', 'true');
|
||||
iframe.setAttribute('remote', 'true');
|
||||
iframe.setAttribute("src", "http://example.org:80");
|
||||
|
||||
iframe.addEventListener("mozbrowserloadend", function loadend(e) {
|
||||
iframe.removeEventListener("mozbrowserloadend", loadend);
|
||||
info("Got mozbrowserloadend");
|
||||
iframe.setAttribute("src", "http://mochi.test:8888/tests/netwerk/test/mochitests/signed_web_packaged_app.sjs!//index.html");
|
||||
|
||||
iframe.addEventListener("mozbrowserloadend", function loadend(e) {
|
||||
iframe.removeEventListener("mozbrowserloadend", loadend);
|
||||
info("Got 2nd mozbrowserloadend");
|
||||
|
||||
// Expected origin attributes for signed package.
|
||||
var expectedSignedOA = {inBrowser: true,
|
||||
signedPkg: "09bc9714-7ab6-4320-9d20-fde4c237522c"};
|
||||
|
||||
// Expected origin attributes for network request.
|
||||
var expectedOA = {inBrowser: true};
|
||||
|
||||
function checkOriginAttributes(attrs, expected) {
|
||||
for (var p in expected) {
|
||||
is(attrs[p], expected[p]);
|
||||
}
|
||||
}
|
||||
|
||||
var mm = SpecialPowers.wrap(iframe)
|
||||
.QueryInterface(Ci.nsIFrameLoaderOwner)
|
||||
.frameLoader
|
||||
.messageManager;
|
||||
mm.addMessageListener("test-document-origin-attributes", function (message) {
|
||||
info("checking origin attributes from document");
|
||||
checkOriginAttributes(message.data.originAttributes, expectedSignedOA);
|
||||
});
|
||||
|
||||
mm.addMessageListener("test-tabchild-origin-attributes", function (message) {
|
||||
info("checking origin attributes from TabChild");
|
||||
checkOriginAttributes(message.data.originAttributes, expectedSignedOA);
|
||||
});
|
||||
|
||||
mm.addMessageListener("test-child-docshell-origin-attributes", function (message) {
|
||||
info("checking origin attributes from inner iframe");
|
||||
checkOriginAttributes(message.data.originAttributes, expectedSignedOA);
|
||||
});
|
||||
|
||||
mm.addMessageListener("test-necko-origin-attributes", function (message) {
|
||||
checkOriginAttributes(message.data.originAttributes, expectedOA);
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
||||
var scriptLoader = mm.QueryInterface(Ci.nsIFrameScriptLoader);
|
||||
getOriginAttributes(scriptLoader, iframe);
|
||||
sendNetworkRequest(scriptLoader, iframe);
|
||||
});
|
||||
});
|
||||
|
||||
document.body.appendChild(iframe);
|
||||
}
|
||||
|
||||
function getOriginAttributes(scriptLoader, iframe) {
|
||||
var frameScript =
|
||||
`
|
||||
function sendOA() {
|
||||
sendAsyncMessage("test-document-origin-attributes",
|
||||
{originAttributes: content.document.nodePrincipal.originAttributes});
|
||||
|
||||
var loadContext = content.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShell)
|
||||
.QueryInterface(Ci.nsILoadContext);
|
||||
sendAsyncMessage("test-tabchild-origin-attributes",
|
||||
{originAttributes: loadContext.originAttributes});
|
||||
|
||||
var frameWindow = content.document.getElementById("innerFrame").contentWindow;
|
||||
var childLoadContext = frameWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShell)
|
||||
.QueryInterface(Ci.nsILoadContext);
|
||||
sendAsyncMessage("test-child-docshell-origin-attributes",
|
||||
{originAttributes: childLoadContext.originAttributes});
|
||||
}
|
||||
`;
|
||||
scriptLoader.loadFrameScript("data:,(" + frameScript + ")()", true);
|
||||
}
|
||||
|
||||
function sendNetworkRequest(scriptLoader, iframe) {
|
||||
var frameScript =
|
||||
`
|
||||
function sendNetworkerOA() {
|
||||
var myXHR = new content.XMLHttpRequest();
|
||||
myXHR.open("GET", "http://mochi.test:8888/tests/netwerk/test/mochitests/signed_web_packaged_app.sjs!//page2.html");
|
||||
myXHR.send();
|
||||
myXHR.onload = function() {
|
||||
var loadInfo = myXHR.channel.loadInfo;
|
||||
sendAsyncMessage("test-necko-origin-attributes",
|
||||
{originAttributes: loadInfo.originAttributes});
|
||||
};
|
||||
}
|
||||
`;
|
||||
scriptLoader.loadFrameScript("data:,(" + frameScript + ")()", true)
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
@@ -91,4 +91,4 @@ function getNodePrincipalOrigin() {
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
@@ -102,7 +102,7 @@ nsUrlClassifierStreamUpdater::FetchUpdate(nsIURI *aUpdateUrl,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->GetLoadInfo();
|
||||
loadInfo->SetOriginAttributes(mozilla::NeckoOriginAttributes(NECKO_SAFEBROWSING_APP_ID, false));
|
||||
loadInfo->SetOriginAttributes(mozilla::OriginAttributes(NECKO_SAFEBROWSING_APP_ID, false));
|
||||
|
||||
mBeganStream = false;
|
||||
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
|
||||
using namespace mozilla::ipc;
|
||||
using mozilla::BasePrincipal;
|
||||
using mozilla::DocShellOriginAttributes;
|
||||
using mozilla::PrincipalOriginAttributes;
|
||||
using mozilla::OriginAttributes;
|
||||
using mozilla::dom::TabParent;
|
||||
|
||||
//
|
||||
@@ -53,7 +52,7 @@ NS_IMPL_ISUPPORTS(OfflineCacheUpdateParent,
|
||||
// OfflineCacheUpdateParent <public>
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
OfflineCacheUpdateParent::OfflineCacheUpdateParent(const DocShellOriginAttributes& aAttrs)
|
||||
OfflineCacheUpdateParent::OfflineCacheUpdateParent(const OriginAttributes& aAttrs)
|
||||
: mIPCClosed(false)
|
||||
, mOriginAttributes(aAttrs)
|
||||
{
|
||||
@@ -94,10 +93,8 @@ OfflineCacheUpdateParent::Schedule(const URIParams& aManifestURI,
|
||||
|
||||
bool offlinePermissionAllowed = false;
|
||||
|
||||
PrincipalOriginAttributes principalAttrs;
|
||||
principalAttrs.InheritFromDocShellToDoc(mOriginAttributes, manifestURI);
|
||||
nsCOMPtr<nsIPrincipal> principal =
|
||||
BasePrincipal::CreateCodebasePrincipal(manifestURI, principalAttrs);
|
||||
BasePrincipal::CreateCodebasePrincipal(manifestURI, mOriginAttributes);
|
||||
|
||||
nsresult rv = service->OfflineAppAllowed(
|
||||
principal, nullptr, &offlinePermissionAllowed);
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
mIPCClosed = true;
|
||||
}
|
||||
|
||||
explicit OfflineCacheUpdateParent(const mozilla::DocShellOriginAttributes& aAttrs);
|
||||
explicit OfflineCacheUpdateParent(const mozilla::OriginAttributes& aAttrs);
|
||||
|
||||
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
|
||||
private:
|
||||
@@ -53,7 +53,7 @@ private:
|
||||
|
||||
bool mIPCClosed;
|
||||
|
||||
mozilla::DocShellOriginAttributes mOriginAttributes;
|
||||
mozilla::OriginAttributes mOriginAttributes;
|
||||
};
|
||||
|
||||
} // namespace docshell
|
||||
|
||||
Reference in New Issue
Block a user