[MediaStream] Expose media capture devices persistent permissions to WebCore
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Dec 2015 04:06:05 +0000 (04:06 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Dec 2015 04:06:05 +0000 (04:06 +0000)
commit625d3b87e3991be208eb3ca60857f649568d1aae
tree085142fc62b5e5a0f82fd2c0b25e4836cb90b478
parent3750b51361cfce8dde6cb4267362c5d200db3ca3
[MediaStream] Expose media capture devices persistent permissions to WebCore
https://bugs.webkit.org/show_bug.cgi?id=152087

Source/WebCore:

Reviewed by Chris Dumez.

No new tests, an existing test was updated to test the change.

* CMakeLists.txt: Add UserMediaPermissionCheck.cpp.

* Modules/mediastream/MediaDevicesRequest.cpp:
(WebCore::MediaDevicesRequest::~MediaDevicesRequest): Clear the permission checker client.
(WebCore::MediaDevicesRequest::contextDestroyed): Ditto.
(WebCore::MediaDevicesRequest::start): Create a permission checker and start it running.
(WebCore::MediaDevicesRequest::didCompleteCheck): Start the media source checker.
(WebCore::MediaDevicesRequest::didCompleteRequest): Only include a track's label if the
  page has permission to use a capture device.
* Modules/mediastream/MediaDevicesRequest.h:

* Modules/mediastream/UserMediaClient.h: Include prototypes for permission checker.
(WebCore::UserMediaClient::~UserMediaClient):

* Modules/mediastream/MediaStreamTrackSourcesRequest.cpp: Removed, not longer used.
* Modules/mediastream/MediaStreamTrackSourcesRequest.h:

* Modules/mediastream/UserMediaController.h:
(WebCore::UserMediaController::checkUserMediaPermission): New.
(WebCore::UserMediaController::cancelUserMediaPermissionCheck): Ditto.

* Modules/mediastream/UserMediaPermissionCheck.cpp: Added.
(WebCore::UserMediaPermissionCheck::create):
(WebCore::UserMediaPermissionCheck::UserMediaPermissionCheck):
(WebCore::UserMediaPermissionCheck::~UserMediaPermissionCheck):
(WebCore::UserMediaPermissionCheck::securityOrigin):
(WebCore::UserMediaPermissionCheck::contextDestroyed):
(WebCore::UserMediaPermissionCheck::start):
(WebCore::UserMediaPermissionCheck::setDeviceAccessMode):
* Modules/mediastream/UserMediaPermissionCheck.h: Added.
(WebCore::UserMediaPermissionCheckClient::~UserMediaPermissionCheckClient):
(WebCore::UserMediaPermissionCheck::setClient):

* WebCore.xcodeproj/project.pbxproj: Add UserMediaPermissionCheck.cpp|.h

* platform/mock/UserMediaClientMock.h: Removed, it is no longer used.

* testing/Internals.cpp: Remove UserMediaClientMock.h include, it is gone.

Source/WebKit/mac:

Reviewed by Chris Dumez.

Add methods and helpers for WK1 permission checker interface.
* WebCoreSupport/WebUserMediaClient.h:
* WebCoreSupport/WebUserMediaClient.mm:
(userMediaRequestsMap):
(AddRequestToRequestMap):
(RemoveRequestFromRequestMap):
(userMediaCheckMap):
(AddPermissionCheckToMap):
(RemovePermissionCheckFromMap):
(WebUserMediaClient::WebUserMediaClient):
(WebUserMediaClient::requestUserMediaAccess):
(WebUserMediaClient::cancelUserMediaAccessRequest):
(WebUserMediaClient::checkUserMediaPermission):
(WebUserMediaClient::cancelUserMediaPermissionCheck):
(-[WebUserMediaPolicyListener allow]):
(-[WebUserMediaPolicyListener deny]):
(-[WebUserMediaPolicyCheckerListener initWithUserMediaPermissionCheck:]):
(-[WebUserMediaPolicyCheckerListener cancelUserMediaPermissionCheck]):
(-[WebUserMediaPolicyCheckerListener allow]):
(-[WebUserMediaPolicyCheckerListener deny]):
(-[WebUserMediaPolicyCheckerListener denyOnlyThisRequest]):
(-[WebUserMediaPolicyCheckerListener shouldClearCache]):
(AddRequestToMap): Deleted.
(RemoveRequestFromMap): Deleted.
* WebView/WebUIDelegatePrivate.h:

Source/WebKit2:

Reviewed by Chris Dumez.

* CMakeLists.txt: Add UserMediaPermissionCheckProxy.cpp and WKUserMediaPermissionCheck.cpp.

* Shared/API/APIObject.h: Define UserMediaPermissionCheck.

* Shared/API/c/WKBase.h: Add WKUserMediaPermissionCheckRef typedef.

* UIProcess/API/APIUIClient.h:
(API::UIClient::checkUserMediaPermissionForOrigin): New.

* UIProcess/API/C/WKAPICast.h: Add WKUserMediaPermissionCheckRef/UserMediaPermissionCheckProxy mapping.

* UIProcess/API/C/WKPage.cpp:
(WKPageSetPageUIClient): Implement checkUserMediaPermissionForOrigin.

* UIProcess/API/C/WKPageUIClient.h: Add WKCheckUserMediaPermissionCallback typedef and add
  checkUserMediaPermissionForOrigin to WKPageUIClientV6.

* UIProcess/API/C/WKUserMediaPermissionCheck.cpp: Added.
(WKUserMediaPermissionCheckGetTypeID):
(WKUserMediaPermissionCheckSetHasPermission):

* UIProcess/API/C/WKUserMediaPermissionCheck.h: Added.

* UIProcess/UserMediaPermissionCheckProxy.cpp: Added.
(WebKit::UserMediaPermissionCheckProxy::UserMediaPermissionCheckProxy):
(WebKit::UserMediaPermissionCheckProxy::setHasPermission):
(WebKit::UserMediaPermissionCheckProxy::invalidate):
* UIProcess/UserMediaPermissionCheckProxy.h: Added.
(WebKit::UserMediaPermissionCheckProxy::create):
* UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
(WebKit::UserMediaPermissionRequestManagerProxy::invalidateRequests):
(WebKit::UserMediaPermissionRequestManagerProxy::createRequest):
(WebKit::UserMediaPermissionRequestManagerProxy::didReceiveUserMediaPermissionDecision):
(WebKit::UserMediaPermissionRequestManagerProxy::createUserMediaPermissionCheck):
(WebKit::UserMediaPermissionRequestManagerProxy::didCompleteUserMediaPermissionCheck):
* UIProcess/UserMediaPermissionRequestManagerProxy.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::requestUserMediaPermissionForFrame):
(WebKit::WebPageProxy::checkUserMediaPermissionForFrame):
(WebKit::WebPageProxy::requestNotificationPermission):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:

* WebKit2.xcodeproj/project.pbxproj: Add UserMediaPermissionCheckProxy.*, and WKUserMediaPermissionCheck.*.

* WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp:
(WebKit::UserMediaPermissionRequestManager::startUserMediaRequest): Renamed from startRequest.
(WebKit::UserMediaPermissionRequestManager::cancelUserMediaRequest): Renamed from cancelRequest.
(WebKit::UserMediaPermissionRequestManager::didReceiveUserMediaPermissionDecision): m_requestToIDMap ->
  m_userMediaRequestToIDMap.remove.
(WebKit::UserMediaPermissionRequestManager::startUserMediaPermissionCheck): New, start the request.
(WebKit::UserMediaPermissionRequestManager::cancelUserMediaPermissionCheck): New, cancel
  the request.
(WebKit::UserMediaPermissionRequestManager::didCompleteUserMediaPermissionCheck): New,
  all the request completion method.
(WebKit::UserMediaPermissionRequestManager::startRequest): Deleted.
(WebKit::UserMediaPermissionRequestManager::cancelRequest): Deleted.
* WebProcess/MediaStream/UserMediaPermissionRequestManager.h:

* WebProcess/WebCoreSupport/WebUserMediaClient.cpp:
(WebKit::WebUserMediaClient::requestUserMediaAccess): startRequest -> startUserMediaRequest.
(WebKit::WebUserMediaClient::cancelUserMediaAccessRequest): cancelRequest -> cancelUserMediaRequest.
(WebKit::WebUserMediaClient::checkUserMediaPermission): New.
(WebKit::WebUserMediaClient::cancelUserMediaPermissionCheck): New.
* WebProcess/WebCoreSupport/WebUserMediaClient.h:

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::didCompleteUserMediaPermissionCheck): New.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in: Add DidCompleteUserMediaPermissionCheck.

Tools:

Add support for the new user media permission checker page UI client method.

Reviewed by Chris Dumez.

* WebKitTestRunner/TestController.cpp:
(WTR::decidePolicyForUserMediaPermissionRequest):
(WTR::checkUserMediaPermissionForOrigin):
(WTR::TestController::createOtherPage): Add checkUserMediaPermissionForOrigin.
(WTR::TestController::createWebViewWithOptions): Ditto.
(WTR::TestController::resetStateToConsistentValues): Clear m_userMediaOriginPermissions.
(WTR::originUserVisibleName): New, create a string for the origin.
(WTR::TestController::handleCheckOfUserMediaPermissionForOrigin): Set the WKUserMediaPermissionCheckRef
  according to the state of the origin permission map.
(WTR::TestController::handleUserMediaPermissionRequest): Remember both the origin and the
  request so we can update the origin permission map in decidePolicyForUserMediaPermissionRequestIfPossible.
(WTR::TestController::decidePolicyForUserMediaPermissionRequestIfPossible): Update the
  origin permission map.
* WebKitTestRunner/TestController.h:

LayoutTests:

Reviewed by Chris Dumez.

* fast/mediastream/MediaDevices-enumerateDevices-expected.txt:
* fast/mediastream/MediaDevices-enumerateDevices.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@193944 268f45cc-cd09-0410-ab3c-d52691b4dbfc
49 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/mediastream/MediaDevices-enumerateDevices-expected.txt
LayoutTests/fast/mediastream/MediaDevices-enumerateDevices.html
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/MediaDevicesRequest.cpp
Source/WebCore/Modules/mediastream/MediaDevicesRequest.h
Source/WebCore/Modules/mediastream/MediaStreamTrackSourcesRequest.cpp [deleted file]
Source/WebCore/Modules/mediastream/MediaStreamTrackSourcesRequest.h [deleted file]
Source/WebCore/Modules/mediastream/UserMediaClient.h
Source/WebCore/Modules/mediastream/UserMediaController.h
Source/WebCore/Modules/mediastream/UserMediaPermissionCheck.cpp [new file with mode: 0644]
Source/WebCore/Modules/mediastream/UserMediaPermissionCheck.h [new file with mode: 0644]
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/mock/UserMediaClientMock.h [deleted file]
Source/WebCore/testing/Internals.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebUserMediaClient.h
Source/WebKit/mac/WebCoreSupport/WebUserMediaClient.mm
Source/WebKit/mac/WebView/WebUIDelegatePrivate.h
Source/WebKit2/CMakeLists.txt
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/API/APIObject.h
Source/WebKit2/Shared/API/c/WKBase.h
Source/WebKit2/UIProcess/API/APIUIClient.h
Source/WebKit2/UIProcess/API/C/WKAPICast.h
Source/WebKit2/UIProcess/API/C/WKPage.cpp
Source/WebKit2/UIProcess/API/C/WKPageUIClient.h
Source/WebKit2/UIProcess/API/C/WKUserMediaPermissionCheck.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/C/WKUserMediaPermissionCheck.h [new file with mode: 0644]
Source/WebKit2/UIProcess/UserMediaPermissionCheckProxy.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/UserMediaPermissionCheckProxy.h [new file with mode: 0644]
Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.cpp
Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.h
Source/WebKit2/UIProcess/UserMediaPermissionRequestProxy.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp
Source/WebKit2/WebProcess/MediaStream/UserMediaPermissionRequestManager.h
Source/WebKit2/WebProcess/WebCoreSupport/WebUserMediaClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebUserMediaClient.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Tools/ChangeLog
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h