Changeset 247662 in webkit


Ignore:
Timestamp:
Jul 19, 2019 5:55:16 PM (5 years ago)
Author:
youenn@apple.com
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:
Location:
trunk/Source
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r247655 r247662  
     12019-07-19  Youenn Fablet  <youenn@apple.com>
     2
     3        Remote WebInspector should enable mock capture devices in UIProcess if doing it in WebProcess
     4        https://bugs.webkit.org/show_bug.cgi?id=199924
     5        <rdar://problem/50552067>
     6
     7        Reviewed by Devin Rousso.
     8
     9        Add necessary API to set mock capture devices override.
     10        In case of desynchronization between webprocess and uiprocess, make sure to return early
     11        and fail capture instead of crashing.
     12
     13        * inspector/InspectorClient.h:
     14        (WebCore::InspectorClient::setMockCaptureDevicesEnabled):
     15        * inspector/agents/InspectorPageAgent.cpp:
     16        (WebCore::InspectorPageAgent::disable):
     17        (WebCore::InspectorPageAgent::overrideSetting):
     18        * platform/mock/MockRealtimeMediaSourceCenter.cpp:
     19
    1202019-07-19  Andy Estes  <aestes@apple.com>
    221
  • trunk/Source/WebCore/inspector/InspectorClient.h

    r238192 r247662  
    2828
    2929#include <wtf/Forward.h>
     30#include <wtf/Optional.h>
    3031
    3132namespace Inspector {
     
    6364    virtual void elementSelectionChanged(bool) { }
    6465
     66    virtual void setMockCaptureDevicesEnabledOverride(Optional<bool>) { }
     67
    6568#if ENABLE(REMOTE_INSPECTOR)
    6669    virtual bool allowRemoteInspectionToPageDirectly() const { return false; }
  • trunk/Source/WebCore/inspector/agents/InspectorPageAgent.cpp

    r247438 r247662  
    389389#undef DISABLE_INSPECTOR_OVERRIDE_SETTING
    390390
     391    m_client->setMockCaptureDevicesEnabledOverride(WTF::nullopt);
     392
    391393    m_instrumentingAgents.setInspectorPageAgent(nullptr);
    392394}
     
    436438    switch (setting.value()) {
    437439#define CASE_INSPECTOR_OVERRIDE_SETTING(name) \
    438     case Inspector::Protocol::Page::Setting::name: { \
    439         if (value) \
    440             m_inspectedPage.settings().set##name##InspectorOverride(*value); \
    441         else \
     440    case Inspector::Protocol::Page::Setting::name: {                               \
     441        if (value)                                                                 \
     442            m_inspectedPage.settings().set##name##InspectorOverride(*value);       \
     443        else                                                                       \
    442444            m_inspectedPage.settings().set##name##InspectorOverride(WTF::nullopt); \
    443         return; \
    444     } \
     445        break;                                                                    \
     446    }                                                                              \
    445447
    446448    FOR_EACH_INSPECTOR_OVERRIDE_SETTING(CASE_INSPECTOR_OVERRIDE_SETTING)
     
    449451    }
    450452
    451     ASSERT_NOT_REACHED();
     453    // Update the UIProcess / client for particular overrides.
     454    if (setting.value() == Inspector::Protocol::Page::Setting::MockCaptureDevicesEnabled)
     455        m_client->setMockCaptureDevicesEnabledOverride(value);
    452456}
    453457
  • trunk/Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp

    r246002 r247662  
    9090    {
    9191        ASSERT(device.type() == CaptureDevice::DeviceType::Camera);
    92         ASSERT(MockRealtimeMediaSourceCenter::captureDeviceWithPersistentID(CaptureDevice::DeviceType::Camera, device.persistentId()));
     92        if (!MockRealtimeMediaSourceCenter::captureDeviceWithPersistentID(CaptureDevice::DeviceType::Camera, device.persistentId()))
     93            return { };
    9394
    9495        return MockRealtimeVideoSource::create(String { device.persistentId() }, String { device.label() }, WTFMove(hashSalt), constraints);
     
    110111    CaptureSourceOrError createDisplayCaptureSource(const CaptureDevice& device, const MediaConstraints* constraints) final
    111112    {
    112         ASSERT(MockRealtimeMediaSourceCenter::captureDeviceWithPersistentID(device.type(), device.persistentId()));
     113        if (!MockRealtimeMediaSourceCenter::captureDeviceWithPersistentID(device.type(), device.persistentId()))
     114            return { };
    113115
    114116        switch (device.type()) {
     
    135137    {
    136138        ASSERT(device.type() == CaptureDevice::DeviceType::Microphone);
    137         ASSERT(MockRealtimeMediaSourceCenter::captureDeviceWithPersistentID(CaptureDevice::DeviceType::Microphone, device.persistentId()));
     139        if (!MockRealtimeMediaSourceCenter::captureDeviceWithPersistentID(CaptureDevice::DeviceType::Microphone, device.persistentId()))
     140            return { };
    138141
    139142        return MockRealtimeAudioSource::create(String { device.persistentId() }, String { device.label() }, WTFMove(hashSalt), constraints);
  • trunk/Source/WebKit/ChangeLog

    r247658 r247662  
     12019-07-19  Youenn Fablet  <youenn@apple.com>
     2
     3        Remote WebInspector should enable mock capture devices in UIProcess if doing it in WebProcess
     4        https://bugs.webkit.org/show_bug.cgi?id=199924
     5        <rdar://problem/50552067>
     6
     7        Reviewed by Devin Rousso.
     8
     9        Add IPC plumbery to pass inspector override value for mock capture devices.
     10        Add an override in UserMediaPermissionRequestManagerProxy so that the value stays in sync with web inspector.
     11        The override will be removed when web inspector goes away.
     12
     13        * UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
     14        (WebKit::UserMediaPermissionRequestManagerProxy::syncWithWebCorePrefs const):
     15        * UIProcess/UserMediaPermissionRequestManagerProxy.h:
     16        (WebKit::UserMediaPermissionRequestManagerProxy::setMockCaptureDevicesEnabledOverride):
     17        * UIProcess/WebInspectorProxy.cpp:
     18        (WebKit::WebInspectorProxy::setMockCaptureDevicesEnabled):
     19        * UIProcess/WebInspectorProxy.h:
     20        * UIProcess/WebInspectorProxy.messages.in:
     21        * UIProcess/WebPageProxy.cpp:
     22        (WebKit::WebPageProxy::setMockCaptureDevicesEnabledOverride):
     23        * UIProcess/WebPageProxy.h:
     24        * WebProcess/WebCoreSupport/WebInspectorClient.cpp:
     25        (WebKit::WebInspectorClient::setMockCaptureDevicesEnabled):
     26        * WebProcess/WebCoreSupport/WebInspectorClient.h:
     27        * WebProcess/WebPage/WebInspector.cpp:
     28        (WebKit::WebInspector::setMockCaptureDevicesEnabled):
     29        * WebProcess/WebPage/WebInspector.h:
     30
    1312019-07-19  Tim Horton  <timothy_horton@apple.com>
    232
  • trunk/Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.cpp

    r246185 r247662  
    652652    // Enable/disable the mock capture devices for the UI process as per the WebCore preferences. Note that
    653653    // this is a noop if the preference hasn't changed since the last time this was called.
    654     bool mockDevicesEnabled = m_page.preferences().mockCaptureDevicesEnabled();
     654    bool mockDevicesEnabled = m_mockDevicesEnabledOverride ? *m_mockDevicesEnabledOverride : m_page.preferences().mockCaptureDevicesEnabled();
    655655    MockRealtimeMediaSourceCenter::setMockRealtimeMediaSourceCenterEnabled(mockDevicesEnabled);
    656656#endif
  • trunk/Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.h

    r246185 r247662  
    8686    };
    8787
     88    void setMockCaptureDevicesEnabledOverride(Optional<bool> enabled) { m_mockDevicesEnabledOverride = enabled; }
     89
    8890private:
    8991#if !RELEASE_LOG_DISABLED
     
    151153    bool m_hasFilteredDeviceList { false };
    152154    uint64_t m_hasPendingCapture { 0 };
     155    Optional<bool> m_mockDevicesEnabledOverride;
    153156};
    154157
  • trunk/Source/WebKit/UIProcess/WebInspectorProxy.cpp

    r247043 r247662  
    4343#include "WebProcessProxy.h"
    4444#include <WebCore/CertificateInfo.h>
     45#include <WebCore/MockRealtimeMediaSourceCenter.h>
    4546#include <WebCore/NotImplemented.h>
    4647#include <WebCore/TextEncoding.h>
     
    593594}
    594595
     596void WebInspectorProxy::setMockCaptureDevicesEnabledOverride(Optional<bool> enabled)
     597{
     598#if ENABLE(MEDIA_STREAM)
     599    if (!m_inspectedPage)
     600        return;
     601
     602    m_inspectedPage->setMockCaptureDevicesEnabledOverride(enabled);
     603#else
     604    UNUSED_PARAM(enabled);
     605#endif
     606}
     607
    595608void WebInspectorProxy::save(const String& filename, const String& content, bool base64Encoded, bool forceSaveAs)
    596609{
  • trunk/Source/WebKit/UIProcess/WebInspectorProxy.h

    r247043 r247662  
    228228    void showCertificate(const WebCore::CertificateInfo&);
    229229    void elementSelectionChanged(bool);
     230    void setMockCaptureDevicesEnabledOverride(Optional<bool>);
    230231
    231232    void save(const String& filename, const String& content, bool base64Encoded, bool forceSaveAs);
  • trunk/Source/WebKit/UIProcess/WebInspectorProxy.messages.in

    r247043 r247662  
    3636    ShowCertificate(WebCore::CertificateInfo certificateInfo)
    3737    ElementSelectionChanged(bool active)
     38    SetMockCaptureDevicesEnabledOverride(Optional<bool> enabled)
    3839
    3940    Save(String filename, String content, bool base64Encoded, bool forceSaveAs)
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r247490 r247662  
    73957395    return *m_userMediaPermissionRequestManager;
    73967396}
     7397
     7398void WebPageProxy::setMockCaptureDevicesEnabledOverride(Optional<bool> enabled)
     7399{
     7400    userMediaPermissionRequestManager().setMockCaptureDevicesEnabledOverride(enabled);
     7401}
    73977402#endif
    73987403
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r247490 r247662  
    15621562    URL currentResourceDirectoryURL() const;
    15631563
     1564#if ENABLE(MEDIA_STREAM)
     1565    void setMockCaptureDevicesEnabledOverride(Optional<bool>);
     1566#endif
     1567
    15641568private:
    15651569    WebPageProxy(PageClient&, WebProcessProxy&, WebCore::PageIdentifier, Ref<API::PageConfiguration>&&);
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/WebInspectorClient.cpp

    r241183 r247662  
    212212}
    213213
     214void WebInspectorClient::setMockCaptureDevicesEnabledOverride(Optional<bool> enabled)
     215{
     216    if (m_page->inspector())
     217        m_page->inspector()->setMockCaptureDevicesEnabledOverride(enabled);
     218}
     219
    214220void WebInspectorClient::willMoveToPage(PageOverlay&, Page* page)
    215221{
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/WebInspectorClient.h

    r237266 r247662  
    7272    void showPaintRect(const WebCore::FloatRect&) override;
    7373
     74    void setMockCaptureDevicesEnabledOverride(Optional<bool>) final;
     75
    7476    // PageOverlay::Client
    7577    void willMoveToPage(WebCore::PageOverlay&, WebCore::Page*) override;
  • trunk/Source/WebKit/WebProcess/WebPage/WebInspector.cpp

    r244167 r247662  
    285285}
    286286
     287void WebInspector::setMockCaptureDevicesEnabledOverride(Optional<bool> enabled)
     288{
     289    WebProcess::singleton().parentProcessConnection()->send(Messages::WebInspectorProxy::SetMockCaptureDevicesEnabledOverride(enabled), m_page->pageID());
     290}
     291
    287292bool WebInspector::canAttachWindow()
    288293{
  • trunk/Source/WebKit/WebProcess/WebPage/WebInspector.h

    r238660 r247662  
    7474    void stopElementSelection();
    7575    void elementSelectionChanged(bool);
     76    void setMockCaptureDevicesEnabledOverride(Optional<bool>);
    7677
    7778    void setFrontendConnection(IPC::Attachment);
Note: See TracChangeset for help on using the changeset viewer.