зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1535799 - nsIHttpChannel.isTrackingResource should be a method, r=Ehsan
Differential Revision: https://phabricator.services.mozilla.com/D23765 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
e348ad0b6c
Коммит
5bb6c49ba8
|
@ -494,7 +494,7 @@ NetworkObserver.prototype = {
|
|||
.toISOString();
|
||||
event.fromCache = fromCache;
|
||||
event.fromServiceWorker = fromServiceWorker;
|
||||
event.isThirdPartyTrackingResource = channel.isThirdPartyTrackingResource;
|
||||
event.isThirdPartyTrackingResource = channel.isThirdPartyTrackingResource();
|
||||
event.referrerPolicy =
|
||||
Services.netUtils.getReferrerPolicyString(channel.referrerPolicy);
|
||||
httpActivity.fromServiceWorker = fromServiceWorker;
|
||||
|
|
|
@ -8328,7 +8328,7 @@ bool nsContentUtils::IsTrackingResourceWindow(nsPIDOMWindowInner* aWindow) {
|
|||
return false;
|
||||
}
|
||||
|
||||
return httpChannel->GetIsTrackingResource();
|
||||
return httpChannel->IsTrackingResource();
|
||||
}
|
||||
|
||||
// static public
|
||||
|
@ -8347,7 +8347,7 @@ bool nsContentUtils::IsThirdPartyTrackingResourceWindow(
|
|||
return false;
|
||||
}
|
||||
|
||||
return httpChannel->GetIsThirdPartyTrackingResource();
|
||||
return httpChannel->IsThirdPartyTrackingResource();
|
||||
}
|
||||
|
||||
static bool StorageDisabledByAntiTrackingInternal(nsPIDOMWindowInner* aWindow,
|
||||
|
|
|
@ -1000,7 +1000,7 @@ already_AddRefed<nsIChannel> nsHTMLDocument::CreateDummyChannelForCookies(
|
|||
|
||||
nsCOMPtr<nsIHttpChannel> docHTTPChannel = do_QueryInterface(GetChannel());
|
||||
if (docHTTPChannel) {
|
||||
bool isTracking = docHTTPChannel->GetIsTrackingResource();
|
||||
bool isTracking = docHTTPChannel->IsTrackingResource();
|
||||
if (isTracking) {
|
||||
// If our document channel is from a tracking resource, we must
|
||||
// override our channel's tracking status.
|
||||
|
|
|
@ -3496,7 +3496,7 @@ nsresult ScriptLoader::PrepareLoadedRequest(ScriptLoadRequest* aRequest,
|
|||
aRequest->mSourceMapURL = NS_ConvertUTF8toUTF16(sourceMapURL);
|
||||
}
|
||||
|
||||
if (httpChannel->GetIsThirdPartyTrackingResource()) {
|
||||
if (httpChannel->IsThirdPartyTrackingResource()) {
|
||||
aRequest->SetIsTracking();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ void CookieServiceChild::TrackCookieLoad(nsIChannel *aChannel) {
|
|||
}
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
|
||||
if (httpChannel) {
|
||||
isTrackingResource = httpChannel->GetIsTrackingResource();
|
||||
isTrackingResource = httpChannel->IsTrackingResource();
|
||||
// Check first-party storage access even for non-tracking resources, since
|
||||
// we will need the result when computing the access rights for the reject
|
||||
// foreign cookie behavior mode.
|
||||
|
@ -484,7 +484,7 @@ nsresult CookieServiceChild::GetCookieStringInternal(nsIURI *aHostURI,
|
|||
bool firstPartyStorageAccessGranted = false;
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
|
||||
if (httpChannel) {
|
||||
isTrackingResource = httpChannel->GetIsTrackingResource();
|
||||
isTrackingResource = httpChannel->IsTrackingResource();
|
||||
// Check first-party storage access even for non-tracking resources, since
|
||||
// we will need the result when computing the access rights for the reject
|
||||
// foreign cookie behavior mode.
|
||||
|
@ -532,7 +532,7 @@ nsresult CookieServiceChild::SetCookieStringInternal(nsIURI *aHostURI,
|
|||
bool firstPartyStorageAccessGranted = false;
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
|
||||
if (httpChannel) {
|
||||
isTrackingResource = httpChannel->GetIsTrackingResource();
|
||||
isTrackingResource = httpChannel->IsTrackingResource();
|
||||
// Check first-party storage access even for non-tracking resources, since
|
||||
// we will need the result when computing the access rights for the reject
|
||||
// foreign cookie behavior mode.
|
||||
|
|
|
@ -136,7 +136,7 @@ void CookieServiceParent::TrackCookieLoad(nsIChannel *aChannel) {
|
|||
bool storageAccessGranted = false;
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
|
||||
if (httpChannel) {
|
||||
isTrackingResource = httpChannel->GetIsTrackingResource();
|
||||
isTrackingResource = httpChannel->IsTrackingResource();
|
||||
// Check first-party storage access even for non-tracking resources, since
|
||||
// we will need the result when computing the access rights for the reject
|
||||
// foreign cookie behavior mode.
|
||||
|
|
|
@ -1977,7 +1977,7 @@ nsresult nsCookieService::GetCookieStringCommon(nsIURI *aHostURI,
|
|||
bool firstPartyStorageAccessGranted = false;
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
|
||||
if (httpChannel) {
|
||||
isTrackingResource = httpChannel->GetIsTrackingResource();
|
||||
isTrackingResource = httpChannel->IsTrackingResource();
|
||||
|
||||
// Check first-party storage access even for non-tracking resources, since
|
||||
// we will need the result when computing the access rights for the reject
|
||||
|
@ -2096,7 +2096,7 @@ nsresult nsCookieService::SetCookieStringCommon(nsIURI *aHostURI,
|
|||
bool firstPartyStorageAccessGranted = false;
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
|
||||
if (httpChannel) {
|
||||
isTrackingResource = httpChannel->GetIsTrackingResource();
|
||||
isTrackingResource = httpChannel->IsTrackingResource();
|
||||
|
||||
// Check first-party storage access even for non-tracking resources, since
|
||||
// we will need the result when computing the access rights for the reject
|
||||
|
|
|
@ -1473,33 +1473,23 @@ NS_IMETHODIMP HttpBaseChannel::SetTopLevelContentWindowId(uint64_t aWindowId) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
HttpBaseChannel::IsTrackingResource() const {
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::IsTrackingResource(bool* aIsTrackingResource) {
|
||||
MOZ_ASSERT(!mFirstPartyClassificationFlags ||
|
||||
!mThirdPartyClassificationFlags);
|
||||
return UrlClassifierCommon::IsTrackingClassificationFlag(
|
||||
mThirdPartyClassificationFlags) ||
|
||||
UrlClassifierCommon::IsTrackingClassificationFlag(
|
||||
mFirstPartyClassificationFlags);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::GetIsTrackingResource(bool* aIsTrackingResource) {
|
||||
*aIsTrackingResource = IsTrackingResource();
|
||||
*aIsTrackingResource = UrlClassifierCommon::IsTrackingClassificationFlag(
|
||||
mThirdPartyClassificationFlags) ||
|
||||
UrlClassifierCommon::IsTrackingClassificationFlag(
|
||||
mFirstPartyClassificationFlags);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
HttpBaseChannel::IsThirdPartyTrackingResource() const {
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::IsThirdPartyTrackingResource(bool* aIsTrackingResource) {
|
||||
MOZ_ASSERT(
|
||||
!(mFirstPartyClassificationFlags && mThirdPartyClassificationFlags));
|
||||
return UrlClassifierCommon::IsTrackingClassificationFlag(
|
||||
*aIsTrackingResource = UrlClassifierCommon::IsTrackingClassificationFlag(
|
||||
mThirdPartyClassificationFlags);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::GetIsThirdPartyTrackingResource(bool* aIsTrackingResource) {
|
||||
*aIsTrackingResource = IsThirdPartyTrackingResource();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -236,9 +236,8 @@ class HttpBaseChannel : public nsHashPropertyBag,
|
|||
NS_IMETHOD SetTopLevelContentWindowId(uint64_t aContentWindowId) override;
|
||||
NS_IMETHOD GetTopLevelOuterContentWindowId(uint64_t *aWindowId) override;
|
||||
NS_IMETHOD SetTopLevelOuterContentWindowId(uint64_t aWindowId) override;
|
||||
NS_IMETHOD GetIsTrackingResource(bool *aIsTrackingResource) override;
|
||||
NS_IMETHOD GetIsThirdPartyTrackingResource(
|
||||
bool *aIsTrackingResource) override;
|
||||
NS_IMETHOD IsTrackingResource(bool *aIsTrackingResource) override;
|
||||
NS_IMETHOD IsThirdPartyTrackingResource(bool *aIsTrackingResource) override;
|
||||
NS_IMETHOD GetClassificationFlags(uint32_t *aIsClassificationFlags) override;
|
||||
NS_IMETHOD GetFirstPartyClassificationFlags(
|
||||
uint32_t *aIsClassificationFlags) override;
|
||||
|
@ -249,6 +248,8 @@ class HttpBaseChannel : public nsHashPropertyBag,
|
|||
NS_IMETHOD GetFlashPluginState(
|
||||
nsIHttpChannel::FlashPluginState *aState) override;
|
||||
|
||||
using nsIHttpChannel::IsThirdPartyTrackingResource;
|
||||
|
||||
// nsIHttpChannelInternal
|
||||
NS_IMETHOD GetDocumentURI(nsIURI **aDocumentURI) override;
|
||||
NS_IMETHOD SetDocumentURI(nsIURI *aDocumentURI) override;
|
||||
|
@ -538,9 +539,6 @@ class HttpBaseChannel : public nsHashPropertyBag,
|
|||
bool MaybeWaitForUploadStreamLength(nsIStreamListener *aListener,
|
||||
nsISupports *aContext);
|
||||
|
||||
bool IsThirdPartyTrackingResource() const;
|
||||
bool IsTrackingResource() const;
|
||||
|
||||
friend class PrivateBrowsingChannel<HttpBaseChannel>;
|
||||
friend class InterceptFailedOnStop;
|
||||
|
||||
|
|
|
@ -84,12 +84,12 @@ NullHttpChannel::SetTopLevelOuterContentWindowId(uint64_t aWindowId) {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NullHttpChannel::GetIsTrackingResource(bool *aIsTrackingResource) {
|
||||
NullHttpChannel::IsTrackingResource(bool *aIsTrackingResource) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NullHttpChannel::GetIsThirdPartyTrackingResource(bool *aIsTrackingResource) {
|
||||
NullHttpChannel::IsThirdPartyTrackingResource(bool *aIsTrackingResource) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
|
|
@ -560,9 +560,20 @@ interface nsIHttpChannel : nsIChannel
|
|||
*
|
||||
* Note that top-level channels could be marked as tracking
|
||||
* resource. In order to identify third-party tracking resources
|
||||
* specifically, use isThirdPartyTrackingResource.
|
||||
* specifically, use isThirdPartyTrackingResource().
|
||||
*/
|
||||
[infallible] readonly attribute boolean isTrackingResource;
|
||||
boolean isTrackingResource();
|
||||
|
||||
%{ C++
|
||||
inline bool IsTrackingResource()
|
||||
{
|
||||
bool value = false;
|
||||
if (NS_SUCCEEDED(IsTrackingResource(&value)) && value) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
%}
|
||||
|
||||
/**
|
||||
* Returns the classification flags if the channel has been processed by
|
||||
|
@ -572,7 +583,18 @@ interface nsIHttpChannel : nsIChannel
|
|||
* This is a helper attribute which returns the same value of
|
||||
* (thirdPartyClassificationFlags & CLASSIFIED_ANY_TRACKING)
|
||||
*/
|
||||
[infallible] readonly attribute boolean isThirdPartyTrackingResource;
|
||||
boolean isThirdPartyTrackingResource();
|
||||
|
||||
%{ C++
|
||||
inline bool IsThirdPartyTrackingResource()
|
||||
{
|
||||
bool value = false;
|
||||
if (NS_SUCCEEDED(IsThirdPartyTrackingResource(&value)) && value) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
%}
|
||||
|
||||
/**
|
||||
* Returns the allowing status for flash plugin for this channel.
|
||||
|
|
|
@ -704,18 +704,16 @@ nsViewSourceChannel::SetTopLevelOuterContentWindowId(uint64_t aWindowId) {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsViewSourceChannel::GetIsTrackingResource(bool *aIsTrackingResource) {
|
||||
return !mHttpChannel
|
||||
? NS_ERROR_NULL_POINTER
|
||||
: mHttpChannel->GetIsTrackingResource(aIsTrackingResource);
|
||||
nsViewSourceChannel::IsTrackingResource(bool *aIsTrackingResource) {
|
||||
return !mHttpChannel ? NS_ERROR_NULL_POINTER
|
||||
: mHttpChannel->IsTrackingResource(aIsTrackingResource);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsViewSourceChannel::GetIsThirdPartyTrackingResource(
|
||||
bool *aIsTrackingResource) {
|
||||
return !mHttpChannel ? NS_ERROR_NULL_POINTER
|
||||
: mHttpChannel->GetIsThirdPartyTrackingResource(
|
||||
aIsTrackingResource);
|
||||
nsViewSourceChannel::IsThirdPartyTrackingResource(bool *aIsTrackingResource) {
|
||||
return !mHttpChannel
|
||||
? NS_ERROR_NULL_POINTER
|
||||
: mHttpChannel->IsThirdPartyTrackingResource(aIsTrackingResource);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -34,7 +34,7 @@ function listener(tracking, priority, throttleable, nextTest) {
|
|||
}
|
||||
listener.prototype = {
|
||||
onStartRequest: function(request) {
|
||||
Assert.equal(request.QueryInterface(Ci.nsIHttpChannel).isTrackingResource,
|
||||
Assert.equal(request.QueryInterface(Ci.nsIHttpChannel).isTrackingResource(),
|
||||
this._tracking, "tracking flag");
|
||||
Assert.equal(request.QueryInterface(Ci.nsISupportsPriority).priority,
|
||||
this._priority, "channel priority");
|
||||
|
|
|
@ -1412,7 +1412,7 @@ bool AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
|
|||
MOZ_ASSERT(behavior == nsICookieService::BEHAVIOR_REJECT_TRACKER);
|
||||
|
||||
// Not a tracker.
|
||||
if (!aChannel->GetIsThirdPartyTrackingResource()) {
|
||||
if (!aChannel->IsThirdPartyTrackingResource()) {
|
||||
LOG(("Our channel isn't a third-party tracking channel"));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ function runTests(flag, prefs, trackingResource) {
|
|||
// eslint-disable-next-line no-undef
|
||||
sendAsyncMessage("last-channel-flags", {
|
||||
classificationFlags: channel.classificationFlags,
|
||||
isTrackingResource: channel.isTrackingResource,
|
||||
isTrackingResource: channel.isTrackingResource(),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче