Bug 1695707 - Update copy for DRM panel buttons and migrate to Fluent. r=Gijs,flod
authorMike Conley <mconley@mozilla.com>
Wed, 03 Mar 2021 23:12:13 +0000
changeset 569569 ce5ddd2afe7108fffb52441ba013651113ae0f81
parent 569568 9ea9e1c55a78f439718532f7188cf42f1622adac
child 569570 f953699c07a294ea44ed655ca0cee3b547509c56
push id137695
push usermconley@mozilla.com
push dateWed, 03 Mar 2021 23:14:37 +0000
treeherderautoland@ce5ddd2afe71 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, flod
bugs1695707
milestone88.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1695707 - Update copy for DRM panel buttons and migrate to Fluent. r=Gijs,flod Differential Revision: https://phabricator.services.mozilla.com/D106819
browser/actors/EncryptedMediaParent.jsm
browser/locales/en-US/browser/browser.ftl
browser/locales/en-US/chrome/browser/browser.properties
python/l10n/fluent_migrations/bug_1695707_drm_panel_message.py
--- a/browser/actors/EncryptedMediaParent.jsm
+++ b/browser/actors/EncryptedMediaParent.jsm
@@ -19,16 +19,20 @@ XPCOMUtils.defineLazyGetter(this, "gBran
 });
 
 XPCOMUtils.defineLazyGetter(this, "gNavigatorBundle", function() {
   return Services.strings.createBundle(
     "chrome://browser/locale/browser.properties"
   );
 });
 
+XPCOMUtils.defineLazyGetter(this, "gFluentStrings", function() {
+  return new Localization(["branding/brand.ftl", "browser/browser.ftl"], true);
+});
+
 class EncryptedMediaParent extends JSWindowActorParent {
   isUiEnabled() {
     return Services.prefs.getBoolPref("browser.eme.ui.enabled");
   }
 
   ensureEMEEnabled(aBrowser, aKeySystem) {
     Services.prefs.setBoolPref("media.eme.enabled", true);
     if (
@@ -150,36 +154,36 @@ class EncryptedMediaParent extends JSWin
     }
 
     let buttons = [];
     if (supportPage) {
       buttons.push({ supportPage });
     }
     if (buttonCallback) {
       let msgPrefix = "emeNotifications." + notificationId + ".";
-      let btnLabelId = msgPrefix + "button.label";
-      let btnAccessKeyId = msgPrefix + "button.accesskey";
+      let manageLabelId = msgPrefix + "button.label";
+      let manageAccessKeyId = msgPrefix + "button.accesskey";
       buttons.push({
-        label: gNavigatorBundle.GetStringFromName(btnLabelId),
-        accessKey: gNavigatorBundle.GetStringFromName(btnAccessKeyId),
+        label: gNavigatorBundle.GetStringFromName(manageLabelId),
+        accessKey: gNavigatorBundle.GetStringFromName(manageAccessKeyId),
         callback: buttonCallback,
       });
     }
 
     let iconURL = "chrome://browser/skin/drm-icon.svg";
     notificationBox.appendNotification(
       notificationMessage,
       notificationId,
       iconURL,
       notificationBox.PRIORITY_INFO_HIGH,
       buttons
     );
   }
 
-  showPopupNotificationForSuccess(aBrowser) {
+  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);
       }
     });
@@ -189,55 +193,79 @@ class EncryptedMediaParent extends JSWin
       aBrowser.ownerGlobal.PopupNotifications.getNotification(
         "drmContentPlaying",
         aBrowser
       )
     ) {
       return;
     }
 
-    let msgPrefix = "emeNotifications.drmContentPlaying.";
-    let msgId = msgPrefix + "message2";
-    let btnLabelId = msgPrefix + "button.label";
-    let btnAccessKeyId = msgPrefix + "button.accesskey";
+    let msgPrefix = "eme-notifications-drm-content-playing";
+    let msgId = msgPrefix;
+    let manageLabelId = msgPrefix + "-manage";
+    let manageAccessKeyId = msgPrefix + "-manage-accesskey";
+    let dismissLabelId = msgPrefix + "-dismiss";
+    let dismissAccessKeyId = msgPrefix + "-dismiss-accesskey";
 
-    let message = gNavigatorBundle.formatStringFromName(msgId, [
-      gBrandBundle.GetStringFromName("brandShortName"),
+    let [
+      message,
+      manageLabel,
+      manageAccessKey,
+      dismissLabel,
+      dismissAccessKey,
+    ] = await 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: gNavigatorBundle.GetStringFromName(btnLabelId),
-      accessKey: gNavigatorBundle.GetStringFromName(btnAccessKeyId),
+      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,
-      null,
+      secondaryActions,
       options
     );
   }
 }
--- a/browser/locales/en-US/browser/browser.ftl
+++ b/browser/locales/en-US/browser/browser.ftl
@@ -613,8 +613,16 @@ library-bookmarks-menu =
 library-recent-activity-title =
   .value = Recent Activity
 
 ## More items
 
 more-menu-go-offline =
   .label = Work Offline
   .accesskey = k
+
+## EME notification panel
+
+eme-notifications-drm-content-playing = Some audio or video on this site uses DRM software, which may limit what { -brand-short-name } can let you do with it.
+eme-notifications-drm-content-playing-manage = Manage Settings
+eme-notifications-drm-content-playing-manage-accesskey = M
+eme-notifications-drm-content-playing-dismiss = Dismiss
+eme-notifications-drm-content-playing-dismiss-accesskey = D
--- a/browser/locales/en-US/chrome/browser/browser.properties
+++ b/browser/locales/en-US/chrome/browser/browser.properties
@@ -854,21 +854,16 @@ getUserMedia.sharingMenuMicrophoneBrowse
 getUserMedia.sharingMenuAudioCaptureApplication = %S (tab audio and application)
 getUserMedia.sharingMenuAudioCaptureScreen = %S (tab audio and screen)
 getUserMedia.sharingMenuAudioCaptureWindow = %S (tab audio and window)
 getUserMedia.sharingMenuAudioCaptureBrowser = %S (tab audio and tab)
 # LOCALIZATION NOTE(getUserMedia.sharingMenuUnknownHost): this is used for the website
 # origin for the sharing menu if no readable origin could be deduced from the URL.
 getUserMedia.sharingMenuUnknownHost = Unknown origin
 
-# LOCALIZATION NOTE(emeNotifications.drmContentPlaying.message2): %S is brandShortName.
-emeNotifications.drmContentPlaying.message2 = Some audio or video on this site uses DRM software, which may limit what %S can let you do with it.
-emeNotifications.drmContentPlaying.button.label = Configureā€¦
-emeNotifications.drmContentPlaying.button.accesskey = C
-
 # LOCALIZATION NOTE(emeNotifications.drmContentDisabled.message): NB: inserted via innerHTML, so please don't use <, > or & in this string. %S will be the 'learn more' link
 emeNotifications.drmContentDisabled.message2 = You must enable DRM to play some audio or video on this page.
 emeNotifications.drmContentDisabled.button.label = Enable DRM
 emeNotifications.drmContentDisabled.button.accesskey = E
 
 # LOCALIZATION NOTE(emeNotifications.drmContentCDMInstalling.message): NB: inserted via innerHTML, so please don't use <, > or & in this string. %S is brandShortName
 emeNotifications.drmContentCDMInstalling.message = %S is installing components needed to play the audio or video on this page. Please try again later.
 
new file mode 100644
--- /dev/null
+++ b/python/l10n/fluent_migrations/bug_1695707_drm_panel_message.py
@@ -0,0 +1,29 @@
+# Any copyright is dedicated to the Public Domain.
+# http://creativecommons.org/publicdomain/zero/1.0/
+
+from __future__ import absolute_import
+import fluent.syntax.ast as FTL
+from fluent.migrate.helpers import transforms_from
+from fluent.migrate import COPY, CONCAT, REPLACE
+from fluent.migrate.helpers import TERM_REFERENCE
+
+
+def migrate(ctx):
+    """Bug 1695707 - Migrate the DRM panel message to Fluent, part {index}"""
+    ctx.add_transforms(
+        "browser/browser/browser.ftl",
+        "browser/browser/browser.ftl",
+        [
+            FTL.Message(
+                id=FTL.Identifier("eme-notifications-drm-content-playing"),
+                value=REPLACE(
+                    "browser/chrome/browser/browser.properties",
+                    "emeNotifications.drmContentPlaying.message2",
+                    {
+                        "%1$S": TERM_REFERENCE("brand-short-name"),
+                    },
+                    normalize_printf=True,
+                ),
+            ),
+        ],
+    )