-
Notifications
You must be signed in to change notification settings - Fork 78
/
privacy.js
39 lines (37 loc) · 964 Bytes
/
privacy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'use strict';
const privacy = {
onchanges: [],
modes: {
0: 'default_public_and_private_interfaces',
1: 'default_public_interface_only',
2: 'disable_non_proxied_udp',
3: 'proxy_only'
},
current: {
value: 'default'
},
set(mode = 2, callback = function() {}) {
chrome.privacy.network.webRTCIPHandlingPolicy.get({}, o => {
privacy.current = {
value: o.value
};
chrome.privacy.network.webRTCIPHandlingPolicy.set({
value: privacy.modes[mode]
}, () => {
privacy.onchanges.forEach(c => c('webrtc', privacy.modes[mode]));
callback();
});
});
},
reset(callback = function() {}) {
chrome.privacy.network.webRTCIPHandlingPolicy.set(privacy.current, () => {
privacy.onchanges.forEach(c => c('webrtc', false));
callback();
});
},
addListener(method, callback) {
if (method === 'change') {
privacy.onchanges.push(callback);
}
}
};