mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 15:25:52 +00:00
Bug 1462662 - Wipe the container for privacy.usercontext.about_newtab_segregation.enabled on shutdown, r=johannh
This commit is contained in:
parent
bea2e0899f
commit
612caa865c
@ -17,6 +17,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
setTimeout: "resource://gre/modules/Timer.jsm",
|
||||
ServiceWorkerCleanUp: "resource://gre/modules/ServiceWorkerCleanUp.jsm",
|
||||
OfflineAppCacheHelper: "resource://gre/modules/offlineAppCache.jsm",
|
||||
ContextualIdentityService: "resource://gre/modules/ContextualIdentityService.jsm",
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "sas",
|
||||
@ -71,6 +72,12 @@ var Sanitizer = {
|
||||
*/
|
||||
PREF_TIMESPAN: "privacy.sanitize.timeSpan",
|
||||
|
||||
/**
|
||||
* Pref to newTab segregation. If true, on shutdown, the private container
|
||||
* used in about:newtab is cleaned up. Exposed because used in tests.
|
||||
*/
|
||||
PREF_NEWTAB_SEGREGATION: "privacy.usercontext.about_newtab_segregation.enabled",
|
||||
|
||||
/**
|
||||
* Time span constants corresponding to values of the privacy.sanitize.timeSpan
|
||||
* pref. Used to determine how much history to clear, for various items
|
||||
@ -91,6 +98,11 @@ var Sanitizer = {
|
||||
*/
|
||||
shouldSanitizeOnShutdown: false,
|
||||
|
||||
/**
|
||||
* Whether we should sanitize the private container for about:newtab.
|
||||
*/
|
||||
shouldSanitizeNewTabContainer: false,
|
||||
|
||||
/**
|
||||
* Shows a sanitization dialog to the user.
|
||||
*
|
||||
@ -145,6 +157,17 @@ var Sanitizer = {
|
||||
{fetchState: () => ({ progress })}
|
||||
);
|
||||
|
||||
this.shouldSanitizeNewTabContainer = Services.prefs.getBoolPref(this.PREF_NEWTAB_SEGREGATION, false);
|
||||
if (this.shouldSanitizeNewTabContainer) {
|
||||
addPendingSanitization("newtab-container", [], {});
|
||||
}
|
||||
|
||||
let i = pendingSanitizations.findIndex(s => s.id == "newtab-container");
|
||||
if (i != -1) {
|
||||
pendingSanitizations.splice(i, 1);
|
||||
sanitizeNewTabSegregation();
|
||||
}
|
||||
|
||||
// Finally, run the sanitizations that were left pending, because we crashed
|
||||
// before completing them.
|
||||
for (let {itemsToClear, options} of pendingSanitizations) {
|
||||
@ -272,6 +295,12 @@ var Sanitizer = {
|
||||
let itemsToClear = getItemsToClearFromPrefBranch(Sanitizer.PREF_SHUTDOWN_BRANCH);
|
||||
addPendingSanitization("shutdown", itemsToClear, {});
|
||||
}
|
||||
} else if (data == this.PREF_NEWTAB_SEGREGATION) {
|
||||
this.shouldSanitizeNewTabContainer = Services.prefs.getBoolPref(this.PREF_NEWTAB_SEGREGATION, false);
|
||||
removePendingSanitization("newtab-container");
|
||||
if (this.shouldSanitizeNewTabContainer) {
|
||||
addPendingSanitization("newtab-container", [], {});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -990,6 +1019,11 @@ async function sanitizeOnShutdown(progress) {
|
||||
}
|
||||
}
|
||||
|
||||
if (Sanitizer.shouldSanitizeNewTabContainer) {
|
||||
sanitizeNewTabSegregation();
|
||||
removePendingSanitization("newtab-container");
|
||||
}
|
||||
|
||||
if (Sanitizer.shouldSanitizeOnShutdown) {
|
||||
// We didn't crash during shutdown sanitization, so annotate it to avoid
|
||||
// sanitizing again on startup.
|
||||
@ -1061,6 +1095,14 @@ async function sanitizeSessionPrincipal(principal) {
|
||||
]);
|
||||
}
|
||||
|
||||
function sanitizeNewTabSegregation() {
|
||||
let identity = ContextualIdentityService.getPrivateIdentity("userContextIdInternal.thumbnail");
|
||||
if (identity) {
|
||||
Services.obs.notifyObservers(null, "clear-origin-attributes-data",
|
||||
JSON.stringify({ userContextId: identity.userContextId }));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of items to clear from the given pref branch.
|
||||
* @param branch The pref branch to fetch.
|
||||
|
@ -11,9 +11,13 @@ do_get_profile();
|
||||
|
||||
add_task(async function() {
|
||||
ChromeUtils.import("resource:///modules/Sanitizer.jsm");
|
||||
|
||||
Services.prefs.setBoolPref(Sanitizer.PREF_NEWTAB_SEGREGATION, false);
|
||||
|
||||
registerCleanupFunction(() => {
|
||||
Services.prefs.clearUserPref(Sanitizer.PREF_SANITIZE_ON_SHUTDOWN);
|
||||
Services.prefs.clearUserPref(Sanitizer.PREF_SHUTDOWN_BRANCH + "formdata");
|
||||
Services.prefs.clearUserPref(Sanitizer.PREF_NEWTAB_SEGREGATION);
|
||||
});
|
||||
Services.prefs.setBoolPref(Sanitizer.PREF_SANITIZE_ON_SHUTDOWN, true);
|
||||
Services.prefs.setBoolPref(Sanitizer.PREF_SHUTDOWN_BRANCH + "formdata", true);
|
||||
|
Loading…
Reference in New Issue
Block a user