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

Changeset 267414 in webkit


Ignore:
Timestamp:
Sep 22, 2020, 9:32:11 AM (6 years ago)
Author:
youenn@apple.com
Message:

Implement a default prompt for getUserMedia
https://bugs.webkit.org/show_bug.cgi?id=216821

Reviewed by Eric Carlson.

Source/WebCore:

Manually tested by running Minibrowser.

  • en.lproj/Localizable.strings:

Source/WebKit:

Move preferences used by WebRTC develop menu to internals.
This allows having them in MiniBrowser.

Enable video capture in UIProcess by default for non Safari applications.
Add support for a getUserMedia prompt, very similar to iOS current prompt.
Use the prompt in case the application does not implement any of the two delegates.

  • Shared/WebPreferences.yaml:
  • Shared/WebPreferencesDefaultValues.cpp:

(WebKit::defaultCaptureVideoInUIProcessEnabled):

  • Shared/WebPreferencesDefaultValues.h:
  • Shared/WebPreferencesExperimental.yaml:
  • Shared/WebPreferencesInternal.yaml:
  • UIProcess/Cocoa/UIDelegate.h:
  • UIProcess/Cocoa/UIDelegate.mm:

(WebKit::UIDelegate::setDelegate):
(WebKit::requestUserMediaAuthorizationForFrame):
(WebKit::UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest):

  • UIProcess/Cocoa/WKUserMediaCaptureAccessAlert.h: Added.
  • UIProcess/Cocoa/WKUserMediaCaptureAccessAlert.mm: Added.

(WebKit::visibleDomain):
(WebKit::alertMessageText):
(WebKit::presentUserMediaCaptureAccessAlert):

  • WebKit.xcodeproj/project.pbxproj:

Tools:

Remove getUserMedia delegate implementations to use WebKit built-in prompt.
Add camera and microphone entitlements to allow using real cameras and microphones.
Keep using mock devices as the default.

  • MiniBrowser/MiniBrowser.entitlements:
  • MiniBrowser/mac/WK2BrowserWindowController.m:

(-[WK2BrowserWindowController _webView:requestMediaCaptureAuthorization:decisionHandler:]): Deleted.
(-[WK2BrowserWindowController _webView:includeSensitiveMediaDeviceDetails:]): Deleted.

Location:
trunk
Files:
2 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r267413 r267414  
     12020-09-22  Youenn Fablet  <youenn@apple.com>
     2
     3        Implement a default prompt for getUserMedia
     4        https://bugs.webkit.org/show_bug.cgi?id=216821
     5
     6        Reviewed by Eric Carlson.
     7
     8        Manually tested by running Minibrowser.
     9
     10        * en.lproj/Localizable.strings:
     11
    1122020-09-22  Chris Dumez  <cdumez@apple.com>
    213
  • trunk/Source/WebCore/en.lproj/Localizable.strings

    r266342 r267414  
    125125"Allow “%@” to use cookies and website data while browsing “%@”?" = "Allow “%@” to use cookies and website data while browsing “%@”?";
    126126
     127/* Message for user media prompt */
     128"Allow “%@” to use your camera and microphone?" = "Allow “%@” to use your camera and microphone?";
     129
     130/* Message for user camera access prompt */
     131"Allow “%@” to use your camera?" = "Allow “%@” to use your camera?";
     132
     133/* Message for user microphone access prompt */
     134"Allow “%@” to use your microphone?" = "Allow “%@” to use your microphone?";
     135
     136/* Allow button title in user media prompt */
     137"Allow (usermedia)" = "Allow";
     138
     139/* Disallow button title in user media prompt */
     140"Don’t Allow (usermedia)" = "Don’t Allow";
     141
    127142/* WKErrorUnknown description */
    128143"An unknown error occurred" = "An unknown error occurred";
  • trunk/Source/WebKit/ChangeLog

    r267412 r267414  
     12020-09-22  Youenn Fablet  <youenn@apple.com>
     2
     3        Implement a default prompt for getUserMedia
     4        https://bugs.webkit.org/show_bug.cgi?id=216821
     5
     6        Reviewed by Eric Carlson.
     7
     8        Move preferences used by WebRTC develop menu to internals.
     9        This allows having them in MiniBrowser.
     10
     11        Enable video capture in UIProcess by default for non Safari applications.
     12        Add support for a getUserMedia prompt, very similar to iOS current prompt.
     13        Use the prompt in case the application does not implement any of the two delegates.
     14
     15        * Shared/WebPreferences.yaml:
     16        * Shared/WebPreferencesDefaultValues.cpp:
     17        (WebKit::defaultCaptureVideoInUIProcessEnabled):
     18        * Shared/WebPreferencesDefaultValues.h:
     19        * Shared/WebPreferencesExperimental.yaml:
     20        * Shared/WebPreferencesInternal.yaml:
     21        * UIProcess/Cocoa/UIDelegate.h:
     22        * UIProcess/Cocoa/UIDelegate.mm:
     23        (WebKit::UIDelegate::setDelegate):
     24        (WebKit::requestUserMediaAuthorizationForFrame):
     25        (WebKit::UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest):
     26        * UIProcess/Cocoa/WKUserMediaCaptureAccessAlert.h: Added.
     27        * UIProcess/Cocoa/WKUserMediaCaptureAccessAlert.mm: Added.
     28        (WebKit::visibleDomain):
     29        (WebKit::alertMessageText):
     30        (WebKit::presentUserMediaCaptureAccessAlert):
     31        * WebKit.xcodeproj/project.pbxproj:
     32
    1332020-09-22  Brady Eidson  <beidson@apple.com>
    234
  • trunk/Source/WebKit/Shared/WebPreferences.yaml

    r267385 r267414  
    995995  webcoreBinding: RuntimeEnabledFeatures
    996996  condition: ENABLE(ACCESSIBILITY_ISOLATED_TREE)
    997 
    998 # Deprecated
    999 
    1000 ICECandidateFilteringEnabled:
    1001   type: bool
    1002   defaultValue: true
    1003 
    1004 MockCaptureDevicesEnabled:
    1005   type: bool
    1006   defaultValue: DEFAULT_MOCK_CAPTURE_DEVICES_ENABLED
    1007   condition: ENABLE(MEDIA_STREAM)
    1008 
    1009 MediaCaptureRequiresSecureConnection:
    1010   type: bool
    1011   defaultValue: true
    1012   condition: ENABLE(MEDIA_STREAM)
  • trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.cpp

    r267400 r267414  
    170170}
    171171
     172bool defaultCaptureVideoInUIProcessEnabled()
     173{
     174#if PLATFORM(MAC)
     175    return !MacApplication::isSafari();
     176#endif
     177
     178    return false;
     179}
     180
    172181#endif // ENABLE(MEDIA_STREAM)
    173182
  • trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h

    r267225 r267414  
    345345bool defaultCaptureAudioInUIProcessEnabled();
    346346bool defaultCaptureVideoInGPUProcessEnabled();
     347bool defaultCaptureVideoInUIProcessEnabled();
    347348#endif
    348349
  • trunk/Source/WebKit/Shared/WebPreferencesExperimental.yaml

    r267403 r267414  
    394394  webcoreName: genericCueAPIEnabled
    395395
    396 CaptureVideoInUIProcessEnabled:
    397   type: bool
    398   defaultValue: false
    399   humanReadableName: "Capture video in UI Process"
    400   humanReadableDescription: "Enable video capture in UI Process"
    401   webcoreBinding: none
    402   condition: ENABLE(MEDIA_STREAM)
    403 
    404396AspectRatioOfImgFromWidthAndHeightEnabled:
    405397  type: bool
  • trunk/Source/WebKit/Shared/WebPreferencesInternal.yaml

    r267403 r267414  
    107107  humanReadableDescription: "Stop plugins smaller than a certain threshold from loading."
    108108
     109CaptureAudioInUIProcessEnabled:
     110  type: bool
     111  defaultValue: defaultCaptureAudioInUIProcessEnabled()
     112  humanReadableName: "Capture audio in UI Process"
     113  humanReadableDescription: "Enable audio capture in UI Process"
     114  webcoreBinding: none
     115  condition: ENABLE(MEDIA_STREAM)
     116
     117CaptureAudioInGPUProcessEnabled:
     118  type: bool
     119  defaultValue: defaultCaptureAudioInGPUProcessEnabled()
     120  humanReadableName: "Use GPU Process to capture audio"
     121  humanReadableDescription: "Enable audio capture in GPU Process"
     122  webcoreBinding: none
     123  condition: ENABLE(MEDIA_STREAM)
     124
     125CaptureVideoInUIProcessEnabled:
     126  type: bool
     127  defaultValue: defaultCaptureVideoInUIProcessEnabled()
     128  humanReadableName: "Capture video in UI Process"
     129  humanReadableDescription: "Enable video capture in UI Process"
     130  webcoreBinding: none
     131  condition: ENABLE(MEDIA_STREAM)
     132
    109133CaptureVideoInGPUProcessEnabled:
    110134  type: bool
     
    300324  condition: ENABLE(LAYOUT_FORMATTING_CONTEXT)
    301325
    302 CaptureAudioInUIProcessEnabled:
    303   type: bool
    304   defaultValue: defaultCaptureAudioInUIProcessEnabled()
    305   humanReadableName: "Capture audio in UI Process"
    306   humanReadableDescription: "Enable audio capture in UI Process"
    307   webcoreBinding: none
    308   condition: ENABLE(MEDIA_STREAM)
    309 
    310 CaptureAudioInGPUProcessEnabled:
    311   type: bool
    312   defaultValue: defaultCaptureAudioInGPUProcessEnabled()
    313   humanReadableName: "Use GPU Process to capture audio"
    314   humanReadableDescription: "Enable audio capture in GPU Process"
    315   webcoreBinding: none
    316   condition: ENABLE(MEDIA_STREAM)
    317 
    318326RenderCanvasInGPUProcessEnabled:
    319327  type: bool
     
    408416  humanReadableName: "Live Ranges in Selection"
    409417  humanReadableDescription: "Live range behavior for ranges in the Selection object"
    410   category: internal
     418
     419ICECandidateFilteringEnabled:
     420  type: bool
     421  defaultValue: true
     422  humanReadableName: "Enable ICE Candidate Filtering"
     423  humanReadableDescription: "Enable ICE Candidate Filtering"
     424
     425MockCaptureDevicesEnabled:
     426  type: bool
     427  defaultValue: DEFAULT_MOCK_CAPTURE_DEVICES_ENABLED
     428  condition: ENABLE(MEDIA_STREAM)
     429  humanReadableName: "Enable Mock Capture Devices"
     430  humanReadableDescription: "Enable Mock Capture Devices"
     431
     432MediaCaptureRequiresSecureConnection:
     433  type: bool
     434  defaultValue: true
     435  condition: ENABLE(MEDIA_STREAM)
     436  humanReadableName: "Limit Media Capture to Secure Sites"
     437  humanReadableDescription: "Limit Media Capture to Secure Sites"
  • trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h

    r266890 r267414  
    216216        bool webViewDidEnterFullscreen : 1;
    217217        bool webViewDidExitFullscreen : 1;
    218         bool webViewRequestMediaCaptureAuthorizationForFrameDecisionHandler : 1;
    219218        bool webViewIsMediaCaptureAuthorizedForFrameDecisionHandler : 1;
    220219        bool webViewMediaCaptureStateDidChange : 1;
  • trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm

    r266890 r267414  
    4545#import "WKStorageAccessAlert.h"
    4646#import "WKUIDelegatePrivate.h"
     47#import "WKUserMediaCaptureAccessAlert.h"
    4748#import "WKWebViewConfigurationInternal.h"
    4849#import "WKWebViewInternal.h"
     
    154155    m_delegateMethods.presentingViewControllerForWebView = [delegate respondsToSelector:@selector(_presentingViewControllerForWebView:)];
    155156#endif
    156     m_delegateMethods.webViewRequestMediaCaptureAuthorizationForFrameDecisionHandler = [delegate respondsToSelector:@selector(_webView:requestUserMediaAuthorizationForDevices:url:mainFrameURL:decisionHandler:)] || [delegate respondsToSelector:@selector(_webView:requestMediaCaptureAuthorization:decisionHandler:)];
    157157    m_delegateMethods.webViewIsMediaCaptureAuthorizedForFrameDecisionHandler = [delegate respondsToSelector:@selector(_webView:checkUserMediaPermissionForURL:mainFrameURL:frameIdentifier:decisionHandler:)] || [delegate respondsToSelector:@selector(_webView:includeSensitiveMediaDeviceDetails:)];
    158158
     
    922922    }
    923923
    924     const auto* mainFrame = frame.page()->mainFrame();
     924    bool respondsToRequestMediaCaptureAuthorization = [delegate respondsToSelector:@selector(_webView:requestMediaCaptureAuthorization:decisionHandler:)];
     925    bool respondsToRequestUserMediaAuthorizationForDevices = [delegate respondsToSelector:@selector(_webView:requestUserMediaAuthorizationForDevices:url:mainFrameURL:decisionHandler:)];
     926    if (!request.requiresDisplayCapture() && !respondsToRequestUserMediaAuthorizationForDevices && !respondsToRequestMediaCaptureAuthorization) {
     927        presentUserMediaCaptureAccessAlert(&webView, topLevelOrigin, devices, [decisionHandler = WTFMove(decisionHandler)](bool authorized) mutable {
     928            decisionHandler(authorized);
     929        });
     930        return;
     931    }
    925932
    926933    // FIXME: Provide a specific delegate for display capture.
    927     if (!request.requiresDisplayCapture() && [delegate respondsToSelector:@selector(_webView:requestMediaCaptureAuthorization:decisionHandler:)]) {
    928 
     934    if (!request.requiresDisplayCapture() && respondsToRequestMediaCaptureAuthorization) {
    929935        [delegate _webView:&webView requestMediaCaptureAuthorization:devices decisionHandler:decisionHandler.get()];
    930936        return;
     
    932938
    933939    URL requestFrameURL { frame.url() };
    934     URL mainFrameURL { mainFrame->url() };
     940    URL mainFrameURL { frame.page()->mainFrame()->url() };
    935941
    936942    [delegate _webView:&webView requestUserMediaAuthorizationForDevices:devices url:requestFrameURL mainFrameURL:mainFrameURL decisionHandler:decisionHandler.get()];
     
    942948#if ENABLE(MEDIA_STREAM)
    943949    auto delegate = m_uiDelegate.m_delegate.get();
    944     if (!delegate || !m_uiDelegate.m_delegateMethods.webViewRequestMediaCaptureAuthorizationForFrameDecisionHandler) {
     950    if (!delegate) {
    945951        request.deny(UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::UserMediaDisabled);
    946952        return;
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r267411 r267414  
    906906                413CCD5020DEBC740065A21A /* com.google.googletalkbrowserplugin.sb in Copy Plug-in Sandbox Profiles */ = {isa = PBXBuildFile; fileRef = 413CCD4F20DEBC2F0065A21A /* com.google.googletalkbrowserplugin.sb */; };
    907907                4143751C20EAEA2D00FAD06C /* cn.microdone.cmb.safari.sb in Copy Plug-in Sandbox Profiles */ = {isa = PBXBuildFile; fileRef = 4143751B20EAEA1E00FAD06C /* cn.microdone.cmb.safari.sb */; };
     908                4147DC692519EC3300214EE7 /* WKUserMediaCaptureAccessAlert.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4147DC672519E29D00214EE7 /* WKUserMediaCaptureAccessAlert.mm */; };
    908909                414DD37920BF43F5006959FB /* com.cisco.webex.plugin.gpc64.sb in Resources */ = {isa = PBXBuildFile; fileRef = 414DD37820BF43EA006959FB /* com.cisco.webex.plugin.gpc64.sb */; };
    909910                414DD37A20BF49A5006959FB /* com.cisco.webex.plugin.gpc64.sb in Copy Plug-in Sandbox Profiles */ = {isa = PBXBuildFile; fileRef = 414DD37820BF43EA006959FB /* com.cisco.webex.plugin.gpc64.sb */; };
     
    34193420                413CCD4F20DEBC2F0065A21A /* com.google.googletalkbrowserplugin.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = com.google.googletalkbrowserplugin.sb; sourceTree = "<group>"; };
    34203421                4143751B20EAEA1E00FAD06C /* cn.microdone.cmb.safari.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = cn.microdone.cmb.safari.sb; sourceTree = "<group>"; };
     3422                4147DC672519E29D00214EE7 /* WKUserMediaCaptureAccessAlert.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKUserMediaCaptureAccessAlert.mm; sourceTree = "<group>"; };
     3423                4147DC682519E29D00214EE7 /* WKUserMediaCaptureAccessAlert.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKUserMediaCaptureAccessAlert.h; sourceTree = "<group>"; };
    34213424                414DD37820BF43EA006959FB /* com.cisco.webex.plugin.gpc64.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = com.cisco.webex.plugin.gpc64.sb; sourceTree = "<group>"; };
    34223425                4150A5A023E06C910051264A /* GPUProcessSessionParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPUProcessSessionParameters.h; sourceTree = "<group>"; };
     
    64026405                                2DC6D9C118C44A610043BAD4 /* WKWebViewContentProviderRegistry.h */,
    64036406                                2DC6D9C218C44A610043BAD4 /* WKWebViewContentProviderRegistry.mm */,
     6407                                4147DC682519E29D00214EE7 /* WKUserMediaCaptureAccessAlert.h */,
     6408                                4147DC672519E29D00214EE7 /* WKUserMediaCaptureAccessAlert.mm */,
    64046409                                C1710CF224A7BD0300D7C112 /* XPCEventHandler.h */,
    64056410                        );
     
    1299112996                                2D11B7C12126A283006F8878 /* UnifiedSource57-mm.mm in Sources */,
    1299212997                                2D11B7C22126A283006F8878 /* UnifiedSource57.cpp in Sources */,
     12998                                4147DC692519EC3300214EE7 /* WKUserMediaCaptureAccessAlert.mm in Sources */,
    1299312999                                2D11B7C32126A283006F8878 /* UnifiedSource58-mm.mm in Sources */,
    1299413000                                2D11B7C42126A283006F8878 /* UnifiedSource58.cpp in Sources */,
  • trunk/Tools/ChangeLog

    r267411 r267414  
     12020-09-22  Youenn Fablet  <youenn@apple.com>
     2
     3        Implement a default prompt for getUserMedia
     4        https://bugs.webkit.org/show_bug.cgi?id=216821
     5
     6        Reviewed by Eric Carlson.
     7
     8        Remove getUserMedia delegate implementations to use WebKit built-in prompt.
     9        Add camera and microphone entitlements to allow using real cameras and microphones.
     10        Keep using mock devices as the default.
     11
     12        * MiniBrowser/MiniBrowser.entitlements:
     13        * MiniBrowser/mac/WK2BrowserWindowController.m:
     14        (-[WK2BrowserWindowController _webView:requestMediaCaptureAuthorization:decisionHandler:]): Deleted.
     15        (-[WK2BrowserWindowController _webView:includeSensitiveMediaDeviceDetails:]): Deleted.
     16
    1172020-09-22  Brian Burg  <bburg@apple.com>
    218
  • trunk/Tools/MiniBrowser/MiniBrowser.entitlements

    r259279 r267414  
    2323                <string>(allow mach-issue-extension (require-all (extension-class &quot;com.apple.webkit.extension.mach&quot;)))</string>
    2424        </array>
     25        <key>com.apple.security.device.camera</key>
     26        <true/>
     27        <key>com.apple.security.device.microphone</key>
     28        <true/>
    2529</dict>
    2630</plist>
  • trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m

    r265061 r267414  
    874874}
    875875
    876 - (void)_webView:(WKWebView *)webView requestMediaCaptureAuthorization: (_WKCaptureDevices)devices decisionHandler:(void (^)(BOOL authorized))decisionHandler
    877 {
    878     decisionHandler(true);
    879 }
    880 
    881 - (void)_webView:(WKWebView *)webView includeSensitiveMediaDeviceDetails:(void (^)(BOOL includeSensitiveDetails))decisionHandler
    882 {
    883     decisionHandler(false);
    884 }
    885 
    886876- (IBAction)saveAsPDF:(id)sender
    887877{
Note: See TracChangeset for help on using the changeset viewer.