Bug 1876097 - Migrate old prefs to the new prefs for clear on shutdown in the new clear history dialog. r=pbz
Differential Revision: https://phabricator.services.mozilla.com/D199445
This commit is contained in:
@@ -396,6 +396,58 @@ export var Sanitizer = {
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Migrate old sanitize on shutdown prefs to the new prefs for the new
|
||||
* clear on shutdown dialog. Does nothing if the migration was completed before
|
||||
* based on the pref privacy.sanitize.sanitizeOnShutdown.hasMigratedToNewPrefs
|
||||
*
|
||||
*/
|
||||
maybeMigrateSanitizeOnShutdownPrefs() {
|
||||
if (
|
||||
Services.prefs.getBoolPref(
|
||||
"privacy.sanitize.sanitizeOnShutdown.hasMigratedToNewPrefs"
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
let cookies = Services.prefs.getBoolPref("privacy.clearOnShutdown.cookies");
|
||||
let history = Services.prefs.getBoolPref("privacy.clearOnShutdown.history");
|
||||
let cache = Services.prefs.getBoolPref("privacy.clearOnShutdown.cache");
|
||||
let siteSettings = Services.prefs.getBoolPref(
|
||||
"privacy.clearOnShutdown.siteSettings"
|
||||
);
|
||||
|
||||
// We set cookiesAndStorage to true if cookies are enabled for clearing on shutdown
|
||||
// regardless of what sessions and offlineApps are set to
|
||||
// This is because cookie clearing behaviour takes precedence over sessions and offlineApps clearing.
|
||||
Services.prefs.setBoolPref(
|
||||
"privacy.clearOnShutdown_v2.cookiesAndStorage",
|
||||
cookies
|
||||
);
|
||||
|
||||
// we set historyFormDataAndDownloads to true if history is enabled for clearing on
|
||||
// shutdown, regardless of what form data is set to.
|
||||
// This is because history clearing behavious takes precedence over formdata clearing.
|
||||
Services.prefs.setBoolPref(
|
||||
"privacy.clearOnShutdown_v2.historyFormDataAndDownloads",
|
||||
history
|
||||
);
|
||||
|
||||
// cache and siteSettings follow the old dialog prefs
|
||||
Services.prefs.setBoolPref("privacy.clearOnShutdown_v2.cache", cache);
|
||||
|
||||
Services.prefs.setBoolPref(
|
||||
"privacy.clearOnShutdown_v2.siteSettings",
|
||||
siteSettings
|
||||
);
|
||||
|
||||
Services.prefs.setBoolPref(
|
||||
"privacy.sanitize.sanitizeOnShutdown.hasMigratedToNewPrefs",
|
||||
true
|
||||
);
|
||||
},
|
||||
|
||||
// When making any changes to the sanitize implementations here,
|
||||
// please check whether the changes are applicable to Android
|
||||
// (mobile/android/modules/geckoview/GeckoViewStorageController.jsm) as well.
|
||||
@@ -1031,6 +1083,10 @@ async function sanitizeOnShutdown(progress) {
|
||||
),
|
||||
};
|
||||
} else {
|
||||
// Perform a migration if this is the first time sanitizeOnShutdown is
|
||||
// running for the user with the new dialog
|
||||
Sanitizer.maybeMigrateSanitizeOnShutdownPrefs();
|
||||
|
||||
progress.sanitizationPrefs = {
|
||||
privacy_sanitize_sanitizeOnShutdown: Services.prefs.getBoolPref(
|
||||
"privacy.sanitize.sanitizeOnShutdown"
|
||||
|
||||
Reference in New Issue
Block a user