Skip to content

Commit f0b2428

Browse files
committed
(1.0.3) Use nsIPromptService for modal dialogs
1 parent 10d73ed commit f0b2428

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

chrome/button.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
var prefs = null;
66
var observerObj = null;
7+
var title = "WebRTC Permissions UI Toggle";
78

89
this.addEventListener("load", function () {
910
prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("media.navigator.permission.");
@@ -17,11 +18,11 @@ this.addEventListener("load", function () {
1718

1819
var message = "";
1920
if (newValue) {
20-
toolbarbutton.label = toolbarbutton.tooltipText = "WebRTC Auto (On)";
21+
toolbarbutton.label = toolbarbutton.tooltipText = "WebRTC Override (On)";
2122
toolbarbutton.classList.add("setting-true");
2223
message = "Automatic WebRTC connection has been turned on. Make sure to turn it off when you're done!\nYou might need to refresh the current page.";
2324
} else {
24-
toolbarbutton.label = toolbarbutton.tooltipText = "WebRTC Auto (Off)";
25+
toolbarbutton.label = toolbarbutton.tooltipText = "WebRTC Override (Off)";
2526
toolbarbutton.classList.remove("setting-true");
2627
message = "Automatic WebRTC connection has been turned off.";
2728
}
@@ -35,20 +36,24 @@ this.addEventListener("load", function () {
3536
try {
3637
Components.classes['@mozilla.org/alerts-service;1']
3738
.getService(Components.interfaces.nsIAlertsService)
38-
.showAlertNotification(null, "WebRTC Permissions UI Toggle", message, false, '', null);
39+
.showAlertNotification(null, title, message, false, '', null);
3940
} catch (e) {
40-
alert(message);
41+
Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
42+
.getService(Components.interfaces.nsIPromptService)
43+
.alert(thisWindow, title, message);
4144
}
4245
break;
4346
case "none":
4447
break;
4548
default:
4649
try {
47-
alert(message);
50+
Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
51+
.getService(Components.interfaces.nsIPromptService)
52+
.alert(thisWindow, title, message);
4853
} catch (e) {
4954
Components.classes['@mozilla.org/alerts-service;1']
5055
.getService(Components.interfaces.nsIAlertsService)
51-
.showAlertNotification(null, "WebRTC Permissions UI Toggle", message, false, '', null);
56+
.showAlertNotification(null, title, message, false, '', null);
5257
}
5358
break;
5459
}
@@ -60,7 +65,7 @@ this.addEventListener("load", function () {
6065

6166
var value = prefs.getBoolPref("disabled");
6267
if (value) {
63-
toolbarbutton.label = toolbarbutton.tooltipText = "WebRTC Auto (On)";
68+
toolbarbutton.label = toolbarbutton.tooltipText = "WebRTC Override (On)";
6469
toolbarbutton.classList.add("setting-true");
6570

6671
var r = Components.classes["@mozilla.org/preferences-service;1"]
@@ -71,19 +76,22 @@ this.addEventListener("load", function () {
7176
prefs.setBoolPref("disabled", false);
7277
}
7378
} else {
74-
toolbarbutton.label = toolbarbutton.tooltipText = "WebRTC Auto (Off)";
79+
toolbarbutton.label = toolbarbutton.tooltipText = "WebRTC Override (Off)";
7580
}
7681
});
7782
this.addEventListener("unload", function () {
7883
prefs.removeObserver("", observerObj);
7984
});
8085

8186
WebRTCPermissionsButtons = {
82-
TogglePermissionsUI: function (toolbarbutton) {
87+
TogglePermissionsUI: toolbarbutton => {
88+
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
89+
.getService(Components.interfaces.nsIPromptService);
90+
8391
var actualValue = prefs.getBoolPref("disabled");
8492
if (actualValue) {
8593
prefs.setBoolPref("disabled", false);
86-
} else if (confirm(`Only use this feature with sites you trust. Sharing can allow deceptive sites to browse as you and steal your private data.
94+
} else if (promptService.confirm(this.window, title, `Only use this feature with sites you trust. Sharing can allow deceptive sites to browse as you and steal your private data.
8795
Are you sure you want to share your camera, microphone, and screen with all open web sites?
8896
`)) {
8997
prefs.setBoolPref("disabled", true);

chrome/button.xul

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
<!-- button details -->
2323
<toolbarbutton id="webrtc-permissions-ui-toggle-1"
24-
label="WebRTC Permissions"
25-
tooltiptext="WebRTC Permissions"
24+
label="WebRTC Override"
25+
tooltiptext="WebRTC Override"
2626
oncommand="WebRTCPermissionsButtons.TogglePermissionsUI(this)"
2727
class="webrtc-permissions-ui-button chromeclass-toolbar-additional"
2828
/>

install.rdf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
about="urn:mozilla:install-manifest"
88

99
em:name="WebRTC Permissions UI Toggle"
10-
em:description="A toolbar button to disable the WebRTC permissions dialog and allow media capture automatically."
10+
em:description="A toolbar button for SeaMonkey to override the missing WebRTC permissions dialog and allow media capture automatically."
1111
em:creator="Isaac Schemm"
1212

1313
14-
em:version="1.0.2"
14+
em:version="1.0.3"
1515
em:homepageURL="https://github.com/IsaacSchemm/webrtc-permissions-ui-toggle"
1616

1717
em:iconURL="chrome://webrtc-permissions-ui-toggle/content/icon.png"

0 commit comments

Comments
 (0)