Bug 1422365 - Introduce nsIClearDataService - part 6 - Media devices, r=johannh

This commit is contained in:
Andrea Marchesini 2018-06-01 14:30:00 +02:00
Родитель d50201f106
Коммит 1a54d00d85
3 изменённых файлов: 30 добавлений и 8 удалений

Просмотреть файл

@ -324,17 +324,11 @@ var Sanitizer = {
cookies: {
async clear(range) {
let refObj = {};
// Clear cookies and plugin data.
TelemetryStopwatch.start("FX_SANITIZE_COOKIES_2", refObj);
await clearData(range, Ci.nsIClearDataService.CLEAR_COOKIES |
Ci.nsIClearDataService.CLEAR_PLUGIN_DATA);
Ci.nsIClearDataService.CLEAR_PLUGIN_DATA |
Ci.nsIClearDataService.CLEAR_MEDIA_DEVICES);
TelemetryStopwatch.finish("FX_SANITIZE_COOKIES_2", refObj);
// Clear deviceIds. Done asynchronously (returns before complete).
let mediaMgr = Cc["@mozilla.org/mediaManagerService;1"]
.getService(Ci.nsIMediaManagerService);
mediaMgr.sanitizeDeviceIds(range && range[0]);
},
},

Просмотреть файл

@ -229,6 +229,26 @@ const PasswordsCleaner = {
},
};
const MediaDevicesCleaner = {
deleteByRange(aFrom, aTo) {
return new Promise(aResolve => {
let mediaMgr = Cc["@mozilla.org/mediaManagerService;1"]
.getService(Ci.nsIMediaManagerService);
mediaMgr.sanitizeDeviceIds(aFrom);
aResolve();
});
},
deleteAll() {
return new Promise(aResolve => {
let mediaMgr = Cc["@mozilla.org/mediaManagerService;1"]
.getService(Ci.nsIMediaManagerService);
mediaMgr.sanitizeDeviceIds(null);
aResolve();
});
},
};
// Here the map of Flags-Cleaner.
const FLAGS_MAP = [
{ flag: Ci.nsIClearDataService.CLEAR_COOKIES,
@ -248,6 +268,9 @@ const FLAGS_MAP = [
{ flag: Ci.nsIClearDataService.CLEAR_PASSWORDS,
cleaner: PasswordsCleaner, },
{ flag: Ci.nsIClearDataService.CLEAR_MEDIA_DEVICES,
cleaner: MediaDevicesCleaner, },
];
this.ClearDataService = function() {};

Просмотреть файл

@ -113,6 +113,11 @@ interface nsIClearDataService : nsISupports
*/
const uint32_t CLEAR_PASSWORDS = 1 << 5;
/**
* Media devices.
*/
const uint32_t CLEAR_MEDIA_DEVICES = 1 << 6;
/* TODO
const uint32_t CLEAR_EME = 1 << 4;
const uint32_t CLEAR_PERMISSIONS = 1 << 7;