Bug 1588640: Show OS Screen Recording helper prompt when user makes a selection. r=johannh,haik
authorJan-Ivar Bruaroey <jib@mozilla.com>
Wed, 16 Oct 2019 16:13:15 +0000
changeset 559255 503c19dcad61f4f0418c80880f8f05183abcd15e
parent 559254 4a248350fc01345a3120760b3ed9856800535632
child 559256 9de30d23836b70b0a85a2ffceafd513b02aa2f8d
push id12175
push userccoroiu@mozilla.com
push dateThu, 17 Oct 2019 19:29:09 +0000
treeherdermozilla-beta@d333b6ef1fd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh, haik
bugs1588640
milestone71.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 1588640: Show OS Screen Recording helper prompt when user makes a selection. r=johannh,haik Depends on D49217 Differential Revision: https://phabricator.services.mozilla.com/D49328
browser/modules/webrtcUI.jsm
--- a/browser/modules/webrtcUI.jsm
+++ b/browser/modules/webrtcUI.jsm
@@ -948,16 +948,33 @@ function prompt(aBrowser, aRequest) {
                 [brand, "<>"]
               );
             }
 
             let [pre, post] = string.split("<>");
             warning.textContent = pre;
             warning.appendChild(learnMore);
             warning.appendChild(chromeWin.document.createTextNode(post));
+
+            // On Catalina, we don't want to blow our chance to show the
+            // OS-level helper prompt to enable screen recording if the user
+            // intends to reject anyway. OTOH showing it when they click Allow
+            // is too late. A happy middle is to show it when the user makes a
+            // choice in the picker. This already happens implicitly if the
+            // user chooses "Entire desktop", as a side-effect of our preview,
+            // we just need to also do it if they choose "Firefox". These are
+            // the lone two options when permission is absent on Catalina.
+            // Ironically, these are the two sources marked "scary" from a
+            // web-sharing perspective, which is why this code resides here.
+            // A restart doesn't appear to be necessary in spite of OS wording.
+            let scrStatus = {};
+            OSPermissions.getScreenCapturePermissionState(scrStatus);
+            if (scrStatus.value == OSPermissions.PERMISSION_STATE_DENIED) {
+              OSPermissions.maybeRequestScreenCapturePermission();
+            }
           }
 
           let perms = Services.perms;
           let chromePrincipal = Services.scriptSecurityManager.getSystemPrincipal();
           perms.addFromPrincipal(
             chromePrincipal,
             "MediaManagerVideo",
             perms.ALLOW_ACTION,