Skip to content

Commit

Permalink
Properly reset WebRTC disabled status when browser is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacSchemm committed Feb 28, 2018
1 parent 892864d commit 54c40e0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
30 changes: 21 additions & 9 deletions components/WebRTCToggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
});
Expand Down Expand Up @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 54c40e0

Please sign in to comment.