Bug 1475697 - Part 3: Update the security UI when blocking 3rd party cookies from trackers; r=baku

This commit is contained in:
Ehsan Akhgari 2018-07-17 06:12:00 +03:00
Родитель ac25ec44da
Коммит 16d186f4ec
2 изменённых файлов: 38 добавлений и 6 удалений

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

@ -8855,18 +8855,17 @@ nsContentUtils::IsTrackingResourceWindow(nsPIDOMWindowInner* aWindow)
return httpChannel->GetIsTrackingResource();
}
// static public
bool
nsContentUtils::StorageDisabledByAntiTracking(nsPIDOMWindowInner* aWindow,
nsIChannel* aChannel,
nsIURI* aURI)
static bool
StorageDisabledByAntiTrackingInternal(nsPIDOMWindowInner* aWindow,
nsIChannel* aChannel,
nsIURI* aURI)
{
if (!StaticPrefs::privacy_restrict3rdpartystorage_enabled()) {
return false;
}
// Let's check if this is a 3rd party context.
if (!IsThirdPartyWindowOrChannel(aWindow, aChannel, aURI)) {
if (!nsContentUtils::IsThirdPartyWindowOrChannel(aWindow, aChannel, aURI)) {
return false;
}
@ -8904,6 +8903,33 @@ nsContentUtils::StorageDisabledByAntiTracking(nsPIDOMWindowInner* aWindow,
uri);
}
// static public
bool
nsContentUtils::StorageDisabledByAntiTracking(nsPIDOMWindowInner* aWindow,
nsIChannel* aChannel,
nsIURI* aURI)
{
bool disabled =
StorageDisabledByAntiTrackingInternal(aWindow, aChannel, aURI);
if (disabled &&
StaticPrefs::privacy_restrict3rdpartystorage_ui_enabled()) {
nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil = services::GetThirdPartyUtil();
if (!thirdPartyUtil) {
return false;
}
nsCOMPtr<mozIDOMWindowProxy> win;
nsresult rv = thirdPartyUtil->GetTopWindowForChannel(aChannel,
getter_AddRefs(win));
NS_ENSURE_SUCCESS(rv, false);
auto* pwin = nsPIDOMWindowOuter::From(win);
pwin->NotifyContentBlockingState(
nsIWebProgressListener::STATE_BLOCKED_TRACKING_COOKIES, aChannel);
}
return disabled;
}
// static, private
nsContentUtils::StorageAccess
nsContentUtils::InternalStorageAllowedForPrincipal(nsIPrincipal* aPrincipal,

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

@ -1120,6 +1120,12 @@ VARCACHE_PREF(
RelaxedAtomicBool, false
)
VARCACHE_PREF(
"privacy.restrict3rdpartystorage.ui.enabled",
privacy_restrict3rdpartystorage_ui_enabled,
RelaxedAtomicBool, false
)
// Anti-tracking permission expiration
VARCACHE_PREF(
"privacy.restrict3rdpartystorage.expiration",