Diff
Modified: trunk/Source/WebKit/ChangeLog (258321 => 258322)
--- trunk/Source/WebKit/ChangeLog 2020-03-12 13:30:10 UTC (rev 258321)
+++ trunk/Source/WebKit/ChangeLog 2020-03-12 13:41:54 UTC (rev 258322)
@@ -1,3 +1,41 @@
+2020-03-12 youenn fablet <[email protected]>
+
+ GPUProcess should ensure UIProcess granted capture access to a WebProcess making a capture request
+ https://bugs.webkit.org/show_bug.cgi?id=208910
+
+ Reviewed by Eric Carlson.
+
+ When UIProcess receives a getUserMedia request, it will send to GPUProcess a notification of what is allowed.
+ GPUProcess stores for each connection to web process whether microphone, camera and/or display are allowed.
+ We do not disable access for a given process for now.
+ A future refactoring should probably streamline the implementation so that, in case capture happens in GPUProcess,
+ GPUProcess receives the getUserMedia request, asks permission to UIProcess and, upon granted permission, creates directly the sources.
+
+ Covered by existing tests.
+
+ * GPUProcess/GPUConnectionToWebProcess.cpp:
+ (WebKit::GPUConnectionToWebProcess::updateCaptureAccess):
+ * GPUProcess/GPUConnectionToWebProcess.h:
+ (WebKit::GPUConnectionToWebProcess::allowsAudioCapture const):
+ (WebKit::GPUConnectionToWebProcess::allowsVideoCapture const):
+ (WebKit::GPUConnectionToWebProcess::allowsDisplayCapture const):
+ * GPUProcess/GPUProcess.cpp:
+ (WebKit::GPUProcess::createGPUConnectionToWebProcess):
+ (WebKit::GPUProcess::updateCaptureAccess):
+ * GPUProcess/GPUProcess.h:
+ * GPUProcess/GPUProcess.messages.in:
+ * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:
+ (WebKit::UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints):
+ * UIProcess/Cocoa/UserMediaCaptureManagerProxy.h:
+ * UIProcess/GPU/GPUProcessProxy.cpp:
+ (WebKit::GPUProcessProxy::updateCaptureAccess):
+ * UIProcess/GPU/GPUProcessProxy.h:
+ * UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
+ (WebKit::UserMediaPermissionRequestManagerProxy::finishGrantingRequest):
+ * UIProcess/WebPageProxy.cpp:
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebProcessProxy.cpp:
+
2020-03-12 Brent Fulgham <[email protected]>
Drop unused EnableEnumeratingAllNetworkInterfaces / DisableEnumeratingAllNetworkInterfaces IPC messages
Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp (258321 => 258322)
--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp 2020-03-12 13:30:10 UTC (rev 258321)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp 2020-03-12 13:41:54 UTC (rev 258322)
@@ -117,18 +117,28 @@
void addMessageReceiver(IPC::StringReference messageReceiverName, IPC::MessageReceiver& receiver) final { }
void removeMessageReceiver(IPC::StringReference messageReceiverName) final { }
IPC::Connection& connection() final { return m_process.connection(); }
+ bool willStartCapture(CaptureDevice::DeviceType type) const final
+ {
+ switch (type) {
+ case CaptureDevice::DeviceType::Unknown:
+ return false;
+ case CaptureDevice::DeviceType::Microphone:
+ return m_process.allowsAudioCapture();
+ case CaptureDevice::DeviceType::Camera:
+ if (!m_process.allowsVideoCapture())
+ return false;
#if PLATFORM(IOS)
- void willStartCameraCapture() final
- {
- if (m_providedPresentingApplicationPID)
- return;
- m_providedPresentingApplicationPID = true;
- MediaSessionManageriOS::providePresentingApplicationPID();
+ MediaSessionManageriOS::providePresentingApplicationPID();
+#endif
+ return true;
+ break;
+ case CaptureDevice::DeviceType::Screen:
+ return m_process.allowsDisplayCapture();
+ case CaptureDevice::DeviceType::Window:
+ return m_process.allowsDisplayCapture();
+ }
}
- bool m_providedPresentingApplicationPID { false };
-#endif
-
GPUConnectionToWebProcess& m_process;
};
#endif
@@ -499,6 +509,13 @@
{
userMediaCaptureManagerProxy().setOrientation(orientation);
}
+
+void GPUConnectionToWebProcess::updateCaptureAccess(bool allowAudioCapture, bool allowVideoCapture, bool allowDisplayCapture)
+{
+ m_allowsAudioCapture |= allowAudioCapture;
+ m_allowsVideoCapture |= allowVideoCapture;
+ m_allowsDisplayCapture |= allowDisplayCapture;
+}
#endif
} // namespace WebKit
Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h (258321 => 258322)
--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h 2020-03-12 13:30:10 UTC (rev 258321)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h 2020-03-12 13:41:54 UTC (rev 258322)
@@ -84,6 +84,10 @@
#if ENABLE(MEDIA_STREAM)
void setOrientationForMediaCapture(uint64_t orientation);
+ void updateCaptureAccess(bool allowAudioCapture, bool allowVideoCapture, bool allowDisplayCapture);
+ bool allowsAudioCapture() const { return m_allowsAudioCapture; }
+ bool allowsVideoCapture() const { return m_allowsVideoCapture; }
+ bool allowsDisplayCapture() const { return m_allowsDisplayCapture; }
#endif
#if ENABLE(ENCRYPTED_MEDIA)
@@ -170,6 +174,11 @@
std::unique_ptr<RemoteSampleBufferDisplayLayerManager> m_sampleBufferDisplayLayerManager;
#endif
#endif
+#if ENABLE(MEDIA_STREAM)
+ bool m_allowsAudioCapture { false };
+ bool m_allowsVideoCapture { false };
+ bool m_allowsDisplayCapture { false };
+#endif
#if PLATFORM(COCOA) && USE(LIBWEBRTC)
std::unique_ptr<LibWebRTCCodecsProxy> m_libWebRTCCodecsProxy;
#endif
Modified: trunk/Source/WebKit/GPUProcess/GPUProcess.cpp (258321 => 258322)
--- trunk/Source/WebKit/GPUProcess/GPUProcess.cpp 2020-03-12 13:30:10 UTC (rev 258321)
+++ trunk/Source/WebKit/GPUProcess/GPUProcess.cpp 2020-03-12 13:41:54 UTC (rev 258322)
@@ -82,6 +82,12 @@
auto newConnection = GPUConnectionToWebProcess::create(*this, identifier, ipcConnection->first, sessionID);
+#if ENABLE(MEDIA_STREAM)
+ // FIXME: We should refactor code to go from WebProcess -> GPUProcess -> UIProcess when getUserMedia is called instead of going from WebProcess -> UIProcess directly.
+ auto access = m_mediaCaptureAccessMap.take(identifier);
+ newConnection->updateCaptureAccess(access.allowAudioCapture, access.allowVideoCapture, access.allowDisplayCapture);
+#endif
+
ASSERT(!m_webProcessConnections.contains(identifier));
m_webProcessConnections.add(identifier, WTFMove(newConnection));
@@ -182,6 +188,21 @@
for (auto& connection : m_webProcessConnections.values())
connection->setOrientationForMediaCapture(orientation);
}
+
+void GPUProcess::updateCaptureAccess(bool allowAudioCapture, bool allowVideoCapture, bool allowDisplayCapture, ProcessIdentifier processID, CompletionHandler<void()>&& completionHandler)
+{
+ if (auto* connection = webProcessConnection(processID)) {
+ connection->updateCaptureAccess(allowAudioCapture, allowVideoCapture, allowDisplayCapture);
+ return completionHandler();
+ }
+
+ auto& access = m_mediaCaptureAccessMap.add(processID, MediaCaptureAccess { allowAudioCapture, allowVideoCapture, allowDisplayCapture }).iterator->value;
+ access.allowAudioCapture |= allowAudioCapture;
+ access.allowVideoCapture |= allowVideoCapture;
+ access.allowDisplayCapture |= allowDisplayCapture;
+
+ completionHandler();
+}
#endif
void GPUProcess::addSession(PAL::SessionID sessionID, GPUProcessSessionParameters&& parameters)
Modified: trunk/Source/WebKit/GPUProcess/GPUProcess.h (258321 => 258322)
--- trunk/Source/WebKit/GPUProcess/GPUProcess.h 2020-03-12 13:30:10 UTC (rev 258321)
+++ trunk/Source/WebKit/GPUProcess/GPUProcess.h 2020-03-12 13:41:54 UTC (rev 258322)
@@ -98,11 +98,21 @@
#if ENABLE(MEDIA_STREAM)
void setMockCaptureDevicesEnabled(bool);
void setOrientationForMediaCapture(uint64_t orientation);
+ void updateCaptureAccess(bool allowAudioCapture, bool allowVideoCapture, bool allowDisplayCapture, WebCore::ProcessIdentifier, CompletionHandler<void()>&&);
#endif
// Connections to WebProcesses.
HashMap<WebCore::ProcessIdentifier, Ref<GPUConnectionToWebProcess>> m_webProcessConnections;
+#if ENABLE(MEDIA_STREAM)
+ struct MediaCaptureAccess {
+ bool allowAudioCapture { false };
+ bool allowVideoCapture { false };
+ bool allowDisplayCapture { false };
+ };
+ HashMap<WebCore::ProcessIdentifier, MediaCaptureAccess> m_mediaCaptureAccessMap;
+#endif
+
struct GPUSession {
String mediaCacheDirectory;
#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
Modified: trunk/Source/WebKit/GPUProcess/GPUProcess.messages.in (258321 => 258322)
--- trunk/Source/WebKit/GPUProcess/GPUProcess.messages.in 2020-03-12 13:30:10 UTC (rev 258321)
+++ trunk/Source/WebKit/GPUProcess/GPUProcess.messages.in 2020-03-12 13:41:54 UTC (rev 258322)
@@ -38,6 +38,7 @@
#if ENABLE(MEDIA_STREAM)
SetMockCaptureDevicesEnabled(bool isEnabled)
SetOrientationForMediaCapture(uint64_t orientation);
+ UpdateCaptureAccess(bool allowAudioCapture, bool allowVideoCapture, bool allowDisplayCapture, WebCore::ProcessIdentifier processID) -> () Async
#endif
}
Modified: trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp (258321 => 258322)
--- trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp 2020-03-12 13:30:10 UTC (rev 258321)
+++ trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp 2020-03-12 13:41:54 UTC (rev 258322)
@@ -179,6 +179,9 @@
void UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints(RealtimeMediaSourceIdentifier id, const CaptureDevice& device, String&& hashSalt, const MediaConstraints& constraints, CompletionHandler<void(bool succeeded, String invalidConstraints, WebCore::RealtimeMediaSourceSettings&&, WebCore::RealtimeMediaSourceCapabilities&&)>&& completionHandler)
{
+ if (!m_connectionProxy->willStartCapture(device.type()))
+ return completionHandler(false, "Request is not allowed"_s, RealtimeMediaSourceSettings { }, { });
+
CaptureSourceOrError sourceOrError;
switch (device.type()) {
case WebCore::CaptureDevice::DeviceType::Microphone:
@@ -186,10 +189,8 @@
break;
case WebCore::CaptureDevice::DeviceType::Camera:
sourceOrError = RealtimeMediaSourceCenter::singleton().videoCaptureFactory().createVideoCaptureSource(device, WTFMove(hashSalt), &constraints);
- if (sourceOrError) {
+ if (sourceOrError)
sourceOrError.captureSource->monitorOrientation(m_orientationNotifier);
- m_connectionProxy->willStartCameraCapture();
- }
break;
case WebCore::CaptureDevice::DeviceType::Screen:
case WebCore::CaptureDevice::DeviceType::Window:
Modified: trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h (258321 => 258322)
--- trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h 2020-03-12 13:30:10 UTC (rev 258321)
+++ trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h 2020-03-12 13:41:54 UTC (rev 258322)
@@ -30,6 +30,7 @@
#include "Connection.h"
#include "MessageReceiver.h"
#include "UserMediaCaptureManager.h"
+#include <WebCore/CaptureDevice.h>
#include <WebCore/OrientationNotifier.h>
#include <WebCore/RealtimeMediaSource.h>
#include <WebCore/RealtimeMediaSourceIdentifier.h>
@@ -53,7 +54,7 @@
virtual void addMessageReceiver(IPC::StringReference, IPC::MessageReceiver&) = 0;
virtual void removeMessageReceiver(IPC::StringReference) = 0;
virtual IPC::Connection& connection() = 0;
- virtual void willStartCameraCapture() { }
+ virtual bool willStartCapture(WebCore::CaptureDevice::DeviceType) const = 0;
virtual Logger& logger() = 0;
};
explicit UserMediaCaptureManagerProxy(UniqueRef<ConnectionProxy>&&);
Modified: trunk/Source/WebKit/UIProcess/GPU/GPUProcessProxy.cpp (258321 => 258322)
--- trunk/Source/WebKit/UIProcess/GPU/GPUProcessProxy.cpp 2020-03-12 13:30:10 UTC (rev 258321)
+++ trunk/Source/WebKit/UIProcess/GPU/GPUProcessProxy.cpp 2020-03-12 13:41:54 UTC (rev 258322)
@@ -154,6 +154,11 @@
m_orientation = orientation;
send(Messages::GPUProcess::SetOrientationForMediaCapture { orientation }, 0);
}
+
+void GPUProcessProxy::updateCaptureAccess(bool allowAudioCapture, bool allowVideoCapture, bool allowDisplayCapture, WebCore::ProcessIdentifier processID, CompletionHandler<void()>&& completionHandler)
+{
+ sendWithAsyncReply(Messages::GPUProcess::UpdateCaptureAccess { allowAudioCapture, allowVideoCapture, allowDisplayCapture, processID }, WTFMove(completionHandler));
+}
#endif
void GPUProcessProxy::getLaunchOptions(ProcessLauncher::LaunchOptions& launchOptions)
Modified: trunk/Source/WebKit/UIProcess/GPU/GPUProcessProxy.h (258321 => 258322)
--- trunk/Source/WebKit/UIProcess/GPU/GPUProcessProxy.h 2020-03-12 13:30:10 UTC (rev 258321)
+++ trunk/Source/WebKit/UIProcess/GPU/GPUProcessProxy.h 2020-03-12 13:41:54 UTC (rev 258322)
@@ -66,6 +66,7 @@
#if ENABLE(MEDIA_STREAM)
void setUseMockCaptureDevices(bool);
void setOrientationForMediaCapture(uint64_t orientation);
+ void updateCaptureAccess(bool allowAudioCapture, bool allowVideoCapture, bool allowDisplayCapture, WebCore::ProcessIdentifier, CompletionHandler<void()>&&);
#endif
void removeSession(PAL::SessionID);
Modified: trunk/Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.cpp (258321 => 258322)
--- trunk/Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.cpp 2020-03-12 13:30:10 UTC (rev 258321)
+++ trunk/Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.cpp 2020-03-12 13:41:54 UTC (rev 258322)
@@ -236,32 +236,39 @@
return;
}
- if (request.requestType() == MediaStreamRequest::Type::UserMedia)
- m_grantedRequests.append(makeRef(request));
+ m_page.willStartCapture(request, [this, weakThis = makeWeakPtr(this), strongRequest = makeRef(request)]() mutable {
+ if (!weakThis)
+ return;
- // FIXME: m_hasFilteredDeviceList will trigger ondevicechange events for various documents from different origins.
- if (m_hasFilteredDeviceList)
- captureDevicesChanged(PermissionInfo::Granted);
- m_hasFilteredDeviceList = false;
+ auto& request = strongRequest.get();
- ++m_hasPendingCapture;
+ if (request.requestType() == MediaStreamRequest::Type::UserMedia)
+ m_grantedRequests.append(makeRef(request));
- SandboxExtension::Handle handle;
+ // FIXME: m_hasFilteredDeviceList will trigger ondevicechange events for various documents from different origins.
+ if (m_hasFilteredDeviceList)
+ captureDevicesChanged(PermissionInfo::Granted);
+ m_hasFilteredDeviceList = false;
+
+ ++m_hasPendingCapture;
+
+ SandboxExtension::Handle handle;
#if PLATFORM(COCOA)
- if (!m_hasCreatedSandboxExtensionForTCCD) {
- SandboxExtension::createHandleForMachLookup("com.apple.tccd", m_page.process().connection()->getAuditToken(), handle);
- m_hasCreatedSandboxExtensionForTCCD = true;
- }
+ if (!m_hasCreatedSandboxExtensionForTCCD) {
+ SandboxExtension::createHandleForMachLookup("com.apple.tccd", m_page.process().connection()->getAuditToken(), handle);
+ m_hasCreatedSandboxExtensionForTCCD = true;
+ }
#endif
- m_page.process().connection()->sendWithAsyncReply(Messages::WebPage::UserMediaAccessWasGranted { request.userMediaID(), request.audioDevice(), request.videoDevice(), request.deviceIdentifierHashSalt(), handle }, [this, weakThis = makeWeakPtr(this)] {
- if (!weakThis)
- return;
- if (!--m_hasPendingCapture)
- UserMediaProcessManager::singleton().revokeSandboxExtensionsIfNeeded(page().process());
- }, m_page.webPageID());
+ m_page.process().connection()->sendWithAsyncReply(Messages::WebPage::UserMediaAccessWasGranted { request.userMediaID(), request.audioDevice(), request.videoDevice(), request.deviceIdentifierHashSalt(), handle }, [this, weakThis = WTFMove(weakThis)] {
+ if (!weakThis)
+ return;
+ if (!--m_hasPendingCapture)
+ UserMediaProcessManager::singleton().revokeSandboxExtensionsIfNeeded(page().process());
+ }, m_page.webPageID());
- processNextUserMediaRequestIfNeeded();
+ processNextUserMediaRequestIfNeeded();
+ });
}
void UserMediaPermissionRequestManagerProxy::resetAccess(Optional<FrameIdentifier> frameID)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (258321 => 258322)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-03-12 13:30:10 UTC (rev 258321)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-03-12 13:41:54 UTC (rev 258322)
@@ -7919,8 +7919,22 @@
{
userMediaPermissionRequestManager().setMockCaptureDevicesEnabledOverride(enabled);
}
+
+void WebPageProxy::willStartCapture(const UserMediaPermissionRequestProxy& request, CompletionHandler<void()>&& callback)
+{
+#if ENABLE(GPU_PROCESS)
+ if (!preferences().captureVideoInGPUProcessEnabled() && !preferences().captureAudioInGPUProcessEnabled())
+ return callback();
+
+ auto& gpuProcess = GPUProcessProxy::singleton();
+ gpuProcess.updateCaptureAccess(request.requiresAudioCapture(), request.requiresVideoCapture(), request.requiresDisplayCapture(), m_process->coreProcessIdentifier(), WTFMove(callback));
+#else
+ callback();
#endif
+}
+#endif
+
void WebPageProxy::requestUserMediaPermissionForFrame(uint64_t userMediaID, FrameIdentifier frameID, const WebCore::SecurityOriginData& userMediaDocumentOriginData, const WebCore::SecurityOriginData& topLevelDocumentOriginData, WebCore::MediaStreamRequest&& request)
{
#if ENABLE(MEDIA_STREAM)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (258321 => 258322)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2020-03-12 13:30:10 UTC (rev 258321)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2020-03-12 13:41:54 UTC (rev 258322)
@@ -295,23 +295,24 @@
class WebEditCommandProxy;
class WebFullScreenManagerProxy;
class PlaybackSessionManagerProxy;
-class WebNavigationState;
+class UserMediaPermissionRequestProxy;
class VideoFullscreenManagerProxy;
class WebAuthenticatorCoordinatorProxy;
class WebBackForwardCache;
+class WebDeviceOrientationUpdateProviderProxy;
class WebKeyboardEvent;
-class WebURLSchemeHandler;
class WebMouseEvent;
+class WebNavigationState;
class WebOpenPanelResultListenerProxy;
class WebPageDebuggable;
class WebPageGroup;
class WebPageInspectorController;
class WebProcessProxy;
+class WebURLSchemeHandler;
class WebUserContentControllerProxy;
+class WebViewDidMoveToWindowObserver;
class WebWheelEvent;
class WebsiteDataStore;
-class WebDeviceOrientationUpdateProviderProxy;
-class WebViewDidMoveToWindowObserver;
struct AttributedString;
struct WebBackForwardListCounts;
@@ -1676,6 +1677,7 @@
#if ENABLE(MEDIA_STREAM)
void setMockCaptureDevicesEnabledOverride(Optional<bool>);
+ void willStartCapture(const UserMediaPermissionRequestProxy&, CompletionHandler<void()>&&);
#endif
void maybeInitializeSandboxExtensionHandle(WebProcessProxy&, const URL&, const URL& resourceDirectoryURL, SandboxExtension::Handle&, bool checkAssumedReadAccessToResourceURL = true);
Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp (258321 => 258322)
--- trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp 2020-03-12 13:30:10 UTC (rev 258321)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp 2020-03-12 13:41:54 UTC (rev 258322)
@@ -168,6 +168,11 @@
}
return *m_logger;
}
+ bool willStartCapture(CaptureDevice::DeviceType) const final
+ {
+ // FIXME: We should validate this is granted.
+ return true;
+ }
RefPtr<Logger> m_logger;
WebProcessProxy& m_process;