Add a new SPI for controlling getUserMedia
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Jan 2019 01:18:05 +0000 (01:18 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Jan 2019 01:18:05 +0000 (01:18 +0000)
commit12df665aef68ba3821618c7595d5e93b80f8921d
tree22dcb3d3849b7c77cb60f19ce1fe9fc1e22b705f
parentc99919794f594bbbab4c0c6dc2a58e2865f809bf
Add a new SPI for controlling getUserMedia
https://bugs.webkit.org/show_bug.cgi?id=192793

Reviewed by Eric Carlson.

Source/WebKit:

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:

Tools:

* 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:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240100 268f45cc-cd09-0410-ab3c-d52691b4dbfc
23 files changed:
Source/WebKit/ChangeLog
Source/WebKit/SourcesCocoa.txt
Source/WebKit/UIProcess/API/APIUIClient.h
Source/WebKit/UIProcess/API/C/WKPage.cpp
Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h
Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp
Source/WebKit/UIProcess/Cocoa/MediaCaptureUtilities.h [new file with mode: 0644]
Source/WebKit/UIProcess/Cocoa/MediaCaptureUtilities.mm [new file with mode: 0644]
Source/WebKit/UIProcess/Cocoa/UIDelegate.h
Source/WebKit/UIProcess/Cocoa/UIDelegate.mm
Source/WebKit/UIProcess/UserMediaPermissionCheckProxy.h
Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.cpp
Source/WebKit/UIProcess/UserMediaPermissionRequestProxy.h
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Tools/ChangeLog
Tools/MiniBrowser/mac/WK2BrowserWindowController.m
Tools/TestWebKitAPI/Tests/WebKit/GetUserMediaNavigation.mm
Tools/TestWebKitAPI/Tests/WebKit/GetUserMediaReprompt.mm
Tools/TestWebKitAPI/Tests/WebKit/MediaStreamTrackDetached.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/UserMediaDisabled.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/UserMediaSimulateFailedSandbox.mm