[MediaStream] MediaDeviceInfo deviceId and groupId must be unique to the page's origin
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Feb 2016 15:18:21 +0000 (15:18 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Feb 2016 15:18:21 +0000 (15:18 +0000)
commit4ad70900c2b06c36af42e8433bdea58d5a15bfda
tree4293a35f5e671257fc45e9e650fe1d4c086ddcf3
parentc8d6a9ed8a6a8513070e38101deb36e41095ba79
[MediaStream] MediaDeviceInfo deviceId and groupId must be unique to the page's origin
https://bugs.webkit.org/show_bug.cgi?id=153163
<rdar://problem/24334526>

Reviewed by Tim Horton.

Source/WebCore:

Tests: http/tests/media/media-stream/enumerate-devices-source-id-persistent.html
       http/tests/media/media-stream/enumerate-devices-source-id.html

* Modules/mediastream/MediaDevicesRequest.cpp:
(WebCore::MediaDevicesRequest::start): Don't check document.hasHadActiveMediaStreamTrack, do it
  in didCompleteTrackSourceInfoRequest where we need the information.
(WebCore::MediaDevicesRequest::didCompletePermissionCheck): Renamed from didCompleteCheck, save
  device ID hash string.
(WebCore::hashString): Hash a string with SHA1.
(WebCore::MediaDevicesRequest::hashID): Hash and ID.
(WebCore::MediaDevicesRequest::didCompleteTrackSourceInfoRequest): Hash deviceId and groupId.
(WebCore::MediaDevicesRequest::didCompleteCheck): Deleted.
(WebCore::MediaDevicesRequest::getTrackSources): Deleted.
(WebCore::MediaDevicesRequest::didCompleteRequest): Deleted.
* Modules/mediastream/MediaDevicesRequest.h:

* Modules/mediastream/UserMediaPermissionCheck.cpp:
(WebCore::UserMediaPermissionCheck::userMediaDocumentOrigin): Renamed from securityOrigin.
(WebCore::UserMediaPermissionCheck::topLevelDocumentOrigin): New, return the top level document origin.
(WebCore::UserMediaPermissionCheck::setUserMediaAccessInfo): Renamed from setHasPersistentPermission.
(WebCore::UserMediaPermissionCheck::securityOrigin): Deleted.
(WebCore::UserMediaPermissionCheck::setHasPersistentPermission): Deleted.
* Modules/mediastream/UserMediaPermissionCheck.h:

* Modules/mediastream/UserMediaRequest.cpp:
(WebCore::UserMediaRequest::userMediaDocumentOrigin): Renamed from securityOrigin.
(WebCore::UserMediaRequest::topLevelDocumentOrigin): New, return the top level document origin.
(WebCore::UserMediaRequest::securityOrigin): Deleted.
* Modules/mediastream/UserMediaRequest.h:
(WebCore::UserMediaRequest::requiresAudio): Deleted, unused.
(WebCore::UserMediaRequest::requiresVideo): Ditto.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::mediaPlayerMediaDeviceIdentifierStorageDirectory): Deleted, unused.
* html/HTMLMediaElement.h:

* platform/graphics/MediaPlayer.h:
(WebCore::MediaPlayerClient::mediaPlayerMediaDeviceIdentifierStorageDirectory): Deleted.

* platform/mediastream/MediaStreamTrackSourcesRequestClient.h:
(WebCore::MediaStreamTrackSourcesRequestClient::didCompleteTrackSourceInfoRequest): Renamed from didCompleteRequest.

* platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp:
(WebCore::RealtimeMediaSourceCenterMac::getMediaStreamTrackSources): Ditto.

* platform/mock/MockRealtimeMediaSourceCenter.cpp:
(WebCore::MockRealtimeMediaSourceCenter::getMediaStreamTrackSources): Ditto.

Source/WebKit/mac:

* WebCoreSupport/WebUserMediaClient.mm:
(WebUserMediaClient::requestUserMediaAccess):
(WebUserMediaClient::checkUserMediaPermission):
(-[WebUserMediaPolicyCheckerListener allow]):
(-[WebUserMediaPolicyCheckerListener deny]):

Source/WebKit2:

* CMakeLists.txt: Add WKFrameHandleRef.cpp.

* Shared/API/c/WKBase.h: Add WKFrameHandleRef.
* UIProcess/API/APIUIClient.h:
(API::UIClient::decidePolicyForUserMediaPermissionRequest): Add parameter top level document
  security context.
(API::UIClient::checkUserMediaPermissionForOrigin): Ditto.

* UIProcess/API/C/WKAPICast.h: Add FrameHandle.

* UIProcess/API/C/WKFrameHandleRef.cpp: Added.
* UIProcess/API/C/WKFrameHandleRef.h: Added.

* UIProcess/API/C/WKFrameInfoRef.cpp:
(WKFrameInfoGetFrameHandleRef): Added.
* UIProcess/API/C/WKFrameInfoRef.h:

* UIProcess/API/C/WKPage.cpp:
(WKPageSetPageUIClient): Add parameters to decidePolicyForUserMediaPermissionRequest and
  checkUserMediaPermissionForOrigin for top level document security context.

* UIProcess/API/C/WKPageUIClient.h: Ditto.

* UIProcess/API/C/WKUserMediaPermissionCheck.cpp:
(WKUserMediaPermissionCheckSetUserMediaAccessInfo): Renamed from WKUserMediaPermissionCheckSetHasPersistentPermission,
  add parameter for top level document security context.
(WKUserMediaPermissionCheckSetHasPersistentPermission): Deleted.
* UIProcess/API/C/WKUserMediaPermissionCheck.h:

* UIProcess/API/gtk/WebKitUserMediaPermissionRequest.cpp:
(webkitUserMediaPermissionRequestCreate): Add top level document origin.

* UIProcess/UserMediaPermissionCheckProxy.cpp:
(WebKit::UserMediaPermissionCheckProxy::setUserMediaAccessInfo): Renamed from setHasPersistentPermission.
(WebKit::UserMediaPermissionCheckProxy::setHasPersistentPermission): Deleted.
* UIProcess/UserMediaPermissionCheckProxy.h:

* UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
(WebKit::UserMediaPermissionRequestManagerProxy::didCompleteUserMediaPermissionCheck): Add parameter
 for device id hash salt.
* UIProcess/UserMediaPermissionRequestManagerProxy.h:

* UIProcess/UserMediaPermissionRequestProxy.h:
(WebKit::UserMediaPermissionRequestProxy::requiresAudio): Deleted, unused.
(WebKit::UserMediaPermissionRequestProxy::requiresVideo): Ditto.
(WebKit::UserMediaPermissionRequestProxy::firstVideoDeviceUID): Ditto.
(WebKit::UserMediaPermissionRequestProxy::firstAudioDeviceUID): Ditto.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::requestUserMediaPermissionForFrame): Pass through parameter for top
  level document security context.
(WebKit::WebPageProxy::checkUserMediaPermissionForFrame): Ditto.
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:

* WebKit2.xcodeproj/project.pbxproj: Add WKFrameHandleRef.cpp|.h.

* WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp:
(WebKit::UserMediaPermissionRequestManager::startUserMediaRequest): Pass through parameter for top
  level document security context.
(WebKit::UserMediaPermissionRequestManager::startUserMediaPermissionCheck): Ditto.
(WebKit::UserMediaPermissionRequestManager::didCompleteUserMediaPermissionCheck): Pass through
  device id hash salt.
* WebProcess/MediaStream/UserMediaPermissionRequestManager.h:

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::didCompleteUserMediaPermissionCheck): Ditto.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

Tools:

* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::setUserMediaPermissionForOrigin): Take top level document origin.
* WebKitTestRunner/InjectedBundle/InjectedBundle.h:

* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setUserMediaPermissionForOrigin): Ditto.
* WebKitTestRunner/InjectedBundle/TestRunner.h:

* WebKitTestRunner/TestController.cpp:
(WTR::decidePolicyForUserMediaPermissionRequest): Pass through top level document origin.
(WTR::checkUserMediaPermissionForOrigin): Ditto.
(WTR::TestController::resetStateToConsistentValues): m_userMediaOriginPermissions -> m_cahcedUserMediaPermissions.
(WTR::originUserVisibleName): Return a String.
(WTR::userMediaOriginHash): Create a hash of the origin plus top level document origin.
(WTR::TestController::saltForOrigin): Return salt for an origin.
(WTR::TestController::setUserMediaPermissionForOrigin): Return permission for an origin.
(WTR::TestController::handleCheckOfUserMediaPermissionForOrigin):
(WTR::TestController::handleUserMediaPermissionRequest):
(WTR::TestController::decidePolicyForUserMediaPermissionRequestIfPossible):
(WTR::OriginSettings::OriginSettings): New, class to cache settings for an origin.
(WTR::OriginSettings::persistentPermission): Persistent permissions for origin.
(WTR::OriginSettings::setPersistentPermission): Set permissions for origin.
(WTR::OriginSettings::persistentSalt): Return the persistent salt for the origin, if any.
(WTR::OriginSettings::setPersistentSalt): Set the persistent salt for the origin
(WTR::OriginSettings::ephemeralSalts): Return hashmap used to store per-frame salts.
* WebKitTestRunner/TestController.h:

* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):

LayoutTests:

* fast/mediastream/MediaDevices-enumerateDevices-expected.txt:
* fast/mediastream/MediaDevices-enumerateDevices.html:
* http/tests/media/media-stream/enumerate-devices-source-id-expected.txt: Added.
* http/tests/media/media-stream/enumerate-devices-source-id-persistent-expected.txt: Added.
* http/tests/media/media-stream/enumerate-devices-source-id-persistent.html: Added.
* http/tests/media/media-stream/enumerate-devices-source-id.html: Added.
* http/tests/media/media-stream/resources/enumerate-devices-source-id-frame.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@197114 268f45cc-cd09-0410-ab3c-d52691b4dbfc
62 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/mediastream/MediaDevices-enumerateDevices-expected.txt
LayoutTests/fast/mediastream/MediaDevices-enumerateDevices.html
LayoutTests/http/tests/media/media-stream/enumerate-devices-source-id-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/media/media-stream/enumerate-devices-source-id-persistent-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/media/media-stream/enumerate-devices-source-id-persistent.html [new file with mode: 0644]
LayoutTests/http/tests/media/media-stream/enumerate-devices-source-id.html [new file with mode: 0644]
LayoutTests/http/tests/media/media-stream/resources/enumerate-devices-source-id-frame.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/MediaDevicesRequest.cpp
Source/WebCore/Modules/mediastream/MediaDevicesRequest.h
Source/WebCore/Modules/mediastream/UserMediaPermissionCheck.cpp
Source/WebCore/Modules/mediastream/UserMediaPermissionCheck.h
Source/WebCore/Modules/mediastream/UserMediaRequest.cpp
Source/WebCore/Modules/mediastream/UserMediaRequest.h
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/platform/graphics/MediaPlayer.h
Source/WebCore/platform/mediastream/MediaStreamTrackSourcesRequestClient.h
Source/WebCore/platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp
Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebUserMediaClient.mm
Source/WebKit2/CMakeLists.txt
Source/WebKit2/ChangeLog
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/WKFrameHandleRef.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/C/WKFrameHandleRef.h [new file with mode: 0644]
Source/WebKit2/UIProcess/API/C/WKFrameInfoRef.cpp
Source/WebKit2/UIProcess/API/C/WKFrameInfoRef.h
Source/WebKit2/UIProcess/API/C/WKPage.cpp
Source/WebKit2/UIProcess/API/C/WKPageUIClient.h
Source/WebKit2/UIProcess/API/C/WKUserMediaPermissionCheck.cpp
Source/WebKit2/UIProcess/API/C/WKUserMediaPermissionCheck.h
Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitUserMediaPermissionRequest.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitUserMediaPermissionRequestPrivate.h
Source/WebKit2/UIProcess/UserMediaPermissionCheckProxy.cpp
Source/WebKit2/UIProcess/UserMediaPermissionCheckProxy.h
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/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h
Tools/WebKitTestRunner/TestInvocation.cpp