Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Cocoa] Use new screen/window picker API when available
https://bugs.webkit.org/show_bug.cgi?id=251893 rdar://101206117 Reviewed by Jer Noble. * Source/WebCore/Headers.cmake: Add DisplayCapturePromptType.h. * Source/WebCore/WebCore.xcodeproj/project.pbxproj: Ditto. * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: SC_CONTENT_SHARING_SESSION -> SCREEN_CAPTURE_KIT. Add new runtime preference. * Source/WTF/wtf/PlatformHave.h: Remove HAVE_SC_CONTENT_SHARING_SESSION. * Source/WebCore/PAL/pal/mac/ScreenCaptureKitSoftLink.h:SCStreamFrameInfoStatus is always available when ScreenCaptureKit is available. * Source/WebCore/PAL/pal/mac/ScreenCaptureKitSoftLink.mm: * Source/WebCore/PAL/pal/spi/mac/ScreenCaptureKitSPI.h: * Source/WebKit/Shared/Cocoa/WebPreferencesDefaultValuesCocoa.mm: (WebKit::defaultUseSCContentSharingPicker): Initialize to feature flag value. * Source/WebKit/Shared/WebPreferencesDefaultValues.h: * Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp: (WebCore::PlatformMediaSessionManager::setUseSCContentSharingPicker): New preference access. (WebCore::PlatformMediaSessionManager::useSCContentSharingPicker): * Source/WebCore/platform/audio/PlatformMediaSessionManager.h: * Source/WebCore/platform/mediastream/mac/ScreenCaptureKitCaptureSource.h: * Source/WebCore/platform/mediastream/mac/ScreenCaptureKitCaptureSource.mm: Rewrite to not be a direct `SCContentSharingSession` delegate and to not create `SCContentStream` directly, but to do both through the ScreenCaptureKitSharingSessionManager.h. (-[WebCoreScreenCaptureKitHelper stream:didStopWithError:]): (-[WebCoreScreenCaptureKitHelper stream:didOutputSampleBuffer:ofType:]): (WebCore::ScreenCaptureKitCaptureSource::~ScreenCaptureKitCaptureSource): (WebCore::ScreenCaptureKitCaptureSource::stop): (WebCore::ScreenCaptureKitCaptureSource::sessionFailedWithError): (WebCore::ScreenCaptureKitCaptureSource::sessionFilterDidChange): (WebCore::ScreenCaptureKitCaptureSource::sessionStreamDidEnd): (WebCore::ScreenCaptureKitCaptureSource::startContentStream): (WebCore::ScreenCaptureKitCaptureSource::updateStreamConfiguration): (WebCore::ScreenCaptureKitCaptureSource::commitConfiguration): (WebCore::ScreenCaptureKitCaptureSource::streamDidOutputVideoSampleBuffer): (-[WebCoreScreenCaptureKitHelper sessionDidEnd:]): Deleted. (-[WebCoreScreenCaptureKitHelper sessionDidChangeContent:]): Deleted. (-[WebCoreScreenCaptureKitHelper pickerCanceledForSession:]): Deleted. (WebCore::ScreenCaptureKitCaptureSource::streamFailedWithError): Deleted. (WebCore::ScreenCaptureKitCaptureSource::sessionDidChangeContent): Deleted. (WebCore::ScreenCaptureKitCaptureSource::sessionDidEnd): Deleted. (WebCore::findSharableDevice): Deleted. (WebCore::ScreenCaptureKitCaptureSource::findShareableContent): Deleted. (WebCore::ScreenCaptureKitCaptureSource::frameAvailableHandler): Deleted. (WebCore::ScreenCaptureKitCaptureSource::streamDidOutputSampleBuffer): Deleted. * Source/WebCore/platform/mediastream/mac/ScreenCaptureKitSharingSessionManager.h: (WebCore::ScreenCaptureSessionSource::stream const): (WebCore::ScreenCaptureSessionSource::contentFilter const): (WebCore::ScreenCaptureSessionSource::sharingSession const): (WebCore::ScreenCaptureSessionSource::observer const): * Source/WebCore/platform/mediastream/mac/ScreenCaptureKitSharingSessionManager.mm: Don't pass ownership of `SCContentSharingSession` to ScreenCaptureSessionSource, instead pass necessary information through ScreenCaptureSessionSource interface to source. (-[WebDisplayMediaPromptHelper initWithCallback:]): (-[WebDisplayMediaPromptHelper sessionDidEnd:]): (-[WebDisplayMediaPromptHelper sessionDidChangeContent:]): (-[WebDisplayMediaPromptHelper pickerCanceledForSession:]): (-[WebDisplayMediaPromptHelper contentSharingPicker:didSelectFilter:forStream:]): (-[WebDisplayMediaPromptHelper contentSharingPickerDidCancel:forStream:]): (-[WebDisplayMediaPromptHelper contentSharingPickerStartDidFailWithError:]): (-[WebDisplayMediaPromptHelper contentSharingPicker:didRequestNewStreamWithFilter:]): (-[WebDisplayMediaPromptHelper contentSharingPicker:didRequestUpdateWithFilter:forStream:]): (WebCore::ScreenCaptureKitSharingSessionManager::isAvailable): (WebCore::ScreenCaptureKitSharingSessionManager::useSCContentSharingPicker): (WebCore::ScreenCaptureKitSharingSessionManager::~ScreenCaptureKitSharingSessionManager): (WebCore::ScreenCaptureKitSharingSessionManager::cancelPicking): (WebCore::ScreenCaptureKitSharingSessionManager::completeDeviceSelection): (WebCore::ScreenCaptureKitSharingSessionManager::findActiveSource): (WebCore::ScreenCaptureKitSharingSessionManager::sharingSessionDidEnd): (WebCore::ScreenCaptureKitSharingSessionManager::sharingSessionDidChangeContent): (WebCore::ScreenCaptureKitSharingSessionManager::contentSharingPickerSelectedFilterForStream): (WebCore::ScreenCaptureKitSharingSessionManager::contentSharingPickerUpdatedFilterForStream): (WebCore::ScreenCaptureKitSharingSessionManager::promptForGetDisplayMedia): (WebCore::ScreenCaptureKitSharingSessionManager::promptWithSCContentSharingSession): (WebCore::ScreenCaptureKitSharingSessionManager::promptWithSCContentSharingPicker): (WebCore::ScreenCaptureKitSharingSessionManager::contentSharingPickerFailedWithError): (WebCore::operator==): (WebCore::ScreenCaptureKitSharingSessionManager::createSessionSourceForDevice): (WebCore::ScreenCaptureKitSharingSessionManager::cleanupSessionSource): (WebCore::ScreenCaptureSessionSource::create): (WebCore::ScreenCaptureSessionSource::ScreenCaptureSessionSource): (WebCore::ScreenCaptureSessionSource::~ScreenCaptureSessionSource): (WebCore::ScreenCaptureSessionSource::operator== const): (WebCore::screenCaptureKitPickerFeatureEnabled): Deleted. (WebCore::ScreenCaptureKitSharingSessionManager::pickerCanceledForSession): Deleted. (WebCore::ScreenCaptureKitSharingSessionManager::sessionDidEnd): Deleted. (WebCore::ScreenCaptureKitSharingSessionManager::sessionDidChangeContent): Deleted. (WebCore::ScreenCaptureKitSharingSessionManager::showWindowPicker): Deleted. (WebCore::ScreenCaptureKitSharingSessionManager::showScreenPicker): Deleted. (WebCore::ScreenCaptureKitSharingSessionManager::takeSharingSessionForFilter): Deleted. * Source/WebKit/GPUProcess/GPUProcess.cpp: (WebKit::GPUProcess::promptForGetDisplayMedia): Combine showWindowPicker and showScreenPicker. (WebKit::GPUProcess::showWindowPicker): Deleted. (WebKit::GPUProcess::showScreenPicker): Deleted. * Source/WebKit/GPUProcess/GPUProcess.h: * Source/WebKit/GPUProcess/GPUProcess.messages.in: * Source/WebKit/GPUProcess/mac/com.apple.WebKit.GPUProcess.sb.in: * Source/WebKit/UIProcess/Cocoa/UIDelegate.mm: (WebKit::UIDelegate::UIClient::promptForDisplayCapturePermission): Cleanup and simplify. (WebKit::UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest): * Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm: SC_CONTENT_SHARING_SESSION -> SCREEN_CAPTURE_KIT * Source/WebKit/UIProcess/GPU/GPUProcessProxy.cpp: (WebKit::GPUProcessProxy::updateSandboxAccess): Ditto. (WebKit::GPUProcessProxy::promptForGetDisplayMedia): (WebKit::GPUProcessProxy::showWindowPicker): Deleted. (WebKit::GPUProcessProxy::showScreenPicker): Deleted. * Source/WebKit/UIProcess/GPU/GPUProcessProxy.h: * Source/WebKit/UIProcess/UserMediaPermissionRequestProxy.cpp: (WebKit::UserMediaPermissionRequestProxy::promptForGetDisplayMedia): canPromptForGetDisplayMedia -> canRequestDisplayCapturePermission. (WebKit::UserMediaPermissionRequestProxy::doDefaultAction): (WebKit::UserMediaPermissionRequestProxy::canRequestDisplayCapturePermission): Rename from canPromptForGetDisplayMedia. (WebKit::UserMediaPermissionRequestProxy::canPromptForGetDisplayMedia): Deleted. * Source/WebKit/UIProcess/UserMediaPermissionRequestProxy.h: * Source/WebKit/UIProcess/WebPageProxy.cpp: * Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h: * Source/WebKit/UIProcess/API/Cocoa/WKWebViewTesting.mm: (-[WKWebView _setSystemCanPromptForGetDisplayMediaForTesting:]): Simulate when system can and can not prompt for type of display capture. * Source/WebKit/UIProcess/mac/DisplayCaptureSessionManager.h: * Source/WebKit/UIProcess/mac/DisplayCaptureSessionManager.mm: (WebKit::DisplayCaptureSessionManager::showWindowPicker): (WebKit::DisplayCaptureSessionManager::showScreenPicker): (WebKit::DisplayCaptureSessionManager::canRequestDisplayCapturePermission): (WebKit::toScreenCaptureKitPromptType): (WebKit::DisplayCaptureSessionManager::promptForGetDisplayMedia): * Source/WebKit/UIProcess/mac/UserMediaPermissionRequestProxyMac.h: * Source/WebKit/UIProcess/mac/UserMediaPermissionRequestProxyMac.mm: (WebKit::UserMediaPermissionRequestProxyMac::promptForGetDisplayMedia): (WebKit::UserMediaPermissionRequestProxyMac::canRequestDisplayCapturePermission): (WebKit::UserMediaPermissionRequestProxyMac::canPromptForGetDisplayMedia): Deleted. * Source/WebKit/WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::updatePreferences): * Tools/TestWebKitAPI/Tests/WebKitCocoa/GetDisplayMedia.mm: Test when system can and can not prompt for type of capture. (-[GetDisplayMediaUIDelegate _webView:requestDisplayCapturePermissionForOrigin:initiatedByFrame:withSystemAudio:decisionHandler:]): (TestWebKitAPI::GetDisplayMediaTest::promptForCapture): (TestWebKitAPI::TEST_F): (-[GetDisplayMediaUIDelegate _webView:requestUserMediaAuthorizationForDevices:url:mainFrameURL:decisionHandler:]): Deleted. Canonical link: https://commits.webkit.org/261180@main
- Loading branch information