Bug 1487093 - Call AntiTrackingCommon::NotifyRejection when cookies are rejected because of cookie policies, r=ehsan

This commit is contained in:
Andrea Marchesini 2018-08-30 17:44:38 +02:00
Родитель 0d812e2b6b
Коммит 1d190ffa57
4 изменённых файлов: 23 добавлений и 4 удалений

Просмотреть файл

@ -2234,7 +2234,7 @@ nsCookieService::SetCookieStringInternal(nsIURI *aHostURI,
// (but not if there was an error)
switch (cookieStatus) {
case STATUS_REJECTED:
NotifyRejected(aHostURI);
NotifyRejected(aHostURI, aChannel);
if (aIsForeign) {
NotifyThirdParty(aHostURI, false, aChannel);
}
@ -2264,12 +2264,14 @@ nsCookieService::SetCookieStringInternal(nsIURI *aHostURI,
// notify observers that a cookie was rejected due to the users' prefs.
void
nsCookieService::NotifyRejected(nsIURI *aHostURI)
nsCookieService::NotifyRejected(nsIURI *aHostURI, nsIChannel* aChannel)
{
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
if (os) {
os->NotifyObservers(aHostURI, "cookie-rejected", nullptr);
}
AntiTrackingCommon::NotifyRejection(aChannel);
}
// notify observers that a third-party cookie was accepted/rejected
@ -3608,7 +3610,7 @@ nsCookieService::SetCookieInternal(nsIURI *aHostURI,
&permission);
if (!permission) {
COOKIE_LOGFAILURE(SET_COOKIE, aHostURI, savedCookieHeader, "cookie rejected by permission manager");
NotifyRejected(aHostURI);
NotifyRejected(aHostURI, aChannel);
return newCookie;
}

Просмотреть файл

@ -319,7 +319,7 @@ class nsCookieService final : public nsICookieService
bool FindSecureCookie(const nsCookieKey& aKey, nsCookie* aCookie);
int64_t FindStaleCookie(nsCookieEntry *aEntry, int64_t aCurrentTime, nsIURI* aSource, const mozilla::Maybe<bool> &aIsSecure, nsListIter &aIter);
void TelemetryForEvictingStaleCookie(nsCookie* aEvicted, int64_t oldestCookieTime);
void NotifyRejected(nsIURI *aHostURI);
void NotifyRejected(nsIURI *aHostURI, nsIChannel* aChannel);
void NotifyThirdParty(nsIURI *aHostURI, bool aAccepted, nsIChannel *aChannel);
void NotifyChanged(nsISupports *aSubject, const char16_t *aData, bool aOldCookieIsSession = false, bool aFromHttp = false);
void NotifyPurged(nsICookie2* aCookie);

Просмотреть файл

@ -833,3 +833,14 @@ AntiTrackingCommon::IsOnContentBlockingAllowList(nsIURI* aTopWinURI,
return NS_OK;
}
/* static */ void
AntiTrackingCommon::NotifyRejection(nsIChannel* aChannel)
{
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
if (!httpChannel) {
return;
}
// TODO: use aState to inform the rest of the world.
}

Просмотреть файл

@ -11,6 +11,7 @@
#include "mozilla/MozPromise.h"
#include "mozilla/RefPtr.h"
class nsIChannel;
class nsIHttpChannel;
class nsIPrincipal;
class nsIURI;
@ -88,6 +89,11 @@ public:
static nsresult
IsOnContentBlockingAllowList(nsIURI* aTopWinURI, bool& aIsAllowListed);
// This method can be called on the parent process or on the content process.
// The notification is propagated to the child channel if aChannel is a parent
// channel proxy.
static void
NotifyRejection(nsIChannel* aChannel);
};
} // namespace mozilla