1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-06 09:37:12 +02:00

code review re. changes in chrome.privacy.network with Chromium 48

This commit is contained in:
gorhill 2016-08-31 17:28:10 -04:00
parent c96c097d6c
commit 0d7e326dce

View File

@ -75,6 +75,12 @@ vAPI.storage = chrome.storage.local;
vAPI.browserSettings = {
webRTCSupported: undefined,
// https://github.com/gorhill/uBlock/issues/875
// Must not leave `lastError` unchecked.
noopCallback: function() {
void chrome.runtime.lastError;
},
// https://github.com/gorhill/uBlock/issues/533
// We must first check wether this Chromium-based browser was compiled
// with WebRTC support. To do this, we use an iframe, this way the
@ -121,30 +127,35 @@ vAPI.browserSettings = {
return;
}
// Older version of Chromium do not support this setting.
if ( typeof chrome.privacy.network.webRTCMultipleRoutesEnabled !== 'object' ) {
return;
var cp = chrome.privacy, cpi = cp.IPHandlingPolicy, cpn = cp.network;
// Older version of Chromium do not support this setting, and is
// marked as "deprecated" since Chromium 48.
if ( typeof cpn.webRTCMultipleRoutesEnabled === 'object' ) {
try {
cpn.webRTCMultipleRoutesEnabled.set({
value: !!setting,
scope: 'regular'
}, this.noopCallback);
} catch(ex) {
console.error(ex);
}
}
try {
chrome.privacy.network.webRTCMultipleRoutesEnabled.set({
value: !!setting,
scope: 'regular'
}, function() {
void chrome.runtime.lastError;
});
} catch(ex) {
console.error(ex);
// This setting became available in Chromium 48.
if ( typeof cpn.webRTCIPHandlingPolicy === 'object' ) {
try {
cpn.webRTCIPHandlingPolicy.set({
value: !!setting ? cpi.DEFAULT : cpi.DEFAULT_PUBLIC_INTERFACE_ONLY,
scope: 'regular'
}, this.noopCallback);
} catch(ex) {
console.error(ex);
}
}
},
set: function(details) {
// https://github.com/gorhill/uBlock/issues/875
// Must not leave `lastError` unchecked.
var callback = function() {
void chrome.runtime.lastError;
};
for ( var setting in details ) {
if ( details.hasOwnProperty(setting) === false ) {
continue;
@ -155,7 +166,7 @@ vAPI.browserSettings = {
chrome.privacy.network.networkPredictionEnabled.set({
value: !!details[setting],
scope: 'regular'
}, callback);
}, this.noopCallback);
} catch(ex) {
console.error(ex);
}
@ -166,7 +177,7 @@ vAPI.browserSettings = {
chrome.privacy.websites.hyperlinkAuditingEnabled.set({
value: !!details[setting],
scope: 'regular'
}, callback);
}, this.noopCallback);
} catch(ex) {
console.error(ex);
}