diff --git a/docshell/base/LoadContext.cpp b/docshell/base/LoadContext.cpp index 723d15a51e877..0fe0055a99468 100644 --- a/docshell/base/LoadContext.cpp +++ b/docshell/base/LoadContext.cpp @@ -50,7 +50,7 @@ LoadContext::LoadContext(nsIPrincipal* aPrincipal, , mIsNotNull(true) #endif { - PrincipalOriginAttributes poa = BasePrincipal::Cast(aPrincipal)->OriginAttributesRef(); + PrincipalOriginAttributes poa = aPrincipal->OriginAttributesRef(); mOriginAttributes.InheritFromDocToChildDocShell(poa); if (!aOptionalBase) { return; diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 6815c6db5daab..84a8ad2ce77e1 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -3576,7 +3576,7 @@ nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem, nsCOMPtr accessingPrincipal = accessingDoc->NodePrincipal(); accessingOA.mFirstPartyDomain = - BasePrincipal::Cast(accessingPrincipal)->OriginAttributesRef().mFirstPartyDomain; + accessingPrincipal->OriginAttributesRef().mFirstPartyDomain; } } @@ -3590,7 +3590,7 @@ nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem, nsCOMPtr targetPrincipal = targetDoc->NodePrincipal(); targetOA.mFirstPartyDomain = - BasePrincipal::Cast(targetPrincipal)->OriginAttributesRef().mFirstPartyDomain; + targetPrincipal->OriginAttributesRef().mFirstPartyDomain; } } } @@ -7980,7 +7980,7 @@ nsDocShell::CreateAboutBlankContentViewer(nsIPrincipal* aPrincipal, if (aPrincipal && !nsContentUtils::IsSystemPrincipal(aPrincipal) && mItemType != typeChrome) { MOZ_ASSERT(ChromeUtils::IsOriginAttributesEqualIgnoringAddonId( - BasePrincipal::Cast(aPrincipal)->OriginAttributesRef(), + aPrincipal->OriginAttributesRef(), mOriginAttributes)); } diff --git a/dom/base/PostMessageEvent.cpp b/dom/base/PostMessageEvent.cpp index 78d9337df188f..c7f34994fe9be 100644 --- a/dom/base/PostMessageEvent.cpp +++ b/dom/base/PostMessageEvent.cpp @@ -113,8 +113,8 @@ PostMessageEvent::Run() NS_ENSURE_SUCCESS(rv, rv); MOZ_DIAGNOSTIC_ASSERT(providedOrigin != targetOrigin || - (BasePrincipal::Cast(mProvidedPrincipal)->OriginAttributesRef() == - BasePrincipal::Cast(targetPrin)->OriginAttributesRef()), + (mProvidedPrincipal->OriginAttributesRef() == + targetPrin->OriginAttributesRef()), "Unexpected postMessage call to a window with mismatched " "origin attributes"); diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index d6b44b8fd5a08..6e4432797c3b8 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -2386,7 +2386,7 @@ nsFrameLoader::MaybeCreateDocShell() if (parentType == nsIDocShellTreeItem::typeContent && !nsContentUtils::IsSystemPrincipal(doc->NodePrincipal()) && !OwnerIsMozBrowserFrame()) { - PrincipalOriginAttributes poa = BasePrincipal::Cast(doc->NodePrincipal())->OriginAttributesRef(); + PrincipalOriginAttributes poa = doc->NodePrincipal()->OriginAttributesRef(); // Assert on the firstPartyDomain from top-level docshell should be empty if (mIsTopLevelContent) { diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 0444051c60ecf..8ca370d78e062 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -2464,8 +2464,7 @@ nsGlobalWindow::ComputeIsSecureContext(nsIDocument* aDocument) // IsOriginPotentiallyTrustworthy doesn't care about origin attributes so // it doesn't actually matter what we use here, but reusing the document // principal's attributes is convenient. - const PrincipalOriginAttributes& attrs = - BasePrincipal::Cast(principal)->OriginAttributesRef(); + const PrincipalOriginAttributes& attrs = principal->OriginAttributesRef(); // CreateCodebasePrincipal correctly gets a useful principal for blob: and // other URI_INHERITS_SECURITY_CONTEXT URIs. principal = BasePrincipal::CreateCodebasePrincipal(uri, attrs); @@ -8465,8 +8464,7 @@ nsGlobalWindow::PostMessageMozOuter(JSContext* aCx, JS::Handle aMessa return; } - PrincipalOriginAttributes attrs = - BasePrincipal::Cast(&aSubjectPrincipal)->OriginAttributesRef(); + PrincipalOriginAttributes attrs = aSubjectPrincipal.OriginAttributesRef(); if (aSubjectPrincipal.GetIsSystemPrincipal()) { auto principal = BasePrincipal::Cast(GetPrincipal()); diff --git a/dom/console/Console.cpp b/dom/console/Console.cpp index 8ae1b13f1d7e6..655655df9fae6 100644 --- a/dom/console/Console.cpp +++ b/dom/console/Console.cpp @@ -1217,7 +1217,7 @@ Console::MethodInternal(JSContext* aCx, MethodName aMethodName, return; } - oa = BasePrincipal::Cast(principal)->OriginAttributesRef(); + oa = principal->OriginAttributesRef(); #ifdef DEBUG if (!nsContentUtils::IsSystemPrincipal(principal)) { diff --git a/dom/quota/ActorsParent.cpp b/dom/quota/ActorsParent.cpp index 09e9f87f632e2..b85e5558d34b7 100644 --- a/dom/quota/ActorsParent.cpp +++ b/dom/quota/ActorsParent.cpp @@ -4671,7 +4671,7 @@ QuotaManager::GetInfoFromPrincipal(nsIPrincipal* aPrincipal, } nsCString suffix; - BasePrincipal::Cast(aPrincipal)->OriginAttributesRef().CreateSuffix(suffix); + aPrincipal->OriginAttributesRef().CreateSuffix(suffix); if (aSuffix) { diff --git a/dom/quota/QuotaManagerService.cpp b/dom/quota/QuotaManagerService.cpp index 5380535795073..6af8c218d01e4 100644 --- a/dom/quota/QuotaManagerService.cpp +++ b/dom/quota/QuotaManagerService.cpp @@ -572,7 +572,7 @@ QuotaManagerService::ClearStoragesForPrincipal(nsIPrincipal* aPrincipal, MOZ_ASSERT(nsContentUtils::IsCallerChrome()); nsCString suffix; - BasePrincipal::Cast(aPrincipal)->OriginAttributesRef().CreateSuffix(suffix); + aPrincipal->OriginAttributesRef().CreateSuffix(suffix); if (NS_WARN_IF(aClearAll && !suffix.IsEmpty())) { // The originAttributes should be default originAttributes when the diff --git a/dom/storage/DOMStorageCache.cpp b/dom/storage/DOMStorageCache.cpp index 811f79fd3681d..7345fc8408110 100644 --- a/dom/storage/DOMStorageCache.cpp +++ b/dom/storage/DOMStorageCache.cpp @@ -133,7 +133,7 @@ DOMStorageCache::Init(DOMStorageManager* aManager, mInitialized = true; mPrincipal = aPrincipal; - BasePrincipal::Cast(aPrincipal)->OriginAttributesRef().CreateSuffix(mOriginSuffix); + aPrincipal->OriginAttributesRef().CreateSuffix(mOriginSuffix); mPersistent = aPersistent; if (aQuotaOriginScope.IsEmpty()) { mQuotaOriginScope = Origin(); diff --git a/dom/storage/DOMStorageManager.cpp b/dom/storage/DOMStorageManager.cpp index 7e6dc2fb92ef5..556a0f40c6fe2 100644 --- a/dom/storage/DOMStorageManager.cpp +++ b/dom/storage/DOMStorageManager.cpp @@ -201,7 +201,7 @@ CreateQuotaDBKey(nsIPrincipal* aPrincipal, NS_ENSURE_SUCCESS(rv, rv); aKey.Truncate(); - BasePrincipal::Cast(aPrincipal)->OriginAttributesRef().CreateSuffix(aKey); + aPrincipal->OriginAttributesRef().CreateSuffix(aKey); nsAutoCString subdomainsDBKey; CreateReversedDomain(eTLDplusOne, subdomainsDBKey); @@ -315,7 +315,7 @@ DOMStorageManager::GetStorageInternal(bool aCreate, nsresult rv; nsAutoCString originAttrSuffix; - BasePrincipal::Cast(aPrincipal)->OriginAttributesRef().CreateSuffix(originAttrSuffix); + aPrincipal->OriginAttributesRef().CreateSuffix(originAttrSuffix); nsAutoCString originKey; rv = AppendOriginNoSuffix(aPrincipal, originKey); @@ -441,7 +441,7 @@ DOMStorageManager::CheckStorage(nsIPrincipal* aPrincipal, } nsAutoCString suffix; - BasePrincipal::Cast(aPrincipal)->OriginAttributesRef().CreateSuffix(suffix); + aPrincipal->OriginAttributesRef().CreateSuffix(suffix); nsAutoCString origin; rv = AppendOriginNoSuffix(aPrincipal, origin); diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp index 2f83901c91413..e3995f0c97bb1 100644 --- a/dom/workers/RuntimeService.cpp +++ b/dom/workers/RuntimeService.cpp @@ -2427,7 +2427,7 @@ RuntimeService::CreateSharedWorkerFromLoadInfo(JSContext* aCx, MOZ_ASSERT(aLoadInfo->mPrincipal); nsAutoCString key; GenerateSharedWorkerKey(scriptSpec, aName, - BasePrincipal::Cast(aLoadInfo->mPrincipal)->OriginAttributesRef(), key); + aLoadInfo->mPrincipal->OriginAttributesRef(), key); if (mDomainMap.Get(aLoadInfo->mDomain, &domainInfo) && domainInfo->mSharedWorkerInfos.Get(key, &sharedWorkerInfo)) { diff --git a/dom/workers/ServiceWorkerInfo.cpp b/dom/workers/ServiceWorkerInfo.cpp index 5d7644b63078f..4ce9670f52c84 100644 --- a/dom/workers/ServiceWorkerInfo.cpp +++ b/dom/workers/ServiceWorkerInfo.cpp @@ -184,7 +184,7 @@ ServiceWorkerInfo::ServiceWorkerInfo(nsIPrincipal* aPrincipal, { MOZ_ASSERT(mPrincipal); // cache origin attributes so we can use them off main thread - mOriginAttributes = BasePrincipal::Cast(mPrincipal)->OriginAttributesRef(); + mOriginAttributes = mPrincipal->OriginAttributesRef(); MOZ_ASSERT(!mScope.IsEmpty()); MOZ_ASSERT(!mScriptSpec.IsEmpty()); MOZ_ASSERT(!mCacheName.IsEmpty()); diff --git a/dom/workers/ServiceWorkerManager.cpp b/dom/workers/ServiceWorkerManager.cpp index 2e7cb8f5efdec..a586c23380bb7 100644 --- a/dom/workers/ServiceWorkerManager.cpp +++ b/dom/workers/ServiceWorkerManager.cpp @@ -3328,7 +3328,7 @@ ServiceWorkerManager::RemoveAllRegistrations(OriginAttributesPattern* aPattern) MOZ_ASSERT(reg->mPrincipal); bool matches = - aPattern->Matches(BasePrincipal::Cast(reg->mPrincipal)->OriginAttributesRef()); + aPattern->Matches(reg->mPrincipal->OriginAttributesRef()); if (!matches) { continue; } @@ -3892,8 +3892,7 @@ ServiceWorkerManager::UpdateTimerFired(nsIPrincipal* aPrincipal, return; } - PrincipalOriginAttributes attrs = - BasePrincipal::Cast(aPrincipal)->OriginAttributesRef(); + PrincipalOriginAttributes attrs = aPrincipal->OriginAttributesRef(); SoftUpdate(attrs, aScope); } diff --git a/dom/workers/ServiceWorkerScriptCache.cpp b/dom/workers/ServiceWorkerScriptCache.cpp index d6913a51a7339..b7499fd10d8f6 100644 --- a/dom/workers/ServiceWorkerScriptCache.cpp +++ b/dom/workers/ServiceWorkerScriptCache.cpp @@ -20,6 +20,7 @@ #include "nsIPrincipal.h" #include "nsIScriptError.h" +#include "nsIScriptSecurityManager.h" #include "nsContentUtils.h" #include "nsNetUtil.h" #include "nsScriptLoader.h" diff --git a/embedding/components/windowwatcher/nsWindowWatcher.cpp b/embedding/components/windowwatcher/nsWindowWatcher.cpp index b0e0ff398fe63..2822814db9221 100644 --- a/embedding/components/windowwatcher/nsWindowWatcher.cpp +++ b/embedding/components/windowwatcher/nsWindowWatcher.cpp @@ -1104,7 +1104,7 @@ nsWindowWatcher::OpenWindowInternal(mozIDOMWindowProxy* aParent, !nsContentUtils::IsSystemOrExpandedPrincipal(subjectPrincipal) && docShell->ItemType() != nsIDocShellTreeItem::typeChrome) { DocShellOriginAttributes attrs; - attrs.InheritFromDocToChildDocShell(BasePrincipal::Cast(subjectPrincipal)->OriginAttributesRef()); + attrs.InheritFromDocToChildDocShell(subjectPrincipal->OriginAttributesRef()); isPrivateBrowsingWindow = !!attrs.mPrivateBrowsingId; docShell->SetOriginAttributes(attrs); } else { diff --git a/extensions/cookie/nsPermission.cpp b/extensions/cookie/nsPermission.cpp index 3d1eb140a276a..4eb9a65438c4d 100644 --- a/extensions/cookie/nsPermission.cpp +++ b/extensions/cookie/nsPermission.cpp @@ -110,8 +110,8 @@ nsPermission::Matches(nsIPrincipal* aPrincipal, bool aExactHost, bool* aMatches) } // Compare their OriginAttributes - const mozilla::PrincipalOriginAttributes& theirAttrs = mozilla::BasePrincipal::Cast(principal)->OriginAttributesRef(); - const mozilla::PrincipalOriginAttributes& ourAttrs = mozilla::BasePrincipal::Cast(mPrincipal)->OriginAttributesRef(); + const mozilla::PrincipalOriginAttributes& theirAttrs = principal->OriginAttributesRef(); + const mozilla::PrincipalOriginAttributes& ourAttrs = mPrincipal->OriginAttributesRef(); if (theirAttrs != ourAttrs) { return NS_OK; diff --git a/extensions/cookie/nsPermissionManager.cpp b/extensions/cookie/nsPermissionManager.cpp index d6ed06b9ea95f..2dab718e521d9 100644 --- a/extensions/cookie/nsPermissionManager.cpp +++ b/extensions/cookie/nsPermissionManager.cpp @@ -2208,8 +2208,7 @@ nsPermissionManager::GetPermissionHashKey(nsIPrincipal* aPrincipal, } // Copy the attributes over - mozilla::PrincipalOriginAttributes attrs = - mozilla::BasePrincipal::Cast(aPrincipal)->OriginAttributesRef(); + mozilla::PrincipalOriginAttributes attrs = aPrincipal->OriginAttributesRef(); // Disable userContext and firstParty isolation for permissions. attrs.StripUserContextIdAndFirstPartyDomain(); @@ -2410,7 +2409,7 @@ nsPermissionManager::RemovePermissionsWithAttributes(mozilla::OriginAttributesPa continue; } - if (!aPattern.Matches(mozilla::BasePrincipal::Cast(principal)->OriginAttributesRef())) { + if (!aPattern.Matches(principal->OriginAttributesRef())) { continue; } diff --git a/image/imgLoader.cpp b/image/imgLoader.cpp index eca141fc5de93..cacb100a424fc 100644 --- a/image/imgLoader.cpp +++ b/image/imgLoader.cpp @@ -753,7 +753,7 @@ NewImageChannel(nsIChannel** aResult, // loadingPrincipal as the channel's originAttributes. This allows the favicon // loading from XUL will use the correct originAttributes. NeckoOriginAttributes neckoAttrs; - neckoAttrs.InheritFromDocToNecko(BasePrincipal::Cast(aLoadingPrincipal)->OriginAttributesRef()); + neckoAttrs.InheritFromDocToNecko(aLoadingPrincipal->OriginAttributesRef()); nsCOMPtr loadInfo = (*aResult)->GetLoadInfo(); rv = loadInfo->SetOriginAttributes(neckoAttrs); @@ -783,7 +783,7 @@ NewImageChannel(nsIChannel** aResult, // has asked us to perform. NeckoOriginAttributes neckoAttrs; if (aLoadingPrincipal) { - neckoAttrs.InheritFromDocToNecko(BasePrincipal::Cast(aLoadingPrincipal)->OriginAttributesRef()); + neckoAttrs.InheritFromDocToNecko(aLoadingPrincipal->OriginAttributesRef()); } neckoAttrs.mPrivateBrowsingId = aRespectPrivacy ? 1 : 0; @@ -1352,7 +1352,7 @@ imgLoader::FindEntryProperties(nsIURI* uri, if (doc) { nsCOMPtr principal = doc->NodePrincipal(); if (principal) { - attrs = BasePrincipal::Cast(principal)->OriginAttributesRef(); + attrs = principal->OriginAttributesRef(); } } @@ -2114,7 +2114,7 @@ imgLoader::LoadImage(nsIURI* aURI, // of post data. PrincipalOriginAttributes attrs; if (aLoadingPrincipal) { - attrs = BasePrincipal::Cast(aLoadingPrincipal)->OriginAttributesRef(); + attrs = aLoadingPrincipal->OriginAttributesRef(); } ImageCacheKey key(aURI, attrs, aLoadingDocument, rv); NS_ENSURE_SUCCESS(rv, rv); diff --git a/ipc/glue/BackgroundUtils.cpp b/ipc/glue/BackgroundUtils.cpp index 75893be885d98..d43b946124334 100644 --- a/ipc/glue/BackgroundUtils.cpp +++ b/ipc/glue/BackgroundUtils.cpp @@ -154,8 +154,7 @@ PrincipalToPrincipalInfo(nsIPrincipal* aPrincipal, } *aPrincipalInfo = - NullPrincipalInfo(BasePrincipal::Cast(aPrincipal)->OriginAttributesRef(), - spec); + NullPrincipalInfo(aPrincipal->OriginAttributesRef(), spec); return NS_OK; } @@ -198,7 +197,7 @@ PrincipalToPrincipalInfo(nsIPrincipal* aPrincipal, } *aPrincipalInfo = - ExpandedPrincipalInfo(BasePrincipal::Cast(aPrincipal)->OriginAttributesRef(), + ExpandedPrincipalInfo(aPrincipal->OriginAttributesRef(), Move(whitelistInfo)); return NS_OK; } @@ -221,7 +220,7 @@ PrincipalToPrincipalInfo(nsIPrincipal* aPrincipal, return rv; } - *aPrincipalInfo = ContentPrincipalInfo(BasePrincipal::Cast(aPrincipal)->OriginAttributesRef(), + *aPrincipalInfo = ContentPrincipalInfo(aPrincipal->OriginAttributesRef(), spec); return NS_OK; } diff --git a/js/xpconnect/src/Sandbox.cpp b/js/xpconnect/src/Sandbox.cpp index e82f652e1c638..239927ddd3f43 100644 --- a/js/xpconnect/src/Sandbox.cpp +++ b/js/xpconnect/src/Sandbox.cpp @@ -1377,7 +1377,7 @@ GetExpandedPrincipal(JSContext* cx, HandleObject arrayObj, if (!options.originAttributes) { const PrincipalOriginAttributes prinAttrs = - BasePrincipal::Cast(principal)->OriginAttributesRef(); + principal->OriginAttributesRef(); if (attrs.isNothing()) { attrs.emplace(prinAttrs); } else if (prinAttrs != attrs.ref()) { diff --git a/js/xpconnect/src/XPCWrappedNativeScope.cpp b/js/xpconnect/src/XPCWrappedNativeScope.cpp index 24f1067d0d3df..988477bb8b66f 100644 --- a/js/xpconnect/src/XPCWrappedNativeScope.cpp +++ b/js/xpconnect/src/XPCWrappedNativeScope.cpp @@ -297,7 +297,7 @@ XPCWrappedNativeScope::EnsureContentXBLScope(JSContext* cx) principalAsArray.AppendElement(principal); nsCOMPtr ep = new nsExpandedPrincipal(principalAsArray, - BasePrincipal::Cast(principal)->OriginAttributesRef()); + principal->OriginAttributesRef()); // Create the sandbox. RootedValue v(cx); diff --git a/netwerk/base/LoadInfo.cpp b/netwerk/base/LoadInfo.cpp index 216cf559cd3ed..1091a68da6d6f 100644 --- a/netwerk/base/LoadInfo.cpp +++ b/netwerk/base/LoadInfo.cpp @@ -32,7 +32,7 @@ static void InheritOriginAttributes(nsIPrincipal* aLoadingPrincipal, NeckoOriginAttributes& aAttrs) { const PrincipalOriginAttributes attrs = - BasePrincipal::Cast(aLoadingPrincipal)->OriginAttributesRef(); + aLoadingPrincipal->OriginAttributesRef(); aAttrs.InheritFromDocToNecko(attrs); } diff --git a/netwerk/protocol/http/nsHttpAuthManager.cpp b/netwerk/protocol/http/nsHttpAuthManager.cpp index a2f1b7c5e750c..1de39bdf20f7e 100644 --- a/netwerk/protocol/http/nsHttpAuthManager.cpp +++ b/netwerk/protocol/http/nsHttpAuthManager.cpp @@ -70,7 +70,7 @@ nsHttpAuthManager::GetAuthIdentity(const nsACString & aScheme, nsAutoCString originSuffix; if (aPrincipal) { - BasePrincipal::Cast(aPrincipal)->OriginAttributesRef().CreateSuffix(originSuffix); + aPrincipal->OriginAttributesRef().CreateSuffix(originSuffix); } if (!aPath.IsEmpty()) @@ -118,10 +118,9 @@ nsHttpAuthManager::SetAuthIdentity(const nsACString & aScheme, nsAutoCString originSuffix; if (aPrincipal) { - BasePrincipal::Cast(aPrincipal)->OriginAttributesRef().CreateSuffix(originSuffix); + aPrincipal->OriginAttributesRef().CreateSuffix(originSuffix); } - nsHttpAuthCache* auth_cache = aIsPrivate ? mPrivateAuthCache : mAuthCache; return auth_cache->SetAuthEntry(PromiseFlatCString(aScheme).get(), PromiseFlatCString(aHost).get(), diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index 580db67516f11..42fe2f2a8bc9e 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -2311,7 +2311,7 @@ nsHttpHandler::SpeculativeConnectInternal(nsIURI *aURI, // loadContext. if (aPrincipal) { neckoOriginAttributes.InheritFromDocToNecko( - BasePrincipal::Cast(aPrincipal)->OriginAttributesRef()); + aPrincipal->OriginAttributesRef()); } else if (loadContext) { DocShellOriginAttributes docshellOriginAttributes; loadContext->GetOriginAttributes(docshellOriginAttributes);