Skip to content
Permalink
Browse files
Unreviewed, rolling out r209008.
This change appears to have caused two fast/mediastrem
LayoutTests to fail.

Reverted changeset:

"[MediaStream] Don't request user permission for a device if
it has already been granted in the current browsing context"
https://bugs.webkit.org/show_bug.cgi?id=164760
http://trac.webkit.org/changeset/209008

Canonical link: https://commits.webkit.org/182729@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209024 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
ryanhaddad committed Nov 28, 2016
1 parent 554bd6d commit 36b4aff9442c1402c8d6e5480f04d2ce6b529675
@@ -1,3 +1,17 @@
2016-11-28 Ryan Haddad <ryanhaddad@apple.com>

Unreviewed, rolling out r209008.

This change appears to have caused two fast/mediastrem
LayoutTests to fail.

Reverted changeset:

"[MediaStream] Don't request user permission for a device if
it has already been granted in the current browsing context"
https://bugs.webkit.org/show_bug.cgi?id=164760
http://trac.webkit.org/changeset/209008

2016-11-28 Eric Carlson <eric.carlson@apple.com>

[MediaStream] Don't request user permission for a device if it has already been granted in the current browsing context
@@ -58,7 +58,7 @@
{
if (window.testRunner) {
testRunner.setUserMediaPermission(true);
testRunner.setUserMediaPersistentPermissionForOrigin(false, document.location.href, "");
testRunner.setUserMediaPermissionForOrigin(false, document.location.href, "");
}

navigator.mediaDevices
@@ -77,7 +77,7 @@
function grantPermission()
{
if (window.testRunner)
testRunner.setUserMediaPersistentPermissionForOrigin(true, document.location.href, "");
testRunner.setUserMediaPermissionForOrigin(true, document.location.href, "");

debug(`<br>*** Calling mediaDevices.enumerateDevices with persistent access, and without a media stream track<br>`);
havePermission = true;
@@ -11,7 +11,7 @@

if (window.testRunner) {
testRunner.setUserMediaPermission(true);
testRunner.setUserMediaPersistentPermissionForOrigin(true, "http://localhost:8000", location.href);
testRunner.setUserMediaPermissionForOrigin(true, "http://localhost:8000", location.href);
}

function setup()

This file was deleted.

This file was deleted.

@@ -1,3 +1,17 @@
2016-11-28 Ryan Haddad <ryanhaddad@apple.com>

Unreviewed, rolling out r209008.

This change appears to have caused two fast/mediastrem
LayoutTests to fail.

Reverted changeset:

"[MediaStream] Don't request user permission for a device if
it has already been granted in the current browsing context"
https://bugs.webkit.org/show_bug.cgi?id=164760
http://trac.webkit.org/changeset/209008

2016-11-28 Andrew Gold <agold@apple.com>

Support for HTML Media Capture API
@@ -34,61 +34,6 @@ using namespace WebCore;

namespace WebKit {

FrameAuthorizationState::FrameAuthorizationState(UserMediaPermissionRequestProxy& request)
: m_userMediaDocumentSecurityOrigin(request.userMediaDocumentSecurityOrigin())
, m_topLevelDocumentSecurityOrigin(request.topLevelDocumentSecurityOrigin())
{
}

bool FrameAuthorizationState::hasPermissionToUseCaptureDevice(const String& deviceUID)
{
return m_authorizedDeviceUIDs.find(deviceUID) != notFound;
}

void FrameAuthorizationState::setHasPermissionToUseCaptureDevice(const String& deviceUID, bool hasPermission)
{
if (deviceUID.isEmpty())
return;

size_t index = m_authorizedDeviceUIDs.find(deviceUID);
if (hasPermission == (index != notFound))
return;

if (hasPermission)
m_authorizedDeviceUIDs.append(deviceUID);
else
m_authorizedDeviceUIDs.remove(index);
}

void FrameAuthorizationState::ensureSecurityOriginsAreEqual(UserMediaPermissionRequestProxy& request)
{
do {
if (!m_userMediaDocumentSecurityOrigin || !m_userMediaDocumentSecurityOrigin->equal(request.userMediaDocumentSecurityOrigin()))
break;

if (!m_topLevelDocumentSecurityOrigin || !m_topLevelDocumentSecurityOrigin->equal(request.topLevelDocumentSecurityOrigin()))
break;

return;
} while (0);

m_userMediaDocumentSecurityOrigin = request.userMediaDocumentSecurityOrigin();
m_topLevelDocumentSecurityOrigin = request.topLevelDocumentSecurityOrigin();
m_authorizedDeviceUIDs.clear();
}

FrameAuthorizationState& UserMediaPermissionRequestManagerProxy::stateForRequest(UserMediaPermissionRequestProxy& request)
{
auto& state = m_frameStates.add(request.frameID(), nullptr).iterator->value;
if (state) {
state->ensureSecurityOriginsAreEqual(request);
return *state;
}

state = std::make_unique<FrameAuthorizationState>(request);
return *state;
}

UserMediaPermissionRequestManagerProxy::UserMediaPermissionRequestManagerProxy(WebPageProxy& page)
: m_page(page)
{
@@ -104,12 +49,19 @@ void UserMediaPermissionRequestManagerProxy::invalidateRequests()
request->invalidate();
m_pendingDeviceRequests.clear();

m_frameStates.clear();
m_pageSandboxExtensionsGranted.clear();
}

Ref<UserMediaPermissionRequestProxy> UserMediaPermissionRequestManagerProxy::createRequest(uint64_t userMediaID, const Vector<String>& audioDeviceUIDs, const Vector<String>& videoDeviceUIDs)
{
Ref<UserMediaPermissionRequestProxy> request = UserMediaPermissionRequestProxy::create(*this, userMediaID, audioDeviceUIDs, videoDeviceUIDs);
m_pendingUserMediaRequests.add(userMediaID, request.ptr());
return request;
}

Ref<UserMediaPermissionRequestProxy> UserMediaPermissionRequestManagerProxy::createRequest(uint64_t userMediaID, uint64_t frameID, const String& userMediaDocumentOriginIdentifier, const String& topLevelDocumentOriginIdentifier, const Vector<String>& audioDeviceUIDs, const Vector<String>& videoDeviceUIDs)
Ref<UserMediaPermissionRequestProxy> UserMediaPermissionRequestManagerProxy::createRequest(uint64_t userMediaID)
{
auto request = UserMediaPermissionRequestProxy::create(*this, userMediaID, frameID, userMediaDocumentOriginIdentifier, topLevelDocumentOriginIdentifier, audioDeviceUIDs, videoDeviceUIDs);
Ref<UserMediaPermissionRequestProxy> request = UserMediaPermissionRequestProxy::create(*this, userMediaID, Vector<String>(), Vector<String>());
m_pendingUserMediaRequests.add(userMediaID, request.ptr());
return request;
}
@@ -151,17 +103,10 @@ void UserMediaPermissionRequestManagerProxy::userMediaAccessWasDenied(uint64_t u
if (!m_page.isValid())
return;

auto request = m_pendingUserMediaRequests.take(userMediaID);
if (!request)
if (!m_pendingUserMediaRequests.take(userMediaID))
return;

auto fameState = stateForRequest(*request);
for (const auto& deviceUID : request->videoDeviceUIDs())
fameState.setHasPermissionToUseCaptureDevice(deviceUID, false);
for (const auto& deviceUID : request->audioDeviceUIDs())
fameState.setHasPermissionToUseCaptureDevice(deviceUID, false);

denyRequest(userMediaID, reason, emptyString());
denyRequest(userMediaID, reason, "");
}

void UserMediaPermissionRequestManagerProxy::denyRequest(uint64_t userMediaID, UserMediaPermissionRequestProxy::UserMediaAccessDenialReason reason, const String& invalidConstraint)
@@ -183,15 +128,10 @@ void UserMediaPermissionRequestManagerProxy::userMediaAccessWasGranted(uint64_t
if (!m_page.isValid())
return;

#if ENABLE(MEDIA_STREAM)
auto request = m_pendingUserMediaRequests.take(userMediaID);
if (!request)
if (!m_pendingUserMediaRequests.take(userMediaID))
return;

auto& fameState = stateForRequest(*request);
fameState.setHasPermissionToUseCaptureDevice(audioDeviceUID, true);
fameState.setHasPermissionToUseCaptureDevice(videoDeviceUID, true);

#if ENABLE(MEDIA_STREAM)
size_t extensionCount = 0;
unsigned requiredExtensions = SandboxExtensionsGranted::None;
if (!audioDeviceUID.isEmpty()) {
@@ -203,10 +143,10 @@ void UserMediaPermissionRequestManagerProxy::userMediaAccessWasGranted(uint64_t
extensionCount++;
}

unsigned currentExtensions = m_pageSandboxExtensionsGranted;
unsigned currentExtensions = m_pageSandboxExtensionsGranted.get(m_page.pageID());
if (!(requiredExtensions & currentExtensions)) {
ASSERT(extensionCount);
m_pageSandboxExtensionsGranted = requiredExtensions | currentExtensions;
m_pageSandboxExtensionsGranted.set(m_page.pageID(), requiredExtensions | currentExtensions);
SandboxExtension::HandleArray handles;
handles.allocate(extensionCount);
if (!videoDeviceUID.isEmpty())
@@ -218,7 +158,6 @@ void UserMediaPermissionRequestManagerProxy::userMediaAccessWasGranted(uint64_t

m_page.process().send(Messages::WebPage::UserMediaAccessWasGranted(userMediaID, audioDeviceUID, videoDeviceUID), m_page.pageID());
#else
UNUSED_PARAM(userMediaID);
UNUSED_PARAM(audioDeviceUID);
UNUSED_PARAM(videoDeviceUID);
#endif
@@ -239,38 +178,18 @@ void UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame(
return;

if (videoDeviceUIDs.isEmpty() && audioDeviceUIDs.isEmpty()) {
denyRequest(userMediaID, UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::NoConstraints, emptyString());
denyRequest(userMediaID, UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::NoConstraints, "");
return;
}

auto userMediaOrigin = API::SecurityOrigin::create(SecurityOriginData::fromDatabaseIdentifier(userMediaDocumentOriginIdentifier)->securityOrigin());
auto topLevelOrigin = API::SecurityOrigin::create(SecurityOriginData::fromDatabaseIdentifier(topLevelDocumentOriginIdentifier)->securityOrigin());
auto request = createRequest(userMediaID, frameID, userMediaDocumentOriginIdentifier, topLevelDocumentOriginIdentifier, audioDeviceUIDs, videoDeviceUIDs);

String authorizedAudioDevice;
String authorizedVideoDevice;
auto& fameState = stateForRequest(request);
for (auto deviceUID : audioDeviceUIDs) {
if (fameState.hasPermissionToUseCaptureDevice(deviceUID)) {
authorizedAudioDevice = deviceUID;
break;
}
}
for (auto deviceUID : videoDeviceUIDs) {
if (fameState.hasPermissionToUseCaptureDevice(deviceUID)) {
authorizedVideoDevice = deviceUID;
break;
}
}
auto request = createRequest(userMediaID, audioDeviceUIDs, videoDeviceUIDs);

if (audioDeviceUIDs.isEmpty() == authorizedAudioDevice.isEmpty() && videoDeviceUIDs.isEmpty() == authorizedVideoDevice.isEmpty()) {
userMediaAccessWasGranted(userMediaID, authorizedAudioDevice, authorizedVideoDevice);
return;
if (!m_page.uiClient().decidePolicyForUserMediaPermissionRequest(m_page, *m_page.process().webFrame(frameID), *userMediaOrigin.get(), *topLevelOrigin.get(), request.get())) {
m_pendingUserMediaRequests.take(userMediaID);
request->deny(UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::UserMediaDisabled);
}

if (!m_page.uiClient().decidePolicyForUserMediaPermissionRequest(m_page, *m_page.process().webFrame(frameID), *userMediaOrigin.get(), *topLevelOrigin.get(), request.get()))
userMediaAccessWasDenied(userMediaID, UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::UserMediaDisabled);

};

auto audioConstraints = MediaConstraintsImpl::create(audioConstraintsData);

0 comments on commit 36b4aff

Please sign in to comment.