WebKit Bugzilla
Attachment 359296 Details for
Bug 192793
: Add a new SPI for controlling getUserMedia
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-192793-20190116131602.patch (text/plain), 55.96 KB, created by
youenn fablet
on 2019-01-16 13:16:03 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
youenn fablet
Created:
2019-01-16 13:16:03 PST
Size:
55.96 KB
patch
obsolete
>Subversion Revision: 239989 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index f8109c24375348f1b6b96c5b542c1b116d9c27c3..c66f9dc34278146f1c4cfcfbff3dbc1b5a60b329 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,49 @@ >+2019-01-16 Youenn Fablet <youenn@apple.com> >+ >+ Add a new SPI for controlling getUserMedia >+ https://bugs.webkit.org/show_bug.cgi?id=192793 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Some weaknesses of the current getUserMedia/enumerateDevices SPI were found. >+ In particular: >+ - The hash salt should be handled by WebKit not by apps using WebKit. >+ - No need to expose the frame URL, only the top level origin is needed. >+ - The names of the callback are changed to improve the intent of these callbacks. >+ Addressed these by creating a new SPI which will replace the current one. >+ The current SPI will be removed later on. >+ >+ Did some refactoring by making the callbacks not return false. >+ Instead, implement the default behavior inside the request objects as deny methods. >+ Some further refactoring will be done as a follow-up to better align the C API with the Cocoa API. >+ >+ * UIProcess/API/APIUIClient.h: >+ (API::UIClient::decidePolicyForUserMediaPermissionRequest): >+ (API::UIClient::checkUserMediaPermissionForOrigin): >+ * UIProcess/API/C/WKPage.cpp: >+ (WKPageSetPageUIClient): >+ * UIProcess/API/Cocoa/WKUIDelegatePrivate.h: >+ * UIProcess/API/Cocoa/WKWebView.mm: >+ (-[WKWebView _mediaCaptureState]): >+ (-[WKWebView _setMediaCaptureMuted:]): >+ * UIProcess/API/Cocoa/WKWebViewPrivate.h: >+ * UIProcess/API/glib/WebKitUIClient.cpp: >+ * UIProcess/Cocoa/MediaCaptureUtilities.h: Added. >+ * UIProcess/Cocoa/MediaCaptureUtilities.mm: Added. >+ * UIProcess/Cocoa/UIDelegate.h: >+ * UIProcess/Cocoa/UIDelegate.mm: >+ (WebKit::UIDelegate::setDelegate): >+ (WebKit::requestUserMediaAuthorizationForFrame): >+ (WebKit::UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest): >+ (WebKit::UIDelegate::UIClient::checkUserMediaPermissionForOrigin): >+ (WebKit::UIDelegate::UIClient::mediaCaptureStateDidChange): >+ * UIProcess/UserMediaPermissionCheckProxy.h: >+ (WebKit::UserMediaPermissionCheckProxy::deny): >+ * UIProcess/UserMediaPermissionRequestManagerProxy.cpp: >+ (WebKit::UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame): >+ (WebKit::UserMediaPermissionRequestManagerProxy::getUserMediaPermissionInfo): >+ * UIProcess/UserMediaPermissionRequestProxy.h: >+ > 2019-01-16 Youenn Fablet <youenn@apple.com> > > Add a new SPI to request for cache storage quota increase >diff --git a/Source/WebKit/SourcesCocoa.txt b/Source/WebKit/SourcesCocoa.txt >index 308f66cbe6d23246eddafda31d2aa458582c94e2..d2fa235042568f214228e666db032795826923c7 100644 >--- a/Source/WebKit/SourcesCocoa.txt >+++ b/Source/WebKit/SourcesCocoa.txt >@@ -321,6 +321,7 @@ UIProcess/Cocoa/FullscreenClient.mm > UIProcess/Cocoa/GlobalFindInPageState.mm > UIProcess/Cocoa/IconLoadingDelegate.mm > UIProcess/Cocoa/LegacyCustomProtocolManagerClient.mm >+UIProcess/Cocoa/MediaCaptureUtilities.mm > UIProcess/Cocoa/NavigationState.mm > UIProcess/Cocoa/PageClientImplCocoa.mm > UIProcess/Cocoa/PlaybackSessionManagerProxy.mm >diff --git a/Source/WebKit/UIProcess/API/APIUIClient.h b/Source/WebKit/UIProcess/API/APIUIClient.h >index 43ff763b9048cc40a967d9456bbe03acbb95027c..03d12300d17169f47c81dc2601a6a40717d70aac 100644 >--- a/Source/WebKit/UIProcess/API/APIUIClient.h >+++ b/Source/WebKit/UIProcess/API/APIUIClient.h >@@ -129,8 +129,8 @@ public: > > virtual bool runOpenPanel(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, const WebCore::SecurityOriginData&, OpenPanelParameters*, WebKit::WebOpenPanelResultListenerProxy*) { return false; } > virtual void decidePolicyForGeolocationPermissionRequest(WebKit::WebPageProxy&, WebKit::WebFrameProxy&, SecurityOrigin&, Function<void(bool)>&) { } >- virtual bool decidePolicyForUserMediaPermissionRequest(WebKit::WebPageProxy&, WebKit::WebFrameProxy&, SecurityOrigin&, SecurityOrigin&, WebKit::UserMediaPermissionRequestProxy&) { return false; } >- virtual bool checkUserMediaPermissionForOrigin(WebKit::WebPageProxy&, WebKit::WebFrameProxy&, SecurityOrigin&, SecurityOrigin&, WebKit::UserMediaPermissionCheckProxy&) { return false; } >+ virtual void decidePolicyForUserMediaPermissionRequest(WebKit::WebPageProxy&, WebKit::WebFrameProxy&, SecurityOrigin&, SecurityOrigin&, WebKit::UserMediaPermissionRequestProxy&) { } >+ virtual void checkUserMediaPermissionForOrigin(WebKit::WebPageProxy&, WebKit::WebFrameProxy&, SecurityOrigin&, SecurityOrigin&, WebKit::UserMediaPermissionCheckProxy&) { } > virtual void decidePolicyForNotificationPermissionRequest(WebKit::WebPageProxy&, SecurityOrigin&, Function<void(bool)>&& completionHandler) { completionHandler(false); } > virtual void requestStorageAccessConfirm(WebKit::WebPageProxy&, WebKit::WebFrameProxy*, const WTF::String& requestingDomain, const WTF::String& currentDomain, CompletionHandler<void(bool)>&& completionHandler) { completionHandler(true); } > >diff --git a/Source/WebKit/UIProcess/API/C/WKPage.cpp b/Source/WebKit/UIProcess/API/C/WKPage.cpp >index d4ee8cc0b5fd9a853562dbe00d573137788c1fa8..b60a8012d6d6a01717fc2248833f90093d45eac6 100644 >--- a/Source/WebKit/UIProcess/API/C/WKPage.cpp >+++ b/Source/WebKit/UIProcess/API/C/WKPage.cpp >@@ -1855,22 +1855,24 @@ void WKPageSetPageUIClient(WKPageRef pageRef, const WKPageUIClientBase* wkClient > m_client.decidePolicyForGeolocationPermissionRequest(toAPI(&page), toAPI(&frame), toAPI(&origin), toAPI(GeolocationPermissionRequest::create(std::exchange(completionHandler, nullptr)).ptr()), m_client.base.clientInfo); > } > >- bool decidePolicyForUserMediaPermissionRequest(WebPageProxy& page, WebFrameProxy& frame, API::SecurityOrigin& userMediaDocumentOrigin, API::SecurityOrigin& topLevelDocumentOrigin, UserMediaPermissionRequestProxy& permissionRequest) final >+ void decidePolicyForUserMediaPermissionRequest(WebPageProxy& page, WebFrameProxy& frame, API::SecurityOrigin& userMediaDocumentOrigin, API::SecurityOrigin& topLevelDocumentOrigin, UserMediaPermissionRequestProxy& permissionRequest) final > { >- if (!m_client.decidePolicyForUserMediaPermissionRequest) >- return false; >+ if (!m_client.decidePolicyForUserMediaPermissionRequest) { >+ permissionRequest.deny(); >+ return; >+ } > > m_client.decidePolicyForUserMediaPermissionRequest(toAPI(&page), toAPI(&frame), toAPI(&userMediaDocumentOrigin), toAPI(&topLevelDocumentOrigin), toAPI(&permissionRequest), m_client.base.clientInfo); >- return true; > } > >- bool checkUserMediaPermissionForOrigin(WebPageProxy& page, WebFrameProxy& frame, API::SecurityOrigin& userMediaDocumentOrigin, API::SecurityOrigin& topLevelDocumentOrigin, UserMediaPermissionCheckProxy& request) final >+ void checkUserMediaPermissionForOrigin(WebPageProxy& page, WebFrameProxy& frame, API::SecurityOrigin& userMediaDocumentOrigin, API::SecurityOrigin& topLevelDocumentOrigin, UserMediaPermissionCheckProxy& request) final > { >- if (!m_client.checkUserMediaPermissionForOrigin) >- return false; >+ if (!m_client.checkUserMediaPermissionForOrigin) { >+ request.deny(); >+ return; >+ } > > m_client.checkUserMediaPermissionForOrigin(toAPI(&page), toAPI(&frame), toAPI(&userMediaDocumentOrigin), toAPI(&topLevelDocumentOrigin), toAPI(&request), m_client.base.clientInfo); >- return true; > } > > void decidePolicyForNotificationPermissionRequest(WebPageProxy& page, API::SecurityOrigin& origin, Function<void(bool)>&& completionHandler) final >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h b/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h >index cd9a54ee1752525bd409fb99acd2eb5790896ac5..55680830e79d0d4b1999336864ba67fb044b67fe 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h >@@ -107,6 +107,8 @@ struct UIEdgeInsets; > > - (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 requestMediaCaptureAuthorization:(_WKCaptureDevices)devices decisionHandler:(void (^)(BOOL authorized))decisionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); >+- (void)_webView:(WKWebView *)webView includeSensitiveMediaDeviceDetails:(void (^)(BOOL includeSensitiveDetails))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(10.13), ios(11.0)); > - (void)_webView:(WKWebView *)webView checkUserMediaPermissionForURL:(NSURL *)url mainFrameURL:(NSURL *)mainFrameURL frameIdentifier:(NSUInteger)frameIdentifier decisionHandler:(void (^)(NSString *salt, BOOL authorized))decisionHandler WK_API_AVAILABLE(macosx(10.12.3), ios(10.3)); > - (void)_webView:(WKWebView *)webView mediaCaptureStateDidChange:(_WKMediaCaptureState)state WK_API_AVAILABLE(macosx(10.13), ios(11.0)); >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm b/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >index 074cddfd2784e869128d020bed59213a1cbdde68..a65ebed2fa61e7b3c86a1fc141bb270336158d09 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >@@ -41,6 +41,7 @@ > #import "IconLoadingDelegate.h" > #import "LegacySessionStateCoding.h" > #import "Logging.h" >+#import "MediaCaptureUtilities.h" > #import "NavigationState.h" > #import "ObjCObjectGraph.h" > #import "PageClient.h" >@@ -5550,6 +5551,16 @@ - (BOOL)_isInFullscreen > #endif > } > >+- (_WKMediaCaptureState)_mediaCaptureState >+{ >+ return WebKit::toWKMediaCaptureState(_page->mediaStateFlags()); >+} >+ >+- (void)_setMediaCaptureMuted:(BOOL)muted >+{ >+ _page->setMediaStreamCaptureMuted(muted); >+} >+ > - (void)_muteMediaCapture > { > _page->setMediaStreamCaptureMuted(true); >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h b/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h >index 26c0c346002f58d4649cdad2c92d48d377becf22..12b01e85d193601df1a2ba3e8411e4815cf7e477 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h >@@ -404,6 +404,9 @@ typedef NS_OPTIONS(NSUInteger, _WKRectEdge) { > @property (nonatomic, setter=_setFullscreenDelegate:) id<_WKFullscreenDelegate> _fullscreenDelegate WK_API_AVAILABLE(macosx(10.13), ios(11.0)); > @property (nonatomic, readonly) BOOL _isInFullscreen WK_API_AVAILABLE(macosx(10.12.3)); > >+@property (nonatomic, readonly) _WKMediaCaptureState _mediaCaptureState WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); >+ >+- (void)_setMediaCaptureMuted:(BOOL)muted WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); > - (void)_muteMediaCapture WK_API_AVAILABLE(macosx(10.13), ios(11.0)); > - (void)_setPageMuted:(_WKMediaMutedState)mutedState WK_API_AVAILABLE(macosx(10.13), ios(11.0)); > >diff --git a/Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp b/Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp >index d4a8d1e99c7ad5f0327bb874fc0eac30c1a4edf2..2e52a3e5a6948120ac9880a476ae744ade08c6d2 100644 >--- a/Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp >+++ b/Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp >@@ -184,18 +184,16 @@ private: > webkitWebViewMakePermissionRequest(m_webView, WEBKIT_PERMISSION_REQUEST(geolocationPermissionRequest.get())); > } > >- bool decidePolicyForUserMediaPermissionRequest(WebPageProxy&, WebFrameProxy&, API::SecurityOrigin& userMediaDocumentOrigin, API::SecurityOrigin& topLevelDocumentOrigin, UserMediaPermissionRequestProxy& permissionRequest) final >+ void decidePolicyForUserMediaPermissionRequest(WebPageProxy&, WebFrameProxy&, API::SecurityOrigin& userMediaDocumentOrigin, API::SecurityOrigin& topLevelDocumentOrigin, UserMediaPermissionRequestProxy& permissionRequest) final > { > GRefPtr<WebKitUserMediaPermissionRequest> userMediaPermissionRequest = adoptGRef(webkitUserMediaPermissionRequestCreate(permissionRequest, userMediaDocumentOrigin, topLevelDocumentOrigin)); > webkitWebViewMakePermissionRequest(m_webView, WEBKIT_PERMISSION_REQUEST(userMediaPermissionRequest.get())); >- return true; > } > >- bool checkUserMediaPermissionForOrigin(WebPageProxy& page, WebFrameProxy&, API::SecurityOrigin& userMediaDocumentOrigin, API::SecurityOrigin& topLevelDocumentOrigin, UserMediaPermissionCheckProxy& permissionRequest) override >+ void checkUserMediaPermissionForOrigin(WebPageProxy& page, WebFrameProxy&, API::SecurityOrigin& userMediaDocumentOrigin, API::SecurityOrigin& topLevelDocumentOrigin, UserMediaPermissionCheckProxy& permissionRequest) override > { > auto deviceInfoPermissionRequest = adoptGRef(webkitDeviceInfoPermissionRequestCreate(permissionRequest, &page.websiteDataStore().deviceIdHashSaltStorage())); > webkitWebViewMakePermissionRequest(m_webView, WEBKIT_PERMISSION_REQUEST(deviceInfoPermissionRequest.get())); >- return true; > } > > void decidePolicyForNotificationPermissionRequest(WebPageProxy&, API::SecurityOrigin&, Function<void(bool)>&& completionHandler) final >diff --git a/Source/WebKit/UIProcess/Cocoa/MediaCaptureUtilities.h b/Source/WebKit/UIProcess/Cocoa/MediaCaptureUtilities.h >new file mode 100644 >index 0000000000000000000000000000000000000000..400403ffd839b1d67390b2052502432ae1a16b23 >--- /dev/null >+++ b/Source/WebKit/UIProcess/Cocoa/MediaCaptureUtilities.h >@@ -0,0 +1,39 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if WK_API_ENABLED >+ >+#import "WKWebViewPrivate.h" >+#import <WebCore/MediaProducer.h> >+ >+namespace WebKit { >+ >+_WKMediaCaptureState toWKMediaCaptureState(WebCore::MediaProducer::MediaStateFlags); >+ >+} // namespace WebKit >+ >+#endif >diff --git a/Source/WebKit/UIProcess/Cocoa/MediaCaptureUtilities.mm b/Source/WebKit/UIProcess/Cocoa/MediaCaptureUtilities.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..5aee38eb64e2e248416087688f3fc600d6a1128c >--- /dev/null >+++ b/Source/WebKit/UIProcess/Cocoa/MediaCaptureUtilities.mm >@@ -0,0 +1,50 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "MediaCaptureUtilities.h" >+ >+#if WK_API_ENABLED >+ >+namespace WebKit { >+ >+_WKMediaCaptureState toWKMediaCaptureState(WebCore::MediaProducer::MediaStateFlags state) >+{ >+ _WKMediaCaptureState mediaCaptureState = _WKMediaCaptureStateNone; >+ if (state & WebCore::MediaProducer::HasActiveAudioCaptureDevice) >+ mediaCaptureState |= _WKMediaCaptureStateActiveMicrophone; >+ if (state & WebCore::MediaProducer::HasActiveVideoCaptureDevice) >+ mediaCaptureState |= _WKMediaCaptureStateActiveCamera; >+ if (state & WebCore::MediaProducer::HasMutedAudioCaptureDevice) >+ mediaCaptureState |= _WKMediaCaptureStateMutedMicrophone; >+ if (state & WebCore::MediaProducer::HasMutedVideoCaptureDevice) >+ mediaCaptureState |= _WKMediaCaptureStateMutedCamera; >+ >+ return mediaCaptureState; >+} >+ >+} // namespace WebKit >+ >+#endif >diff --git a/Source/WebKit/UIProcess/Cocoa/UIDelegate.h b/Source/WebKit/UIProcess/Cocoa/UIDelegate.h >index 38dd7ecbcfb5f2a60fc86c98be8b0f31a854ff86..8fd16a9812c04adf085e544aee3804c822d5f166 100644 >--- a/Source/WebKit/UIProcess/Cocoa/UIDelegate.h >+++ b/Source/WebKit/UIProcess/Cocoa/UIDelegate.h >@@ -123,8 +123,8 @@ private: > #endif > bool needsFontAttributes() const final { return m_uiDelegate.m_delegateMethods.webViewDidChangeFontAttributes; } > void didChangeFontAttributes(const WebCore::FontAttributes&) final; >- bool decidePolicyForUserMediaPermissionRequest(WebPageProxy&, WebFrameProxy&, API::SecurityOrigin&, API::SecurityOrigin&, UserMediaPermissionRequestProxy&) final; >- bool checkUserMediaPermissionForOrigin(WebPageProxy&, WebFrameProxy&, API::SecurityOrigin&, API::SecurityOrigin&, UserMediaPermissionCheckProxy&) final; >+ void decidePolicyForUserMediaPermissionRequest(WebPageProxy&, WebFrameProxy&, API::SecurityOrigin&, API::SecurityOrigin&, UserMediaPermissionRequestProxy&) final; >+ void checkUserMediaPermissionForOrigin(WebPageProxy&, WebFrameProxy&, API::SecurityOrigin&, API::SecurityOrigin&, UserMediaPermissionCheckProxy&) final; > void mediaCaptureStateDidChange(WebCore::MediaProducer::MediaStateFlags) final; > void printFrame(WebPageProxy&, WebFrameProxy&) final; > #if PLATFORM(IOS_FAMILY) >@@ -198,8 +198,8 @@ private: > bool webViewFullscreenMayReturnToInline : 1; > bool webViewDidEnterFullscreen : 1; > bool webViewDidExitFullscreen : 1; >- bool webViewRequestUserMediaAuthorizationForDevicesURLMainFrameURLDecisionHandler : 1; >- bool webViewCheckUserMediaPermissionForURLMainFrameURLFrameIdentifierDecisionHandler : 1; >+ bool webViewRequestMediaCaptureAuthorizationForFrameDecisionHandler : 1; >+ bool webViewIsMediaCaptureAuthorizedForFrameDecisionHandler : 1; > bool webViewMediaCaptureStateDidChange : 1; > bool webViewDidChangeFontAttributes : 1; > #if PLATFORM(IOS_FAMILY) >diff --git a/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm b/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm >index c16853fa4db1ce492402afceeda510fb60cc62ee..c35eb5a9055668ff9cd3f1d4138aa6ecec3ee9a0 100644 >--- a/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm >+++ b/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm >@@ -31,6 +31,7 @@ > #import "APIFrameInfo.h" > #import "APIHitTestResult.h" > #import "CompletionHandlerCallChecker.h" >+#import "MediaCaptureUtilities.h" > #import "NativeWebWheelEvent.h" > #import "NavigationActionData.h" > #import "UserMediaPermissionCheckProxy.h" >@@ -150,8 +151,9 @@ void UIDelegate::setDelegate(id <WKUIDelegate> delegate) > m_delegateMethods.webViewDidNotHandleTapAsClickAtPoint = [delegate respondsToSelector:@selector(_webView:didNotHandleTapAsClickAtPoint:)]; > m_delegateMethods.presentingViewControllerForWebView = [delegate respondsToSelector:@selector(_presentingViewControllerForWebView:)]; > #endif >- m_delegateMethods.webViewRequestUserMediaAuthorizationForDevicesURLMainFrameURLDecisionHandler = [delegate respondsToSelector:@selector(_webView:requestUserMediaAuthorizationForDevices:url:mainFrameURL:decisionHandler:)]; >- m_delegateMethods.webViewCheckUserMediaPermissionForURLMainFrameURLFrameIdentifierDecisionHandler = [delegate respondsToSelector:@selector(_webView:checkUserMediaPermissionForURL:mainFrameURL:frameIdentifier:decisionHandler:)]; >+ m_delegateMethods.webViewRequestMediaCaptureAuthorizationForFrameDecisionHandler = [delegate respondsToSelector:@selector(_webView:requestUserMediaAuthorizationForDevices:url:mainFrameURL:decisionHandler:)] || [delegate respondsToSelector:@selector(_webView:requestMediaCaptureAuthorization:decisionHandler:)]; >+ m_delegateMethods.webViewIsMediaCaptureAuthorizedForFrameDecisionHandler = [delegate respondsToSelector:@selector(_webView:checkUserMediaPermissionForURL:mainFrameURL:frameIdentifier:decisionHandler:)] || [delegate respondsToSelector:@selector(_webView:includeSensitiveMediaDeviceDetails:)]; >+ > m_delegateMethods.webViewMediaCaptureStateDidChange = [delegate respondsToSelector:@selector(_webView:mediaCaptureStateDidChange:)]; > m_delegateMethods.webViewDidChangeFontAttributes = [delegate respondsToSelector:@selector(_webView:didChangeFontAttributes:)]; > m_delegateMethods.dataDetectionContextForWebView = [delegate respondsToSelector:@selector(_dataDetectionContextForWebView:)]; >@@ -858,10 +860,24 @@ bool UIDelegate::UIClient::runOpenPanel(WebPageProxy*, WebFrameProxy* webFramePr > } > #endif > >+void UIDelegate::UIClient::didChangeFontAttributes(const WebCore::FontAttributes& fontAttributes) >+{ >+ if (!needsFontAttributes()) >+ return; >+ >+ auto privateUIDelegate = (id <WKUIDelegatePrivate>)m_uiDelegate.m_delegate.get(); >+ [privateUIDelegate _webView:m_uiDelegate.m_webView didChangeFontAttributes:fontAttributes.createDictionary().get()]; >+} >+ > #if ENABLE(MEDIA_STREAM) >-static void requestUserMediaAuthorizationForDevices(const WebFrameProxy& frame, UserMediaPermissionRequestProxy& request, id <WKUIDelegatePrivate> delegate, WKWebView& webView) >+static void requestUserMediaAuthorizationForFrame(const WebFrameProxy& frame, API::SecurityOrigin& topLevelOrigin, UserMediaPermissionRequestProxy& request, id <WKUIDelegatePrivate> delegate, WKWebView& webView) > { >- auto decisionHandler = makeBlockPtr([protectedRequest = makeRef(request)](BOOL authorized) { >+ auto checker = CompletionHandlerCallChecker::create(delegate, @selector(_webView:requestMediaCaptureAuthorization:decisionHandler:)); >+ auto decisionHandler = makeBlockPtr([protectedRequest = makeRef(request), checker = WTFMove(checker)](BOOL authorized) { >+ if (checker->completionHandlerHasBeenCalled()) >+ return; >+ checker->didCallCompletionHandler(); >+ > if (!authorized) { > protectedRequest->deny(UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::PermissionDenied); > return; >@@ -871,10 +887,6 @@ static void requestUserMediaAuthorizationForDevices(const WebFrameProxy& frame, > protectedRequest->allow(audioDeviceUID, videoDeviceUID); > }); > >- const WebFrameProxy* mainFrame = frame.page()->mainFrame(); >- URL requestFrameURL(URL(), frame.url()); >- URL mainFrameURL(URL(), mainFrame->url()); >- > _WKCaptureDevices devices = 0; > if (request.requiresAudioCapture()) > devices |= _WKCaptureDeviceMicrophone; >@@ -885,27 +897,29 @@ static void requestUserMediaAuthorizationForDevices(const WebFrameProxy& frame, > ASSERT(!(devices & _WKCaptureDeviceCamera)); > } > >- auto protectedWebView = RetainPtr<WKWebView>(&webView); >- [delegate _webView:protectedWebView.get() requestUserMediaAuthorizationForDevices:devices url:requestFrameURL mainFrameURL:mainFrameURL decisionHandler:decisionHandler.get()]; >-} >-#endif >+ const auto* mainFrame = frame.page()->mainFrame(); > >-void UIDelegate::UIClient::didChangeFontAttributes(const WebCore::FontAttributes& fontAttributes) >-{ >- if (!needsFontAttributes()) >+ // FIXME: Provide a specific delegate for display capture. >+ if (!request.requiresDisplayCapture() && [delegate respondsToSelector:@selector(_webView:requestMediaCaptureAuthorization:decisionHandler:)]) { >+ >+ [delegate _webView:&webView requestMediaCaptureAuthorization:devices decisionHandler:decisionHandler.get()]; > return; >+ } > >- auto privateUIDelegate = (id <WKUIDelegatePrivate>)m_uiDelegate.m_delegate.get(); >- [privateUIDelegate _webView:m_uiDelegate.m_webView didChangeFontAttributes:fontAttributes.createDictionary().get()]; >+ URL requestFrameURL { URL(), frame.url() }; >+ URL mainFrameURL { URL(), mainFrame->url() }; >+ >+ [delegate _webView:&webView requestUserMediaAuthorizationForDevices:devices url:requestFrameURL mainFrameURL:mainFrameURL decisionHandler:decisionHandler.get()]; > } >+#endif > >-bool UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest(WebPageProxy& page, WebFrameProxy& frame, API::SecurityOrigin& userMediaOrigin, API::SecurityOrigin& topLevelOrigin, UserMediaPermissionRequestProxy& request) >+void UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest(WebPageProxy& page, WebFrameProxy& frame, API::SecurityOrigin& userMediaOrigin, API::SecurityOrigin& topLevelOrigin, UserMediaPermissionRequestProxy& request) > { > #if ENABLE(MEDIA_STREAM) > auto delegate = m_uiDelegate.m_delegate.get(); >- if (!delegate || !m_uiDelegate.m_delegateMethods.webViewRequestUserMediaAuthorizationForDevicesURLMainFrameURLDecisionHandler) { >+ if (!delegate || !m_uiDelegate.m_delegateMethods.webViewRequestMediaCaptureAuthorizationForFrameDecisionHandler) { > request.deny(UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::UserMediaDisabled); >- return true; >+ return; > } > > bool requiresAudioCapture = request.requiresAudioCapture(); >@@ -913,33 +927,33 @@ bool UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest(WebPageProx > bool requiresDisplayCapture = request.requiresDisplayCapture(); > if (!requiresAudioCapture && !requiresVideoCapture && !requiresDisplayCapture) { > request.deny(UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::NoConstraints); >- return true; >+ return; > } > > #if HAVE(AUTHORIZATION_STATUS_FOR_MEDIA_TYPE) > bool usingMockCaptureDevices = page.preferences().mockCaptureDevicesEnabled(); >- auto requestCameraAuthorization = makeBlockPtr([this, &frame, protectedRequest = makeRef(request), webView = RetainPtr<WKWebView>(m_uiDelegate.m_webView), usingMockCaptureDevices]() { >+ auto requestCameraAuthorization = makeBlockPtr([this, &frame, protectedRequest = makeRef(request), webView = RetainPtr<WKWebView>(m_uiDelegate.m_webView), topLevelOrigin = makeRef(topLevelOrigin), usingMockCaptureDevices]() mutable { > > if (!protectedRequest->requiresVideoCapture()) { >- requestUserMediaAuthorizationForDevices(frame, protectedRequest, (id <WKUIDelegatePrivate>)m_uiDelegate.m_delegate.get(), *webView.get()); >+ requestUserMediaAuthorizationForFrame(frame, topLevelOrigin, protectedRequest, (id <WKUIDelegatePrivate>)m_uiDelegate.m_delegate.get(), *webView.get()); > return; > } > AVAuthorizationStatus cameraAuthorizationStatus = usingMockCaptureDevices ? AVAuthorizationStatusAuthorized : [getAVCaptureDeviceClass() authorizationStatusForMediaType:getAVMediaTypeVideo()]; > switch (cameraAuthorizationStatus) { > case AVAuthorizationStatusAuthorized: >- requestUserMediaAuthorizationForDevices(frame, protectedRequest, (id <WKUIDelegatePrivate>)m_uiDelegate.m_delegate.get(), *webView.get()); >+ requestUserMediaAuthorizationForFrame(frame, topLevelOrigin, protectedRequest, (id <WKUIDelegatePrivate>)m_uiDelegate.m_delegate.get(), *webView.get()); > break; > case AVAuthorizationStatusDenied: > case AVAuthorizationStatusRestricted: > protectedRequest->deny(UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::PermissionDenied); > return; > case AVAuthorizationStatusNotDetermined: >- auto decisionHandler = makeBlockPtr([this, &frame, protectedRequest = makeRef(protectedRequest.get()), webView = RetainPtr<WKWebView>(m_uiDelegate.m_webView)](BOOL authorized) { >+ auto decisionHandler = makeBlockPtr([this, &frame, protectedRequest = makeRef(protectedRequest.get()), webView = RetainPtr<WKWebView>(m_uiDelegate.m_webView), topLevelOrigin = WTFMove(topLevelOrigin)](BOOL authorized) { > if (!authorized) { > protectedRequest->deny(UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::PermissionDenied); > return; > } >- requestUserMediaAuthorizationForDevices(frame, protectedRequest, (id <WKUIDelegatePrivate>)m_uiDelegate.m_delegate.get(), *webView.get()); >+ requestUserMediaAuthorizationForFrame(frame, topLevelOrigin, protectedRequest, (id <WKUIDelegatePrivate>)m_uiDelegate.m_delegate.get(), *webView.get()); > }); > > [getAVCaptureDeviceClass() requestAccessForMediaType:getAVMediaTypeVideo() completionHandler:decisionHandler.get()]; >@@ -956,7 +970,7 @@ bool UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest(WebPageProx > case AVAuthorizationStatusDenied: > case AVAuthorizationStatusRestricted: > request.deny(UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::PermissionDenied); >- return true; >+ return; > case AVAuthorizationStatusNotDetermined: > auto decisionHandler = makeBlockPtr([protectedRequest = makeRef(request), requestCameraAuthorization](BOOL authorized) { > if (!authorized) { >@@ -972,53 +986,61 @@ bool UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest(WebPageProx > } else > requestCameraAuthorization(); > #else >- requestUserMediaAuthorizationForDevices(frame, request, (id <WKUIDelegatePrivate>)m_uiDelegate.m_delegate.get(), *m_uiDelegate.m_webView); >+ requestUserMediaAuthorizationForFrame(frame, topLevelOrigin, request, (id <WKUIDelegatePrivate>)m_uiDelegate.m_delegate.get(), *m_uiDelegate.m_webView); > #endif > #endif >- >- return true; > } > >-bool UIDelegate::UIClient::checkUserMediaPermissionForOrigin(WebPageProxy& page, WebFrameProxy& frame, API::SecurityOrigin& userMediaOrigin, API::SecurityOrigin& topLevelOrigin, UserMediaPermissionCheckProxy& request) >+void UIDelegate::UIClient::checkUserMediaPermissionForOrigin(WebPageProxy& page, WebFrameProxy& frame, API::SecurityOrigin& userMediaOrigin, API::SecurityOrigin& topLevelOrigin, UserMediaPermissionCheckProxy& request) > { > auto delegate = m_uiDelegate.m_delegate.get(); >- if (!delegate || !m_uiDelegate.m_delegateMethods.webViewCheckUserMediaPermissionForURLMainFrameURLFrameIdentifierDecisionHandler) { >+ if (!delegate || !m_uiDelegate.m_delegateMethods.webViewIsMediaCaptureAuthorizedForFrameDecisionHandler) { > request.setUserMediaAccessInfo(false); >- return true; >+ return; > } > >- WKWebView *webView = m_uiDelegate.m_webView; >- const WebFrameProxy* mainFrame = frame.page()->mainFrame(); >- URL requestFrameURL(URL(), frame.url()); >- URL mainFrameURL(URL(), mainFrame->url()); >+ const auto* mainFrame = frame.page()->mainFrame(); >+ >+ if ([delegate respondsToSelector:@selector(_webView:includeSensitiveMediaDeviceDetails:)]) { >+ auto checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(_webView:includeSensitiveMediaDeviceDetails:)); >+ auto decisionHandler = makeBlockPtr([protectedRequest = makeRef(request), checker = WTFMove(checker)](BOOL includeSensitiveDetails) { >+ if (checker->completionHandlerHasBeenCalled()) >+ return; >+ checker->didCallCompletionHandler(); >+ >+ protectedRequest->setUserMediaAccessInfo(includeSensitiveDetails); >+ }); >+ >+ [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView includeSensitiveMediaDeviceDetails:decisionHandler.get()]; >+ return; >+ } >+ >+ auto checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(_webView:checkUserMediaPermissionForURL:mainFrameURL:frameIdentifier:decisionHandler:)); >+ auto decisionHandler = makeBlockPtr([protectedRequest = makeRef(request), checker = WTFMove(checker)](NSString*, BOOL authorized) { >+ if (checker->completionHandlerHasBeenCalled()) >+ return; >+ checker->didCallCompletionHandler(); > >- auto decisionHandler = makeBlockPtr([protectedRequest = makeRef(request)](NSString*, BOOL authorized) { > protectedRequest->setUserMediaAccessInfo(authorized); > }); > >- [(id <WKUIDelegatePrivate>)delegate _webView:webView checkUserMediaPermissionForURL:requestFrameURL mainFrameURL:mainFrameURL frameIdentifier:frame.frameID() decisionHandler:decisionHandler.get()]; >+ URL requestFrameURL { URL(), frame.url() }; >+ URL mainFrameURL { URL(), mainFrame->url() }; > >- return true; >+ [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView checkUserMediaPermissionForURL:requestFrameURL mainFrameURL:mainFrameURL frameIdentifier:frame.frameID() decisionHandler:decisionHandler.get()]; > } > > void UIDelegate::UIClient::mediaCaptureStateDidChange(WebCore::MediaProducer::MediaStateFlags state) > { > WKWebView *webView = m_uiDelegate.m_webView; >+ >+ [webView didChangeValueForKey:@"mediaCaptureState"]; >+ > auto delegate = m_uiDelegate.m_delegate.get(); > if (!delegate || !m_uiDelegate.m_delegateMethods.webViewMediaCaptureStateDidChange) > return; > >- _WKMediaCaptureState mediaCaptureState = _WKMediaCaptureStateNone; >- if (state & WebCore::MediaProducer::HasActiveAudioCaptureDevice) >- mediaCaptureState |= _WKMediaCaptureStateActiveMicrophone; >- if (state & WebCore::MediaProducer::HasActiveVideoCaptureDevice) >- mediaCaptureState |= _WKMediaCaptureStateActiveCamera; >- if (state & WebCore::MediaProducer::HasMutedAudioCaptureDevice) >- mediaCaptureState |= _WKMediaCaptureStateMutedMicrophone; >- if (state & WebCore::MediaProducer::HasMutedVideoCaptureDevice) >- mediaCaptureState |= _WKMediaCaptureStateMutedCamera; >- >- [(id <WKUIDelegatePrivate>)delegate _webView:webView mediaCaptureStateDidChange:mediaCaptureState]; >+ [(id <WKUIDelegatePrivate>)delegate _webView:webView mediaCaptureStateDidChange:toWKMediaCaptureState(state)]; > } > > void UIDelegate::UIClient::reachedApplicationCacheOriginQuota(WebPageProxy*, const WebCore::SecurityOrigin& securityOrigin, uint64_t currentQuota, uint64_t totalBytesNeeded, Function<void (unsigned long long)>&& completionHandler) >diff --git a/Source/WebKit/UIProcess/UserMediaPermissionCheckProxy.h b/Source/WebKit/UIProcess/UserMediaPermissionCheckProxy.h >index d91f04ffdab8d142454d5063fe17f0ebfa8334eb..6a089506cea388d1d4c3d6defda5fe0e0aee57c4 100644 >--- a/Source/WebKit/UIProcess/UserMediaPermissionCheckProxy.h >+++ b/Source/WebKit/UIProcess/UserMediaPermissionCheckProxy.h >@@ -46,6 +46,7 @@ public: > return adoptRef(*new UserMediaPermissionCheckProxy(frameID, WTFMove(handler), WTFMove(userMediaDocumentOrigin), WTFMove(topLevelDocumentOrigin))); > } > >+ void deny() { setUserMediaAccessInfo(false); } > void setUserMediaAccessInfo(bool); > void invalidate(); > >diff --git a/Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.cpp b/Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.cpp >index 7f17b2d3d57b8f8e5c56a3666ff2b7bb9ed6e856..78cd0c691068181baa9ad6d0be3f0b10fc44b682 100644 >--- a/Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.cpp >+++ b/Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.cpp >@@ -378,8 +378,16 @@ void UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame( > return; > } > >- if (!m_page.uiClient().decidePolicyForUserMediaPermissionRequest(m_page, *m_page.process().webFrame(frameID), WTFMove(userMediaOrigin), WTFMove(topLevelOrigin), pendingRequest.get())) >- userMediaAccessWasDenied(userMediaID, UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::UserMediaDisabled); >+ // If page navigated, there is no need to call the page client for authorization. >+ auto* webFrame = m_page.process().webFrame(frameID); >+ >+ if (!webFrame || !SecurityOrigin::createFromString(m_page.pageLoadState().activeURL())->isSameSchemeHostPort(topLevelOrigin->securityOrigin())) { >+ denyRequest(userMediaID, UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::NoConstraints, emptyString()); >+ return; >+ } >+ >+ // FIXME: Remove webFrame, userMediaOrigin and topLevelOrigin from this uiClient API call. >+ m_page.uiClient().decidePolicyForUserMediaPermissionRequest(m_page, *webFrame, WTFMove(userMediaOrigin), WTFMove(topLevelOrigin), pendingRequest.get()); > }; > > auto requestID = generateRequestID(); >@@ -412,15 +420,19 @@ void UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame( > #if ENABLE(MEDIA_STREAM) > void UserMediaPermissionRequestManagerProxy::getUserMediaPermissionInfo(uint64_t requestID, uint64_t frameID, UserMediaPermissionCheckProxy::CompletionHandler&& handler, Ref<SecurityOrigin>&& userMediaDocumentOrigin, Ref<SecurityOrigin>&& topLevelDocumentOrigin) > { >+ auto* webFrame = m_page.process().webFrame(frameID); >+ if (!webFrame || !SecurityOrigin::createFromString(m_page.pageLoadState().activeURL())->isSameSchemeHostPort(topLevelDocumentOrigin.get())) { >+ handler(false); >+ return; >+ } >+ > auto userMediaOrigin = API::SecurityOrigin::create(userMediaDocumentOrigin.get()); > auto topLevelOrigin = API::SecurityOrigin::create(topLevelDocumentOrigin.get()); > auto request = UserMediaPermissionCheckProxy::create(frameID, WTFMove(handler), WTFMove(userMediaDocumentOrigin), WTFMove(topLevelDocumentOrigin)); > > m_pendingDeviceRequests.add(requestID, request.copyRef()); >- if (!m_page.uiClient().checkUserMediaPermissionForOrigin(m_page, *m_page.process().webFrame(frameID), userMediaOrigin.get(), topLevelOrigin.get(), request.get())) { >- m_pendingDeviceRequests.take(requestID); >- handler(false); >- } >+ // FIXME: Remove webFrame, userMediaOrigin and topLevelOrigin from this uiClient API call. >+ m_page.uiClient().checkUserMediaPermissionForOrigin(m_page, *webFrame, userMediaOrigin.get(), topLevelOrigin.get(), request.get()); > } > > bool UserMediaPermissionRequestManagerProxy::wasGrantedVideoOrAudioAccess(uint64_t frameID, const SecurityOrigin& userMediaDocumentOrigin, const SecurityOrigin& topLevelDocumentOrigin) >diff --git a/Source/WebKit/UIProcess/UserMediaPermissionRequestProxy.h b/Source/WebKit/UIProcess/UserMediaPermissionRequestProxy.h >index 5980dc709a00285d0aa8e735cd308197c9118bdb..ac805e788be2317e0a7aaeb718909cf45bca8908 100644 >--- a/Source/WebKit/UIProcess/UserMediaPermissionRequestProxy.h >+++ b/Source/WebKit/UIProcess/UserMediaPermissionRequestProxy.h >@@ -45,7 +45,7 @@ public: > void allow(); > > enum class UserMediaAccessDenialReason { NoConstraints, UserMediaDisabled, NoCaptureDevices, InvalidConstraint, HardwareError, PermissionDenied, OtherFailure }; >- void deny(UserMediaAccessDenialReason); >+ void deny(UserMediaAccessDenialReason = UserMediaAccessDenialReason::UserMediaDisabled); > > void invalidate(); > >diff --git a/Source/WebKit/WebKit.xcodeproj/project.pbxproj b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >index e3374e70942aa57682e7977a5ae252b55e25b138..a08ccfdc5f5897dee15f3bc87fbc1d39ce4cf66c 100644 >--- a/Source/WebKit/WebKit.xcodeproj/project.pbxproj >+++ b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >@@ -2977,6 +2977,8 @@ > 410482CB1DDD2FB500F006D0 /* RTCNetwork.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RTCNetwork.cpp; sourceTree = "<group>"; }; > 410482CC1DDD2FB500F006D0 /* RTCNetwork.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCNetwork.h; sourceTree = "<group>"; }; > 4111436320F677B10026F912 /* InjectUserScriptImmediately.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectUserScriptImmediately.h; sourceTree = "<group>"; }; >+ 411286EF21C8A90C003A8550 /* MediaCaptureUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaCaptureUtilities.h; sourceTree = "<group>"; }; >+ 411286F021C8A90D003A8550 /* MediaCaptureUtilities.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaCaptureUtilities.mm; sourceTree = "<group>"; }; > 4112B5471F9FD3AB00E67875 /* NetworkRTCResolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkRTCResolver.cpp; sourceTree = "<group>"; }; > 4112B5471F9FD3AB00E67986 /* NetworkRTCResolverCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkRTCResolverCocoa.cpp; sourceTree = "<group>"; }; > 4112B5481F9FD3AC00E67875 /* NetworkRTCResolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkRTCResolver.h; sourceTree = "<group>"; }; >@@ -4836,13 +4838,13 @@ > children = ( > 1A4832C01A965A33008B4DFE /* Cocoa */, > 4118DC1C21E6D35B00DE04C7 /* DataStoreQuotaManager.h */, >- 4118DC1B21E6D11A00DE04C7 /* WebsiteDataStoreQuotaManager.h */, > 1A4832D81A9D1FD2008B4DFE /* WebsiteDataRecord.cpp */, > 1A4832CF1A9BD821008B4DFE /* WebsiteDataRecord.h */, > 1A53C2A41A32569F004E8C70 /* WebsiteDataStore.cpp */, > 1A53C2A51A32569F004E8C70 /* WebsiteDataStore.h */, > 5C46C0AC21B7198B00BC5991 /* WebsiteDataStoreConfiguration.cpp */, > 5C46C0AD21B7198C00BC5991 /* WebsiteDataStoreConfiguration.h */, >+ 4118DC1B21E6D11A00DE04C7 /* WebsiteDataStoreQuotaManager.h */, > ); > path = WebsiteData; > sourceTree = "<group>"; >@@ -5282,6 +5284,8 @@ > 51C0C9731DDD74F00032CAD3 /* IconLoadingDelegate.mm */, > 7A821F4B1E2F664800604577 /* LegacyCustomProtocolManagerClient.h */, > 7A821F4D1E2F679E00604577 /* LegacyCustomProtocolManagerClient.mm */, >+ 411286EF21C8A90C003A8550 /* MediaCaptureUtilities.h */, >+ 411286F021C8A90D003A8550 /* MediaCaptureUtilities.mm */, > 1ABC3DF41899E437004F0626 /* NavigationState.h */, > 1ABC3DF31899E437004F0626 /* NavigationState.mm */, > 5C6CE6D31F59EA350007C6CB /* PageClientImplCocoa.h */, >@@ -9822,6 +9826,7 @@ > 1DB01943211CF002009FB3E8 /* WKShareSheet.h in Headers */, > 513E462D1AD837560016234A /* WKSharingServicePickerDelegate.h in Headers */, > 93F549B41E3174B7000E7239 /* WKSnapshotConfiguration.h in Headers */, >+ 4118DC1F21E7BF5D00DE04C7 /* WKStorageQuotaDelegatePrivate.h in Headers */, > BC407606124FF0270068F20A /* WKString.h in Headers */, > BC40761A124FF0370068F20A /* WKStringCF.h in Headers */, > BC9099801256A98200083756 /* WKStringPrivate.h in Headers */, >@@ -9894,7 +9899,6 @@ > 1F7506B51859165400EC0FF7 /* WKWebProcessPlugInScriptWorldInternal.h in Headers */, > 1A4832CC1A9BC465008B4DFE /* WKWebsiteDataRecord.h in Headers */, > 1A4832CE1A9BC484008B4DFE /* WKWebsiteDataRecordInternal.h in Headers */, >- 4118DC1F21E7BF5D00DE04C7 /* WKStorageQuotaDelegatePrivate.h in Headers */, > 1AA654D11B14F71400BF1D3E /* WKWebsiteDataRecordPrivate.h in Headers */, > 75A8D2C8187CCFAB00C39C9E /* WKWebsiteDataStore.h in Headers */, > 75A8D2D6187D1C0E00C39C9E /* WKWebsiteDataStoreInternal.h in Headers */, >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 9b32562831308fb95e3e9ab32826da9ae92ae776..a8bc6cbca28b8e40f848faed9fe635e111fed4b4 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,26 @@ >+2019-01-16 Youenn Fablet <youenn@apple.com> >+ >+ Add a new SPI for controlling getUserMedia >+ https://bugs.webkit.org/show_bug.cgi?id=192793 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * MiniBrowser/mac/WK2BrowserWindowController.m: >+ (-[WK2BrowserWindowController _webView:requestUserMediaAuthorizationForFrame:devices:decisionHandler:]): >+ (-[WK2BrowserWindowController _webView:isMediaCaptureAuthorizedForFrame:decisionHandler:]): >+ * TestWebKitAPI/Tests/WebKit/GetUserMediaNavigation.mm: >+ (-[NavigationWhileGetUserMediaPromptDisplayedUIDelegate _webView:requestMediaCaptureAuthorizationForFrame:devices:decisionHandler:]): >+ * TestWebKitAPI/Tests/WebKit/GetUserMediaReprompt.mm: >+ (-[GetUserMediaRepromptUIDelegate _webView:requestMediaCaptureAuthorizationForFrame:devices:decisionHandler:]): >+ * TestWebKitAPI/Tests/WebKit/MediaStreamTrackDetached.mm: >+ (-[MediaStreamTrackDetachedUIDelegate _webView:requestMediaCaptureAuthorizationForFrame:devices:decisionHandler:]): >+ * TestWebKitAPI/Tests/WebKitCocoa/UserMediaDisabled.mm: >+ (-[UserMediaUIDelegate _webView:requestMediaCaptureAuthorizationForFrame:devices:decisionHandler:]): >+ (-[UserMediaUIDelegate _webView:isMediaCaptureAuthorizedForFrame:decisionHandler:]): >+ * TestWebKitAPI/Tests/WebKitCocoa/UserMediaSimulateFailedSandbox.mm: >+ (-[SimulateFailedSandboxUIDelegate _webView:requestMediaCaptureAuthorizationForFrame:devices:decisionHandler:]): >+ (-[SimulateFailedSandboxUIDelegate _webView:isMediaCaptureAuthorizedForFrame:decisionHandler:]): >+ > 2019-01-16 Youenn Fablet <youenn@apple.com> > > Add a new SPI to request for cache storage quota increase >diff --git a/Tools/MiniBrowser/mac/WK2BrowserWindowController.m b/Tools/MiniBrowser/mac/WK2BrowserWindowController.m >index 3d3b7f3fdbe3371c25958e5ea7182027b60695ac..e9d4152ef64c478b56aa983fdaa176f83cdf9f45 100644 >--- a/Tools/MiniBrowser/mac/WK2BrowserWindowController.m >+++ b/Tools/MiniBrowser/mac/WK2BrowserWindowController.m >@@ -791,14 +791,14 @@ - (void)findBarViewDidChangeHeight > { > } > >-- (void)_webView:(WKWebView *)webView requestUserMediaAuthorizationForDevices:(_WKCaptureDevices)devices url:(NSURL *)url mainFrameURL:(NSURL *)mainFrameURL decisionHandler:(void (^)(BOOL authorized))decisionHandler >+- (void)_webView:(WKWebView *)webView requestMediaCaptureAuthorization: (_WKCaptureDevices)devices decisionHandler:(void (^)(BOOL authorized))decisionHandler > { > decisionHandler(true); > } > >-- (void)_webView:(WKWebView *)webView checkUserMediaPermissionForURL:(NSURL *)url mainFrameURL:(NSURL *)mainFrameURL frameIdentifier:(NSUInteger)frameIdentifier decisionHandler:(void (^)(NSString *salt, BOOL authorized))decisionHandler >+- (void)_webView:(WKWebView *)webView includeSensitiveMediaDeviceDetails:(void (^)(BOOL includeSensitiveDetails))decisionHandler > { >- decisionHandler(@"", false); >+ decisionHandler(false); > } > > @end >diff --git a/Tools/TestWebKitAPI/Tests/WebKit/GetUserMediaNavigation.mm b/Tools/TestWebKitAPI/Tests/WebKit/GetUserMediaNavigation.mm >index 421eea4292cbab14e946f798a35deb73f82b3508..ce3a438ea7667c6de5a5f5e0093a109825647a6b 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKit/GetUserMediaNavigation.mm >+++ b/Tools/TestWebKitAPI/Tests/WebKit/GetUserMediaNavigation.mm >@@ -42,12 +42,12 @@ static bool okToProceed = false; > static bool shouldReleaseInEnumerate = false; > > @interface NavigationWhileGetUserMediaPromptDisplayedUIDelegate : NSObject<WKUIDelegate> >-- (void)_webView:(WKWebView *)webView requestUserMediaAuthorizationForDevices:(_WKCaptureDevices)devices url:(NSURL *)url mainFrameURL:(NSURL *)mainFrameURL decisionHandler:(void (^)(BOOL authorized))decisionHandler; >+- (void)_webView:(WKWebView *)webView requestMediaCaptureAuthorization: (_WKCaptureDevices)devices decisionHandler:(void (^)(BOOL))decisionHandler; > - (void)_webView:(WKWebView *)webView checkUserMediaPermissionForURL:(NSURL *)url mainFrameURL:(NSURL *)mainFrameURL frameIdentifier:(NSUInteger)frameIdentifier decisionHandler:(void (^)(NSString *salt, BOOL authorized))decisionHandler; > @end > > @implementation NavigationWhileGetUserMediaPromptDisplayedUIDelegate >-- (void)_webView:(WKWebView *)webView requestUserMediaAuthorizationForDevices:(_WKCaptureDevices)devices url:(NSURL *)url mainFrameURL:(NSURL *)mainFrameURL decisionHandler:(void (^)(BOOL authorized))decisionHandler >+- (void)_webView:(WKWebView *)webView requestMediaCaptureAuthorization: (_WKCaptureDevices)devices decisionHandler:(void (^)(BOOL))decisionHandler > { > [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]]]; > [webView release]; >diff --git a/Tools/TestWebKitAPI/Tests/WebKit/GetUserMediaReprompt.mm b/Tools/TestWebKitAPI/Tests/WebKit/GetUserMediaReprompt.mm >index c432fcae5e8fc59791233e50bdbb7532cbac4f7e..fbc3b596db6109799ab50a57255240c07e0e2026 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKit/GetUserMediaReprompt.mm >+++ b/Tools/TestWebKitAPI/Tests/WebKit/GetUserMediaReprompt.mm >@@ -41,12 +41,12 @@ > static bool wasPrompted = false; > > @interface GetUserMediaRepromptUIDelegate : NSObject<WKUIDelegate> >-- (void)_webView:(WKWebView *)webView requestUserMediaAuthorizationForDevices:(_WKCaptureDevices)devices url:(NSURL *)url mainFrameURL:(NSURL *)mainFrameURL decisionHandler:(void (^)(BOOL authorized))decisionHandler; >+- (void)_webView:(WKWebView *)webView requestMediaCaptureAuthorization: (_WKCaptureDevices)devices decisionHandler:(void (^)(BOOL))decisionHandler; > - (void)_webView:(WKWebView *)webView checkUserMediaPermissionForURL:(NSURL *)url mainFrameURL:(NSURL *)mainFrameURL frameIdentifier:(NSUInteger)frameIdentifier decisionHandler:(void (^)(NSString *salt, BOOL authorized))decisionHandler; > @end > > @implementation GetUserMediaRepromptUIDelegate >-- (void)_webView:(WKWebView *)webView requestUserMediaAuthorizationForDevices:(_WKCaptureDevices)devices url:(NSURL *)url mainFrameURL:(NSURL *)mainFrameURL decisionHandler:(void (^)(BOOL authorized))decisionHandler >+- (void)_webView:(WKWebView *)webView requestMediaCaptureAuthorization: (_WKCaptureDevices)devices decisionHandler:(void (^)(BOOL))decisionHandler > { > wasPrompted = true; > decisionHandler(YES); >diff --git a/Tools/TestWebKitAPI/Tests/WebKit/MediaStreamTrackDetached.mm b/Tools/TestWebKitAPI/Tests/WebKit/MediaStreamTrackDetached.mm >index 1eccd0a6ee331642632d4d5c6df0bbcd02ae2f43..d2cbda806c9afac76760a85b0544803127ccd563 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKit/MediaStreamTrackDetached.mm >+++ b/Tools/TestWebKitAPI/Tests/WebKit/MediaStreamTrackDetached.mm >@@ -40,13 +40,13 @@ > static bool hasRecievedCorrectCaptureState = false; > > @interface MediaStreamTrackDetachedUIDelegate : NSObject<WKUIDelegate> >-- (void)_webView:(WKWebView *)webView requestUserMediaAuthorizationForDevices:(_WKCaptureDevices)devices url:(NSURL *)url mainFrameURL:(NSURL *)mainFrameURL decisionHandler:(void (^)(BOOL authorized))decisionHandler; >+- (void)_webView:(WKWebView *)webView requestMediaCaptureAuthorization: (_WKCaptureDevices)devices decisionHandler:(void (^)(BOOL))decisionHandler; > - (void)_webView:(WKWebView *)webView checkUserMediaPermissionForURL:(NSURL *)url mainFrameURL:(NSURL *)mainFrameURL frameIdentifier:(NSUInteger)frameIdentifier decisionHandler:(void (^)(NSString *salt, BOOL authorized))decisionHandler; > - (void)_webView:(WKWebView *)webView mediaCaptureStateDidChange:(_WKMediaCaptureState)state; > @end > > @implementation MediaStreamTrackDetachedUIDelegate >-- (void)_webView:(WKWebView *)webView requestUserMediaAuthorizationForDevices:(_WKCaptureDevices)devices url:(NSURL *)url mainFrameURL:(NSURL *)mainFrameURL decisionHandler:(void (^)(BOOL authorized))decisionHandler >+- (void)_webView:(WKWebView *)webView requestMediaCaptureAuthorization: (_WKCaptureDevices)devices decisionHandler:(void (^)(BOOL))decisionHandler > { > decisionHandler(YES); > } >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/UserMediaDisabled.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/UserMediaDisabled.mm >index 88333c3fbb680e165e7f261a626e5b1d131b3bab..65d28f28868848f55f3c00721d1909e000540965 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/UserMediaDisabled.mm >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/UserMediaDisabled.mm >@@ -39,7 +39,6 @@ > > #if WK_API_ENABLED > >-static bool refuseRequest = false; > static bool wasPrompted = false; > > static bool receivedScriptMessage = false; >@@ -62,15 +61,10 @@ @end > > @implementation UserMediaUIDelegate > >-- (void)_webView:(WKWebView *)webView requestUserMediaAuthorizationForDevices:(NSUInteger)devices url:(NSURL *)url mainFrameURL:(NSURL *)mainFrameURL decisionHandler:(void (^)(BOOL))decisionHandler >+- (void)_webView:(WKWebView *)webView requestMediaCaptureAuthorization: (_WKCaptureDevices)devices decisionHandler:(void (^)(BOOL))decisionHandler > { > wasPrompted = true; > >- if (refuseRequest) { >- decisionHandler(NO); >- return; >- } >- > BOOL needsMicrophoneAuthorized = devices & _WKCaptureDeviceMicrophone; > BOOL needsCameraAuthorized = devices & _WKCaptureDeviceCamera; > if (!needsMicrophoneAuthorized && !needsCameraAuthorized) { >@@ -81,14 +75,9 @@ - (void)_webView:(WKWebView *)webView requestUserMediaAuthorizationForDevices:(N > decisionHandler(YES); > } > >-- (void)_webView:(WKWebView *)webView checkUserMediaPermissionForURL:(NSURL *)url mainFrameURL:(NSURL *)mainFrameURL frameIdentifier:(NSUInteger)frameIdentifier decisionHandler:(void (^)(NSString *, BOOL))decisionHandler >+- (void)_webView:(WKWebView *)webView includeSensitiveMediaDeviceDetails:(void (^)(BOOL includeSensitiveDetails))decisionHandler > { >- if (refuseRequest) { >- decisionHandler(nil, NO); >- return; >- } >- >- decisionHandler(@"0x987654321", NO); >+ decisionHandler(NO); > } > @end > >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/UserMediaSimulateFailedSandbox.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/UserMediaSimulateFailedSandbox.mm >index c73c98994e417334902552a878def5d17225bdf4..27dce83e4110014a9effbf08b901fb90d266b444 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/UserMediaSimulateFailedSandbox.mm >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/UserMediaSimulateFailedSandbox.mm >@@ -39,7 +39,6 @@ > > #if WK_API_ENABLED > >-static bool refuseRequest = false; > static bool wasPrompted = false; > > static bool receivedScriptMessage = false; >@@ -62,15 +61,10 @@ @end > > @implementation SimulateFailedSandboxUIDelegate > >-- (void)_webView:(WKWebView *)webView requestUserMediaAuthorizationForDevices:(NSUInteger)devices url:(NSURL *)url mainFrameURL:(NSURL *)mainFrameURL decisionHandler:(void (^)(BOOL))decisionHandler >+- (void)_webView:(WKWebView *)webView requestMediaCaptureAuthorization: (_WKCaptureDevices)devices decisionHandler:(void (^)(BOOL))decisionHandler > { > wasPrompted = true; > >- if (refuseRequest) { >- decisionHandler(NO); >- return; >- } >- > BOOL needsMicrophoneAuthorized = devices & _WKCaptureDeviceMicrophone; > BOOL needsCameraAuthorized = devices & _WKCaptureDeviceCamera; > if (!needsMicrophoneAuthorized && !needsCameraAuthorized) { >@@ -81,14 +75,9 @@ - (void)_webView:(WKWebView *)webView requestUserMediaAuthorizationForDevices:(N > decisionHandler(YES); > } > >-- (void)_webView:(WKWebView *)webView checkUserMediaPermissionForURL:(NSURL *)url mainFrameURL:(NSURL *)mainFrameURL frameIdentifier:(NSUInteger)frameIdentifier decisionHandler:(void (^)(NSString *, BOOL))decisionHandler >+- (void)_webView:(WKWebView *)webView includeSensitiveMediaDeviceDetails:(void (^)(BOOL includeSensitiveDetails))decisionHandler > { >- if (refuseRequest) { >- decisionHandler(nil, NO); >- return; >- } >- >- decisionHandler(@"0x987654321", NO); >+ decisionHandler(NO); > } > @end >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 192793
:
357581
|
357590
|
357605
|
357639
|
357729
|
357745
|
357873
|
357885
|
358631
|
358647
|
359296
|
359314
|
359331