⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 271229 in webkit


Ignore:
Timestamp:
Jan 7, 2021, 12:31:21 AM (6 years ago)
Author:
youenn@apple.com
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):

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r271228 r271229  
     12021-01-07  Youenn Fablet  <youenn@apple.com>
     2
     3        WKWebView should expose navigator.mediaDevices when content is loaded from app bundle
     4        https://bugs.webkit.org/show_bug.cgi?id=220184
     5        <rdar://problem/72792032>
     6
     7        Reviewed by Eric Carlson.
     8
     9        In case of non HTTP or HTTPS origins, getUserMedia was always denied.
     10        This patch updates the code by allowing getUserMedia prompts for other protocols.
     11        In that case, the user is presented the prompt with the application name since the origin domain does not mean anything.
     12        Manually tested.
     13
     14        * UIProcess/Cocoa/MediaPermissionUtilities.mm:
     15        (WebKit::alertMessageText):
     16
    1172021-01-07  Jiewen Tan  <jiewen_tan@apple.com>
    218
  • trunk/Source/WebKit/UIProcess/Cocoa/MediaPermissionUtilities.mm

    r271031 r271229  
    3737#import <wtf/SoftLinking.h>
    3838#import <wtf/URLHelpers.h>
     39#import <wtf/spi/cf/CFBundleSPI.h>
    3940#import <wtf/spi/darwin/SandboxSPI.h>
    4041
     
    119120static NSString *alertMessageText(MediaPermissionReason reason, OptionSet<MediaPermissionType> types, const WebCore::SecurityOrigin& origin)
    120121{
    121     if (origin.protocol() != "http" && origin.protocol() != "https")
    122         return nil;
     122    NSString *visibleOrigin;
     123    if (origin.protocol() != "http" && origin.protocol() != "https") {
     124        NSBundle *appBundle = [NSBundle mainBundle];
     125        NSString *displayName = appBundle.infoDictionary[(__bridge NSString *)_kCFBundleDisplayNameKey];
     126        NSString *readableName = appBundle.infoDictionary[(__bridge NSString *)kCFBundleNameKey];
     127        visibleOrigin = displayName ?: readableName;
     128    } else
     129        visibleOrigin = visibleDomain(origin.host());
    123130
    124131    switch (reason) {
    125132    case MediaPermissionReason::UserMedia:
    126133        if (types.contains(MediaPermissionType::Audio) && types.contains(MediaPermissionType::Video))
    127             return [NSString stringWithFormat:WEB_UI_NSSTRING(@"Allow “%@” to use your camera and microphone?", @"Message for user media prompt"), visibleDomain(origin.host())];
     134            return [NSString stringWithFormat:WEB_UI_NSSTRING(@"Allow “%@” to use your camera and microphone?", @"Message for user media prompt"), visibleOrigin];
    128135        if (types.contains(MediaPermissionType::Audio))
    129             return [NSString stringWithFormat:WEB_UI_NSSTRING(@"Allow “%@” to use your microphone?", @"Message for user microphone access prompt"), visibleDomain(origin.host())];
     136            return [NSString stringWithFormat:WEB_UI_NSSTRING(@"Allow “%@” to use your microphone?", @"Message for user microphone access prompt"), visibleOrigin];
    130137        if (types.contains(MediaPermissionType::Video))
    131             return [NSString stringWithFormat:WEB_UI_NSSTRING(@"Allow “%@” to use your camera?", @"Message for user camera access prompt"), visibleDomain(origin.host())];
     138            return [NSString stringWithFormat:WEB_UI_NSSTRING(@"Allow “%@” to use your camera?", @"Message for user camera access prompt"), visibleOrigin];
    132139        return nil;
    133140    case MediaPermissionReason::SpeechRecognition:
Note: See TracChangeset for help on using the changeset viewer.