diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
commit | da4c7e7ed675c3bf405668739c3012d140856109 (patch) | |
tree | cdd868dba063fecba609a1d819de271f0d51b23e /toolkit/components/cleardata/ClearDataService.sys.mjs | |
parent | Adding upstream version 125.0.3. (diff) | |
download | firefox-da4c7e7ed675c3bf405668739c3012d140856109.tar.xz firefox-da4c7e7ed675c3bf405668739c3012d140856109.zip |
Adding upstream version 126.0.upstream/126.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/cleardata/ClearDataService.sys.mjs')
-rw-r--r-- | toolkit/components/cleardata/ClearDataService.sys.mjs | 100 |
1 files changed, 79 insertions, 21 deletions
diff --git a/toolkit/components/cleardata/ClearDataService.sys.mjs b/toolkit/components/cleardata/ClearDataService.sys.mjs index ba34558f7e..5df5c03f58 100644 --- a/toolkit/components/cleardata/ClearDataService.sys.mjs +++ b/toolkit/components/cleardata/ClearDataService.sys.mjs @@ -193,7 +193,7 @@ const CookieCleaner = { }); }, - deleteByRange(aFrom, aTo) { + deleteByRange(aFrom) { return Services.cookies.removeAllSince(aFrom); }, @@ -584,7 +584,7 @@ const DownloadsCleaner = { }; const PasswordsCleaner = { - deleteByHost(aHost, aOriginAttributes) { + deleteByHost(aHost) { // Clearing by host also clears associated subdomains. return this._deleteInternal(aLogin => Services.eTLD.hasRootDomain(aLogin.hostname, aHost) @@ -630,7 +630,7 @@ const PasswordsCleaner = { }; const MediaDevicesCleaner = { - async deleteByRange(aFrom, aTo) { + async deleteByRange(aFrom) { let mediaMgr = Cc["@mozilla.org/mediaManagerService;1"].getService( Ci.nsIMediaManagerService ); @@ -799,7 +799,7 @@ const QuotaCleaner = { } }, - async deleteByHost(aHost, aOriginAttributes) { + async deleteByHost(aHost) { // XXX: The aOriginAttributes is expected to always be empty({}). Maybe have // a debug assertion here to ensure that? @@ -872,7 +872,7 @@ const QuotaCleaner = { _ => /* exceptionThrown = */ false, _ => /* exceptionThrown = */ true ) - .then(exceptionThrown => { + .then(() => { // QuotaManager: In the event of a failure, we call reject to propagate // the error upwards. return new Promise((aResolve, aReject) => { @@ -1002,7 +1002,7 @@ const PushNotificationsCleaner = { }); }, - deleteByHost(aHost, aOriginAttributes) { + deleteByHost(aHost) { // Will also clear entries for subdomains of aHost. Data is cleared across // all origin attributes. return this._deleteByRootDomain(aHost); @@ -1078,7 +1078,7 @@ const StorageAccessCleaner = { }); }, - async deleteByHost(aHost, aOriginAttributes) { + async deleteByHost(aHost) { // Clearing by host also clears associated subdomains. this._deleteInternal(({ principal }) => { let toBeRemoved = false; @@ -1095,7 +1095,7 @@ const StorageAccessCleaner = { ); }, - async deleteByRange(aFrom, aTo) { + async deleteByRange(aFrom) { Services.perms.removeByTypeSince("storageAccessAPI", aFrom / 1000); }, @@ -1105,7 +1105,7 @@ const StorageAccessCleaner = { }; const HistoryCleaner = { - deleteByHost(aHost, aOriginAttributes) { + deleteByHost(aHost) { if (!AppConstants.MOZ_PLACES) { return Promise.resolve(); } @@ -1142,7 +1142,7 @@ const HistoryCleaner = { }; const SessionHistoryCleaner = { - async deleteByHost(aHost, aOriginAttributes) { + async deleteByHost(aHost) { // Session storage and history also clear subdomains of aHost. Services.obs.notifyObservers(null, "browser:purge-sessionStorage", aHost); Services.obs.notifyObservers( @@ -1160,7 +1160,7 @@ const SessionHistoryCleaner = { return this.deleteByHost(aBaseDomain, {}); }, - async deleteByRange(aFrom, aTo) { + async deleteByRange(aFrom) { Services.obs.notifyObservers( null, "browser:purge-session-history", @@ -1275,7 +1275,7 @@ const PermissionsCleaner = { } }, - deleteByHost(aHost, aOriginAttributes) { + deleteByHost(aHost) { return this._deleteInternal({ host: aHost }); }, @@ -1287,7 +1287,7 @@ const PermissionsCleaner = { return this._deleteInternal({ baseDomain: aBaseDomain }); }, - async deleteByRange(aFrom, aTo) { + async deleteByRange(aFrom) { Services.perms.removeAllSince(aFrom / 1000); }, @@ -1301,7 +1301,7 @@ const PermissionsCleaner = { }; const PreferencesCleaner = { - deleteByHost(aHost, aOriginAttributes) { + deleteByHost(aHost) { // Also clears subdomains of aHost. return new Promise((aResolve, aReject) => { let cps2 = Cc["@mozilla.org/content-pref/service;1"].getService( @@ -1328,7 +1328,7 @@ const PreferencesCleaner = { return this.deleteByHost(aBaseDomain, {}); }, - async deleteByRange(aFrom, aTo) { + async deleteByRange(aFrom) { let cps2 = Cc["@mozilla.org/content-pref/service;1"].getService( Ci.nsIContentPrefService2 ); @@ -1477,7 +1477,7 @@ const EMECleaner = { }; const ReportsCleaner = { - deleteByHost(aHost, aOriginAttributes) { + deleteByHost(aHost) { // Also clears subdomains of aHost. return new Promise(aResolve => { Services.obs.notifyObservers(null, "reporting:purge-host", aHost); @@ -1520,7 +1520,7 @@ const ContentBlockingCleaner = { await this.deleteAll(); }, - deleteByRange(aFrom, aTo) { + deleteByRange(aFrom) { return lazy.TrackingDBService.clearSince(aFrom); }, }; @@ -1616,7 +1616,7 @@ const IdentityCredentialStorageCleaner = { } }, - async deleteByPrincipal(aPrincipal, aIsUserRequest) { + async deleteByPrincipal(aPrincipal) { if ( Services.prefs.getBoolPref( "dom.security.credentialmanagement.identity.enabled", @@ -1698,7 +1698,7 @@ const BounceTrackingProtectionStateCleaner = { await lazy.bounceTrackingProtection.clearAll(); }, - async deleteByPrincipal(aPrincipal, aIsUserRequest) { + async deleteByPrincipal(aPrincipal) { if (!lazy.isBounceTrackingProtectionEnabled) { return; } @@ -1709,7 +1709,7 @@ const BounceTrackingProtectionStateCleaner = { ); }, - async deleteByBaseDomain(aBaseDomain, aIsUserRequest) { + async deleteByBaseDomain(aBaseDomain) { if (!lazy.isBounceTrackingProtectionEnabled) { return; } @@ -1723,7 +1723,7 @@ const BounceTrackingProtectionStateCleaner = { await lazy.bounceTrackingProtection.clearByTimeRange(aFrom, aTo); }, - async deleteByHost(aHost, aOriginAttributes) { + async deleteByHost(aHost) { if (!lazy.isBounceTrackingProtectionEnabled) { return; } @@ -1741,6 +1741,59 @@ const BounceTrackingProtectionStateCleaner = { }, }; +const StoragePermissionsCleaner = { + async deleteByRange(aFrom) { + // We lack the ability to clear by range, but can clear from a certain time to now + // We have to divice aFrom by 1000 to convert the time from ms to microseconds + Services.perms.removeByTypeSince("storage-access", aFrom / 1000); + Services.perms.removeByTypeSince("persistent-storage", aFrom / 1000); + }, + + async deleteByPrincipal(aPrincipal) { + Services.perms.removeFromPrincipal(aPrincipal, "storage-access"); + Services.perms.removeFromPrincipal(aPrincipal, "persistent-storage"); + }, + + async deleteByHost(aHost) { + let permissions = this._getStoragePermissions(); + for (let perm of permissions) { + if (Services.eTLD.hasRootDomain(perm.principal.host, aHost)) { + Services.perms.removePermission(perm); + } + } + }, + + async deleteByBaseDomain(aBaseDomain) { + let permissions = this._getStoragePermissions(); + for (let perm of permissions) { + if (perm.principal.baseDomain == aBaseDomain) { + Services.perms.removePermission(perm); + } + } + }, + + async deleteByLocalFiles() { + let permissions = this._getStoragePermissions(); + for (let perm of permissions) { + if (perm.principal.schemeIs("file")) { + Services.perms.removePermission(perm); + } + } + }, + + async deleteAll() { + Services.perms.removeByType("storage-access"); + Services.perms.removeByType("persistent-storage"); + }, + + _getStoragePermissions() { + return Services.perms.getAllByTypes([ + "storage-access", + "persistent-storage", + ]); + }, +}; + // Here the map of Flags-Cleaners. const FLAGS_MAP = [ { @@ -1875,6 +1928,11 @@ const FLAGS_MAP = [ flag: Ci.nsIClearDataService.CLEAR_BOUNCE_TRACKING_PROTECTION_STATE, cleaners: [BounceTrackingProtectionStateCleaner], }, + + { + flag: Ci.nsIClearDataService.CLEAR_STORAGE_PERMISSIONS, + cleaners: [StoragePermissionsCleaner], + }, ]; export function ClearDataService() { |