Title: [247662] trunk/Source
Revision
247662
Author
[email protected]
Date
2019-07-19 17:55:16 -0700 (Fri, 19 Jul 2019)

Log Message

Remote WebInspector should enable mock capture devices in UIProcess if doing it in WebProcess
https://bugs.webkit.org/show_bug.cgi?id=199924
<rdar://problem/50552067>

Reviewed by Devin Rousso.

Source/WebCore:

Add necessary API to set mock capture devices override.
In case of desynchronization between webprocess and uiprocess, make sure to return early
and fail capture instead of crashing.

* inspector/InspectorClient.h:
(WebCore::InspectorClient::setMockCaptureDevicesEnabled):
* inspector/agents/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::disable):
(WebCore::InspectorPageAgent::overrideSetting):
* platform/mock/MockRealtimeMediaSourceCenter.cpp:

Source/WebKit:

Add IPC plumbery to pass inspector override value for mock capture devices.
Add an override in UserMediaPermissionRequestManagerProxy so that the value stays in sync with web inspector.
The override will be removed when web inspector goes away.

* UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
(WebKit::UserMediaPermissionRequestManagerProxy::syncWithWebCorePrefs const):
* UIProcess/UserMediaPermissionRequestManagerProxy.h:
(WebKit::UserMediaPermissionRequestManagerProxy::setMockCaptureDevicesEnabledOverride):
* UIProcess/WebInspectorProxy.cpp:
(WebKit::WebInspectorProxy::setMockCaptureDevicesEnabled):
* UIProcess/WebInspectorProxy.h:
* UIProcess/WebInspectorProxy.messages.in:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::setMockCaptureDevicesEnabledOverride):
* UIProcess/WebPageProxy.h:
* WebProcess/WebCoreSupport/WebInspectorClient.cpp:
(WebKit::WebInspectorClient::setMockCaptureDevicesEnabled):
* WebProcess/WebCoreSupport/WebInspectorClient.h:
* WebProcess/WebPage/WebInspector.cpp:
(WebKit::WebInspector::setMockCaptureDevicesEnabled):
* WebProcess/WebPage/WebInspector.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (247661 => 247662)


--- trunk/Source/WebCore/ChangeLog	2019-07-20 00:40:25 UTC (rev 247661)
+++ trunk/Source/WebCore/ChangeLog	2019-07-20 00:55:16 UTC (rev 247662)
@@ -1,3 +1,22 @@
+2019-07-19  Youenn Fablet  <[email protected]>
+
+        Remote WebInspector should enable mock capture devices in UIProcess if doing it in WebProcess
+        https://bugs.webkit.org/show_bug.cgi?id=199924
+        <rdar://problem/50552067>
+
+        Reviewed by Devin Rousso.
+
+        Add necessary API to set mock capture devices override.
+        In case of desynchronization between webprocess and uiprocess, make sure to return early
+        and fail capture instead of crashing.
+
+        * inspector/InspectorClient.h:
+        (WebCore::InspectorClient::setMockCaptureDevicesEnabled):
+        * inspector/agents/InspectorPageAgent.cpp:
+        (WebCore::InspectorPageAgent::disable):
+        (WebCore::InspectorPageAgent::overrideSetting):
+        * platform/mock/MockRealtimeMediaSourceCenter.cpp:
+
 2019-07-19  Andy Estes  <[email protected]>
 
         [Apple Pay] Log less in PaymentCoordinator::shouldEnableApplePayAPIs()

Modified: trunk/Source/WebCore/inspector/InspectorClient.h (247661 => 247662)


--- trunk/Source/WebCore/inspector/InspectorClient.h	2019-07-20 00:40:25 UTC (rev 247661)
+++ trunk/Source/WebCore/inspector/InspectorClient.h	2019-07-20 00:55:16 UTC (rev 247662)
@@ -27,6 +27,7 @@
 #pragma once
 
 #include <wtf/Forward.h>
+#include <wtf/Optional.h>
 
 namespace Inspector {
 class FrontendChannel;
@@ -62,6 +63,8 @@
     virtual void didSetSearchingForNode(bool) { }
     virtual void elementSelectionChanged(bool) { }
 
+    virtual void setMockCaptureDevicesEnabledOverride(Optional<bool>) { }
+
 #if ENABLE(REMOTE_INSPECTOR)
     virtual bool allowRemoteInspectionToPageDirectly() const { return false; }
 #endif

Modified: trunk/Source/WebCore/inspector/agents/InspectorPageAgent.cpp (247661 => 247662)


--- trunk/Source/WebCore/inspector/agents/InspectorPageAgent.cpp	2019-07-20 00:40:25 UTC (rev 247661)
+++ trunk/Source/WebCore/inspector/agents/InspectorPageAgent.cpp	2019-07-20 00:55:16 UTC (rev 247662)
@@ -388,6 +388,8 @@
 
 #undef DISABLE_INSPECTOR_OVERRIDE_SETTING
 
+    m_client->setMockCaptureDevicesEnabledOverride(WTF::nullopt);
+
     m_instrumentingAgents.setInspectorPageAgent(nullptr);
 }
 
@@ -435,13 +437,13 @@
 
     switch (setting.value()) {
 #define CASE_INSPECTOR_OVERRIDE_SETTING(name) \
-    case Inspector::Protocol::Page::Setting::name: { \
-        if (value) \
-            m_inspectedPage.settings().set##name##InspectorOverride(*value); \
-        else \
+    case Inspector::Protocol::Page::Setting::name: {                               \
+        if (value)                                                                 \
+            m_inspectedPage.settings().set##name##InspectorOverride(*value);       \
+        else                                                                       \
             m_inspectedPage.settings().set##name##InspectorOverride(WTF::nullopt); \
-        return; \
-    } \
+        break;                                                                     \
+    }                                                                              \
 
     FOR_EACH_INSPECTOR_OVERRIDE_SETTING(CASE_INSPECTOR_OVERRIDE_SETTING)
 
@@ -448,7 +450,9 @@
 #undef CASE_INSPECTOR_OVERRIDE_SETTING
     }
 
-    ASSERT_NOT_REACHED();
+    // Update the UIProcess / client for particular overrides.
+    if (setting.value() == Inspector::Protocol::Page::Setting::MockCaptureDevicesEnabled)
+        m_client->setMockCaptureDevicesEnabledOverride(value);
 }
 
 static Inspector::Protocol::Page::CookieSameSitePolicy cookieSameSitePolicyJSON(Cookie::SameSitePolicy policy)

Modified: trunk/Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp (247661 => 247662)


--- trunk/Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp	2019-07-20 00:40:25 UTC (rev 247661)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp	2019-07-20 00:55:16 UTC (rev 247662)
@@ -89,7 +89,8 @@
     CaptureSourceOrError createVideoCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints) final
     {
         ASSERT(device.type() == CaptureDevice::DeviceType::Camera);
-        ASSERT(MockRealtimeMediaSourceCenter::captureDeviceWithPersistentID(CaptureDevice::DeviceType::Camera, device.persistentId()));
+        if (!MockRealtimeMediaSourceCenter::captureDeviceWithPersistentID(CaptureDevice::DeviceType::Camera, device.persistentId()))
+            return { };
 
         return MockRealtimeVideoSource::create(String { device.persistentId() }, String { device.label() }, WTFMove(hashSalt), constraints);
     }
@@ -109,7 +110,8 @@
 public:
     CaptureSourceOrError createDisplayCaptureSource(const CaptureDevice& device, const MediaConstraints* constraints) final
     {
-        ASSERT(MockRealtimeMediaSourceCenter::captureDeviceWithPersistentID(device.type(), device.persistentId()));
+        if (!MockRealtimeMediaSourceCenter::captureDeviceWithPersistentID(device.type(), device.persistentId()))
+            return { };
 
         switch (device.type()) {
         case CaptureDevice::DeviceType::Screen:
@@ -134,7 +136,8 @@
     CaptureSourceOrError createAudioCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints) final
     {
         ASSERT(device.type() == CaptureDevice::DeviceType::Microphone);
-        ASSERT(MockRealtimeMediaSourceCenter::captureDeviceWithPersistentID(CaptureDevice::DeviceType::Microphone, device.persistentId()));
+        if (!MockRealtimeMediaSourceCenter::captureDeviceWithPersistentID(CaptureDevice::DeviceType::Microphone, device.persistentId()))
+            return { };
 
         return MockRealtimeAudioSource::create(String { device.persistentId() }, String { device.label() }, WTFMove(hashSalt), constraints);
     }

Modified: trunk/Source/WebKit/ChangeLog (247661 => 247662)


--- trunk/Source/WebKit/ChangeLog	2019-07-20 00:40:25 UTC (rev 247661)
+++ trunk/Source/WebKit/ChangeLog	2019-07-20 00:55:16 UTC (rev 247662)
@@ -1,3 +1,33 @@
+2019-07-19  Youenn Fablet  <[email protected]>
+
+        Remote WebInspector should enable mock capture devices in UIProcess if doing it in WebProcess
+        https://bugs.webkit.org/show_bug.cgi?id=199924
+        <rdar://problem/50552067>
+
+        Reviewed by Devin Rousso.
+
+        Add IPC plumbery to pass inspector override value for mock capture devices.
+        Add an override in UserMediaPermissionRequestManagerProxy so that the value stays in sync with web inspector.
+        The override will be removed when web inspector goes away.
+
+        * UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
+        (WebKit::UserMediaPermissionRequestManagerProxy::syncWithWebCorePrefs const):
+        * UIProcess/UserMediaPermissionRequestManagerProxy.h:
+        (WebKit::UserMediaPermissionRequestManagerProxy::setMockCaptureDevicesEnabledOverride):
+        * UIProcess/WebInspectorProxy.cpp:
+        (WebKit::WebInspectorProxy::setMockCaptureDevicesEnabled):
+        * UIProcess/WebInspectorProxy.h:
+        * UIProcess/WebInspectorProxy.messages.in:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::setMockCaptureDevicesEnabledOverride):
+        * UIProcess/WebPageProxy.h:
+        * WebProcess/WebCoreSupport/WebInspectorClient.cpp:
+        (WebKit::WebInspectorClient::setMockCaptureDevicesEnabled):
+        * WebProcess/WebCoreSupport/WebInspectorClient.h:
+        * WebProcess/WebPage/WebInspector.cpp:
+        (WebKit::WebInspector::setMockCaptureDevicesEnabled):
+        * WebProcess/WebPage/WebInspector.h:
+
 2019-07-19  Tim Horton  <[email protected]>
 
         Web Content process gets stuck suspended after navigating away from a system preview

Modified: trunk/Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.cpp (247661 => 247662)


--- trunk/Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.cpp	2019-07-20 00:40:25 UTC (rev 247661)
+++ trunk/Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.cpp	2019-07-20 00:55:16 UTC (rev 247662)
@@ -651,7 +651,7 @@
 #if ENABLE(MEDIA_STREAM)
     // Enable/disable the mock capture devices for the UI process as per the WebCore preferences. Note that
     // this is a noop if the preference hasn't changed since the last time this was called.
-    bool mockDevicesEnabled = m_page.preferences().mockCaptureDevicesEnabled();
+    bool mockDevicesEnabled = m_mockDevicesEnabledOverride ? *m_mockDevicesEnabledOverride : m_page.preferences().mockCaptureDevicesEnabled();
     MockRealtimeMediaSourceCenter::setMockRealtimeMediaSourceCenterEnabled(mockDevicesEnabled);
 #endif
 }

Modified: trunk/Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.h (247661 => 247662)


--- trunk/Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.h	2019-07-20 00:40:25 UTC (rev 247661)
+++ trunk/Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.h	2019-07-20 00:55:16 UTC (rev 247662)
@@ -85,6 +85,8 @@
         Prompt
     };
 
+    void setMockCaptureDevicesEnabledOverride(Optional<bool> enabled) { m_mockDevicesEnabledOverride = enabled; }
+
 private:
 #if !RELEASE_LOG_DISABLED
     const Logger& logger() const final;
@@ -150,6 +152,7 @@
 #endif
     bool m_hasFilteredDeviceList { false };
     uint64_t m_hasPendingCapture { 0 };
+    Optional<bool> m_mockDevicesEnabledOverride;
 };
 
 String convertEnumerationToString(UserMediaPermissionRequestManagerProxy::RequestAction);

Modified: trunk/Source/WebKit/UIProcess/WebInspectorProxy.cpp (247661 => 247662)


--- trunk/Source/WebKit/UIProcess/WebInspectorProxy.cpp	2019-07-20 00:40:25 UTC (rev 247661)
+++ trunk/Source/WebKit/UIProcess/WebInspectorProxy.cpp	2019-07-20 00:55:16 UTC (rev 247662)
@@ -42,6 +42,7 @@
 #include "WebProcessPool.h"
 #include "WebProcessProxy.h"
 #include <WebCore/CertificateInfo.h>
+#include <WebCore/MockRealtimeMediaSourceCenter.h>
 #include <WebCore/NotImplemented.h>
 #include <WebCore/TextEncoding.h>
 #include <wtf/SetForScope.h>
@@ -592,6 +593,18 @@
         bringToFront();
 }
 
+void WebInspectorProxy::setMockCaptureDevicesEnabledOverride(Optional<bool> enabled)
+{
+#if ENABLE(MEDIA_STREAM)
+    if (!m_inspectedPage)
+        return;
+
+    m_inspectedPage->setMockCaptureDevicesEnabledOverride(enabled);
+#else
+    UNUSED_PARAM(enabled);
+#endif
+}
+
 void WebInspectorProxy::save(const String& filename, const String& content, bool base64Encoded, bool forceSaveAs)
 {
     platformSave(filename, content, base64Encoded, forceSaveAs);

Modified: trunk/Source/WebKit/UIProcess/WebInspectorProxy.h (247661 => 247662)


--- trunk/Source/WebKit/UIProcess/WebInspectorProxy.h	2019-07-20 00:40:25 UTC (rev 247661)
+++ trunk/Source/WebKit/UIProcess/WebInspectorProxy.h	2019-07-20 00:55:16 UTC (rev 247662)
@@ -227,6 +227,7 @@
     void inspectedURLChanged(const String&);
     void showCertificate(const WebCore::CertificateInfo&);
     void elementSelectionChanged(bool);
+    void setMockCaptureDevicesEnabledOverride(Optional<bool>);
 
     void save(const String& filename, const String& content, bool base64Encoded, bool forceSaveAs);
     void append(const String& filename, const String& content);

Modified: trunk/Source/WebKit/UIProcess/WebInspectorProxy.messages.in (247661 => 247662)


--- trunk/Source/WebKit/UIProcess/WebInspectorProxy.messages.in	2019-07-20 00:40:25 UTC (rev 247661)
+++ trunk/Source/WebKit/UIProcess/WebInspectorProxy.messages.in	2019-07-20 00:55:16 UTC (rev 247662)
@@ -35,6 +35,7 @@
     InspectedURLChanged(String urlString)
     ShowCertificate(WebCore::CertificateInfo certificateInfo)
     ElementSelectionChanged(bool active)
+    SetMockCaptureDevicesEnabledOverride(Optional<bool> enabled)
 
     Save(String filename, String content, bool base64Encoded, bool forceSaveAs)
     Append(String filename, String content)

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (247661 => 247662)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2019-07-20 00:40:25 UTC (rev 247661)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2019-07-20 00:55:16 UTC (rev 247662)
@@ -7394,6 +7394,11 @@
     m_userMediaPermissionRequestManager = std::make_unique<UserMediaPermissionRequestManagerProxy>(*this);
     return *m_userMediaPermissionRequestManager;
 }
+
+void WebPageProxy::setMockCaptureDevicesEnabledOverride(Optional<bool> enabled)
+{
+    userMediaPermissionRequestManager().setMockCaptureDevicesEnabledOverride(enabled);
+}
 #endif
 
 void WebPageProxy::requestUserMediaPermissionForFrame(uint64_t userMediaID, uint64_t frameID, const WebCore::SecurityOriginData&  userMediaDocumentOriginData, const WebCore::SecurityOriginData& topLevelDocumentOriginData, WebCore::MediaStreamRequest&& request)

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (247661 => 247662)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2019-07-20 00:40:25 UTC (rev 247661)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2019-07-20 00:55:16 UTC (rev 247662)
@@ -1561,6 +1561,10 @@
 
     URL currentResourceDirectoryURL() const;
 
+#if ENABLE(MEDIA_STREAM)
+    void setMockCaptureDevicesEnabledOverride(Optional<bool>);
+#endif
+
 private:
     WebPageProxy(PageClient&, WebProcessProxy&, WebCore::PageIdentifier, Ref<API::PageConfiguration>&&);
     void platformInitialize();

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebInspectorClient.cpp (247661 => 247662)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebInspectorClient.cpp	2019-07-20 00:40:25 UTC (rev 247661)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebInspectorClient.cpp	2019-07-20 00:55:16 UTC (rev 247662)
@@ -211,6 +211,12 @@
         m_page->inspector()->elementSelectionChanged(active);
 }
 
+void WebInspectorClient::setMockCaptureDevicesEnabledOverride(Optional<bool> enabled)
+{
+    if (m_page->inspector())
+        m_page->inspector()->setMockCaptureDevicesEnabledOverride(enabled);
+}
+
 void WebInspectorClient::willMoveToPage(PageOverlay&, Page* page)
 {
     if (page)

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebInspectorClient.h (247661 => 247662)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebInspectorClient.h	2019-07-20 00:40:25 UTC (rev 247661)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebInspectorClient.h	2019-07-20 00:55:16 UTC (rev 247662)
@@ -71,6 +71,8 @@
     bool overridesShowPaintRects() const override { return true; }
     void showPaintRect(const WebCore::FloatRect&) override;
 
+    void setMockCaptureDevicesEnabledOverride(Optional<bool>) final;
+
     // PageOverlay::Client
     void willMoveToPage(WebCore::PageOverlay&, WebCore::Page*) override;
     void didMoveToPage(WebCore::PageOverlay&, WebCore::Page*) override;

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebInspector.cpp (247661 => 247662)


--- trunk/Source/WebKit/WebProcess/WebPage/WebInspector.cpp	2019-07-20 00:40:25 UTC (rev 247661)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebInspector.cpp	2019-07-20 00:55:16 UTC (rev 247662)
@@ -284,6 +284,11 @@
     WebProcess::singleton().parentProcessConnection()->send(Messages::WebInspectorProxy::ElementSelectionChanged(active), m_page->pageID());
 }
 
+void WebInspector::setMockCaptureDevicesEnabledOverride(Optional<bool> enabled)
+{
+    WebProcess::singleton().parentProcessConnection()->send(Messages::WebInspectorProxy::SetMockCaptureDevicesEnabledOverride(enabled), m_page->pageID());
+}
+
 bool WebInspector::canAttachWindow()
 {
     if (!m_page->corePage())

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebInspector.h (247661 => 247662)


--- trunk/Source/WebKit/WebProcess/WebPage/WebInspector.h	2019-07-20 00:40:25 UTC (rev 247661)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebInspector.h	2019-07-20 00:55:16 UTC (rev 247662)
@@ -73,6 +73,7 @@
     void startElementSelection();
     void stopElementSelection();
     void elementSelectionChanged(bool);
+    void setMockCaptureDevicesEnabledOverride(Optional<bool>);
 
     void setFrontendConnection(IPC::Attachment);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to