1 /* vim: set ts=2 sw=2 sts=2 et tw=80: */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 export class SpeechDispatcherParent extends JSWindowActorParent {
8 return "media.webspeech.synth.dont_notify_on_error";
11 disableNotification() {
12 Services.prefs.setBoolPref(this.prefName(), true);
15 async receiveMessage(aMessage) {
16 // The top level browsing context's embedding element should be a xul browser element.
17 let browser = this.browsingContext.top.embedderElement;
20 // We don't have a browser so bail!
26 if (Services.prefs.getBoolPref(this.prefName(), false)) {
27 console.info("Opted out from speech-dispatcher error notification");
32 switch (aMessage.data) {
34 messageId = "speech-dispatcher-lib-missing";
38 messageId = "speech-dispatcher-lib-too-old";
41 case "missing-symbol":
42 messageId = "speech-dispatcher-missing-symbol";
46 messageId = "speech-dispatcher-open-fail";
50 messageId = "speech-dispatcher-no-voices";
57 let MozXULElement = browser.ownerGlobal.MozXULElement;
58 MozXULElement.insertFTLIfNeeded("browser/speechDispatcher.ftl");
60 // Now actually create the notification
61 let notificationBox = browser.getTabBrowser().getNotificationBox(browser);
62 if (notificationBox.getNotificationWithValue(notificationId)) {
68 supportPage: "speechd-setup",
71 "l10n-id": "speech-dispatcher-dismiss-button",
73 this.disableNotification();
78 let iconURL = "chrome://browser/skin/drm-icon.svg";
79 notificationBox.appendNotification(
82 label: { "l10n-id": messageId },
84 priority: notificationBox.PRIORITY_INFO_HIGH,