--- a/image/imgLoader.cpp
+++ b/image/imgLoader.cpp
@@ -565,17 +565,17 @@ ShouldRevalidateEntry(imgCacheEntry* aEn
return bValidateEntry;
}
/* Call content policies on cached images that went through a redirect */
static bool
ShouldLoadCachedImage(imgRequest* aImgRequest,
nsISupports* aLoadingContext,
- nsIPrincipal* aLoadingPrincipal,
+ nsIPrincipal* aTriggeringPrincipal,
nsContentPolicyType aPolicyType)
{
/* Call content policies on cached images - Bug 1082837
* Cached images are keyed off of the first uri in a redirect chain.
* Hence content policies don't get a chance to test the intermediate hops
* or the final desitnation. Here we test the final destination using
* mCurrentURI off of the imgRequest and passing it into content policies.
* For Mixed Content Blocker, we do an additional check to determine if any
@@ -585,17 +585,17 @@ ShouldLoadCachedImage(imgRequest* aImgRe
bool insecureRedirect = aImgRequest->HadInsecureRedirect();
nsCOMPtr<nsIURI> contentLocation;
aImgRequest->GetCurrentURI(getter_AddRefs(contentLocation));
nsresult rv;
int16_t decision = nsIContentPolicy::REJECT_REQUEST;
rv = NS_CheckContentLoadPolicy(aPolicyType,
contentLocation,
- aLoadingPrincipal,
+ aTriggeringPrincipal,
aLoadingContext,
EmptyCString(), //mime guess
nullptr, //aExtra
&decision,
nsContentUtils::GetContentPolicy());
if (NS_FAILED(rv) || !NS_CP_ACCEPTED(decision)) {
return false;
}
@@ -611,34 +611,34 @@ ShouldLoadCachedImage(imgRequest* aImgRe
nsCOMPtr<nsIDocShell> docShell = NS_CP_GetDocShellFromContext(aLoadingContext);
if (docShell) {
nsIDocument* document = docShell->GetDocument();
if (document && document->GetUpgradeInsecureRequests(false)) {
return false;
}
}
- if (!nsContentUtils::IsSystemPrincipal(aLoadingPrincipal)) {
- // Set the requestingLocation from the aLoadingPrincipal.
+ if (!nsContentUtils::IsSystemPrincipal(aTriggeringPrincipal)) {
+ // Set the requestingLocation from the aTriggeringPrincipal.
nsCOMPtr<nsIURI> requestingLocation;
- if (aLoadingPrincipal) {
- rv = aLoadingPrincipal->GetURI(getter_AddRefs(requestingLocation));
+ if (aTriggeringPrincipal) {
+ rv = aTriggeringPrincipal->GetURI(getter_AddRefs(requestingLocation));
NS_ENSURE_SUCCESS(rv, false);
}
// reset the decision for mixed content blocker check
decision = nsIContentPolicy::REJECT_REQUEST;
rv = nsMixedContentBlocker::ShouldLoad(insecureRedirect,
aPolicyType,
contentLocation,
requestingLocation,
aLoadingContext,
EmptyCString(), //mime guess
nullptr,
- aLoadingPrincipal,
+ aTriggeringPrincipal,
&decision);
if (NS_FAILED(rv) || !NS_CP_ACCEPTED(decision)) {
return false;
}
}
}
bool sendPriming = false;
@@ -658,17 +658,17 @@ ShouldLoadCachedImage(imgRequest* aImgRe
}
// Returns true if this request is compatible with the given CORS mode on the
// given loading principal, and false if the request may not be reused due
// to CORS. Also checks the Referrer Policy, since requests with different
// referrers/policies may generate different responses.
static bool
ValidateSecurityInfo(imgRequest* request, bool forcePrincipalCheck,
- int32_t corsmode, nsIPrincipal* loadingPrincipal,
+ int32_t corsmode, nsIPrincipal* triggeringPrincipal,
nsISupports* aCX, nsContentPolicyType aPolicyType,
ReferrerPolicy referrerPolicy)
{
// If the entry's Referrer Policy doesn't match, we can't use this request.
// XXX: this will return false if an image has different referrer attributes,
// i.e. we currently don't use the cached image but reload the image with
// the new referrer policy bug 1174921
if (referrerPolicy != request->GetReferrerPolicy()) {
@@ -677,56 +677,56 @@ ValidateSecurityInfo(imgRequest* request
// If the entry's CORS mode doesn't match, or the CORS mode matches but the
// document principal isn't the same, we can't use this request.
if (request->GetCORSMode() != corsmode) {
return false;
}
if (request->GetCORSMode() != imgIRequest::CORS_NONE ||
forcePrincipalCheck) {
- nsCOMPtr<nsIPrincipal> otherprincipal = request->GetLoadingPrincipal();
+ nsCOMPtr<nsIPrincipal> otherprincipal = request->GetTriggeringPrincipal();
// If we previously had a principal, but we don't now, we can't use this
// request.
- if (otherprincipal && !loadingPrincipal) {
+ if (otherprincipal && !triggeringPrincipal) {
return false;
}
- if (otherprincipal && loadingPrincipal) {
+ if (otherprincipal && triggeringPrincipal) {
bool equals = false;
- otherprincipal->Equals(loadingPrincipal, &equals);
+ otherprincipal->Equals(triggeringPrincipal, &equals);
if (!equals) {
return false;
}
}
}
// Content Policy Check on Cached Images
- return ShouldLoadCachedImage(request, aCX, loadingPrincipal, aPolicyType);
+ return ShouldLoadCachedImage(request, aCX, triggeringPrincipal, aPolicyType);
}
static nsresult
NewImageChannel(nsIChannel** aResult,
// If aForcePrincipalCheckForCacheEntry is true, then we will
// force a principal check even when not using CORS before
// assuming we have a cache hit on a cache entry that we
// create for this channel. This is an out param that should
// be set to true if this channel ends up depending on
- // aLoadingPrincipal and false otherwise.
+ // aTriggeringPrincipal and false otherwise.
bool* aForcePrincipalCheckForCacheEntry,
nsIURI* aURI,
nsIURI* aInitialDocumentURI,
int32_t aCORSMode,
nsIURI* aReferringURI,
ReferrerPolicy aReferrerPolicy,
nsILoadGroup* aLoadGroup,
const nsCString& aAcceptHeader,
nsLoadFlags aLoadFlags,
nsContentPolicyType aPolicyType,
- nsIPrincipal* aLoadingPrincipal,
+ nsIPrincipal* aTriggeringPrincipal,
nsISupports* aRequestingContext,
bool aRespectPrivacy)
{
MOZ_ASSERT(aResult);
nsresult rv;
nsCOMPtr<nsIHttpChannel> newHttpChannel;
@@ -763,46 +763,46 @@ NewImageChannel(nsIChannel** aResult,
securityFlags |= nsILoadInfo::SEC_COOKIES_INCLUDE;
}
securityFlags |= nsILoadInfo::SEC_ALLOW_CHROME;
// Note we are calling NS_NewChannelWithTriggeringPrincipal() here with a
// node and a principal. This is for things like background images that are
// specified by user stylesheets, where the document is being styled, but
// the principal is that of the user stylesheet.
- if (requestingNode && aLoadingPrincipal) {
+ if (requestingNode && aTriggeringPrincipal) {
rv = NS_NewChannelWithTriggeringPrincipal(aResult,
aURI,
requestingNode,
- aLoadingPrincipal,
+ aTriggeringPrincipal,
securityFlags,
aPolicyType,
nullptr, // loadGroup
callbacks,
aLoadFlags);
if (NS_FAILED(rv)) {
return rv;
}
if (aPolicyType == nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON) {
// If this is a favicon loading, we will use the originAttributes from the
- // loadingPrincipal as the channel's originAttributes. This allows the favicon
+ // triggeringPrincipal as the channel's originAttributes. This allows the favicon
// loading from XUL will use the correct originAttributes.
nsCOMPtr<nsILoadInfo> loadInfo = (*aResult)->GetLoadInfo();
if (loadInfo) {
rv =
- loadInfo->SetOriginAttributes(aLoadingPrincipal->OriginAttributesRef());
+ loadInfo->SetOriginAttributes(aTriggeringPrincipal->OriginAttributesRef());
}
}
} else {
// either we are loading something inside a document, in which case
// we should always have a requestingNode, or we are loading something
- // outside a document, in which case the loadingPrincipal and
+ // outside a document, in which case the triggeringPrincipal and
// triggeringPrincipal should always be the systemPrincipal.
// However, there are exceptions: one is Notifications which create a
// channel in the parent prcoess in which case we can't get a requestingNode.
rv = NS_NewChannel(aResult,
aURI,
nsContentUtils::GetSystemPrincipal(),
securityFlags,
aPolicyType,
@@ -813,36 +813,36 @@ NewImageChannel(nsIChannel** aResult,
if (NS_FAILED(rv)) {
return rv;
}
// Use the OriginAttributes from the loading principal, if one is available,
// and adjust the private browsing ID based on what kind of load the caller
// has asked us to perform.
OriginAttributes attrs;
- if (aLoadingPrincipal) {
- attrs = aLoadingPrincipal->OriginAttributesRef();
+ if (aTriggeringPrincipal) {
+ attrs = aTriggeringPrincipal->OriginAttributesRef();
}
attrs.mPrivateBrowsingId = aRespectPrivacy ? 1 : 0;
nsCOMPtr<nsILoadInfo> loadInfo = (*aResult)->GetLoadInfo();
if (loadInfo) {
rv = loadInfo->SetOriginAttributes(attrs);
}
}
if (NS_FAILED(rv)) {
return rv;
}
// only inherit if we have a principal
*aForcePrincipalCheckForCacheEntry =
- aLoadingPrincipal &&
+ aTriggeringPrincipal &&
nsContentUtils::ChannelShouldInheritPrincipal(
- aLoadingPrincipal,
+ aTriggeringPrincipal,
aURI,
/* aInheritForAboutBlank */ false,
/* aForceInherit */ false);
// Initialize HTTP-specific attributes
newHttpChannel = do_QueryInterface(*aResult);
if (newHttpChannel) {
rv = newHttpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept"),
@@ -1705,17 +1705,17 @@ imgLoader::ValidateRequestWithNewChannel
ReferrerPolicy aReferrerPolicy,
nsILoadGroup* aLoadGroup,
imgINotificationObserver* aObserver,
nsISupports* aCX,
nsIDocument* aLoadingDocument,
nsLoadFlags aLoadFlags,
nsContentPolicyType aLoadPolicyType,
imgRequestProxy** aProxyRequest,
- nsIPrincipal* aLoadingPrincipal,
+ nsIPrincipal* aTriggeringPrincipal,
int32_t aCORSMode)
{
// now we need to insert a new channel request object inbetween the real
// request and the proxy that basically delays loading the image until it
// gets a 304 or figures out that this needs to be a new request
nsresult rv;
@@ -1755,17 +1755,17 @@ imgLoader::ValidateRequestWithNewChannel
aInitialDocumentURI,
aCORSMode,
aReferrerURI,
aReferrerPolicy,
aLoadGroup,
mAcceptHeader,
aLoadFlags,
aLoadPolicyType,
- aLoadingPrincipal,
+ aTriggeringPrincipal,
aCX,
mRespectPrivacy);
if (NS_FAILED(rv)) {
return false;
}
RefPtr<imgRequestProxy> req;
rv = CreateNewProxyForRequest(request, aLoadGroup, aLoadingDocument,
@@ -1827,17 +1827,17 @@ imgLoader::ValidateEntry(imgCacheEntry*
nsILoadGroup* aLoadGroup,
imgINotificationObserver* aObserver,
nsISupports* aCX,
nsIDocument* aLoadingDocument,
nsLoadFlags aLoadFlags,
nsContentPolicyType aLoadPolicyType,
bool aCanMakeNewChannel,
imgRequestProxy** aProxyRequest,
- nsIPrincipal* aLoadingPrincipal,
+ nsIPrincipal* aTriggeringPrincipal,
int32_t aCORSMode)
{
LOG_SCOPE(gImgLog, "imgLoader::ValidateEntry");
bool hasExpired;
uint32_t expirationTime = aEntry->GetExpiryTime();
if (expirationTime <= SecondsFromPRTime(PR_Now())) {
hasExpired = true;
@@ -1867,17 +1867,17 @@ imgLoader::ValidateEntry(imgCacheEntry*
RefPtr<imgRequest> request(aEntry->GetRequest());
if (!request) {
return false;
}
if (!ValidateSecurityInfo(request, aEntry->ForcePrincipalCheck(),
- aCORSMode, aLoadingPrincipal,
+ aCORSMode, aTriggeringPrincipal,
aCX, aLoadPolicyType, aReferrerPolicy))
return false;
// data URIs are immutable and by their nature can't leak data, so we can
// just return true in that case. Doing so would mean that shift-reload
// doesn't reload data URI documents/images though (which is handy for
// debugging during gecko development) so we make an exception in that case.
nsAutoCString scheme;
@@ -1945,17 +1945,17 @@ imgLoader::ValidateEntry(imgCacheEntry*
LOG_SCOPE(gImgLog,
"imgLoader::ValidateRequest |cache hit| must validate");
return ValidateRequestWithNewChannel(request, aURI, aInitialDocumentURI,
aReferrerURI, aReferrerPolicy,
aLoadGroup, aObserver,
aCX, aLoadingDocument,
aLoadFlags, aLoadPolicyType,
- aProxyRequest, aLoadingPrincipal,
+ aProxyRequest, aTriggeringPrincipal,
aCORSMode);
}
return !validateRequest;
}
bool
imgLoader::RemoveFromCache(const ImageCacheKey& aKey)
@@ -2103,17 +2103,17 @@ imgLoader::RemoveFromUncachedImages(imgR
nsIRequest::VALIDATE_NEVER | \
nsIRequest::VALIDATE_ONCE_PER_SESSION)
NS_IMETHODIMP
imgLoader::LoadImageXPCOM(nsIURI* aURI,
nsIURI* aInitialDocumentURI,
nsIURI* aReferrerURI,
const nsAString& aReferrerPolicy,
- nsIPrincipal* aLoadingPrincipal,
+ nsIPrincipal* aTriggeringPrincipal,
nsILoadGroup* aLoadGroup,
imgINotificationObserver* aObserver,
nsISupports* aCX,
nsLoadFlags aLoadFlags,
nsISupports* aCacheKey,
nsContentPolicyType aContentPolicyType,
imgIRequest** _retval)
{
@@ -2124,17 +2124,17 @@ imgLoader::LoadImageXPCOM(nsIURI* aURI,
imgRequestProxy* proxy;
ReferrerPolicy refpol = ReferrerPolicyFromString(aReferrerPolicy);
nsCOMPtr<nsINode> node = do_QueryInterface(aCX);
nsCOMPtr<nsIDocument> doc = do_QueryInterface(aCX);
nsresult rv = LoadImage(aURI,
aInitialDocumentURI,
aReferrerURI,
refpol,
- aLoadingPrincipal,
+ aTriggeringPrincipal,
0,
aLoadGroup,
aObserver,
node,
doc,
aLoadFlags,
aCacheKey,
aContentPolicyType,
@@ -2145,17 +2145,17 @@ imgLoader::LoadImageXPCOM(nsIURI* aURI,
return rv;
}
nsresult
imgLoader::LoadImage(nsIURI* aURI,
nsIURI* aInitialDocumentURI,
nsIURI* aReferrerURI,
ReferrerPolicy aReferrerPolicy,
- nsIPrincipal* aLoadingPrincipal,
+ nsIPrincipal* aTriggeringPrincipal,
uint64_t aRequestContextID,
nsILoadGroup* aLoadGroup,
imgINotificationObserver* aObserver,
nsINode *aContext,
nsIDocument* aLoadingDocument,
nsLoadFlags aLoadFlags,
nsISupports* aCacheKey,
nsContentPolicyType aContentPolicyType,
@@ -2227,28 +2227,28 @@ imgLoader::LoadImage(nsIURI* aURI,
RefPtr<imgCacheEntry> entry;
// Look in the cache for our URI, and then validate it.
// XXX For now ignore aCacheKey. We will need it in the future
// for correctly dealing with image load requests that are a result
// of post data.
OriginAttributes attrs;
- if (aLoadingPrincipal) {
- attrs = aLoadingPrincipal->OriginAttributesRef();
+ if (aTriggeringPrincipal) {
+ attrs = aTriggeringPrincipal->OriginAttributesRef();
}
ImageCacheKey key(aURI, attrs, aLoadingDocument, rv);
NS_ENSURE_SUCCESS(rv, rv);
imgCacheTable& cache = GetCache(key);
if (cache.Get(key, getter_AddRefs(entry)) && entry) {
if (ValidateEntry(entry, aURI, aInitialDocumentURI, aReferrerURI,
aReferrerPolicy, aLoadGroup, aObserver, aLoadingDocument,
aLoadingDocument, requestFlags, aContentPolicyType, true,
- _retval, aLoadingPrincipal, corsmode)) {
+ _retval, aTriggeringPrincipal, corsmode)) {
request = entry->GetRequest();
// If this entry has no proxies, its request has no reference to the
// entry.
if (entry->HasNoProxies()) {
LOG_FUNC_WITH_PARAM(gImgLog,
"imgLoader::LoadImage() adding proxyless entry", "uri", key.Spec());
MOZ_ASSERT(!request->HasCacheEntry(),
@@ -2283,17 +2283,17 @@ imgLoader::LoadImage(nsIURI* aURI,
aInitialDocumentURI,
corsmode,
aReferrerURI,
aReferrerPolicy,
aLoadGroup,
mAcceptHeader,
requestFlags,
aContentPolicyType,
- aLoadingPrincipal,
+ aTriggeringPrincipal,
aContext,
mRespectPrivacy);
if (NS_FAILED(rv)) {
return NS_ERROR_FAILURE;
}
MOZ_ASSERT(NS_UsePrivateBrowsing(newChannel) == mRespectPrivacy);
@@ -2321,17 +2321,17 @@ imgLoader::LoadImage(nsIURI* aURI,
}
}
}
nsCOMPtr<nsILoadGroup> channelLoadGroup;
newChannel->GetLoadGroup(getter_AddRefs(channelLoadGroup));
rv = request->Init(aURI, aURI, /* aHadInsecureRedirect = */ false,
channelLoadGroup, newChannel, entry, aLoadingDocument,
- aLoadingPrincipal, corsmode, aReferrerPolicy);
+ aTriggeringPrincipal, corsmode, aReferrerPolicy);
if (NS_FAILED(rv)) {
return NS_ERROR_FAILURE;
}
// Add the initiator type for this image load
nsCOMPtr<nsITimedChannel> timedChannel = do_QueryInterface(newChannel);
if (timedChannel) {
timedChannel->SetInitiatorType(initiatorType);
@@ -2946,30 +2946,30 @@ imgCacheValidator::OnStartRequest(nsIReq
if (MOZ_LOG_TEST(gImgLog, LogLevel::Debug)) {
LOG_MSG_WITH_PARAM(gImgLog,
"imgCacheValidator::OnStartRequest creating new request",
"uri", uri->GetSpecOrDefault().get());
}
int32_t corsmode = mRequest->GetCORSMode();
ReferrerPolicy refpol = mRequest->GetReferrerPolicy();
- nsCOMPtr<nsIPrincipal> loadingPrincipal = mRequest->GetLoadingPrincipal();
+ nsCOMPtr<nsIPrincipal> triggeringPrincipal = mRequest->GetTriggeringPrincipal();
// Doom the old request's cache entry
mRequest->RemoveFromCache();
mRequest->SetValidator(nullptr);
mRequest = nullptr;
// We use originalURI here to fulfil the imgIRequest contract on GetURI.
nsCOMPtr<nsIURI> originalURI;
channel->GetOriginalURI(getter_AddRefs(originalURI));
nsresult rv =
mNewRequest->Init(originalURI, uri, mHadInsecureRedirect, aRequest, channel,
- mNewEntry, context, loadingPrincipal, corsmode, refpol);
+ mNewEntry, context, triggeringPrincipal, corsmode, refpol);
if (NS_FAILED(rv)) {
return rv;
}
mDestListener = new ProxyListener(mNewRequest);
// Try to add the new request into the cache. Note that the entry must be in
// the cache before the proxies' ownership changes, because adding a proxy