forked from mirrors/gecko-dev
Bug 1486185 - Part 1: Make the Disable Protection button in the control centre UI work for the reject tracker cookie behavior; r=baku
This commit is contained in:
parent
7cb17b8a34
commit
9b43d98f5f
1 changed files with 66 additions and 0 deletions
|
|
@ -16,6 +16,7 @@
|
||||||
#include "nsGlobalWindowInner.h"
|
#include "nsGlobalWindowInner.h"
|
||||||
#include "nsICookiePermission.h"
|
#include "nsICookiePermission.h"
|
||||||
#include "nsICookieService.h"
|
#include "nsICookieService.h"
|
||||||
|
#include "nsIHttpChannelInternal.h"
|
||||||
#include "nsIIOService.h"
|
#include "nsIIOService.h"
|
||||||
#include "nsIPermissionManager.h"
|
#include "nsIPermissionManager.h"
|
||||||
#include "nsIPrincipal.h"
|
#include "nsIPrincipal.h"
|
||||||
|
|
@ -132,6 +133,55 @@ CookiesBehavior(nsIPrincipal* aPrincipal)
|
||||||
return StaticPrefs::network_cookie_cookieBehavior();
|
return StaticPrefs::network_cookie_cookieBehavior();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
CheckContentBlockingAllowList(nsIURI* aTopWinURI)
|
||||||
|
{
|
||||||
|
bool isAllowed = false;
|
||||||
|
nsresult rv =
|
||||||
|
AntiTrackingCommon::IsOnContentBlockingAllowList(aTopWinURI, isAllowed);
|
||||||
|
if (NS_SUCCEEDED(rv) && isAllowed) {
|
||||||
|
LOG_SPEC(("The top-level window (%s) is on the content blocking allow list, "
|
||||||
|
"bail out early", _spec), aTopWinURI);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
LOG_SPEC(("Checking the content blocking allow list for %s failed with %x",
|
||||||
|
_spec, rv), aTopWinURI);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
CheckContentBlockingAllowList(nsPIDOMWindowInner* aWindow)
|
||||||
|
{
|
||||||
|
nsPIDOMWindowOuter* top = aWindow->GetScriptableTop();
|
||||||
|
if (top) {
|
||||||
|
nsIURI* topWinURI = top->GetDocumentURI();
|
||||||
|
return CheckContentBlockingAllowList(topWinURI);
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG(("Could not check the content blocking allow list because the top "
|
||||||
|
"window wasn't accessible"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
CheckContentBlockingAllowList(nsIHttpChannel* aChannel)
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsIHttpChannelInternal> chan = do_QueryInterface(aChannel);
|
||||||
|
if (chan) {
|
||||||
|
nsCOMPtr<nsIURI> topWinURI;
|
||||||
|
nsresult rv = chan->GetTopWindowURI(getter_AddRefs(topWinURI));
|
||||||
|
if (NS_SUCCEEDED(rv)) {
|
||||||
|
return CheckContentBlockingAllowList(topWinURI);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG(("Could not check the content blocking allow list because the top "
|
||||||
|
"window wasn't accessible"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
} // anonymous
|
} // anonymous
|
||||||
|
|
||||||
/* static */ RefPtr<AntiTrackingCommon::StorageAccessGrantPromise>
|
/* static */ RefPtr<AntiTrackingCommon::StorageAccessGrantPromise>
|
||||||
|
|
@ -155,6 +205,10 @@ AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor(const nsAString& aOrigi
|
||||||
return StorageAccessGrantPromise::CreateAndResolve(true, __func__);
|
return StorageAccessGrantPromise::CreateAndResolve(true, __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CheckContentBlockingAllowList(aParentWindow)) {
|
||||||
|
return StorageAccessGrantPromise::CreateAndResolve(true, __func__);
|
||||||
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIPrincipal> topLevelStoragePrincipal;
|
nsCOMPtr<nsIPrincipal> topLevelStoragePrincipal;
|
||||||
nsAutoCString trackingOrigin;
|
nsAutoCString trackingOrigin;
|
||||||
|
|
||||||
|
|
@ -337,6 +391,10 @@ AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(nsPIDOMWindowInner* aWin
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CheckContentBlockingAllowList(aWindow)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!nsContentUtils::IsTrackingResourceWindow(aWindow)) {
|
if (!nsContentUtils::IsTrackingResourceWindow(aWindow)) {
|
||||||
LOG(("Our window isn't a tracking window"));
|
LOG(("Our window isn't a tracking window"));
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -504,6 +562,10 @@ AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(nsIHttpChannel* aChannel
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CheckContentBlockingAllowList(aChannel)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
nsIPrincipal* parentPrincipal = loadInfo->TopLevelStorageAreaPrincipal();
|
nsIPrincipal* parentPrincipal = loadInfo->TopLevelStorageAreaPrincipal();
|
||||||
if (!parentPrincipal) {
|
if (!parentPrincipal) {
|
||||||
LOG(("No top-level storage area principal at hand"));
|
LOG(("No top-level storage area principal at hand"));
|
||||||
|
|
@ -617,6 +679,10 @@ AntiTrackingCommon::MaybeIsFirstPartyStorageAccessGrantedFor(nsPIDOMWindowInner*
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CheckContentBlockingAllowList(aFirstPartyWindow)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!nsContentUtils::IsThirdPartyWindowOrChannel(aFirstPartyWindow,
|
if (!nsContentUtils::IsThirdPartyWindowOrChannel(aFirstPartyWindow,
|
||||||
nullptr, aURI)) {
|
nullptr, aURI)) {
|
||||||
LOG(("Our window isn't a third-party window"));
|
LOG(("Our window isn't a third-party window"));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue