Unreviewed, rolling out r216160 and r216161.
authorryanhaddad@apple.com <ryanhaddad@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 May 2017 01:00:27 +0000 (01:00 +0000)
committerryanhaddad@apple.com <ryanhaddad@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 May 2017 01:00:27 +0000 (01:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=171640

These changes broke the iOS build. (Requested by mlewis13 on
#webkit).

Reverted changesets:

"[MediaStream] Allow host application to enable/disable media
capture"
https://bugs.webkit.org/show_bug.cgi?id=171292
http://trac.webkit.org/changeset/216160

"[MediaStream] Allow host application to enable/disable media
capture"
https://bugs.webkit.org/show_bug.cgi?id=171292
http://trac.webkit.org/changeset/216161

Patch by Commit Queue <commit-queue@webkit.org> on 2017-05-03

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216162 268f45cc-cd09-0410-ab3c-d52691b4dbfc

35 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/MediaStream.cpp
Source/WebCore/Modules/mediastream/MediaStream.h
Source/WebCore/Modules/mediastream/MediaStreamRegistry.cpp
Source/WebCore/Modules/mediastream/MediaStreamRegistry.h
Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp
Source/WebCore/Modules/mediastream/MediaStreamTrack.h
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm
Source/WebCore/platform/mediastream/MediaStreamPrivate.h
Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.mm
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/C/WKPage.cpp
Source/WebKit2/UIProcess/API/C/WKPagePrivate.h
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h
Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm
Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.cpp
Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.h
Source/WebKit2/UIProcess/UserMediaProcessManager.cpp
Source/WebKit2/UIProcess/UserMediaProcessManager.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
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/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/UserMediaDisabled.mm [deleted file]
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/disableGetUserMedia.html [deleted file]

index 299046c..4ca205e 100644 (file)
@@ -1,3 +1,23 @@
+2017-05-03  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r216160 and r216161.
+        https://bugs.webkit.org/show_bug.cgi?id=171640
+
+        These changes broke the iOS build. (Requested by mlewis13 on
+        #webkit).
+
+        Reverted changesets:
+
+        "[MediaStream] Allow host application to enable/disable media
+        capture"
+        https://bugs.webkit.org/show_bug.cgi?id=171292
+        http://trac.webkit.org/changeset/216160
+
+        "[MediaStream] Allow host application to enable/disable media
+        capture"
+        https://bugs.webkit.org/show_bug.cgi?id=171292
+        http://trac.webkit.org/changeset/216161
+
 2017-05-03  Eric Carlson  <eric.carlson@apple.com>
 
         [MediaStream] Allow host application to enable/disable media capture
index b1ee335..604ca3a 100644 (file)
@@ -314,12 +314,6 @@ void MediaStream::stopProducingData()
     m_private->stopProducingData();
 }
 
-void MediaStream::endStream()
-{
-    for (auto& track : m_trackSet.values())
-        track->stopTrack(MediaStreamTrack::StopMode::PostEvent);
-}
-
 void MediaStream::pageMutedStateDidChange()
 {
     if (!m_isActive)
index 82d648b..f6e04a2 100644 (file)
@@ -91,8 +91,6 @@ public:
     void startProducingData();
     void stopProducingData();
 
-    void endStream();
-
     // EventTarget
     EventTargetInterface eventTargetInterface() const final { return MediaStreamEventTargetInterfaceType; }
     ScriptExecutionContext* scriptExecutionContext() const final { return ContextDestructionObserver::scriptExecutionContext(); }
@@ -108,8 +106,6 @@ public:
 
     void addTrackFromPlatform(Ref<MediaStreamTrack>&&);
 
-    Document* document() const;
-
 protected:
     MediaStream(ScriptExecutionContext&, const MediaStreamTrackVector&);
     MediaStream(ScriptExecutionContext&, Ref<MediaStreamPrivate>&&);
@@ -162,6 +158,8 @@ private:
     void setIsActive(bool);
     void statusDidChange();
 
+    Document* document() const;
+
     MediaStreamTrackVector trackVectorForType(RealtimeMediaSource::Type) const;
 
     Ref<MediaStreamPrivate> m_private;
index 8e7cec9..72e1d94 100644 (file)
@@ -62,6 +62,10 @@ URLRegistrable* MediaStreamRegistry::lookup(const String& url) const
     return m_mediaStreams.get(url);
 }
 
+MediaStreamRegistry::MediaStreamRegistry()
+{
+}
+
 MediaStream* MediaStreamRegistry::lookUp(const URL& url) const
 {
     return static_cast<MediaStream*>(lookup(url.string()));
@@ -80,16 +84,21 @@ void MediaStreamRegistry::registerStream(MediaStream& stream)
 
 void MediaStreamRegistry::unregisterStream(MediaStream& stream)
 {
-    auto& allStreams = mediaStreams();
+    Vector<MediaStream*>& allStreams = mediaStreams();
     size_t pos = allStreams.find(&stream);
     if (pos != notFound)
         allStreams.remove(pos);
 }
 
-void MediaStreamRegistry::forEach(std::function<void(MediaStream&)> callback) const
+MediaStream* MediaStreamRegistry::lookUp(const MediaStreamPrivate& privateStream) const
 {
-    for (auto& stream : mediaStreams())
-        callback(*stream);
+    Vector<MediaStream*>& allStreams = mediaStreams();
+    for (auto& stream : allStreams) {
+        if (&stream->privateStream() == &privateStream)
+            return stream;
+    }
+
+    return nullptr;
 }
 
 } // namespace WebCore
index 030bce9..7e23a1e 100644 (file)
@@ -54,11 +54,10 @@ public:
     void unregisterStream(MediaStream&);
 
     MediaStream* lookUp(const URL&) const;
-
-    void forEach(std::function<void(MediaStream&)>) const;
+    MediaStream* lookUp(const MediaStreamPrivate&) const;
 
 private:
-    MediaStreamRegistry() = default;
+    MediaStreamRegistry();
     HashMap<String, RefPtr<MediaStream>> m_mediaStreams;
 };
 
index 6a6ba51..c0efea1 100644 (file)
@@ -113,7 +113,7 @@ Ref<MediaStreamTrack> MediaStreamTrack::clone()
     return MediaStreamTrack::create(*scriptExecutionContext(), m_private->clone());
 }
 
-void MediaStreamTrack::stopTrack(StopMode mode)
+void MediaStreamTrack::stopTrack()
 {
     // NOTE: this method is called when the "stop" method is called from JS, using the "ImplementedAs" IDL attribute.
     // This is done because ActiveDOMObject requires a "stop" method.
@@ -121,13 +121,8 @@ void MediaStreamTrack::stopTrack(StopMode mode)
     if (ended())
         return;
 
-    // An 'ended' event is not posted if m_ended is true when trackEnded is called, so set it now if we are
-    // not supposed to post the event.
-    if (mode == StopMode::Silently)
-        m_ended = true;
-
-    m_private->endTrack();
     m_ended = true;
+    m_private->endTrack();
 }
 
 MediaStreamTrack::TrackSettings MediaStreamTrack::getSettings() const
@@ -308,7 +303,7 @@ void MediaStreamTrack::trackEnded(MediaStreamTrackPrivate&)
     
 void MediaStreamTrack::trackMutedChanged(MediaStreamTrackPrivate&)
 {
-    if (scriptExecutionContext()->activeDOMObjectsAreSuspended() || scriptExecutionContext()->activeDOMObjectsAreStopped() || m_ended)
+    if (scriptExecutionContext()->activeDOMObjectsAreSuspended() || scriptExecutionContext()->activeDOMObjectsAreStopped())
         return;
 
     AtomicString eventType = muted() ? eventNames().muteEvent : eventNames().unmuteEvent;
index 3b7ebf9..4b212de 100644 (file)
@@ -71,9 +71,7 @@ public:
     bool ended() const;
 
     Ref<MediaStreamTrack> clone();
-
-    enum class StopMode { Silently, PostEvent };
-    void stopTrack(StopMode = StopMode::Silently);
+    void stopTrack();
 
     bool isCaptureTrack() const;
 
index d9ce033..0f14c28 100644 (file)
 #include "XSLTProcessor.h"
 #endif
 
-#if ENABLE(MEDIA_STREAM)
-#include "MediaStream.h"
-#include "MediaStreamRegistry.h"
-#endif
-
 using namespace WTF;
 using namespace Unicode;
 
@@ -6977,14 +6972,4 @@ void Document::orientationChanged(int orientation)
     m_orientationNotifier.orientationChanged(orientation);
 }
 
-#if ENABLE(MEDIA_STREAM)
-void Document::stopMediaCapture()
-{
-    MediaStreamRegistry::shared().forEach([this](MediaStream& stream) {
-        if (stream.document() == this)
-            stream.endStream();
-    });
-}
-#endif
-
 } // namespace WebCore
index d2e5e5c..398e539 100644 (file)
@@ -1277,7 +1277,6 @@ public:
     bool hasHadActiveMediaStreamTrack() const { return m_hasHadActiveMediaStreamTrack; }
     void setDeviceIDHashSalt(const String& salt) { m_idHashSalt = salt; }
     String deviceIDHashSalt() const { return m_idHashSalt; }
-    void stopMediaCapture();
 #endif
 
 // FIXME: Find a better place for this functionality.
index 90af4df..ffc60df 100644 (file)
@@ -1532,18 +1532,6 @@ void Page::setMuted(MediaProducer::MutedStateFlags muted)
     }
 }
 
-void Page::stopMediaCapture()
-{
-#if ENABLE(MEDIA_STREAM)
-    for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
-        if (!frame->document())
-            continue;
-
-        frame->document()->stopMediaCapture();
-    }
-#endif
-}
-
 #if ENABLE(MEDIA_SESSION)
 void Page::handleMediaEvent(MediaEventType eventType)
 {
index 1942961..8679d86 100644 (file)
@@ -530,7 +530,6 @@ public:
     bool isAudioMuted() const { return m_mutedState & MediaProducer::AudioIsMuted; }
     bool isMediaCaptureMuted() const { return m_mutedState & MediaProducer::CaptureDevicesAreMuted; };
     WEBCORE_EXPORT void setMuted(MediaProducer::MutedStateFlags);
-    WEBCORE_EXPORT void stopMediaCapture();
 
 #if ENABLE(MEDIA_SESSION)
     WEBCORE_EXPORT void handleMediaEvent(MediaEventType);
index f72e365..ccbfb0e 100644 (file)
@@ -580,21 +580,21 @@ PlatformLayer* MediaPlayerPrivateMediaStreamAVFObjC::backgroundLayer()
 
 MediaPlayerPrivateMediaStreamAVFObjC::DisplayMode MediaPlayerPrivateMediaStreamAVFObjC::currentDisplayMode() const
 {
-    if (m_intrinsicSize.isEmpty() || !metaDataAvailable() || !m_sampleBufferDisplayLayer)
+    if (m_ended || m_intrinsicSize.isEmpty() || !metaDataAvailable() || !m_sampleBufferDisplayLayer)
         return None;
 
     if (auto* track = m_mediaStreamPrivate->activeVideoTrack()) {
-        if (!track->enabled() || track->muted() || track->ended())
+        if (!track->enabled() || track->muted())
             return PaintItBlack;
     }
 
-    if (playing() && !m_ended) {
+    if (playing()) {
         if (!m_mediaStreamPrivate->isProducingData())
             return PausedImage;
         return LivePreview;
     }
 
-    if (m_playbackState == PlaybackState::None || m_ended)
+    if (m_playbackState == PlaybackState::None)
         return PaintItBlack;
 
     return PausedImage;
@@ -768,10 +768,8 @@ void MediaPlayerPrivateMediaStreamAVFObjC::activeStatusChanged()
 
         if (ended != m_ended) {
             m_ended = ended;
-            if (m_player) {
+            if (m_player)
                 m_player->timeChanged();
-                m_player->characteristicChanged();
-            }
         }
     });
 }
index a79704d..ad1d501 100644 (file)
@@ -95,8 +95,6 @@ public:
     void stopProducingData();
     bool isProducingData() const;
 
-    void endStream();
-
     bool hasVideo() const;
     bool hasAudio() const;
     bool muted() const;
index 122bdb8..e7db948 100644 (file)
@@ -181,14 +181,11 @@ void AVMediaCaptureSource::startProducingData()
 
 void AVMediaCaptureSource::stopProducingData()
 {
-    if (!m_session)
+    if (!m_session || ![m_session isRunning])
         return;
 
     [m_objcObserver removeNotificationObservers];
-
-    if ([m_session isRunning])
-        [m_session stopRunning];
-
+    [m_session stopRunning];
 #if PLATFORM(IOS)
     m_session = nullptr;
 #endif
index 7ae959e..8a4c3fe 100644 (file)
@@ -1,3 +1,23 @@
+2017-05-03  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r216160 and r216161.
+        https://bugs.webkit.org/show_bug.cgi?id=171640
+
+        These changes broke the iOS build. (Requested by mlewis13 on
+        #webkit).
+
+        Reverted changesets:
+
+        "[MediaStream] Allow host application to enable/disable media
+        capture"
+        https://bugs.webkit.org/show_bug.cgi?id=171292
+        http://trac.webkit.org/changeset/216160
+
+        "[MediaStream] Allow host application to enable/disable media
+        capture"
+        https://bugs.webkit.org/show_bug.cgi?id=171292
+        http://trac.webkit.org/changeset/216161
+
 2017-05-03  Eric Carlson  <eric.carlson@apple.com>
 
         [MediaStream] Allow host application to enable/disable media capture
index a880d3f..4ae752b 100644 (file)
@@ -2677,16 +2677,6 @@ void WKPageSetMuted(WKPageRef page, WKMediaMutedState muted)
     toImpl(page)->setMuted(muted);
 }
 
-void WKPageSetMediaCaptureEnabled(WKPageRef page, bool enabled)
-{
-    toImpl(page)->setMediaCaptureEnabled(enabled);
-}
-
-bool WKPageGetMediaCaptureEnabled(WKPageRef page)
-{
-    return toImpl(page)->mediaCaptureEnabled();
-}
-
 void WKPageDidAllowPointerLock(WKPageRef page)
 {
 #if ENABLE(POINTER_LOCK)
index 6009bad..9c41623 100644 (file)
@@ -127,8 +127,6 @@ typedef uint32_t WKMediaMutedState;
 WK_EXPORT void WKPageSetMuted(WKPageRef page, WKMediaMutedState muted);
 
 WK_EXPORT void WKPageClearUserMediaState(WKPageRef page);
-WK_EXPORT void WKPageSetMediaCaptureEnabled(WKPageRef page, bool enabled);
-WK_EXPORT bool WKPageGetMediaCaptureEnabled(WKPageRef page);
 
 WK_EXPORT void WKPageDidAllowPointerLock(WKPageRef page);
 WK_EXPORT void WKPageDidDenyPointerLock(WKPageRef page);
index 9519246..bd4bf42 100644 (file)
@@ -4473,16 +4473,6 @@ static inline WebKit::FindOptions toFindOptions(_WKFindOptions wkFindOptions)
     _page->setMuted(WebCore::MediaProducer::CaptureDevicesAreMuted);
 }
 
-- (void)_setMediaCaptureEnabled:(BOOL)enabled
-{
-    _page->setMediaCaptureEnabled(enabled);
-}
-
-- (BOOL)_mediaCaptureEnabled
-{
-    return _page->mediaCaptureEnabled();
-}
-
 - (void)_setPageMuted:(_WKMediaMutedState)mutedState
 {
     WebCore::MediaProducer::MutedStateFlags coreState = WebCore::MediaProducer::NoneMuted;
index 3700f30..87d6a6d 100644 (file)
@@ -292,11 +292,9 @@ typedef NS_ENUM(NSInteger, _WKImmediateActionType) {
 @property (nonatomic, setter=_setFullscreenDelegate:) id<_WKFullscreenDelegate> _fullscreenDelegate WK_API_AVAILABLE(macosx(WK_MAC_TBA));
 @property (nonatomic, readonly) BOOL _isInFullscreen WK_API_AVAILABLE(macosx(WK_MAC_TBA));
 
-- (void)_muteMediaCapture WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (void)_muteMediaCapture;
 - (void)_setPageMuted:(_WKMediaMutedState)mutedState WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 
-@property (nonatomic, setter=_setMediaCaptureEnabled:) BOOL _mediaCaptureEnabled WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
-
 @end
 
 #if !TARGET_OS_IPHONE
index 4f21e82..84c5ed1 100644 (file)
@@ -115,11 +115,11 @@ void UIDelegate::setDelegate(id <WKUIDelegate> delegate)
 #endif
     m_delegateMethods.webViewActionsForElementDefaultActions = [delegate respondsToSelector:@selector(_webView:actionsForElement:defaultActions:)];
     m_delegateMethods.webViewDidNotHandleTapAsClickAtPoint = [delegate respondsToSelector:@selector(_webView:didNotHandleTapAsClickAtPoint:)];
-    m_delegateMethods.presentingViewControllerForWebView = [delegate respondsToSelector:@selector(_presentingViewControllerForWebView:)];
-#endif
     m_delegateMethods.webViewRequestUserMediaAuthorizationForDevicesURLMainFrameURLDecisionHandler = [delegate respondsToSelector:@selector(_webView:requestUserMediaAuthorizationForDevices:url:mainFrameURL:decisionHandler:)];
     m_delegateMethods.webViewCheckUserMediaPermissionForURLMainFrameURLFrameIdentifierDecisionHandler = [delegate respondsToSelector:@selector(_webView:checkUserMediaPermissionForURL:mainFrameURL:frameIdentifier:decisionHandler:)];
     m_delegateMethods.webViewMediaCaptureStateDidChange = [delegate respondsToSelector:@selector(_webView:mediaCaptureStateDidChange:)];
+    m_delegateMethods.presentingViewControllerForWebView = [delegate respondsToSelector:@selector(_presentingViewControllerForWebView:)];
+#endif
     m_delegateMethods.dataDetectionContextForWebView = [delegate respondsToSelector:@selector(_dataDetectionContextForWebView:)];
     m_delegateMethods.webViewImageOrMediaDocumentSizeChanged = [delegate respondsToSelector:@selector(_webView:imageOrMediaDocumentSizeChanged:)];
 
index 27ae445..7568040 100644 (file)
@@ -96,7 +96,6 @@ FrameAuthorizationState& UserMediaPermissionRequestManagerProxy::stateForRequest
 
 UserMediaPermissionRequestManagerProxy::UserMediaPermissionRequestManagerProxy(WebPageProxy& page)
     : m_page(page)
-    , m_rejectionTimer(*this, &UserMediaPermissionRequestManagerProxy::rejectionTimerFired)
 {
 #if ENABLE(MEDIA_STREAM)
     UserMediaProcessManager::singleton().addUserMediaPermissionRequestManagerProxy(*this);
@@ -108,10 +107,10 @@ UserMediaPermissionRequestManagerProxy::~UserMediaPermissionRequestManagerProxy(
 #if ENABLE(MEDIA_STREAM)
     UserMediaProcessManager::singleton().removeUserMediaPermissionRequestManagerProxy(*this);
 #endif
-    invalidatePendingRequests();
+    invalidateRequests();
 }
 
-void UserMediaPermissionRequestManagerProxy::invalidatePendingRequests()
+void UserMediaPermissionRequestManagerProxy::invalidateRequests()
 {
     for (auto& request : m_pendingUserMediaRequests.values())
         request->invalidate();
@@ -124,15 +123,9 @@ void UserMediaPermissionRequestManagerProxy::invalidatePendingRequests()
     m_frameStates.clear();
 }
 
-void UserMediaPermissionRequestManagerProxy::stopCapture()
-{
-    invalidatePendingRequests();
-    m_page.process().send(Messages::WebPage::StopMediaCapture(), m_page.pageID());
-}
-
 void UserMediaPermissionRequestManagerProxy::clearCachedState()
 {
-    invalidatePendingRequests();
+    invalidateRequests();
 }
 
 Ref<UserMediaPermissionRequestProxy> UserMediaPermissionRequestManagerProxy::createRequest(uint64_t userMediaID, uint64_t frameID, const String& userMediaDocumentOriginIdentifier, const String& topLevelDocumentOriginIdentifier, const Vector<String>& audioDeviceUIDs, const Vector<String>& videoDeviceUIDs)
@@ -230,23 +223,6 @@ void UserMediaPermissionRequestManagerProxy::userMediaAccessWasGranted(uint64_t
 #endif
 }
 
-void UserMediaPermissionRequestManagerProxy::rejectionTimerFired()
-{
-    uint64_t userMediaID = m_pendingRejections[0];
-    m_pendingRejections.remove(0);
-
-    denyRequest(userMediaID, UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::PermissionDenied, emptyString());
-    if (!m_pendingRejections.isEmpty())
-        scheduleNextRejection();
-}
-
-void UserMediaPermissionRequestManagerProxy::scheduleNextRejection()
-{
-    const double mimimumDelayBeforeReplying = .25;
-    if (!m_rejectionTimer.isActive())
-        m_rejectionTimer.startOneShot(Seconds(mimimumDelayBeforeReplying + randomNumber()));
-}
-
 void UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame(uint64_t userMediaID, uint64_t frameID, String userMediaDocumentOriginIdentifier, String topLevelDocumentOriginIdentifier, const WebCore::MediaConstraintsData& audioConstraintsData, const WebCore::MediaConstraintsData& videoConstraintsData)
 {
 #if ENABLE(MEDIA_STREAM)
@@ -296,12 +272,6 @@ void UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame(
 
     };
 
-    if (!UserMediaProcessManager::singleton().captureEnabled()) {
-        m_pendingRejections.append(userMediaID);
-        scheduleNextRejection();
-        return;
-    }
-
     auto audioConstraints = MediaConstraintsImpl::create(MediaConstraintsData(audioConstraintsData));
     auto videoConstraints = MediaConstraintsImpl::create(MediaConstraintsData(videoConstraintsData));
 
index e12e02d..adef5f8 100644 (file)
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#pragma once
+#ifndef UserMediaPermissionRequestManagerProxy_h
+#define UserMediaPermissionRequestManagerProxy_h
 
 #include "UserMediaPermissionCheckProxy.h"
 #include "UserMediaPermissionRequestProxy.h"
 #include <WebCore/SecurityOrigin.h>
-#include <WebCore/Timer.h>
 #include <WebCore/UserMediaRequest.h>
 #include <wtf/HashMap.h>
-#include <wtf/Seconds.h>
 
 namespace WebCore {
 class CaptureDevice;
@@ -58,7 +57,7 @@ public:
 
     WebPageProxy& page() const { return m_page; }
 
-    void invalidatePendingRequests();
+    void invalidateRequests();
 
     void requestUserMediaPermissionForFrame(uint64_t userMediaID, uint64_t frameID, String userMediaDocumentOriginIdentifier, String topLevelDocumentOriginIdentifier, const WebCore::MediaConstraintsData& audioConstraintsData, const WebCore::MediaConstraintsData& videoConstraintsData);
 
@@ -70,9 +69,6 @@ public:
 
     void didCompleteUserMediaPermissionCheck(uint64_t, const String&, bool allow);
 
-    void stopCapture();
-    void scheduleNextRejection();
-    void rejectionTimerFired();
     void clearCachedState();
 
     void startedCaptureSession();
@@ -89,10 +85,8 @@ private:
     HashMap<uint64_t, std::unique_ptr<FrameAuthorizationState>> m_frameStates;
 
     WebPageProxy& m_page;
-
-    WebCore::Timer m_rejectionTimer;
-    Vector<uint64_t> m_pendingRejections;
 };
 
 } // namespace WebKit
 
+#endif // UserMediaPermissionRequestManagerProxy_h
index 7975304..e71816b 100644 (file)
@@ -115,12 +115,8 @@ void UserMediaProcessManager::willEnableMediaStreamInPage(WebPageProxy& pageStar
     for (auto& state : stateMap()) {
         for (auto& manager : state.value->managers()) {
 
-            if (&manager->page() == &pageStartingCapture) {
-#if PLATFORM(IOS)
-                manager->page().stopCapture();
-#endif
+            if (&manager->page() == &pageStartingCapture)
                 continue;
-            }
 
             manager->page().setMuted(WebCore::MediaProducer::CaptureDevicesAreMuted);
         }
@@ -234,22 +230,6 @@ void UserMediaProcessManager::endedCaptureSession(UserMediaPermissionRequestMana
 #endif
 }
 
-void UserMediaProcessManager::setCaptureEnabled(bool enabled)
-{
-    if (enabled == m_captureEnabled)
-        return;
-
-    m_captureEnabled = enabled;
-
-    if (enabled)
-        return;
-
-    for (auto& state : stateMap()) {
-        for (auto& manager : state.value->managers())
-            manager->stopCapture();
-    }
-}
-
 } // namespace WebKit
 
 #endif
index 8c5bc68..c3ed373 100644 (file)
@@ -39,12 +39,6 @@ public:
 
     void startedCaptureSession(UserMediaPermissionRequestManagerProxy&);
     void endedCaptureSession(UserMediaPermissionRequestManagerProxy&);
-
-    void setCaptureEnabled(bool);
-    bool captureEnabled() const { return m_captureEnabled; }
-
-private:
-    bool m_captureEnabled { true };
 };
 
 } // namespace WebKit
index 9bc5f6a..89006ab 100644 (file)
@@ -4206,18 +4206,6 @@ void WebPageProxy::setMuted(WebCore::MediaProducer::MutedStateFlags state)
     activityStateDidChange(ActivityState::IsAudible | ActivityState::IsCapturingMedia);
 }
 
-void WebPageProxy::setMediaCaptureEnabled(bool enabled)
-{
-    m_mediaCaptureEnabled = enabled;
-
-    if (!isValid())
-        return;
-
-#if ENABLE(MEDIA_STREAM)
-    UserMediaProcessManager::singleton().setCaptureEnabled(enabled);
-#endif
-}
-
 #if ENABLE(MEDIA_SESSION)
 void WebPageProxy::handleMediaEvent(MediaEventType eventType)
 {
index 05fb1b6..b48d646 100644 (file)
@@ -979,9 +979,6 @@ public:
     void setMuted(WebCore::MediaProducer::MutedStateFlags);
     void setMayStartMediaWhenInWindow(bool);
     bool mayStartMediaWhenInWindow() const { return m_mayStartMediaWhenInWindow; }
-    void setMediaCaptureEnabled(bool);
-    bool mediaCaptureEnabled() const { return m_mediaCaptureEnabled; }
-
         
 #if ENABLE(MEDIA_SESSION)
     bool hasMediaSessionWithActiveMediaElements() const { return m_hasMediaSessionWithActiveMediaElements; }
@@ -1938,7 +1935,6 @@ private:
     float m_mediaVolume;
     WebCore::MediaProducer::MutedStateFlags m_mutedState { WebCore::MediaProducer::NoneMuted };
     bool m_mayStartMediaWhenInWindow;
-    bool m_mediaCaptureEnabled { true };
 
     bool m_waitingForDidUpdateActivityState;
 
index fa3bdac..7f11dc7 100644 (file)
@@ -56,15 +56,6 @@ UserMediaPermissionRequestManager::~UserMediaPermissionRequestManager()
         sandboxExtension.value->revoke();
 }
 
-void UserMediaPermissionRequestManager::cancelPendingRequests()
-{
-    for (auto& request : m_idToUserMediaRequestMap.values())
-        cancelUserMediaRequest(*request);
-
-    for (auto& request : m_idToMediaDevicesEnumerationRequestMap.values())
-        cancelMediaDevicesEnumeration(*request);
-}
-
 void UserMediaPermissionRequestManager::startUserMediaRequest(UserMediaRequest& request)
 {
     Document* document = request.document();
@@ -113,8 +104,6 @@ void UserMediaPermissionRequestManager::cancelUserMediaRequest(UserMediaRequest&
     uint64_t requestID = m_userMediaRequestToIDMap.take(&request);
     if (!requestID)
         return;
-
-    request.deny(UserMediaRequest::OtherFailure, emptyString());
     m_idToUserMediaRequestMap.remove(requestID);
     removeMediaRequestFromMaps(request);
 }
@@ -201,7 +190,6 @@ void UserMediaPermissionRequestManager::cancelMediaDevicesEnumeration(WebCore::M
     uint64_t requestID = m_mediaDevicesEnumerationRequestToIDMap.take(&request);
     if (!requestID)
         return;
-    request.setDeviceInfo(Vector<CaptureDevice>(), emptyString(), false);
     m_idToMediaDevicesEnumerationRequestMap.remove(requestID);
 }
 
index 6b441f1..e8a96c2 100644 (file)
@@ -55,8 +55,6 @@ public:
     void grantUserMediaDeviceSandboxExtensions(const MediaDeviceSandboxExtensions&);
     void revokeUserMediaDeviceSandboxExtensions(const Vector<String>&);
 
-    void cancelPendingRequests();
-
 private:
     void sendUserMediaRequest(WebCore::UserMediaRequest&);
 
index f3dd79a..c7ceebb 100644 (file)
@@ -4556,14 +4556,6 @@ void WebPage::setMuted(MediaProducer::MutedStateFlags state)
     m_page->setMuted(state);
 }
 
-void WebPage::stopMediaCapture()
-{
-#if ENABLE(MEDIA_STREAM)
-    m_userMediaPermissionRequestManager.cancelPendingRequests();
-    m_page->stopMediaCapture();
-#endif
-}
-
 #if ENABLE(MEDIA_SESSION)
 void WebPage::handleMediaEvent(uint32_t eventType)
 {
index b011166..882e58d 100644 (file)
@@ -765,7 +765,6 @@ public:
     void setMediaVolume(float);
     void setMuted(WebCore::MediaProducer::MutedStateFlags);
     void setMayStartMediaWhenInWindow(bool);
-    void stopMediaCapture();
 
 #if ENABLE(MEDIA_SESSION)
     void handleMediaEvent(uint32_t /* WebCore::MediaEventType */);
index ef11513..351bd09 100644 (file)
@@ -338,7 +338,6 @@ messages -> WebPage LegacyReceiver {
     SetMediaVolume(float volume)
     SetMuted(WebCore::MediaProducer::MutedStateFlags muted)
     SetMayStartMediaWhenInWindow(bool mayStartMedia)
-    StopMediaCapture()
 
 #if ENABLE(MEDIA_SESSION)
     HandleMediaEvent(uint32_t eventType)
index 059c963..40d2f0f 100644 (file)
@@ -1,3 +1,23 @@
+2017-05-03  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r216160 and r216161.
+        https://bugs.webkit.org/show_bug.cgi?id=171640
+
+        These changes broke the iOS build. (Requested by mlewis13 on
+        #webkit).
+
+        Reverted changesets:
+
+        "[MediaStream] Allow host application to enable/disable media
+        capture"
+        https://bugs.webkit.org/show_bug.cgi?id=171292
+        http://trac.webkit.org/changeset/216160
+
+        "[MediaStream] Allow host application to enable/disable media
+        capture"
+        https://bugs.webkit.org/show_bug.cgi?id=171292
+        http://trac.webkit.org/changeset/216161
+
 2017-05-03  Eric Carlson  <eric.carlson@apple.com>
 
         [MediaStream] Allow host application to enable/disable media capture
index 19864cd..a887e15 100644 (file)
@@ -25,8 +25,6 @@
                07492B3B1DF8B14C00633DE1 /* EnumerateMediaDevices.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07492B3A1DF8AE2D00633DE1 /* EnumerateMediaDevices.cpp */; };
                07492B3C1DF8B86600633DE1 /* enumerateMediaDevices.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 07492B391DF8ADA400633DE1 /* enumerateMediaDevices.html */; };
                074994421EA5034B000DA44E /* getUserMedia.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 4A410F4D19AF7BEF002EBAB5 /* getUserMedia.html */; };
-               0799C3491EBA2D7B003B7532 /* UserMediaDisabled.mm in Sources */ = {isa = PBXBuildFile; fileRef = 07EDEFAC1EB9400C00D43292 /* UserMediaDisabled.mm */; };
-               0799C34B1EBA3301003B7532 /* disableGetUserMedia.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 0799C34A1EBA32F4003B7532 /* disableGetUserMedia.html */; };
                07C046CA1E4262A8007201E7 /* CARingBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07C046C91E42573E007201E7 /* CARingBuffer.cpp */; };
                0F139E771A423A5B00F590F5 /* WeakObjCPtr.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F139E751A423A5300F590F5 /* WeakObjCPtr.mm */; };
                0F139E781A423A6B00F590F5 /* PlatformUtilitiesCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F139E721A423A2B00F590F5 /* PlatformUtilitiesCocoa.mm */; };
                        files = (
                                55226A2F1EBA44B900C36AD0 /* large-red-square-image.html in Copy Resources */,
                                5797FE331EB15AB100B2F4A0 /* navigation-client-default-crypto.html in Copy Resources */,
-                               0799C34B1EBA3301003B7532 /* disableGetUserMedia.html in Copy Resources */,
                                074994421EA5034B000DA44E /* getUserMedia.html in Copy Resources */,
                                C9BF06EF1E9C132500595E3E /* autoplay-muted-with-controls.html in Copy Resources */,
                                F4DEF6ED1E9B4DB60048EF61 /* image-in-link-and-input.html in Copy Resources */,
                07492B391DF8ADA400633DE1 /* enumerateMediaDevices.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = enumerateMediaDevices.html; sourceTree = "<group>"; };
                07492B3A1DF8AE2D00633DE1 /* EnumerateMediaDevices.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EnumerateMediaDevices.cpp; sourceTree = "<group>"; };
                0766DD1F1A5AD5200023E3BB /* PendingAPIRequestURL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PendingAPIRequestURL.cpp; sourceTree = "<group>"; };
-               0799C34A1EBA32F4003B7532 /* disableGetUserMedia.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = disableGetUserMedia.html; sourceTree = "<group>"; };
                07C046C91E42573E007201E7 /* CARingBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CARingBuffer.cpp; sourceTree = "<group>"; };
-               07EDEFAC1EB9400C00D43292 /* UserMediaDisabled.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UserMediaDisabled.mm; sourceTree = "<group>"; };
                0BCD833414857CE400EA2003 /* HashMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HashMap.cpp; sourceTree = "<group>"; };
                0BCD85691485C98B00EA2003 /* SetForScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SetForScope.cpp; sourceTree = "<group>"; };
                0F139E721A423A2B00F590F5 /* PlatformUtilitiesCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PlatformUtilitiesCocoa.mm; path = cocoa/PlatformUtilitiesCocoa.mm; sourceTree = "<group>"; };
                        children = (
                                A16F66B81C40E9E100BD4D24 /* Resources */,
                                7CEFA9641AC0B9E200B910FD /* _WKUserContentExtensionStore.mm */,
-                               07EDEFAC1EB9400C00D43292 /* UserMediaDisabled.mm */,
                                37E7DD631EA06FF2009B396D /* AdditionalReadAccessAllowedURLs.mm */,
                                37E7DD661EA071F3009B396D /* AdditionalReadAccessAllowedURLsPlugin.mm */,
                                37E7DD651EA0715B009B396D /* AdditionalReadAccessAllowedURLsProtocol.h */,
                                2EFF06C61D886A560004BB30 /* change-video-source-on-end.html */,
                                A16F66B91C40EA2000BD4D24 /* ContentFiltering.html */,
                                5C2936941D5BFD1900DEAB1E /* CookieMessage.html */,
-                               0799C34A1EBA32F4003B7532 /* disableGetUserMedia.html */,
                                837A35F01D9A1E6400663C57 /* DownloadRequestBlobURL.html */,
                                5714ECB81CA8B58800051AC8 /* DownloadRequestOriginalURL.html */,
                                5714ECBC1CA8C21800051AC8 /* DownloadRequestOriginalURL2.html */,
                                D34E08761E4E42E1005FF14A /* WKWebViewGetContents.mm in Sources */,
                                315231CA1EB3B3C700A22A16 /* GPUCommandQueue.mm in Sources */,
                                F4FA91811E61849B007B8C1D /* WKWebViewSelectionTests.mm in Sources */,
-                               0799C3491EBA2D7B003B7532 /* UserMediaDisabled.mm in Sources */,
                                93F56DA91E5F919D003EDE84 /* WKWebViewSnapshot.mm in Sources */,
                                9984FACC1CFFAF60008D198C /* WKWebViewTextInput.mm in Sources */,
                                764322D71B61CCC30024F801 /* WordBoundaryTypingAttributes.mm in Sources */,
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/UserMediaDisabled.mm b/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/UserMediaDisabled.mm
deleted file mode 100644 (file)
index 18cff81..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-
-#import "PlatformUtilities.h"
-#import "Test.h"
-#import "TestWKWebView.h"
-
-#import <WebKit/WKPreferencesPrivate.h>
-#import <WebKit/WKUserContentControllerPrivate.h>
-#import <WebKit/WKWebViewConfigurationPrivate.h>
-#import <WebKit/WKWebViewPrivate.h>
-#import <WebKit/WebKit.h>
-#import <WebKit/_WKProcessPoolConfiguration.h>
-#import <wtf/RetainPtr.h>
-
-#if WK_API_ENABLED
-
-static bool refuseRequest = false;
-static bool wasPrompted = false;
-
-static bool receivedScriptMessage = false;
-static RetainPtr<WKScriptMessage> lastScriptMessage;
-
-@interface UserMediaMessageHandler : NSObject <WKScriptMessageHandler>
-@end
-
-@implementation UserMediaMessageHandler
-
-- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
-{
-    lastScriptMessage = message;
-    receivedScriptMessage = true;
-}
-@end
-
-@interface UserMediaUIDelegate : NSObject <WKUIDelegate>
-@end
-
-@implementation UserMediaUIDelegate
-
-- (void)_webView:(WKWebView *)webView requestUserMediaAuthorizationForDevices:(NSUInteger)devices url:(NSURL *)url mainFrameURL:(NSURL *)mainFrameURL decisionHandler:(void (^)(BOOL))decisionHandler
-{
-    wasPrompted = true;
-
-    if (refuseRequest) {
-        decisionHandler(NO);
-        return;
-    }
-
-    BOOL needsMicrophoneAuthorized = devices & _WKCaptureDeviceMicrophone;
-    BOOL needsCameraAuthorized = devices & _WKCaptureDeviceCamera;
-    if (!needsMicrophoneAuthorized && !needsCameraAuthorized) {
-        decisionHandler(NO);
-        return;
-    }
-
-    decisionHandler(YES);
-}
-
-- (void)_webView:(WKWebView *)webView checkUserMediaPermissionForURL:(NSURL *)url mainFrameURL:(NSURL *)mainFrameURL frameIdentifier:(NSUInteger)frameIdentifier decisionHandler:(void (^)(NSString *, BOOL))decisionHandler
-{
-    if (refuseRequest) {
-        decisionHandler(nil, NO);
-        return;
-    }
-}
-@end
-
-class MediaCaptureDisabledTest : public testing::Test {
-public:
-    virtual void SetUp()
-    {
-        m_configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
-
-        RetainPtr<UserMediaMessageHandler> handler = adoptNS([[UserMediaMessageHandler alloc] init]);
-        [[m_configuration userContentController] addScriptMessageHandler:handler.get() name:@"testHandler"];
-
-        m_webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:m_configuration.get()]);
-
-        auto preferences = [m_webView configuration].preferences;
-        preferences._mediaDevicesEnabled = YES;
-        preferences._mockCaptureDevicesEnabled = YES;
-        preferences._mediaCaptureRequiresSecureConnection = NO;
-
-        m_uiDelegate = adoptNS([[UserMediaUIDelegate alloc] init]);
-        [m_webView setUIDelegate:m_uiDelegate.get()];
-    }
-
-    void loadTestAndWaitForMessage(const char* message)
-    {
-        wasPrompted = false;
-        receivedScriptMessage = false;
-        [m_webView loadTestPageNamed:@"disableGetUserMedia"];
-        TestWebKitAPI::Util::run(&receivedScriptMessage);
-        EXPECT_STREQ([(NSString *)[lastScriptMessage body] UTF8String], message);
-    }
-
-    RetainPtr<WKWebViewConfiguration> m_configuration;
-    RetainPtr<UserMediaUIDelegate> m_uiDelegate;
-    RetainPtr<TestWKWebView> m_webView;
-};
-
-TEST_F(MediaCaptureDisabledTest, EnableAndDisable)
-{
-    EXPECT_TRUE(m_webView.get()._mediaCaptureEnabled);
-    loadTestAndWaitForMessage("allowed");
-    EXPECT_TRUE(wasPrompted);
-
-    m_webView.get()._mediaCaptureEnabled = NO;
-    EXPECT_FALSE(m_webView.get()._mediaCaptureEnabled);
-    loadTestAndWaitForMessage("denied");
-    EXPECT_FALSE(wasPrompted);
-
-    m_webView.get()._mediaCaptureEnabled = YES;
-    EXPECT_TRUE(m_webView.get()._mediaCaptureEnabled);
-    loadTestAndWaitForMessage("allowed");
-    EXPECT_TRUE(wasPrompted);
-}
-#endif
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/disableGetUserMedia.html b/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/disableGetUserMedia.html
deleted file mode 100644 (file)
index 8b50b63..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-<script>
-    function gotUserMedia(mediaStream)
-    {
-        window.webkit.messageHandlers.testHandler.postMessage('gUM allowed');
-    }
-
-    function userMediaError(error)
-    {
-        window.webkit.messageHandlers.testHandler.postMessage('gUM denied');
-    }
-
-    var constraints = { audio: false, video: true};
-    navigator.mediaDevices.getUserMedia(constraints)
-        .then(gotUserMedia).
-        catch(userMediaError);
-</script>