Bug 1892947 - Align clear on shutdown for cookies and site data section prefs to the new clear on shutdown prefs. r=pbz,settings-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D208410
This commit is contained in:
@@ -25,18 +25,6 @@ const CONTENT_BLOCKING_PREFS = [
|
||||
"privacy.fingerprintingProtection.pbmode",
|
||||
];
|
||||
|
||||
/*
|
||||
* Prefs that are unique to sanitizeOnShutdown and are not shared
|
||||
* with the deleteOnClose mechanism like privacy.clearOnShutdown.cookies, -cache and -offlineApps
|
||||
*/
|
||||
const SANITIZE_ON_SHUTDOWN_PREFS_ONLY = [
|
||||
"privacy.clearOnShutdown.history",
|
||||
"privacy.clearOnShutdown.downloads",
|
||||
"privacy.clearOnShutdown.sessions",
|
||||
"privacy.clearOnShutdown.formdata",
|
||||
"privacy.clearOnShutdown.siteSettings",
|
||||
];
|
||||
|
||||
const PREF_OPT_OUT_STUDIES_ENABLED = "app.shield.optoutstudies.enabled";
|
||||
const PREF_NORMANDY_ENABLED = "app.normandy.enabled";
|
||||
|
||||
@@ -92,6 +80,34 @@ ChromeUtils.defineESModuleGetters(this, {
|
||||
DoHConfigController: "resource:///modules/DoHConfig.sys.mjs",
|
||||
});
|
||||
|
||||
const SANITIZE_ON_SHUTDOWN_MAPPINGS = {
|
||||
history: "privacy.clearOnShutdown.history",
|
||||
downloads: "privacy.clearOnShutdown.downloads",
|
||||
formdata: "privacy.clearOnShutdown.formdata",
|
||||
sessions: "privacy.clearOnShutdown.sessions",
|
||||
siteSettings: "privacy.clearOnShutdown.siteSettings",
|
||||
cookies: "privacy.clearOnShutdown.cookies",
|
||||
cache: "privacy.clearOnShutdown.cache",
|
||||
offlineApps: "privacy.clearOnShutdown.offlineApps",
|
||||
};
|
||||
|
||||
/*
|
||||
* Prefs that are unique to sanitizeOnShutdown and are not shared
|
||||
* with the deleteOnClose mechanism like privacy.clearOnShutdown.cookies, -cache and -offlineApps
|
||||
*/
|
||||
const SANITIZE_ON_SHUTDOWN_PREFS_ONLY = [
|
||||
"privacy.clearOnShutdown.history",
|
||||
"privacy.clearOnShutdown.downloads",
|
||||
"privacy.clearOnShutdown.sessions",
|
||||
"privacy.clearOnShutdown.formdata",
|
||||
"privacy.clearOnShutdown.siteSettings",
|
||||
];
|
||||
|
||||
const SANITIZE_ON_SHUTDOWN_PREFS_ONLY_V2 = [
|
||||
"privacy.clearOnShutdown_v2.historyFormDataAndDownloads",
|
||||
"privacy.clearOnShutdown_v2.siteSettings",
|
||||
];
|
||||
|
||||
Preferences.addAll([
|
||||
// Content blocking / Tracking Protection
|
||||
{ id: "privacy.trackingprotection.enabled", type: "bool" },
|
||||
@@ -155,13 +171,20 @@ Preferences.addAll([
|
||||
{ id: "privacy.sanitize.sanitizeOnShutdown", type: "bool" },
|
||||
{ id: "privacy.sanitize.timeSpan", type: "int" },
|
||||
{ id: "privacy.clearOnShutdown.cookies", type: "bool" },
|
||||
{ id: "privacy.clearOnShutdown_v2.cookiesAndStorage", type: "bool" },
|
||||
{ id: "privacy.clearOnShutdown.cache", type: "bool" },
|
||||
{ id: "privacy.clearOnShutdown_v2.cache", type: "bool" },
|
||||
{ id: "privacy.clearOnShutdown.offlineApps", type: "bool" },
|
||||
{ id: "privacy.clearOnShutdown.history", type: "bool" },
|
||||
{
|
||||
id: "privacy.clearOnShutdown_v2.historyFormDataAndDownloads",
|
||||
type: "bool",
|
||||
},
|
||||
{ id: "privacy.clearOnShutdown.downloads", type: "bool" },
|
||||
{ id: "privacy.clearOnShutdown.sessions", type: "bool" },
|
||||
{ id: "privacy.clearOnShutdown.formdata", type: "bool" },
|
||||
{ id: "privacy.clearOnShutdown.siteSettings", type: "bool" },
|
||||
{ id: "privacy.clearOnShutdown_v2.siteSettings", type: "bool" },
|
||||
|
||||
// Do not track
|
||||
{ id: "privacy.donottrackheader.enabled", type: "bool" },
|
||||
@@ -2094,11 +2117,25 @@ var gPrivacyPane = {
|
||||
*/
|
||||
initDeleteOnCloseBox() {
|
||||
let deleteOnCloseBox = document.getElementById("deleteOnClose");
|
||||
deleteOnCloseBox.checked =
|
||||
(Preferences.get("privacy.sanitize.sanitizeOnShutdown").value &&
|
||||
|
||||
// We have to branch between the old clear on shutdown prefs and new prefs after the clear history revamp (Bug 1853996)
|
||||
// Once the old dialog is deprecated, we can remove these branches.
|
||||
let isCookiesAndStorageClearingOnShutdown;
|
||||
if (useOldClearHistoryDialog) {
|
||||
isCookiesAndStorageClearingOnShutdown =
|
||||
Preferences.get("privacy.sanitize.sanitizeOnShutdown").value &&
|
||||
Preferences.get("privacy.clearOnShutdown.cookies").value &&
|
||||
Preferences.get("privacy.clearOnShutdown.cache").value &&
|
||||
Preferences.get("privacy.clearOnShutdown.offlineApps").value) ||
|
||||
Preferences.get("privacy.clearOnShutdown.offlineApps").value;
|
||||
} else {
|
||||
isCookiesAndStorageClearingOnShutdown =
|
||||
Preferences.get("privacy.sanitize.sanitizeOnShutdown").value &&
|
||||
Preferences.get("privacy.clearOnShutdown_v2.cookiesAndStorage").value &&
|
||||
Preferences.get("privacy.clearOnShutdown_v2.cache").value;
|
||||
}
|
||||
|
||||
deleteOnCloseBox.checked =
|
||||
isCookiesAndStorageClearingOnShutdown ||
|
||||
Preferences.get("browser.privatebrowsing.autostart").value;
|
||||
},
|
||||
|
||||
@@ -2111,12 +2148,17 @@ var gPrivacyPane = {
|
||||
let sanitizeOnShutdownPref = Preferences.get(
|
||||
"privacy.sanitize.sanitizeOnShutdown"
|
||||
);
|
||||
|
||||
// ClearOnClose cleaning categories
|
||||
let cookiePref = Preferences.get("privacy.clearOnShutdown.cookies");
|
||||
let cachePref = Preferences.get("privacy.clearOnShutdown.cache");
|
||||
let offlineAppsPref = Preferences.get(
|
||||
"privacy.clearOnShutdown.offlineApps"
|
||||
);
|
||||
let cookiePref = useOldClearHistoryDialog
|
||||
? Preferences.get("privacy.clearOnShutdown.cookies")
|
||||
: Preferences.get("privacy.clearOnShutdown_v2.cookiesAndStorage");
|
||||
let cachePref = useOldClearHistoryDialog
|
||||
? Preferences.get("privacy.clearOnShutdown.cache")
|
||||
: Preferences.get("privacy.clearOnShutdown_v2.cache");
|
||||
let offlineAppsPref = useOldClearHistoryDialog
|
||||
? Preferences.get("privacy.clearOnShutdown.offlineApps")
|
||||
: Preferences.get("privacy.clearOnShutdown_v2.cookiesAndStorage");
|
||||
|
||||
// Sync the cleaning prefs with the deleteOnClose box
|
||||
deleteOnCloseBox.addEventListener("command", () => {
|
||||
@@ -2156,18 +2198,32 @@ var gPrivacyPane = {
|
||||
*/
|
||||
_onSanitizePrefChangeSyncClearOnClose() {
|
||||
let deleteOnCloseBox = document.getElementById("deleteOnClose");
|
||||
deleteOnCloseBox.checked =
|
||||
Preferences.get("privacy.clearOnShutdown.cookies").value &&
|
||||
Preferences.get("privacy.clearOnShutdown.cache").value &&
|
||||
Preferences.get("privacy.clearOnShutdown.offlineApps").value &&
|
||||
Preferences.get("privacy.sanitize.sanitizeOnShutdown").value;
|
||||
|
||||
// We have to branch between the old clear on shutdown prefs and new prefs after the clear history revamp (Bug 1853996)
|
||||
// Once the old dialog is deprecated, we can remove these branches.
|
||||
if (useOldClearHistoryDialog) {
|
||||
deleteOnCloseBox.checked =
|
||||
Preferences.get("privacy.sanitize.sanitizeOnShutdown").value &&
|
||||
Preferences.get("privacy.clearOnShutdown.cookies").value &&
|
||||
Preferences.get("privacy.clearOnShutdown.cache").value &&
|
||||
Preferences.get("privacy.clearOnShutdown.offlineApps").value;
|
||||
} else {
|
||||
deleteOnCloseBox.checked =
|
||||
Preferences.get("privacy.sanitize.sanitizeOnShutdown").value &&
|
||||
Preferences.get("privacy.clearOnShutdown_v2.cookiesAndStorage").value &&
|
||||
Preferences.get("privacy.clearOnShutdown_v2.cache").value;
|
||||
}
|
||||
},
|
||||
|
||||
/*
|
||||
* Unsets cleaning prefs that do not belong to DeleteOnClose
|
||||
*/
|
||||
_resetCleaningPrefs() {
|
||||
SANITIZE_ON_SHUTDOWN_PREFS_ONLY.forEach(
|
||||
let sanitizeOnShutdownPrefsArray = useOldClearHistoryDialog
|
||||
? SANITIZE_ON_SHUTDOWN_PREFS_ONLY
|
||||
: SANITIZE_ON_SHUTDOWN_PREFS_ONLY_V2;
|
||||
|
||||
return sanitizeOnShutdownPrefsArray.forEach(
|
||||
pref => (Preferences.get(pref).value = false)
|
||||
);
|
||||
},
|
||||
@@ -2176,7 +2232,11 @@ var gPrivacyPane = {
|
||||
Checks if the user set cleaning prefs that do not belong to DeleteOnClose
|
||||
*/
|
||||
_isCustomCleaningPrefPresent() {
|
||||
return SANITIZE_ON_SHUTDOWN_PREFS_ONLY.some(
|
||||
let sanitizeOnShutdownPrefsArray = useOldClearHistoryDialog
|
||||
? SANITIZE_ON_SHUTDOWN_PREFS_ONLY
|
||||
: SANITIZE_ON_SHUTDOWN_PREFS_ONLY_V2;
|
||||
|
||||
return sanitizeOnShutdownPrefsArray.some(
|
||||
pref => Preferences.get(pref).value
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user