зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1487093 - Implement AntiTrackingCommon::NotifyRejection, r=ehsan
This commit is contained in:
Родитель
1d190ffa57
Коммит
8ad0a3df62
|
@ -542,8 +542,13 @@ Navigator::CookieEnabled()
|
|||
return cookieEnabled;
|
||||
}
|
||||
|
||||
return AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(mWindow,
|
||||
codebaseURI);
|
||||
if (AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(mWindow,
|
||||
codebaseURI)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
AntiTrackingCommon::NotifyRejection(mWindow);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -8917,28 +8917,10 @@ nsContentUtils::StorageDisabledByAntiTracking(nsPIDOMWindowInner* aWindow,
|
|||
bool disabled =
|
||||
StorageDisabledByAntiTrackingInternal(aWindow, aChannel, aPrincipal, aURI);
|
||||
if (disabled && sAntiTrackingControlCenterUIEnabled) {
|
||||
nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil = services::GetThirdPartyUtil();
|
||||
if (!thirdPartyUtil) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowOuter> pwin;
|
||||
if (aWindow) {
|
||||
auto* outer = nsGlobalWindowOuter::Cast(aWindow->GetOuterWindow());
|
||||
if (outer) {
|
||||
pwin = outer->GetTopOuter();
|
||||
}
|
||||
AntiTrackingCommon::NotifyRejection(aWindow);
|
||||
} else if (aChannel) {
|
||||
nsCOMPtr<mozIDOMWindowProxy> win;
|
||||
nsresult rv = thirdPartyUtil->GetTopWindowForChannel(aChannel,
|
||||
getter_AddRefs(win));
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
pwin = nsPIDOMWindowOuter::From(win);
|
||||
}
|
||||
|
||||
if (pwin && aChannel) {
|
||||
pwin->NotifyContentBlockingState(
|
||||
nsIWebProgressListener::STATE_BLOCKED_TRACKING_COOKIES, aChannel);
|
||||
AntiTrackingCommon::NotifyRejection(aChannel);
|
||||
}
|
||||
}
|
||||
return disabled;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "nsIPrincipal.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsScriptSecurityManager.h"
|
||||
#include "prtime.h"
|
||||
|
@ -842,5 +843,49 @@ AntiTrackingCommon::NotifyRejection(nsIChannel* aChannel)
|
|||
return;
|
||||
}
|
||||
|
||||
// TODO: use aState to inform the rest of the world.
|
||||
nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil = services::GetThirdPartyUtil();
|
||||
if (!thirdPartyUtil) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<mozIDOMWindowProxy> win;
|
||||
nsresult rv = thirdPartyUtil->GetTopWindowForChannel(httpChannel,
|
||||
getter_AddRefs(win));
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowOuter> pwin = nsPIDOMWindowOuter::From(win);
|
||||
if (!pwin) {
|
||||
return;
|
||||
}
|
||||
|
||||
pwin->NotifyContentBlockingState(
|
||||
nsIWebProgressListener::STATE_BLOCKED_TRACKING_COOKIES, httpChannel);
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
AntiTrackingCommon::NotifyRejection(nsPIDOMWindowInner* aWindow)
|
||||
{
|
||||
MOZ_ASSERT(aWindow);
|
||||
|
||||
nsIDocument* document = aWindow->GetExtantDoc();
|
||||
if (!document) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel =
|
||||
do_QueryInterface(document->GetChannel());
|
||||
if (!httpChannel) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowOuter> pwin;
|
||||
auto* outer = nsGlobalWindowOuter::Cast(aWindow->GetOuterWindow());
|
||||
if (outer) {
|
||||
pwin = outer->GetTopOuter();
|
||||
}
|
||||
|
||||
if (pwin) {
|
||||
pwin->NotifyContentBlockingState(
|
||||
nsIWebProgressListener::STATE_BLOCKED_TRACKING_COOKIES, httpChannel);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,6 +94,9 @@ public:
|
|||
// channel proxy.
|
||||
static void
|
||||
NotifyRejection(nsIChannel* aChannel);
|
||||
|
||||
static void
|
||||
NotifyRejection(nsPIDOMWindowInner* aWindow);
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
Загрузка…
Ссылка в новой задаче