From 54c40e092fcb1b7a07ff2ec52afbeeaf72539130 Mon Sep 17 00:00:00 2001 From: Isaac Schemm Date: Wed, 28 Feb 2018 14:57:14 -0600 Subject: [PATCH] Properly reset WebRTC disabled status when browser is closed --- components/WebRTCToggle.js | 30 +++++++++++++++++++++--------- install.rdf | 2 +- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/components/WebRTCToggle.js b/components/WebRTCToggle.js index af97806..ea372df 100644 --- a/components/WebRTCToggle.js +++ b/components/WebRTCToggle.js @@ -13,18 +13,26 @@ Components.utils.import("resource://gre/modules/Console.jsm"); AddonManager.addAddonListener({ onUninstalling: function(addon) { if (addon.id == "webrtc-permissions-ui-toggle@lakora.us") { - Components.classes["@mozilla.org/preferences-service;1"] - .getService(Components.interfaces.nsIPrefService) - .getBranch("media.navigator.permission.") + var svc = Components.classes["@mozilla.org/preferences-service;1"] + .getService(Components.interfaces.nsIPrefService); + svc.getBranch("media.navigator.permission.") .setBoolPref("disabled", false); + svc.getBranch("media.navigator.") + .clearUserPref("enabled"); + svc.getBranch("media.peerconnection.") + .clearUserPref("enabled"); } }, onDisabling: function(addon) { if (addon.id == "webrtc-permissions-ui-toggle@lakora.us") { - Components.classes["@mozilla.org/preferences-service;1"] - .getService(Components.interfaces.nsIPrefService) - .getBranch("media.navigator.permission.") + var svc = Components.classes["@mozilla.org/preferences-service;1"] + .getService(Components.interfaces.nsIPrefService); + svc.getBranch("media.navigator.permission.") .setBoolPref("disabled", false); + svc.getBranch("media.navigator.") + .clearUserPref("enabled"); + svc.getBranch("media.peerconnection.") + .clearUserPref("enabled"); } } }); @@ -81,10 +89,14 @@ WebRTCToggle.prototype = { // Turn the override off when closing the application, // regardless of whether or not the add-on is going to be // uninstalled. - Components.classes["@mozilla.org/preferences-service;1"] - .getService(Components.interfaces.nsIPrefService) - .getBranch("media.navigator.permission.") + var svc = Components.classes["@mozilla.org/preferences-service;1"] + .getService(Components.interfaces.nsIPrefService); + svc.getBranch("media.navigator.permission.") .setBoolPref("disabled", false); + svc.getBranch("media.navigator.") + .clearUserPref("enabled"); + svc.getBranch("media.peerconnection.") + .clearUserPref("enabled"); break; case "nsPref:changed": var strings = Components.classes["@mozilla.org/intl/stringbundle;1"] diff --git a/install.rdf b/install.rdf index 127046d..b28d9c7 100644 --- a/install.rdf +++ b/install.rdf @@ -11,7 +11,7 @@ em:creator="Isaac Schemm" em:id="webrtc-permissions-ui-toggle@lakora.us" - em:version="1.3.1" + em:version="1.3.2" em:homepageURL="https://github.com/IsaacSchemm/webrtc-permissions-ui-toggle" em:iconURL="chrome://webrtc-permissions-ui-toggle/content/icon.png"