summaryrefslogtreecommitdiffstats
path: root/browser/actors/SpeechDispatcherParent.sys.mjs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /browser/actors/SpeechDispatcherParent.sys.mjs
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/actors/SpeechDispatcherParent.sys.mjs')
-rw-r--r--browser/actors/SpeechDispatcherParent.sys.mjs90
1 files changed, 90 insertions, 0 deletions
diff --git a/browser/actors/SpeechDispatcherParent.sys.mjs b/browser/actors/SpeechDispatcherParent.sys.mjs
new file mode 100644
index 0000000000..40ddf0b3c4
--- /dev/null
+++ b/browser/actors/SpeechDispatcherParent.sys.mjs
@@ -0,0 +1,90 @@
+/* vim: set ts=2 sw=2 sts=2 et tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+export class SpeechDispatcherParent extends JSWindowActorParent {
+ prefName() {
+ return "media.webspeech.synth.dont_notify_on_error";
+ }
+
+ disableNotification() {
+ Services.prefs.setBoolPref(this.prefName(), true);
+ }
+
+ async receiveMessage(aMessage) {
+ // The top level browsing context's embedding element should be a xul browser element.
+ let browser = this.browsingContext.top.embedderElement;
+
+ if (!browser) {
+ // We don't have a browser so bail!
+ return;
+ }
+
+ let notificationId;
+
+ if (Services.prefs.getBoolPref(this.prefName(), false)) {
+ console.info("Opted out from speech-dispatcher error notification");
+ return;
+ }
+
+ let messageId;
+ switch (aMessage.data) {
+ case "lib-missing":
+ messageId = "speech-dispatcher-lib-missing";
+ break;
+
+ case "lib-too-old":
+ messageId = "speech-dispatcher-lib-too-old";
+ break;
+
+ case "missing-symbol":
+ messageId = "speech-dispatcher-missing-symbol";
+ break;
+
+ case "open-fail":
+ messageId = "speech-dispatcher-open-fail";
+ break;
+
+ case "no-voices":
+ messageId = "speech-dispatcher-no-voices";
+ break;
+
+ default:
+ break;
+ }
+
+ let MozXULElement = browser.ownerGlobal.MozXULElement;
+ MozXULElement.insertFTLIfNeeded("browser/speechDispatcher.ftl");
+
+ // Now actually create the notification
+ let notificationBox = browser.getTabBrowser().getNotificationBox(browser);
+ if (notificationBox.getNotificationWithValue(notificationId)) {
+ return;
+ }
+
+ let buttons = [
+ {
+ supportPage: "speechd-setup",
+ },
+ {
+ "l10n-id": "speech-dispatcher-dismiss-button",
+ callback: () => {
+ this.disableNotification();
+ },
+ },
+ ];
+
+ let iconURL = "chrome://browser/skin/drm-icon.svg";
+ notificationBox.appendNotification(
+ notificationId,
+ {
+ label: { "l10n-id": messageId },
+ image: iconURL,
+ priority: notificationBox.PRIORITY_INFO_HIGH,
+ type: "warning",
+ },
+ buttons
+ );
+ }
+}