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

Changeset 215619 in webkit


Ignore:
Timestamp:
Apr 21, 2017, 11:32:58 AM (9 years ago)
Author:
commit-queue@webkit.org
Message:

-[WKUIDelegatePrivate _webView:requestUserMediaAuthorizationForMicrophone:camera:url:mainFrameURL:decisionHandler:]
decision handler should only have one parameter.
https://bugs.webkit.org/show_bug.cgi?id=171081

Patch by Andrew Gold <agold@apple.com> on 2017-04-21
Reviewed by Tim Horton.

Because user media authorization is all or nothing, we should not have separate booleans
to indicate authorization. Additionally, rather than passing two separate booleans to the
UIDelegate, we now pass an NS_OPTIONS parameter.

  • UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
  • UIProcess/API/Cocoa/WKWebViewPrivate.h: Added _WKCaptureDevice NS_OPTIONS.
  • UIProcess/Cocoa/UIDelegate.mm:
  • UIProcess/Cocoa/UIDelegate.mm:

(WebKit::UIDelegate::setDelegate): Uses new WKUIDelegatePrivate method.
(WebKit::UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest): Ditto.

Location:
trunk/Source/WebKit2
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r215611 r215619  
     12017-04-21  Andrew Gold  <agold@apple.com>
     2
     3        -[WKUIDelegatePrivate _webView:requestUserMediaAuthorizationForMicrophone:camera:url:mainFrameURL:decisionHandler:]
     4        decision handler should only have one parameter.
     5        https://bugs.webkit.org/show_bug.cgi?id=171081
     6
     7        Reviewed by Tim Horton.
     8
     9        Because user media authorization is all or nothing, we should not have separate booleans
     10        to indicate authorization. Additionally, rather than passing two separate booleans to the
     11        UIDelegate, we now pass an NS_OPTIONS parameter.
     12
     13        * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
     14        * UIProcess/API/Cocoa/WKWebViewPrivate.h: Added _WKCaptureDevice NS_OPTIONS.
     15
     16        * UIProcess/Cocoa/UIDelegate.mm:
     17        * UIProcess/Cocoa/UIDelegate.mm:
     18        (WebKit::UIDelegate::setDelegate): Uses new WKUIDelegatePrivate method.
     19        (WebKit::UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest): Ditto.
     20
    1212017-04-21  Konstantin Tokarev  <annulen@yandex.ru>
    222
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h

    r215545 r215619  
    6565- (void)_webView:(WKWebView *)webView imageOrMediaDocumentSizeChanged:(CGSize)size WK_API_AVAILABLE(macosx(10.12), ios(10.0));
    6666- (NSDictionary *)_dataDetectionContextForWebView:(WKWebView *)webView WK_API_AVAILABLE(macosx(10.12), ios(10.0));
    67 - (void)_webView:(WKWebView *)webView requestUserMediaAuthorizationForMicrophone:(BOOL)microphone camera:(BOOL)camera url:(NSURL *)url mainFrameURL:(NSURL *)mainFrameURL decisionHandler:(void (^)(BOOL authorizedMicrophone, BOOL authorizedCamera))decisionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
     67- (void)_webView:(WKWebView *)webView requestUserMediaAuthorizationForDevices:(_WKCaptureDevices)devices url:(NSURL *)url mainFrameURL:(NSURL *)mainFrameURL decisionHandler:(void (^)(BOOL authorized))decisionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
    6868- (void)_webView:(WKWebView *)webView checkUserMediaPermissionForURL:(NSURL *)url mainFrameURL:(NSURL *)mainFrameURL frameIdentifier:(NSUInteger)frameIdentifier decisionHandler:(void (^)(NSString *salt, BOOL authorized))decisionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
    6969- (void)_webView:(WKWebView *)webView mediaCaptureStateDidChange:(_WKMediaCaptureState)state WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h

    r215587 r215619  
    5454} WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
    5555
     56typedef NS_OPTIONS(NSUInteger, _WKCaptureDevices) {
     57    _WKCaptureDeviceMicrophone = 1 << 0,
     58    _WKCaptureDeviceCamera = 1 << 1,
     59} WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
     60
    5661#if !TARGET_OS_IPHONE
    5762
  • trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h

    r215545 r215619  
    137137        bool webViewDidEnterFullscreen : 1;
    138138        bool webViewDidExitFullscreen : 1;
    139         bool webViewRequestUserMediaAuthorizationForMicrophoneCameraURLMainFrameURLDecisionHandler : 1;
     139        bool webViewRequestUserMediaAuthorizationForDevicesURLMainFrameURLDecisionHandler : 1;
    140140        bool webViewCheckUserMediaPermissionForURLMainFrameURLFrameIdentifierDecisionHandler : 1;
    141141        bool webViewMediaCaptureStateDidChange : 1;
  • trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm

    r215598 r215619  
    116116    m_delegateMethods.webViewActionsForElementDefaultActions = [delegate respondsToSelector:@selector(_webView:actionsForElement:defaultActions:)];
    117117    m_delegateMethods.webViewDidNotHandleTapAsClickAtPoint = [delegate respondsToSelector:@selector(_webView:didNotHandleTapAsClickAtPoint:)];
    118     m_delegateMethods.webViewRequestUserMediaAuthorizationForMicrophoneCameraURLMainFrameURLDecisionHandler = [delegate respondsToSelector:@selector(_webView:requestUserMediaAuthorizationForMicrophone:camera:url:mainFrameURL:decisionHandler:)];
     118    m_delegateMethods.webViewRequestUserMediaAuthorizationForDevicesURLMainFrameURLDecisionHandler = [delegate respondsToSelector:@selector(_webView:requestUserMediaAuthorizationForDevices:url:mainFrameURL:decisionHandler:)];
    119119    m_delegateMethods.webViewCheckUserMediaPermissionForURLMainFrameURLFrameIdentifierDecisionHandler = [delegate respondsToSelector:@selector(_webView:checkUserMediaPermissionForURL:mainFrameURL:frameIdentifier:decisionHandler:)];
    120120    m_delegateMethods.webViewMediaCaptureStateDidChange = [delegate respondsToSelector:@selector(_webView:mediaCaptureStateDidChange:)];
     
    378378{
    379379    auto delegate = m_uiDelegate.m_delegate.get();
    380     if (!delegate || !m_uiDelegate.m_delegateMethods.webViewRequestUserMediaAuthorizationForMicrophoneCameraURLMainFrameURLDecisionHandler) {
     380    if (!delegate || !m_uiDelegate.m_delegateMethods.webViewRequestUserMediaAuthorizationForDevicesURLMainFrameURLDecisionHandler) {
    381381        request.deny(UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::UserMediaDisabled);
    382382        return true;
     
    396396        WebCore::URL mainFrameURL(WebCore::URL(), mainFrame->url());
    397397
    398         [(id <WKUIDelegatePrivate>)delegate _webView:webView requestUserMediaAuthorizationForMicrophone:requiresAudio camera:requiresVideo url:requestFrameURL mainFrameURL:mainFrameURL decisionHandler:^(BOOL authorizedMicrophone, BOOL authorizedCamera) {
    399             if ((requiresAudio != authorizedMicrophone) || (requiresVideo != authorizedCamera)) {
     398        _WKCaptureDevices devices = 0;
     399        if (requiresAudio)
     400            devices |= _WKCaptureDeviceMicrophone;
     401        if (requiresVideo)
     402            devices |= _WKCaptureDeviceCamera;
     403
     404        [(id <WKUIDelegatePrivate>)delegate _webView:webView requestUserMediaAuthorizationForDevices:devices url:requestFrameURL mainFrameURL:mainFrameURL decisionHandler:^(BOOL authorized) {
     405            if (!authorized) {
    400406                request.deny(UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::PermissionDenied);
    401407                return;
Note: See TracChangeset for help on using the changeset viewer.