- Revision
- 215619
- Author
- [email protected]
- Date
- 2017-04-21 11:32:58 -0700 (Fri, 21 Apr 2017)
Log 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 <[email protected]> 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.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (215618 => 215619)
--- trunk/Source/WebKit2/ChangeLog 2017-04-21 18:28:51 UTC (rev 215618)
+++ trunk/Source/WebKit2/ChangeLog 2017-04-21 18:32:58 UTC (rev 215619)
@@ -1,3 +1,23 @@
+2017-04-21 Andrew Gold <[email protected]>
+
+ -[WKUIDelegatePrivate _webView:requestUserMediaAuthorizationForMicrophone:camera:url:mainFrameURL:decisionHandler:]
+ decision handler should only have one parameter.
+ https://bugs.webkit.org/show_bug.cgi?id=171081
+
+ 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.
+
2017-04-21 Konstantin Tokarev <[email protected]>
Unreviewed, added missing file to PlatformMac.cmake
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h (215618 => 215619)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h 2017-04-21 18:28:51 UTC (rev 215618)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h 2017-04-21 18:32:58 UTC (rev 215619)
@@ -64,7 +64,7 @@
- (void)_webView:(WKWebView *)webView imageOrMediaDocumentSizeChanged:(CGSize)size WK_API_AVAILABLE(macosx(10.12), ios(10.0));
- (NSDictionary *)_dataDetectionContextForWebView:(WKWebView *)webView WK_API_AVAILABLE(macosx(10.12), ios(10.0));
-- (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));
+- (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));
- (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));
- (void)_webView:(WKWebView *)webView mediaCaptureStateDidChange:(_WKMediaCaptureState)state WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
- (WKDragDestinationAction)_webView:(WKWebView *)webView dragDestinationActionMaskForDraggingInfo:(id)draggingInfo WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (215618 => 215619)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h 2017-04-21 18:28:51 UTC (rev 215618)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h 2017-04-21 18:32:58 UTC (rev 215619)
@@ -53,6 +53,11 @@
_WKMediaCaptureDevicesMuted = 1 << 1,
} WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+typedef NS_OPTIONS(NSUInteger, _WKCaptureDevices) {
+ _WKCaptureDeviceMicrophone = 1 << 0,
+ _WKCaptureDeviceCamera = 1 << 1,
+} WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+
#if !TARGET_OS_IPHONE
typedef NS_ENUM(NSInteger, _WKImmediateActionType) {
Modified: trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h (215618 => 215619)
--- trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h 2017-04-21 18:28:51 UTC (rev 215618)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h 2017-04-21 18:32:58 UTC (rev 215619)
@@ -136,7 +136,7 @@
bool webViewFullscreenMayReturnToInline : 1;
bool webViewDidEnterFullscreen : 1;
bool webViewDidExitFullscreen : 1;
- bool webViewRequestUserMediaAuthorizationForMicrophoneCameraURLMainFrameURLDecisionHandler : 1;
+ bool webViewRequestUserMediaAuthorizationForDevicesURLMainFrameURLDecisionHandler : 1;
bool webViewCheckUserMediaPermissionForURLMainFrameURLFrameIdentifierDecisionHandler : 1;
bool webViewMediaCaptureStateDidChange : 1;
#if PLATFORM(IOS)
Modified: trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm (215618 => 215619)
--- trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm 2017-04-21 18:28:51 UTC (rev 215618)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm 2017-04-21 18:32:58 UTC (rev 215619)
@@ -115,7 +115,7 @@
#endif
m_delegateMethods.webViewActionsForElementDefaultActions = [delegate respondsToSelector:@selector(_webView:actionsForElement:defaultActions:)];
m_delegateMethods.webViewDidNotHandleTapAsClickAtPoint = [delegate respondsToSelector:@selector(_webView:didNotHandleTapAsClickAtPoint:)];
- m_delegateMethods.webViewRequestUserMediaAuthorizationForMicrophoneCameraURLMainFrameURLDecisionHandler = [delegate respondsToSelector:@selector(_webView:requestUserMediaAuthorizationForMicrophone:camera:url:mainFrameURL:decisionHandler:)];
+ m_delegateMethods.webViewRequestUserMediaAuthorizationForDevicesURLMainFrameURLDecisionHandler = [delegate respondsToSelector:@selector(_webView:requestUserMediaAuthorizationForDevices:url:mainFrameURL:decisionHandler:)];
m_delegateMethods.webViewCheckUserMediaPermissionForURLMainFrameURLFrameIdentifierDecisionHandler = [delegate respondsToSelector:@selector(_webView:checkUserMediaPermissionForURL:mainFrameURL:frameIdentifier:decisionHandler:)];
m_delegateMethods.webViewMediaCaptureStateDidChange = [delegate respondsToSelector:@selector(_webView:mediaCaptureStateDidChange:)];
m_delegateMethods.presentingViewControllerForWebView = [delegate respondsToSelector:@selector(_presentingViewControllerForWebView:)];
@@ -377,7 +377,7 @@
bool UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest(WebKit::WebPageProxy& page, WebKit::WebFrameProxy& frame, API::SecurityOrigin& userMediaOrigin, API::SecurityOrigin& topLevelOrigin, WebKit::UserMediaPermissionRequestProxy& request)
{
auto delegate = m_uiDelegate.m_delegate.get();
- if (!delegate || !m_uiDelegate.m_delegateMethods.webViewRequestUserMediaAuthorizationForMicrophoneCameraURLMainFrameURLDecisionHandler) {
+ if (!delegate || !m_uiDelegate.m_delegateMethods.webViewRequestUserMediaAuthorizationForDevicesURLMainFrameURLDecisionHandler) {
request.deny(UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::UserMediaDisabled);
return true;
}
@@ -395,8 +395,14 @@
WebCore::URL requestFrameURL(WebCore::URL(), frame.url());
WebCore::URL mainFrameURL(WebCore::URL(), mainFrame->url());
- [(id <WKUIDelegatePrivate>)delegate _webView:webView requestUserMediaAuthorizationForMicrophone:requiresAudio camera:requiresVideo url:requestFrameURL mainFrameURL:mainFrameURL decisionHandler:^(BOOL authorizedMicrophone, BOOL authorizedCamera) {
- if ((requiresAudio != authorizedMicrophone) || (requiresVideo != authorizedCamera)) {
+ _WKCaptureDevices devices = 0;
+ if (requiresAudio)
+ devices |= _WKCaptureDeviceMicrophone;
+ if (requiresVideo)
+ devices |= _WKCaptureDeviceCamera;
+
+ [(id <WKUIDelegatePrivate>)delegate _webView:webView requestUserMediaAuthorizationForDevices:devices url:requestFrameURL mainFrameURL:mainFrameURL decisionHandler:^(BOOL authorized) {
+ if (!authorized) {
request.deny(UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::PermissionDenied);
return;
}