Bug 1825584 - Integrate clean copy into QueryStringStripper. r=pbz,anti-tracking-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D174250
This commit is contained in:
Hannah Peuckmann 2023-05-11 14:14:41 +00:00
Родитель 1e0d32ed42
Коммит e530f977d1
8 изменённых файлов: 36 добавлений и 4 удалений

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

@ -1890,9 +1890,10 @@ pref("browser.contentblocking.database.enabled", true);
pref("dom.storage_access.enabled", true);
// Enable URL query stripping in Nightly.
// Enable URL query stripping and strip on share in Nightly.
#ifdef NIGHTLY_BUILD
pref("privacy.query_stripping.enabled", true);
pref("privacy.query_stripping.strip_on_share.enabled", true);
#endif
pref("browser.contentblocking.cryptomining.preferences.ui.enabled", true);

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

@ -13389,6 +13389,13 @@
value: true
mirror: always
# Enables / disables the strip on share feature which strips query parameters
# when copying/sharing in-content links or from the url bar.
- name: privacy.query_stripping.strip_on_share.enabled
type: RelaxedAtomicBool
value: false
mirror: always
# Enables / disables the URL query string stripping in normal browsing mode
# which strips query parameters from loading URIs to prevent bounce (redirect)
# tracking.

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

@ -26,6 +26,8 @@ static const char kQueryStrippingEnabledPref[] =
"privacy.query_stripping.enabled";
static const char kQueryStrippingEnabledPBMPref[] =
"privacy.query_stripping.enabled.pbmode";
static const char kQueryStrippingOnShareEnabledPref[] =
"privacy.query_stripping.strip_on_share.enabled";
} // namespace
@ -65,9 +67,22 @@ URLQueryStringStripper::URLQueryStringStripper() {
rv = Preferences::RegisterCallback(&URLQueryStringStripper::OnPrefChange,
kQueryStrippingEnabledPref);
rv = Preferences::RegisterCallback(&URLQueryStringStripper::OnPrefChange,
kQueryStrippingOnShareEnabledPref);
NS_ENSURE_SUCCESS_VOID(rv);
}
NS_IMETHODIMP
URLQueryStringStripper::StripForCopyOrShare(nsIURI* aURI,
nsIURI** strippedURI) {
if (!StaticPrefs::privacy_query_stripping_strip_on_share_enabled()) {
return NS_ERROR_NOT_AVAILABLE;
}
uint32_t numStripped;
return StripQueryString(aURI, strippedURI, &numStripped);
}
NS_IMETHODIMP
URLQueryStringStripper::Strip(nsIURI* aURI, bool aIsPBM, nsIURI** aOutput,
uint32_t* aStripCount) {
@ -100,7 +115,8 @@ void URLQueryStringStripper::OnPrefChange(const char* aPref, void* aData) {
bool prefEnablesComponent =
StaticPrefs::privacy_query_stripping_enabled() ||
StaticPrefs::privacy_query_stripping_enabled_pbmode();
StaticPrefs::privacy_query_stripping_enabled_pbmode() ||
StaticPrefs::privacy_query_stripping_strip_on_share_enabled();
nsresult rv;
if (prefEnablesComponent) {

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

@ -39,8 +39,8 @@ class URLQueryStringStripper final : public nsIObserver,
[[nodiscard]] nsresult Init();
[[nodiscard]] nsresult Shutdown();
nsresult StripQueryString(nsIURI* aURI, nsIURI** aOutput,
uint32_t* aStripCount);
[[nodiscard]] nsresult StripQueryString(nsIURI* aURI, nsIURI** aOutput,
uint32_t* aStripCount);
bool CheckAllowList(nsIURI* aURI);

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

@ -25,6 +25,11 @@ interface nsIURLQueryStringStripper : nsISupports {
// have been stripped or the feature is disabled.
uint32_t strip(in nsIURI aURI, in bool aIsPBM, out nsIURI aOutput);
// Strip the query parameters that are in the stripForCopy/Share strip list.
// Returns ether the stripped URI or null if no query parameters have been stripped
// Thorws NS_ERROR_NOT_AVAILABLE if the feature is disabled.
[must_use] nsIURI stripForCopyOrShare(in nsIURI aURI);
// Test-only method to get the current strip list.
ACString testGetStripList();
};

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

@ -75,6 +75,7 @@ add_setup(async function() {
["privacy.query_stripping.strip_list", "paramToStrip1 paramToStrip2"],
["privacy.query_stripping.redirect", true],
["privacy.query_stripping.listService.logLevel", "Debug"],
["privacy.query_stripping.strip_on_share.enabled", false],
],
});

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

@ -69,6 +69,7 @@ add_setup(async function() {
["privacy.query_stripping.enabled", false],
["privacy.query_stripping.enabled.pbmode", false],
["privacy.query_stripping.strip_list", ""],
["privacy.query_stripping.strip_on_share.enabled", false],
]);
await SpecialPowers.pushPrefEnv({

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

@ -32,6 +32,7 @@ add_setup(async function() {
set: [
["privacy.query_stripping.strip_list", "paramToStrip1 paramToStrip2"],
["privacy.query_stripping.listService.logLevel", "Debug"],
["privacy.query_stripping.strip_on_share.enabled", false],
],
});