Title: [271229] trunk/Source/WebKit
Revision
271229
Author
[email protected]
Date
2021-01-07 00:31:21 -0800 (Thu, 07 Jan 2021)

Log Message

WKWebView should expose navigator.mediaDevices when content is loaded from app bundle
https://bugs.webkit.org/show_bug.cgi?id=220184
<rdar://problem/72792032>

Reviewed by Eric Carlson.

In case of non HTTP or HTTPS origins, getUserMedia was always denied.
This patch updates the code by allowing getUserMedia prompts for other protocols.
In that case, the user is presented the prompt with the application name since the origin domain does not mean anything.
Manually tested.

* UIProcess/Cocoa/MediaPermissionUtilities.mm:
(WebKit::alertMessageText):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (271228 => 271229)


--- trunk/Source/WebKit/ChangeLog	2021-01-07 08:16:56 UTC (rev 271228)
+++ trunk/Source/WebKit/ChangeLog	2021-01-07 08:31:21 UTC (rev 271229)
@@ -1,3 +1,19 @@
+2021-01-07  Youenn Fablet  <[email protected]>
+
+        WKWebView should expose navigator.mediaDevices when content is loaded from app bundle
+        https://bugs.webkit.org/show_bug.cgi?id=220184
+        <rdar://problem/72792032>
+
+        Reviewed by Eric Carlson.
+
+        In case of non HTTP or HTTPS origins, getUserMedia was always denied.
+        This patch updates the code by allowing getUserMedia prompts for other protocols.
+        In that case, the user is presented the prompt with the application name since the origin domain does not mean anything.
+        Manually tested.
+
+        * UIProcess/Cocoa/MediaPermissionUtilities.mm:
+        (WebKit::alertMessageText):
+
 2021-01-07  Jiewen Tan  <[email protected]>
 
         Unreviewed, a build fix after r271221

Modified: trunk/Source/WebKit/UIProcess/Cocoa/MediaPermissionUtilities.mm (271228 => 271229)


--- trunk/Source/WebKit/UIProcess/Cocoa/MediaPermissionUtilities.mm	2021-01-07 08:16:56 UTC (rev 271228)
+++ trunk/Source/WebKit/UIProcess/Cocoa/MediaPermissionUtilities.mm	2021-01-07 08:31:21 UTC (rev 271229)
@@ -36,6 +36,7 @@
 #import <wtf/BlockPtr.h>
 #import <wtf/SoftLinking.h>
 #import <wtf/URLHelpers.h>
+#import <wtf/spi/cf/CFBundleSPI.h>
 #import <wtf/spi/darwin/SandboxSPI.h>
 
 #import <pal/cocoa/AVFoundationSoftLink.h>
@@ -118,17 +119,23 @@
 
 static NSString *alertMessageText(MediaPermissionReason reason, OptionSet<MediaPermissionType> types, const WebCore::SecurityOrigin& origin)
 {
-    if (origin.protocol() != "http" && origin.protocol() != "https")
-        return nil;
+    NSString *visibleOrigin;
+    if (origin.protocol() != "http" && origin.protocol() != "https") {
+        NSBundle *appBundle = [NSBundle mainBundle];
+        NSString *displayName = appBundle.infoDictionary[(__bridge NSString *)_kCFBundleDisplayNameKey];
+        NSString *readableName = appBundle.infoDictionary[(__bridge NSString *)kCFBundleNameKey];
+        visibleOrigin = displayName ?: readableName;
+    } else
+        visibleOrigin = visibleDomain(origin.host());
 
     switch (reason) {
     case MediaPermissionReason::UserMedia:
         if (types.contains(MediaPermissionType::Audio) && types.contains(MediaPermissionType::Video))
-            return [NSString stringWithFormat:WEB_UI_NSSTRING(@"Allow “%@” to use your camera and microphone?", @"Message for user media prompt"), visibleDomain(origin.host())];
+            return [NSString stringWithFormat:WEB_UI_NSSTRING(@"Allow “%@” to use your camera and microphone?", @"Message for user media prompt"), visibleOrigin];
         if (types.contains(MediaPermissionType::Audio))
-            return [NSString stringWithFormat:WEB_UI_NSSTRING(@"Allow “%@” to use your microphone?", @"Message for user microphone access prompt"), visibleDomain(origin.host())];
+            return [NSString stringWithFormat:WEB_UI_NSSTRING(@"Allow “%@” to use your microphone?", @"Message for user microphone access prompt"), visibleOrigin];
         if (types.contains(MediaPermissionType::Video))
-            return [NSString stringWithFormat:WEB_UI_NSSTRING(@"Allow “%@” to use your camera?", @"Message for user camera access prompt"), visibleDomain(origin.host())];
+            return [NSString stringWithFormat:WEB_UI_NSSTRING(@"Allow “%@” to use your camera?", @"Message for user camera access prompt"), visibleOrigin];
         return nil;
     case MediaPermissionReason::SpeechRecognition:
         return [NSString stringWithFormat:WEB_UI_NSSTRING(@"Allow “%@” to capture your audio and use it for speech recognition?", @"Message for spechrecognition prompt"), visibleDomain(origin.host())];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to