Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove WebRTC toggle #2821

Merged
merged 2 commits into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions doc/permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ The Privacy API lets extensions modify browser-wide privacy settings. Privacy Ba
- [prefetching](https://developer.mozilla.org/en-US/docs/Web/HTTP/Link_prefetching_FAQ) (network predictions), as it presents a poor tradeoff between privacy and perceived browsing performance
- suggestions for similar pages when a page can't be found, as this Chrome feature sends visited web addresses to Google

In addition, Privacy Badger allows users to set a stricter WebRTC IP handling policy in order to prevent leaking local network address information.

## Storage
The storage API lets extensions store information that persists after the browser is closed. Privacy Badger uses it to save user settings and information it has learned about trackers.

Expand Down
10 changes: 1 addition & 9 deletions src/_locales/en_US/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@
"message": "blocked",
"description": "Dropdown control setting on the Tracking Domains options page tab."
},
"options_webrtc_setting": {
"message": "Prevent WebRTC from leaking local IP address",
"description": "Checkbox label on the general settings page"
},
"intro_welcome": {
"message": "Privacy Badger automatically learns to block invisible trackers. Take a minute to see how.",
"description": "Intro page welcome paragraph."
Expand Down Expand Up @@ -307,10 +303,6 @@
"message": "To learn how Privacy Badger works, click below for a quick tutorial.",
"description": "Second part of a reminder to visit the intro page"
},
"options_webrtc_warning": {
"message": "WebRTC can leak your local IP address. Note that enabling this option may degrade performance on web conferencing apps like Google Hangouts.",
"description": "Tooltip on the general settings page"
},
"options_general_settings": {
"message": "General Settings",
"description": "This is an options page tab heading."
Expand Down Expand Up @@ -712,7 +704,7 @@
},
"deprecated_setting": {
"message": "The following setting has been deprecated and will be removed in a future Privacy Badger update:",
"description": "Followed by the options_webrtc_setting message ('Prevent WebRTC...')"
"description": "Followed by the label of the deprecated setting (for example: 'Prevent WebRTC...')"
},
"learn_more_link": {
"message": "Visit $LINK$ to learn more.",
Expand Down
95 changes: 19 additions & 76 deletions src/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ function Badger() {
self.isFirstRun = false;
self.isUpdate = false;

self.webRTCAvailable = checkWebRtcBrowserSupport();

self.widgetList = [];
let widgetListPromise = widgetLoader.loadWidgetsFromFile(
"data/socialwidgets.json").catch(console.error);
Expand Down Expand Up @@ -150,36 +148,6 @@ function Badger() {
}
});

/**
* WebRTC availability check
*/
function checkWebRtcBrowserSupport() {
if (!(chrome.privacy && chrome.privacy.network &&
chrome.privacy.network.webRTCIPHandlingPolicy)) {
return false;
}

var available = true;
var connection = null;

try {
var RTCPeerConnection = (
window.RTCPeerConnection || window.webkitRTCPeerConnection
);
if (RTCPeerConnection) {
connection = new RTCPeerConnection(null);
}
} catch (ex) {
available = false;
}

if (connection !== null && connection.close) {
connection.close();
}

return available;
}

}

Badger.prototype = {
Expand Down Expand Up @@ -323,16 +291,6 @@ Badger.prototype = {
(self.getSettings().getItem("disableHyperlinkAuditing") ? false : null)
);
}

// when enabled, WebRTC IP handling policy is set to Mode 3
// https://tools.ietf.org/html/draft-ietf-rtcweb-ip-handling-01#page-5
if (badger.webRTCAvailable) {
_set_override(
"webRTCIPHandlingPolicy",
chrome.privacy.network.webRTCIPHandlingPolicy,
(self.getSettings().getItem("preventWebRTCIPLeak") ? 'default_public_interface_only' : null)
);
}
},

/**
Expand Down Expand Up @@ -821,7 +779,6 @@ Badger.prototype = {
learnInIncognito: false,
learnLocally: false,
migrationLevel: 0,
preventWebRTCIPLeak: false,
seenComic: false,
sendDNTSignal: true,
showCounter: true,
Expand Down Expand Up @@ -885,11 +842,22 @@ Badger.prototype = {
}
badger.initDeprecations();

// remove obsolete settings
if (self.isUpdate) {
// remove obsolete settings
if (settings.hasItem("showTrackingDomains")) {
settings.deleteItem("showTrackingDomains");
}
[
"preventWebRTCIPLeak",
"showTrackingDomains",
"webRTCIPProtection",
].forEach(item => {
if (settings.hasItem(item)) { settings.deleteItem(item); }
});

[
"legacyWebRtcProtectionUser",
"showWebRtcDeprecation",
].forEach(item => {
if (privateStore.hasItem(item)) { privateStore.deleteItem(item); }
});
}
},

Expand All @@ -898,31 +866,7 @@ Badger.prototype = {
*
* Called on Badger startup and user data import.
*/
initDeprecations: function () {
let self = this,
privateStore = self.getPrivateSettings();

if (!privateStore.hasItem("legacyWebRtcProtectionUser")) {
// initialize "legacy WebRTC IP leak protection user" flag
privateStore.setItem("legacyWebRtcProtectionUser",
self.getSettings().getItem("preventWebRTCIPLeak"));

} else if (!privateStore.getItem("legacyWebRtcProtectionUser")) {
// set legacy flag to true if the IP protection gets enabled
// for whatever reason (testing, user data import)
if (self.getSettings().getItem("preventWebRTCIPLeak")) {
privateStore.setItem("legacyWebRtcProtectionUser", true);
}
}

if (!privateStore.hasItem("showWebRtcDeprecation")) {
// will show WebRTC protection deprecation message
// iff showWebRtcDeprecation exists and is set to true
if (privateStore.getItem("legacyWebRtcProtectionUser")) {
privateStore.setItem("showWebRtcDeprecation", true);
}
}
},
initDeprecations: function () {},

runMigrations: function() {
var self = this;
Expand Down Expand Up @@ -952,6 +896,7 @@ Badger.prototype = {
Migrations.resetWebRTCIPHandlingPolicy2,
Migrations.resetWebRtcIpHandlingPolicy3,
Migrations.forgetOpenDNS,
Migrations.unsetWebRTCIPHandlingPolicy,
];

for (var i = migrationLevel; i < migrations.length; i++) {
Expand Down Expand Up @@ -1007,9 +952,7 @@ Badger.prototype = {
return;
}

let special_page = !utils.hasOwn(self.tabData, tab_id);

if (self.criticalError || (!special_page && badger.getPrivateSettings().getItem("showWebRtcDeprecation"))) {
if (self.criticalError) {
chrome.browserAction.setBadgeBackgroundColor({tabId: tab_id, color: "#cc0000"});
chrome.browserAction.setBadgeText({tabId: tab_id, text: "!"});
return;
Expand All @@ -1019,7 +962,7 @@ Badger.prototype = {
// - the counter is disabled
// - we don't have tabData for whatever reason (special browser pages)
// - Privacy Badger is disabled on the page
if (special_page ||
if (!utils.hasOwn(self.tabData, tab_id) ||
!self.getSettings().getItem("showCounter") ||
!self.isPrivacyBadgerEnabled(self.getFrameData(tab_id).host)
) {
Expand Down
56 changes: 39 additions & 17 deletions src/js/migrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,30 +247,52 @@ exports.Migrations= {

resetWebRTCIPHandlingPolicy2: noop,

resetWebRtcIpHandlingPolicy3: function (badger) {
if (!badger.webRTCAvailable) {
resetWebRtcIpHandlingPolicy3: noop,

forgetOpenDNS: (badger) => {
console.log("Forgetting Cisco OpenDNS domains ...");
badger.storage.forget("opendns.com");
},

unsetWebRTCIPHandlingPolicy: function (/*badger*/) {
if (!chrome.privacy || !chrome.privacy.network || !chrome.privacy.network.webRTCIPHandlingPolicy) {
return;
}

console.log("Migrating WebRTC IP protection ...");
chrome.privacy.network.webRTCIPHandlingPolicy.get({}, function (res) {
if (res.levelOfControl != 'controlled_by_this_extension') {
return;
function checkWebRtcBrowserSupport() {
let available = true;
let connection = null;

try {
let RTCPeerConnection = (
window.RTCPeerConnection || window.webkitRTCPeerConnection
);
if (RTCPeerConnection) {
connection = new RTCPeerConnection(null);
}
} catch (ex) {
available = false;
}

// since we previously enabled this privacy override,
// update corresponding Badger setting
badger.getSettings().setItem("preventWebRTCIPLeak", true);
if (connection !== null && connection.close) {
connection.close();
}

// update the browser setting
// in case it needs to be migrated from Mode 4 to Mode 3
badger.setPrivacyOverrides();
});
},
return available;
}

forgetOpenDNS: (badger) => {
console.log("Forgetting Cisco OpenDNS domains ...");
badger.storage.forget("opendns.com");
if (!checkWebRtcBrowserSupport()) {
return;
}

console.log("Unsetting webRTCIPHandlingPolicy ...");
chrome.privacy.network.webRTCIPHandlingPolicy.get({}, function (res) {
if (res.levelOfControl == 'controlled_by_this_extension') {
chrome.privacy.network.webRTCIPHandlingPolicy.clear({
scope: 'regular'
});
}
});
},

};
Expand Down
12 changes: 0 additions & 12 deletions src/js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,6 @@ function loadOptions() {
});
}

if (OPTIONS_DATA.webRTCAvailable && OPTIONS_DATA.legacyWebRtcProtectionUser) {
$("#webRTCToggle").show();
$("#toggle_webrtc_mode")
.prop("checked", OPTIONS_DATA.settings.preventWebRTCIPLeak)
.on("click", function () {
updatePrivacyOverride(
"preventWebRTCIPLeak",
$("#toggle_webrtc_mode").prop("checked")
);
});
}

$('#local-learning-checkbox')
.prop("checked", OPTIONS_DATA.settings.learnLocally)
.on("click", (event) => {
Expand Down
27 changes: 1 addition & 26 deletions src/js/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,6 @@ function showNagMaybe() {
}, cb);
}

function _setSeenWebRtcDeprecation(cb) {
chrome.runtime.sendMessage({
type: "seenWebRtcDeprecation",
tabId: POPUP_DATA.tabId
}, cb);
}

function _hideNag() {
$nag.fadeOut();
$outer.fadeOut();
Expand Down Expand Up @@ -133,25 +126,7 @@ function showNagMaybe() {
$outer.show();
}

function _showWebRtcDeprecationPrompt() {
$('#instruction-text').hide();

$("#webrtc-deprecation-ack-btn").on("click", function () {
_setSeenWebRtcDeprecation(function () {
_hideNag();
});
});

$('#webrtc-deprecation-div').show();
$('#fittslaw').hide();
$nag.show();
$outer.show();
}

if (POPUP_DATA.showWebRtcDeprecation) {
_showWebRtcDeprecationPrompt();

} else if (POPUP_DATA.showLearningPrompt) {
if (POPUP_DATA.showLearningPrompt) {
_showLearningPrompt();

} else if (!POPUP_DATA.settings.seenComic) {
Expand Down
10 changes: 0 additions & 10 deletions src/js/webrequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,6 @@ function dispatcher(request, sender, sendResponse) {
origins,
settings: badger.getSettings().getItemClones(),
showLearningPrompt: badger.getPrivateSettings().getItem("showLearningPrompt"),
showWebRtcDeprecation: !!badger.getPrivateSettings().getItem("showWebRtcDeprecation"),
tabHost: tab_host,
tabId: tab_id,
tabUrl: request.tabUrl,
Expand All @@ -1266,10 +1265,8 @@ function dispatcher(request, sender, sendResponse) {

sendResponse({
cookieblocked,
legacyWebRtcProtectionUser: badger.getPrivateSettings().getItem("legacyWebRtcProtectionUser"),
origins,
settings: badger.getSettings().getItemClones(),
webRTCAvailable: badger.webRTCAvailable,
widgets: badger.widgetList.map(widget => widget.name),
});

Expand Down Expand Up @@ -1308,13 +1305,6 @@ function dispatcher(request, sender, sendResponse) {
break;
}

case "seenWebRtcDeprecation": {
badger.getPrivateSettings().setItem("showWebRtcDeprecation", false);
badger.updateBadge(request.tabId);
sendResponse();
break;
}

case "activateOnSite": {
badger.enablePrivacyBadgerForOrigin(request.tabHost);
badger.updateIcon(request.tabId, request.tabUrl);
Expand Down
9 changes: 0 additions & 9 deletions src/skin/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,6 @@ <h4 class="i18n_options_advanced_settings"></h4>
</label>
</div>
</div>
<div class="checkbox" id="webRTCToggle" style="display:none">
<label>
<input type="checkbox" id="toggle_webrtc_mode">
<span>
<span class="i18n_options_webrtc_setting"></span>
<span class="ui-icon ui-icon-alert tooltip" title="i18n_options_webrtc_warning"></span>
</span>
</label>
</div>

</form>
</div>
Expand Down
Loading