From 21c6ead79354c2df2c3ce0d38708f78b4c626646 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Thu, 20 Sep 2018 15:45:48 +0000 Subject: [PATCH] Bug 1491061 - Part 4: Synchronize the default values of the essential prefs that content blocking depends on for all platforms r=baku Depends on D6356 Differential Revision: https://phabricator.services.mozilla.com/D6357 --HG-- extra : moz-landing-system : lando --- browser/app/profile/firefox.js | 1 - .../init/ContentBlockingDefaultPrefValues.h | 22 +++++++++++++++++++ modules/libpref/init/StaticPrefList.h | 22 ++++++++----------- modules/libpref/moz.build | 1 + .../antitracking/AntiTrackingCommon.cpp | 15 ++++++++++--- 5 files changed, 44 insertions(+), 17 deletions(-) create mode 100644 modules/libpref/init/ContentBlockingDefaultPrefValues.h diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index cbb929c59c1a..f8d0a2a2be78 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -1511,7 +1511,6 @@ pref("browser.contentblocking.fastblock.ui.enabled", true); pref("browser.contentblocking.fastblock.control-center.ui.enabled", true); pref("browser.contentblocking.trackingprotection.ui.enabled", true); pref("browser.contentblocking.trackingprotection.control-center.ui.enabled", true); -pref("browser.contentblocking.rejecttrackers.ui.enabled", true); pref("browser.contentblocking.rejecttrackers.ui.recommended", true); pref("browser.contentblocking.rejecttrackers.control-center.ui.enabled", true); pref("browser.contentblocking.cookies-site-data.ui.reject-trackers.recommended", true); diff --git a/modules/libpref/init/ContentBlockingDefaultPrefValues.h b/modules/libpref/init/ContentBlockingDefaultPrefValues.h new file mode 100644 index 000000000000..1e65e3a44c0b --- /dev/null +++ b/modules/libpref/init/ContentBlockingDefaultPrefValues.h @@ -0,0 +1,22 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// Default value of browser.contentblocking.enabled. +// Please note that privacy protections provided by Gecko may depend on this preference. +// Turning this off may disable some protections. Please do not turn this pref off without +// realizing the implications of what you're doing. +#define CONTENTBLOCKING_ENABLED true + +// Default value of browser.contentblocking.ui.enabled. +// Enable the new Content Blocking UI only on Nightly. +#ifdef NIGHTLY_BUILD +# define CONTENTBLOCKING_UI_ENABLED true +#else +# define CONTENTBLOCKING_UI_ENABLED false +#endif + +// Default value of browser.contentblocking.rejecttrackers.ui.enabled. +#define CONTENTBLOCKING_REJECTTRACKERS_UI_ENABLED true diff --git a/modules/libpref/init/StaticPrefList.h b/modules/libpref/init/StaticPrefList.h index 6f6c9ce50d83..09110f1805da 100644 --- a/modules/libpref/init/StaticPrefList.h +++ b/modules/libpref/init/StaticPrefList.h @@ -1476,37 +1476,33 @@ PREF("preferences.allow.omt-write", bool, true) // Privacy prefs //--------------------------------------------------------------------------- +#include "ContentBlockingDefaultPrefValues.h" + // Whether Content Blocking has been enabled. -// Please note that privacy protections provided by Gecko may depend on this preference. -// Turning this off may disable some protections. Please do not turn this pref off without -// realizing the implications of what you're doing. VARCACHE_PREF( "browser.contentblocking.enabled", browser_contentblocking_enabled, - bool, true + bool, CONTENTBLOCKING_ENABLED ) // Whether Content Blocking UI has been enabled. -// Enable the new Content Blocking UI only on Nightly. -#ifdef NIGHTLY_BUILD -# define PREF_VALUE true -#else -# define PREF_VALUE false -#endif VARCACHE_PREF( "browser.contentblocking.ui.enabled", browser_contentblocking_ui_enabled, - bool, PREF_VALUE + bool, CONTENTBLOCKING_UI_ENABLED ) -#undef PREF_VALUE // Whether Content Blocking Third-Party Cookies UI has been enabled. VARCACHE_PREF( "browser.contentblocking.rejecttrackers.ui.enabled", browser_contentblocking_rejecttrackers_ui_enabled, - bool, false + bool, CONTENTBLOCKING_REJECTTRACKERS_UI_ENABLED ) +#undef CONTENTBLOCKING_ENABLED +#undef CONTENTBLOCKING_UI_ENABLED +#undef CONTENTBLOCKING_REJECTTRACKERS_UI_ENABLED + // Whether FastBlock has been enabled. VARCACHE_PREF( "browser.fastblock.enabled", diff --git a/modules/libpref/moz.build b/modules/libpref/moz.build index 5ad7e787edf2..790653e8d1a3 100644 --- a/modules/libpref/moz.build +++ b/modules/libpref/moz.build @@ -25,6 +25,7 @@ XPIDL_SOURCES += [ XPIDL_MODULE = 'pref' EXPORTS.mozilla += [ + 'init/ContentBlockingDefaultPrefValues.h', 'init/StaticPrefList.h', 'nsRelativeFilePref.h', 'Preferences.h', diff --git a/toolkit/components/antitracking/AntiTrackingCommon.cpp b/toolkit/components/antitracking/AntiTrackingCommon.cpp index fb010bc7d7ce..fed5bc230d92 100644 --- a/toolkit/components/antitracking/AntiTrackingCommon.cpp +++ b/toolkit/components/antitracking/AntiTrackingCommon.cpp @@ -326,9 +326,18 @@ ReportUnblockingConsole(nsPIDOMWindowInner* aWindow, /* static */ bool AntiTrackingCommon::ShouldHonorContentBlockingCookieRestrictions() { - return StaticPrefs::browser_contentblocking_enabled() && - StaticPrefs::browser_contentblocking_ui_enabled() && - StaticPrefs::browser_contentblocking_rejecttrackers_ui_enabled(); +#include "mozilla/ContentBlockingDefaultPrefValues.h" + + return StaticPrefs::browser_contentblocking_enabled() == + CONTENTBLOCKING_ENABLED && + StaticPrefs::browser_contentblocking_ui_enabled() == + CONTENTBLOCKING_UI_ENABLED && + StaticPrefs::browser_contentblocking_rejecttrackers_ui_enabled() == + CONTENTBLOCKING_REJECTTRACKERS_UI_ENABLED; + +#undef CONTENTBLOCKING_ENABLED +#undef CONTENTBLOCKING_UI_ENABLED +#undef CONTENTBLOCKING_REJECTTRACKERS_UI_ENABLED } /* static */ RefPtr