From e33311d3f7186160a64bf77c7380a30bf4511862 Mon Sep 17 00:00:00 2001 From: Paolo Amadini Date: Mon, 16 Jan 2017 14:31:23 +0100 Subject: [PATCH] Bug 1319112 - Adjust strings for the WebRTC permission notifications. r=florian MozReview-Commit-ID: 98jRli5Cqxy --HG-- extra : rebase_source : b3dc18f98c2749c75ccac910693033993e267e2f --- .../en-US/chrome/browser/browser.properties | 28 ++++++++++++------- browser/modules/webrtcUI.jsm | 26 +++++++++++++---- 2 files changed, 39 insertions(+), 15 deletions(-) diff --git a/browser/locales/en-US/chrome/browser/browser.properties b/browser/locales/en-US/chrome/browser/browser.properties index cfa760d51a3f..cf03cb608c27 100644 --- a/browser/locales/en-US/chrome/browser/browser.properties +++ b/browser/locales/en-US/chrome/browser/browser.properties @@ -476,18 +476,22 @@ social.error.closeSidebar.accesskey=C # LOCALIZATION NOTE: %1$S is the label for the toolbar button, %2$S is the associated badge numbering that the social provider may provide. social.aria.toolbarButtonBadgeText=%1$S (%2$S) -# LOCALIZATION NOTE (getUserMedia.shareCamera2.message, getUserMedia.shareMicrophone2.message, -# getUserMedia.shareScreen2.message, getUserMedia.shareCameraAndMicrophone2.message, -# getUserMedia.shareScreenAndMicrophone2.message, getUserMedia.shareCameraAndAudioCapture2.message, -# getUserMedia.shareAudioCapture2.message, getUserMedia.shareScreenAndAudioCapture2.message): -# %S is the website origin (e.g. www.mozilla.org) +# LOCALIZATION NOTE (getUserMedia.shareCamera2.message, +# getUserMedia.shareMicrophone2.message, +# getUserMedia.shareScreen3.message, +# getUserMedia.shareCameraAndMicrophone2.message, +# getUserMedia.shareCameraAndAudioCapture2.message, +# getUserMedia.shareScreenAndMicrophone3.message, +# getUserMedia.shareScreenAndAudioCapture3.message, +# getUserMedia.shareAudioCapture2.message): +# %S is the website origin (e.g. www.mozilla.org) getUserMedia.shareCamera2.message = Will you allow %S to use your camera? getUserMedia.shareMicrophone2.message = Will you allow %S to use your microphone? -getUserMedia.shareScreen2.message = Will you allow %S to see your screen or application window? +getUserMedia.shareScreen3.message = Will you allow %S to see your screen? getUserMedia.shareCameraAndMicrophone2.message = Will you allow %S to use your camera and microphone? getUserMedia.shareCameraAndAudioCapture2.message = Will you allow %S to use your camera and listen to this tab’s audio? -getUserMedia.shareScreenAndMicrophone2.message = Will you allow %S to use your microphone and see your screen or application window? -getUserMedia.shareScreenAndAudioCapture2.message = Will you allow %S to listen to this tab’s audio and see your screen or application window? +getUserMedia.shareScreenAndMicrophone3.message = Will you allow %S to use your microphone and see your screen? +getUserMedia.shareScreenAndAudioCapture3.message = Will you allow %S to listen to this tab’s audio and see your screen? getUserMedia.shareAudioCapture2.message = Will you allow %S to listen to this tab’s audio? # LOCALIZATION NOTE (getUserMedia.shareScreenWarning.message): NB: inserted via innerHTML, so please don't use <, > or & in this string. # %S will be the 'learn more' link @@ -518,16 +522,20 @@ getUserMedia.shareMonitor.label = Screen %S # Replacement for #1 is the name of the application. # Replacement for #2 is the number of windows currently displayed by the application. getUserMedia.shareApplicationWindowCount.label=#1 (#2 window);#1 (#2 windows) +# LOCALIZATION NOTE (getUserMedia.allow.label, +# getUserMedia.dontAllow.label): +# These two buttons are the possible answers to the various prompts in the +# "getUserMedia.share{device}.message" strings. getUserMedia.allow.label = Allow getUserMedia.allow.accesskey = A getUserMedia.dontAllow.label = Don’t Allow getUserMedia.dontAllow.accesskey = D getUserMedia.remember=Remember this decision -# LOCALIZATION NOTE (ggetUserMedia.reasonForNoPermanentAllow.screen, +# LOCALIZATION NOTE (getUserMedia.reasonForNoPermanentAllow.screen2, # getUserMedia.reasonForNoPermanentAllow.audio, # getUserMedia.reasonForNoPermanentAllow.insecure): # %S is brandShortName -getUserMedia.reasonForNoPermanentAllow.screen=%S can not allow permanent access to your screen or application without asking which one to share. +getUserMedia.reasonForNoPermanentAllow.screen2=%S can not allow permanent access to your screen without asking which one to share. getUserMedia.reasonForNoPermanentAllow.audio=%S can not allow permanent access to your tab’s audio without asking which tab to share. getUserMedia.reasonForNoPermanentAllow.insecure=Your connection to this site is not secure. To protect you, %S will only allow access for this session. diff --git a/browser/modules/webrtcUI.jsm b/browser/modules/webrtcUI.jsm index 6b161d5a9bfa..fd86a41f8016 100644 --- a/browser/modules/webrtcUI.jsm +++ b/browser/modules/webrtcUI.jsm @@ -333,14 +333,30 @@ function getHost(uri, href) { } function prompt(aBrowser, aRequest) { - let {audioDevices: audioDevices, videoDevices: videoDevices, - sharingScreen: sharingScreen, sharingAudio: sharingAudio, - requestTypes: requestTypes} = aRequest; + let { audioDevices, videoDevices, sharingScreen, sharingAudio, + requestTypes } = aRequest; let uri = Services.io.newURI(aRequest.documentURI); let host = getHost(uri); let chromeDoc = aBrowser.ownerDocument; let stringBundle = chromeDoc.defaultView.gNavigatorBundle; - let stringId = "getUserMedia.share" + requestTypes.join("And") + "2.message"; + + // Mind the order, because for simplicity we're iterating over the list using + // "includes()". This allows the rotation of string identifiers. We list the + // full identifiers here so they can be cross-referenced more easily. + let joinedRequestTypes = requestTypes.join("And"); + let stringId = [ + // Individual request types first. + "getUserMedia.shareCamera2.message", + "getUserMedia.shareMicrophone2.message", + "getUserMedia.shareScreen3.message", + "getUserMedia.shareAudioCapture2.message", + // Combinations of the above request types last. + "getUserMedia.shareCameraAndMicrophone2.message", + "getUserMedia.shareCameraAndAudioCapture2.message", + "getUserMedia.shareScreenAndMicrophone3.message", + "getUserMedia.shareScreenAndAudioCapture3.message", + ].find(id => id.includes(joinedRequestTypes)); + let message = stringBundle.getFormattedString(stringId, [host]); let notification; // Used by action callbacks. @@ -377,7 +393,7 @@ function prompt(aBrowser, aRequest) { // share without prompting). let reasonForNoPermanentAllow = ""; if (sharingScreen) { - reasonForNoPermanentAllow = "getUserMedia.reasonForNoPermanentAllow.screen"; + reasonForNoPermanentAllow = "getUserMedia.reasonForNoPermanentAllow.screen2"; } else if (sharingAudio) { reasonForNoPermanentAllow = "getUserMedia.reasonForNoPermanentAllow.audio"; } else if (!aRequest.secure) {