Bug 1994682 - Reduce Page Protection: Adjust Tracking-Protection to decide whether it is active upon module r=timhuang
Differential Revision: https://phabricator.services.mozilla.com/D276217
This commit is contained in:
committed by
mbucher@mozilla.com
parent
0d948a1318
commit
64b61baebd
@@ -42,7 +42,14 @@ NS_INTERFACE_MAP_END
|
||||
|
||||
BrowsingContextWebProgress::BrowsingContextWebProgress(
|
||||
CanonicalBrowsingContext* aBrowsingContext)
|
||||
: mCurrentBrowsingContext(aBrowsingContext) {}
|
||||
: mCurrentBrowsingContext(aBrowsingContext) {
|
||||
if (aBrowsingContext->IsTop()) {
|
||||
mScopedPrefs = new mozilla::ScopedPrefs();
|
||||
} else {
|
||||
// inherit top scoped prefs from top browsing context
|
||||
mScopedPrefs = aBrowsingContext->Top()->GetWebProgress()->mScopedPrefs;
|
||||
}
|
||||
}
|
||||
|
||||
BrowsingContextWebProgress::~BrowsingContextWebProgress() = default;
|
||||
|
||||
@@ -210,6 +217,10 @@ void BrowsingContextWebProgress::DropBounceTrackingState() {
|
||||
mBounceTrackingState = nullptr;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIScopedPrefs> BrowsingContextWebProgress::ScopedPrefs() {
|
||||
return do_AddRef(mScopedPrefs);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIWebProgressListener
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#ifndef mozilla_dom_BrowsingContextWebProgress_h
|
||||
#define mozilla_dom_BrowsingContextWebProgress_h
|
||||
|
||||
#include "nsIScopedPrefs.h"
|
||||
#include "nsIWebProgress.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
#include "nsTObserverArray.h"
|
||||
@@ -63,6 +64,7 @@ class BrowsingContextWebProgress final : public nsIWebProgress,
|
||||
void SetLoadType(uint32_t aLoadType) { mLoadType = aLoadType; }
|
||||
|
||||
already_AddRefed<BounceTrackingState> GetBounceTrackingState();
|
||||
already_AddRefed<nsIScopedPrefs> ScopedPrefs();
|
||||
|
||||
// Drops our reference to BounceTrackingState. This is used when the feature
|
||||
// gets disabled.
|
||||
@@ -102,6 +104,10 @@ class BrowsingContextWebProgress final : public nsIWebProgress,
|
||||
bool mIsLoadingDocument = false;
|
||||
|
||||
RefPtr<mozilla::BounceTrackingState> mBounceTrackingState;
|
||||
|
||||
// Allow overriding some prefs for the lifetime of a particular tab
|
||||
// one per TopBrowsingContext
|
||||
nsCOMPtr<nsIScopedPrefs> mScopedPrefs;
|
||||
};
|
||||
|
||||
} // namespace mozilla::dom
|
||||
|
||||
@@ -3620,6 +3620,13 @@ CanonicalBrowsingContext::GetBounceTrackingState() {
|
||||
return mWebProgress->GetBounceTrackingState();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIScopedPrefs> CanonicalBrowsingContext::GetScopedPrefs() {
|
||||
if (!mWebProgress) {
|
||||
return nullptr;
|
||||
}
|
||||
return mWebProgress->ScopedPrefs();
|
||||
}
|
||||
|
||||
bool CanonicalBrowsingContext::CanOpenModalPicker() {
|
||||
if (!mozilla::StaticPrefs::browser_disable_pickers_background_tabs()) {
|
||||
return true;
|
||||
|
||||
@@ -439,6 +439,7 @@ class CanonicalBrowsingContext final : public BrowsingContext {
|
||||
already_AddRefed<nsISHEntry> GetMostRecentLoadingSessionHistoryEntry();
|
||||
|
||||
already_AddRefed<BounceTrackingState> GetBounceTrackingState();
|
||||
already_AddRefed<nsIScopedPrefs> GetScopedPrefs();
|
||||
|
||||
bool CanOpenModalPicker();
|
||||
|
||||
|
||||
@@ -2030,6 +2030,7 @@ addExternalIface('URI', nativeType='nsIURI', headerFile='nsIURI.h',
|
||||
addExternalIface('XULCommandDispatcher', notflattened=True)
|
||||
addExternalIface('nsISHistory', nativeType='nsISHistory', notflattened=True)
|
||||
addExternalIface('nsISHEntry', nativeType='nsISHEntry', notflattened=True)
|
||||
addExternalIface('nsIScopedPrefs', nativeType='nsIScopedPrefs', notflattened=True)
|
||||
addExternalIface('ReferrerInfo', nativeType='nsIReferrerInfo')
|
||||
addExternalIface('nsIPermissionDelegateHandler',
|
||||
nativeType='nsIPermissionDelegateHandler',
|
||||
|
||||
@@ -8,6 +8,7 @@ interface nsIDocShell;
|
||||
interface nsIDOMGeoPosition;
|
||||
interface nsISecureBrowserUI;
|
||||
interface nsISHEntry;
|
||||
interface nsIScopedPrefs;
|
||||
interface nsIPrintSettings;
|
||||
interface nsIWebProgress;
|
||||
|
||||
@@ -468,6 +469,8 @@ interface CanonicalBrowsingContext : BrowsingContext {
|
||||
|
||||
readonly attribute nsISHEntry? mostRecentLoadingSessionHistoryEntry;
|
||||
|
||||
readonly attribute nsIScopedPrefs? scopedPrefs;
|
||||
|
||||
/**
|
||||
* Indicates if the embedder element or an ancestor has hidden
|
||||
* visibility, or no frame.
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/StaticPrefs_privacy.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "mozilla/ScopedPrefs.h"
|
||||
#include "mozilla/net/UrlClassifierCommon.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIClassifiedChannel.h"
|
||||
@@ -101,9 +102,8 @@ UrlClassifierFeatureConsentManagerAnnotation::MaybeCreate(
|
||||
}
|
||||
|
||||
// We also don't need to annotate the channel if we are not blocking trackers
|
||||
if (!StaticPrefs::privacy_trackingprotection_enabled() &&
|
||||
!(NS_UsePrivateBrowsing(aChannel) &&
|
||||
StaticPrefs::privacy_trackingprotection_pbmode_enabled())) {
|
||||
if (!ScopedPrefs::BoolPrefScoped(
|
||||
ScopedPrefs::PRIVACY_TRACKINGPROTECTION_ENABLED, aChannel)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "UrlClassifierFeatureTrackingProtection.h"
|
||||
|
||||
#include "mozilla/AntiTrackingUtils.h"
|
||||
#include "mozilla/ScopedPrefs.h"
|
||||
#include "mozilla/net/UrlClassifierCommon.h"
|
||||
#include "ChannelClassifierService.h"
|
||||
#include "nsIChannel.h"
|
||||
@@ -84,19 +85,26 @@ UrlClassifierFeatureTrackingProtection::MaybeCreate(nsIChannel* aChannel) {
|
||||
("UrlClassifierFeatureTrackingProtection::MaybeCreate - channel %p",
|
||||
aChannel));
|
||||
|
||||
#ifdef ANDROID // TODO(Bug 2005278): keep behavior between platforms consistent
|
||||
nsCOMPtr<nsILoadContext> loadContext;
|
||||
NS_QueryNotificationCallbacks(aChannel, loadContext);
|
||||
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())) {
|
||||
if (!ScopedPrefs::BoolPrefScoped(
|
||||
ScopedPrefs::PRIVACY_TRACKINGPROTECTION_ENABLED, aChannel)) {
|
||||
return nullptr;
|
||||
}
|
||||
} else if (!loadContext->UseTrackingProtection()) {
|
||||
return nullptr;
|
||||
}
|
||||
#else // !ANDROID
|
||||
// Always check tracking protection pref on desktop
|
||||
if (!ScopedPrefs::BoolPrefScoped(
|
||||
ScopedPrefs::PRIVACY_TRACKINGPROTECTION_ENABLED, aChannel)) {
|
||||
return nullptr;
|
||||
}
|
||||
#endif // ANDROID
|
||||
|
||||
RefPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
|
||||
bool isThirdParty = loadInfo->GetIsThirdPartyContextToTopWindow();
|
||||
|
||||
Reference in New Issue
Block a user