Bug 1437626 - P3. Use global tracking Protection pref when a channel doesn't have a loadcontext r=baku

Channels loaded by service worker don't have loadcontext, so we don't
apply tracking protection on them.

Depends on D80183

Differential Revision: https://phabricator.services.mozilla.com/D80184
This commit is contained in:
Dimi Lee 2020-07-02 07:20:52 +00:00
Родитель f334f91266
Коммит 4f69aa8fa0
1 изменённых файлов: 9 добавлений и 1 удалений

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

@ -81,7 +81,15 @@ UrlClassifierFeatureTrackingProtection::MaybeCreate(nsIChannel* aChannel) {
nsCOMPtr<nsILoadContext> loadContext;
NS_QueryNotificationCallbacks(aChannel, loadContext);
if (!loadContext || !loadContext->UseTrackingProtection()) {
if (!loadContext) {
// Some channels don't have a loadcontext, check the global tracking
// protection preference.
if (!StaticPrefs::privacy_trackingprotection_enabled() &&
!(NS_UsePrivateBrowsing(aChannel) &&
StaticPrefs::privacy_trackingprotection_pbmode_enabled())) {
return nullptr;
}
} else if (!loadContext->UseTrackingProtection()) {
return nullptr;
}