} this.reportEMEDecryptionProbe(); // ... and bail! return; case "api-disabled": case "cdm-disabled": this.handledMessages.add(status); notificationId = "drmContentDisabled"; buttonCallback = () => { this.ensureEMEEnabled(browser, keySystem); }; notificationMessage = lazy.gNavigatorBundle.GetStringFromName( "emeNotifications.drmContentDisabled.message2" ); supportPage = "drm-content"; break; case "cdm-not-installed": this.handledMessages.add(status); notificationId = "drmContentCDMInstalling"; notificationMessage = this.getMessageWithBrandName(notificationId); break; case "cdm-not-supported": // Not to pop up user-level notification because they cannot do anything // about it. return; default: console.error( new Error( "Unknown message ('" + status + "') dealing with EME key request: " + aMessage.data ) ); return; } // Now actually create the notification let notificationBox = browser.getTabBrowser().getNotificationBox(browser); if (notificationBox.getNotificationWithValue(notificationId)) { this.handledMessages.delete(status); return; } let buttons = []; if (supportPage) { buttons.push({ supportPage }); } if (buttonCallback) { let msgPrefix = "emeNotifications." + notificationId + "."; let manageLabelId = msgPrefix + "button.label"; let manageAccessKeyId = msgPrefix + "button.accesskey"; buttons.push({ label: lazy.gNavigatorBundle.GetStringFromName(manageLabelId), accessKey: lazy.gNavigatorBundle.GetStringFromName(manageAccessKeyId), callback: buttonCallback, }); } let iconURL = "chrome://browser/skin/drm-icon.svg"; await notificationBox.appendNotification( notificationId, { label: notificationMessage, image: iconURL, priority: notificationBox.PRIORITY_INFO_HIGH, }, buttons ); this.handledMessages.delete(status); } async showPopupNotificationForSuccess(aBrowser) { // We're playing EME content! Remove any "we can't play because..." messages. let notificationBox = aBrowser.getTabBrowser().getNotificationBox(aBrowser); ["drmContentDisabled", "drmContentCDMInstalling"].forEach(function (value) { let notification = notificationBox.getNotificationWithValue(value); if (notification) { notificationBox.removeNotification(notification); } }); // Don't bother creating it if it's already there: if ( aBrowser.ownerGlobal.PopupNotifications.getNotification( "drmContentPlaying", aBrowser ) ) { return; } let msgId = "eme-notifications-drm-content-playing"; let manageLabelId = "eme-notifications-drm-content-playing-manage"; let manageAccessKeyId = "eme-notifications-drm-content-playing-manage-accesskey"; let dismissLabelId = "eme-notifications-drm-content-playing-dismiss"; let dismissAccessKeyId = "eme-notifications-drm-content-playing-dismiss-accesskey"; let [ message, manageLabel, manageAccessKey, dismissLabel, dismissAccessKey, ] = await lazy.gFluentStrings.formatValues([ msgId, manageLabelId, manageAccessKeyId, dismissLabelId, dismissAccessKeyId, ]); let anchorId = "eme-notification-icon"; let firstPlayPref = "browser.eme.ui.firstContentShown"; let document = aBrowser.ownerDocument; if ( !Services.prefs.getPrefType(firstPlayPref) || !Services.prefs.getBoolPref(firstPlayPref) ) { document.getElementById(anchorId).setAttribute("firstplay", "true"); Services.prefs.setBoolPref(firstPlayPref, true); } else { document.getElementById(anchorId).removeAttribute("firstplay"); } let mainAction = { label: manageLabel, accessKey: manageAccessKey, callback() { aBrowser.ownerGlobal.openPreferences("general-drm"); }, dismiss: true, }; let secondaryActions = [ { label: dismissLabel, accessKey: dismissAccessKey, callback: () => {}, dismiss: true, }, ]; let options = { dismissed: true, eventCallback: aTopic => aTopic == "swapping", learnMoreURL: Services.urlFormatter.formatURLPref("app.support.baseURL") + "drm-content", hideClose: true, }; aBrowser.ownerGlobal.PopupNotifications.show( aBrowser, "drmContentPlaying", message, anchorId, mainAction, secondaryActions, options ); } async reportEMEDecryptionProbe() { let hasHardwareDecryption = false; let hasSoftwareClearlead = false; let hasHardwareClearlead = false; let hasWMF = false; // Get CDM capabilities from the GMP process. let infos = []; let cdmInfo = await ChromeUtils.getGMPContentDecryptionModuleInformation(); infos.push(...cdmInfo); // Get CDM capabilities from the MFCDM process, if exists. if (ChromeUtils.getWMFContentDecryptionModuleInformation !== undefined) { hasWMF = true; cdmInfo = await ChromeUtils.getWMFContentDecryptionModuleInformation(); infos.push(...cdmInfo); } for (let info of infos) { if (info.isHardwareDecryption) { hasHardwareDecryption = true; } if (info.clearlead) { if (info.isHardwareDecryption) { hasHardwareClearlead = true; } else { hasSoftwareClearlead = true; } } } Glean.mediadrm.decryption.has_hardware_decryption.set( hasHardwareDecryption ); Glean.mediadrm.decryption.has_hardware_clearlead.set(hasHardwareClearlead); Glean.mediadrm.decryption.has_software_clearlead.set(hasSoftwareClearlead); Glean.mediadrm.decryption.has_wmf.set(hasWMF); } } PK