Changeset 216160 in webkit
- Timestamp:
- May 3, 2017, 5:03:29 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r216159 r216160 1 2017-05-03 Eric Carlson <eric.carlson@apple.com> 2 3 [MediaStream] Allow host application to enable/disable media capture 4 https://bugs.webkit.org/show_bug.cgi?id=171292 5 <rdar://problem/31821492> 6 7 Reviewed by Jer Noble. 8 9 No new layout tests, added an API test instead. 10 11 * Modules/mediastream/MediaStream.cpp: 12 (WebCore::MediaStream::endStream): New, stop all tracks. 13 * Modules/mediastream/MediaStream.h: 14 15 * Modules/mediastream/MediaStreamRegistry.cpp: 16 (WebCore::MediaStreamRegistry::unregisterStream): Minor cleanup. 17 (WebCore::MediaStreamRegistry::forEach): New, call the lambda with each stream. 18 (WebCore::MediaStreamRegistry::MediaStreamRegistry): Deleted, unused. 19 * Modules/mediastream/MediaStreamRegistry.h: 20 21 * Modules/mediastream/MediaStreamTrack.cpp: 22 (WebCore::MediaStreamTrack::stopTrack): Add parameter so caller can specify if an 'ended' 23 event should be sent or not. 24 (WebCore::MediaStreamTrack::trackMutedChanged): Don't post an event if the track has ended. 25 * Modules/mediastream/MediaStreamTrack.h: 26 27 * dom/Document.cpp: 28 (WebCore::Document::stopMediaCapture): Stop all streams in the document. 29 * dom/Document.h: 30 31 * page/Page.cpp: 32 (WebCore::Page::stopMediaCapture): Stop all streams. 33 * page/Page.h: 34 35 * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: 36 (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::currentDisplayMode): Display a black frame 37 when the stream ends. 38 (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::activeStatusChanged): Signal a characteristics 39 change to HTMLMediaElement refresh state. 40 * platform/mediastream/MediaStreamPrivate.h: 41 42 * platform/mediastream/mac/AVMediaCaptureSource.mm: 43 (WebCore::AVMediaCaptureSource::stopProducingData): Don't return early if the session isn't 44 running, we always need to clear m_session on iOS. 45 1 46 2017-05-03 Zalan Bujtas <zalan@apple.com> 2 47 -
trunk/Source/WebCore/Modules/mediastream/MediaStream.cpp
r215668 r216160 315 315 } 316 316 317 void MediaStream::endStream() 318 { 319 for (auto& track : m_trackSet.values()) 320 track->stopTrack(MediaStreamTrack::StopMode::PostEvent); 321 } 322 317 323 void MediaStream::pageMutedStateDidChange() 318 324 { -
trunk/Source/WebCore/Modules/mediastream/MediaStream.h
r215626 r216160 92 92 void stopProducingData(); 93 93 94 void endStream(); 95 94 96 // EventTarget 95 97 EventTargetInterface eventTargetInterface() const final { return MediaStreamEventTargetInterfaceType; } … … 106 108 107 109 void addTrackFromPlatform(Ref<MediaStreamTrack>&&); 110 111 Document* document() const; 108 112 109 113 protected: … … 159 163 void statusDidChange(); 160 164 161 Document* document() const;162 163 165 MediaStreamTrackVector trackVectorForType(RealtimeMediaSource::Type) const; 164 166 -
trunk/Source/WebCore/Modules/mediastream/MediaStreamRegistry.cpp
r215238 r216160 63 63 } 64 64 65 MediaStreamRegistry::MediaStreamRegistry()66 {67 }68 69 65 MediaStream* MediaStreamRegistry::lookUp(const URL& url) const 70 66 { … … 85 81 void MediaStreamRegistry::unregisterStream(MediaStream& stream) 86 82 { 87 Vector<MediaStream*>& allStreams = mediaStreams();83 auto& allStreams = mediaStreams(); 88 84 size_t pos = allStreams.find(&stream); 89 85 if (pos != notFound) … … 91 87 } 92 88 93 MediaStream* MediaStreamRegistry::lookUp(const MediaStreamPrivate& privateStream) const89 void MediaStreamRegistry::forEach(std::function<void(MediaStream&)> callback) const 94 90 { 95 Vector<MediaStream*>& allStreams = mediaStreams(); 96 for (auto& stream : allStreams) { 97 if (&stream->privateStream() == &privateStream) 98 return stream; 99 } 100 101 return nullptr; 91 for (auto& stream : mediaStreams()) 92 callback(*stream); 102 93 } 103 94 -
trunk/Source/WebCore/Modules/mediastream/MediaStreamRegistry.h
r208646 r216160 55 55 56 56 MediaStream* lookUp(const URL&) const; 57 MediaStream* lookUp(const MediaStreamPrivate&) const; 57 58 void forEach(std::function<void(MediaStream&)>) const; 58 59 59 60 private: 60 MediaStreamRegistry() ;61 MediaStreamRegistry() = default; 61 62 HashMap<String, RefPtr<MediaStream>> m_mediaStreams; 62 63 }; -
trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp
r215537 r216160 114 114 } 115 115 116 void MediaStreamTrack::stopTrack( )116 void MediaStreamTrack::stopTrack(StopMode mode) 117 117 { 118 118 // NOTE: this method is called when the "stop" method is called from JS, using the "ImplementedAs" IDL attribute. … … 122 122 return; 123 123 124 // An 'ended' event is not posted if m_ended is true when trackEnded is called, so set it now if we are 125 // not supposed to post the event. 126 if (mode == StopMode::Silently) 127 m_ended = true; 128 129 m_private->endTrack(); 124 130 m_ended = true; 125 m_private->endTrack();126 131 } 127 132 … … 304 309 void MediaStreamTrack::trackMutedChanged(MediaStreamTrackPrivate&) 305 310 { 306 if (scriptExecutionContext()->activeDOMObjectsAreSuspended() || scriptExecutionContext()->activeDOMObjectsAreStopped() )311 if (scriptExecutionContext()->activeDOMObjectsAreSuspended() || scriptExecutionContext()->activeDOMObjectsAreStopped() || m_ended) 307 312 return; 308 313 -
trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.h
r215537 r216160 72 72 73 73 Ref<MediaStreamTrack> clone(); 74 void stopTrack(); 74 75 enum class StopMode { Silently, PostEvent }; 76 void stopTrack(StopMode = StopMode::Silently); 75 77 76 78 bool isCaptureTrack() const; -
trunk/Source/WebCore/dom/Document.cpp
r216023 r216160 272 272 #endif 273 273 274 #if ENABLE(MEDIA_STREAM) 275 #include "MediaStream.h" 276 #include "MediaStreamRegistry.h" 277 #endif 278 274 279 using namespace WTF; 275 280 using namespace Unicode; … … 6973 6978 } 6974 6979 6980 #if ENABLE(MEDIA_STREAM) 6981 void Document::stopMediaCapture() 6982 { 6983 MediaStreamRegistry::shared().forEach([this](MediaStream& stream) { 6984 if (stream.document() == this) 6985 stream.endStream(); 6986 }); 6987 } 6988 #endif 6989 6975 6990 } // namespace WebCore -
trunk/Source/WebCore/dom/Document.h
r215955 r216160 1278 1278 void setDeviceIDHashSalt(const String& salt) { m_idHashSalt = salt; } 1279 1279 String deviceIDHashSalt() const { return m_idHashSalt; } 1280 void stopMediaCapture(); 1280 1281 #endif 1281 1282 -
trunk/Source/WebCore/page/Page.cpp
r216047 r216160 1533 1533 } 1534 1534 1535 void Page::stopMediaCapture() 1536 { 1537 #if ENABLE(MEDIA_STREAM) 1538 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) { 1539 if (!frame->document()) 1540 continue; 1541 1542 frame->document()->stopMediaCapture(); 1543 } 1544 #endif 1545 } 1546 1535 1547 #if ENABLE(MEDIA_SESSION) 1536 1548 void Page::handleMediaEvent(MediaEventType eventType) -
trunk/Source/WebCore/page/Page.h
r216047 r216160 531 531 bool isMediaCaptureMuted() const { return m_mutedState & MediaProducer::CaptureDevicesAreMuted; }; 532 532 WEBCORE_EXPORT void setMuted(MediaProducer::MutedStateFlags); 533 WEBCORE_EXPORT void stopMediaCapture(); 533 534 534 535 #if ENABLE(MEDIA_SESSION) -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm
r215099 r216160 581 581 MediaPlayerPrivateMediaStreamAVFObjC::DisplayMode MediaPlayerPrivateMediaStreamAVFObjC::currentDisplayMode() const 582 582 { 583 if (m_ ended || m_intrinsicSize.isEmpty() || !metaDataAvailable() || !m_sampleBufferDisplayLayer)583 if (m_intrinsicSize.isEmpty() || !metaDataAvailable() || !m_sampleBufferDisplayLayer) 584 584 return None; 585 585 586 586 if (auto* track = m_mediaStreamPrivate->activeVideoTrack()) { 587 if (!track->enabled() || track->muted() )587 if (!track->enabled() || track->muted() || track->ended()) 588 588 return PaintItBlack; 589 589 } 590 590 591 if (playing() ) {591 if (playing() && !m_ended) { 592 592 if (!m_mediaStreamPrivate->isProducingData()) 593 593 return PausedImage; … … 595 595 } 596 596 597 if (m_playbackState == PlaybackState::None )597 if (m_playbackState == PlaybackState::None || m_ended) 598 598 return PaintItBlack; 599 599 … … 769 769 if (ended != m_ended) { 770 770 m_ended = ended; 771 if (m_player) 771 if (m_player) { 772 772 m_player->timeChanged(); 773 m_player->characteristicChanged(); 774 } 773 775 } 774 776 }); -
trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.h
r215955 r216160 96 96 bool isProducingData() const; 97 97 98 void endStream(); 99 98 100 bool hasVideo() const; 99 101 bool hasAudio() const; -
trunk/Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.mm
r215922 r216160 182 182 void AVMediaCaptureSource::stopProducingData() 183 183 { 184 if (!m_session || ![m_session isRunning])184 if (!m_session) 185 185 return; 186 186 187 187 [m_objcObserver removeNotificationObservers]; 188 [m_session stopRunning]; 188 189 if ([m_session isRunning]) 190 [m_session stopRunning]; 191 189 192 #if PLATFORM(IOS) 190 193 m_session = nullptr; -
trunk/Source/WebKit2/ChangeLog
r216152 r216160 1 2017-05-03 Eric Carlson <eric.carlson@apple.com> 2 3 [MediaStream] Allow host application to enable/disable media capture 4 https://bugs.webkit.org/show_bug.cgi?id=171292 5 <rdar://problem/31821492> 6 7 Reviewed by Jer Noble. 8 9 * UIProcess/API/C/WKPage.cpp: 10 (WKPageSetMediaCaptureEnabled): New. 11 (WKPageGetMediaCaptureEnabled): New. 12 (WKPageClearUserMediaState): Deleted, unused. 13 * UIProcess/API/C/WKPagePrivate.h: 14 15 * UIProcess/API/Cocoa/WKWebView.mm: 16 (-[WKWebView _setMediaCaptureEnabled:]): New. 17 (-[WKWebView _mediaCaptureEnabled]): New. 18 * UIProcess/API/Cocoa/WKWebViewPrivate.h: 19 20 * UIProcess/Cocoa/UIDelegate.mm: 21 (WebKit::UIDelegate::setDelegate): Initialize webViewRequestUserMediaAuthorizationForDevicesURLMainFrameURLDecisionHandler 22 and webViewCheckUserMediaPermissionForURLMainFrameURLFrameIdentifierDecisionHandler on macOS 23 and iOS. 24 25 * UIProcess/UserMediaPermissionRequestManagerProxy.cpp: 26 (WebKit::UserMediaPermissionRequestManagerProxy::UserMediaPermissionRequestManagerProxy): 27 Initialize the rejection timer. 28 (WebKit::UserMediaPermissionRequestManagerProxy::~UserMediaPermissionRequestManagerProxy): 29 Call invalidatePendingRequests. 30 (WebKit::UserMediaPermissionRequestManagerProxy::invalidatePendingRequests): Invalidate all 31 pending requests. 32 (WebKit::UserMediaPermissionRequestManagerProxy::stopCapture): New. 33 (WebKit::UserMediaPermissionRequestManagerProxy::rejectionTimerFired): Reject a promise and 34 schedule the timer if there are any others pending. 35 (WebKit::UserMediaPermissionRequestManagerProxy::scheduleNextRejection): 36 (WebKit::UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame): Don't 37 prompt the user if capture is disabled. 38 (WebKit::UserMediaPermissionRequestManagerProxy::invalidateRequests): Deleted. 39 (WebKit::UserMediaPermissionRequestManagerProxy::clearCachedState): Deleted. 40 * UIProcess/UserMediaPermissionRequestManagerProxy.h: 41 42 * UIProcess/UserMediaProcessManager.cpp: 43 (WebKit::UserMediaProcessManager::willEnableMediaStreamInPage): Stop capture in the current 44 page on iOS. 45 (WebKit::UserMediaProcessManager::setCaptureEnabled): 46 * UIProcess/UserMediaProcessManager.h: 47 48 * UIProcess/WebPageProxy.cpp: 49 (WebKit::WebPageProxy::setMediaCaptureEnabled): 50 (WebKit::WebPageProxy::clearUserMediaState): Deleted. 51 52 * UIProcess/WebPageProxy.h: 53 (WebKit::WebPageProxy::mediaCaptureEnabled): 54 55 * WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp: 56 (WebKit::UserMediaPermissionRequestManager::cancelPendingRequests): New, cancel all pending 57 requests. 58 (WebKit::UserMediaPermissionRequestManager::cancelUserMediaRequest): Deny the request. 59 (WebKit::UserMediaPermissionRequestManager::cancelMediaDevicesEnumeration): 60 * WebProcess/MediaStream/UserMediaPermissionRequestManager.h: 61 62 * WebProcess/WebPage/WebPage.cpp: 63 (WebKit::WebPage::stopMediaCapture): 64 * WebProcess/WebPage/WebPage.h: 65 * WebProcess/WebPage/WebPage.messages.in: 66 1 67 2017-05-03 Tim Horton <timothy_horton@apple.com> 2 68 -
trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp
r216129 r216160 2678 2678 } 2679 2679 2680 void WKPageSetMediaCaptureEnabled(WKPageRef page, bool enabled) 2681 { 2682 toImpl(page)->setMediaCaptureEnabled(enabled); 2683 } 2684 2685 bool WKPageGetMediaCaptureEnabled(WKPageRef page) 2686 { 2687 return toImpl(page)->mediaCaptureEnabled(); 2688 } 2689 2680 2690 void WKPageDidAllowPointerLock(WKPageRef page) 2681 2691 { -
trunk/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h
r214976 r216160 128 128 129 129 WK_EXPORT void WKPageClearUserMediaState(WKPageRef page); 130 WK_EXPORT void WKPageSetMediaCaptureEnabled(WKPageRef page, bool enabled); 131 WK_EXPORT bool WKPageGetMediaCaptureEnabled(WKPageRef page); 130 132 131 133 WK_EXPORT void WKPageDidAllowPointerLock(WKPageRef page); -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
r216145 r216160 4474 4474 } 4475 4475 4476 - (void)_setMediaCaptureEnabled:(BOOL)enabled 4477 { 4478 _page->setMediaCaptureEnabled(enabled); 4479 } 4480 4481 - (BOOL)_mediaCaptureEnabled 4482 { 4483 return _page->mediaCaptureEnabled(); 4484 } 4485 4476 4486 - (void)_setPageMuted:(_WKMediaMutedState)mutedState 4477 4487 { -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h
r216047 r216160 293 293 @property (nonatomic, readonly) BOOL _isInFullscreen WK_API_AVAILABLE(macosx(WK_MAC_TBA)); 294 294 295 - (void)_muteMediaCapture ;295 - (void)_muteMediaCapture WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); 296 296 - (void)_setPageMuted:(_WKMediaMutedState)mutedState WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); 297 298 @property (nonatomic, setter=_setMediaCaptureEnabled:) BOOL _mediaCaptureEnabled WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); 297 299 298 300 @end -
trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm
r215619 r216160 116 116 m_delegateMethods.webViewActionsForElementDefaultActions = [delegate respondsToSelector:@selector(_webView:actionsForElement:defaultActions:)]; 117 117 m_delegateMethods.webViewDidNotHandleTapAsClickAtPoint = [delegate respondsToSelector:@selector(_webView:didNotHandleTapAsClickAtPoint:)]; 118 m_delegateMethods.presentingViewControllerForWebView = [delegate respondsToSelector:@selector(_presentingViewControllerForWebView:)]; 119 #endif 118 120 m_delegateMethods.webViewRequestUserMediaAuthorizationForDevicesURLMainFrameURLDecisionHandler = [delegate respondsToSelector:@selector(_webView:requestUserMediaAuthorizationForDevices:url:mainFrameURL:decisionHandler:)]; 119 121 m_delegateMethods.webViewCheckUserMediaPermissionForURLMainFrameURLFrameIdentifierDecisionHandler = [delegate respondsToSelector:@selector(_webView:checkUserMediaPermissionForURL:mainFrameURL:frameIdentifier:decisionHandler:)]; 120 122 m_delegateMethods.webViewMediaCaptureStateDidChange = [delegate respondsToSelector:@selector(_webView:mediaCaptureStateDidChange:)]; 121 m_delegateMethods.presentingViewControllerForWebView = [delegate respondsToSelector:@selector(_presentingViewControllerForWebView:)];122 #endif123 123 m_delegateMethods.dataDetectionContextForWebView = [delegate respondsToSelector:@selector(_dataDetectionContextForWebView:)]; 124 124 m_delegateMethods.webViewImageOrMediaDocumentSizeChanged = [delegate respondsToSelector:@selector(_webView:imageOrMediaDocumentSizeChanged:)]; -
trunk/Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.cpp
r215703 r216160 97 97 UserMediaPermissionRequestManagerProxy::UserMediaPermissionRequestManagerProxy(WebPageProxy& page) 98 98 : m_page(page) 99 , m_rejectionTimer(*this, &UserMediaPermissionRequestManagerProxy::rejectionTimerFired) 99 100 { 100 101 #if ENABLE(MEDIA_STREAM) … … 108 109 UserMediaProcessManager::singleton().removeUserMediaPermissionRequestManagerProxy(*this); 109 110 #endif 110 invalidate Requests();111 } 112 113 void UserMediaPermissionRequestManagerProxy::invalidate Requests()111 invalidatePendingRequests(); 112 } 113 114 void UserMediaPermissionRequestManagerProxy::invalidatePendingRequests() 114 115 { 115 116 for (auto& request : m_pendingUserMediaRequests.values()) … … 124 125 } 125 126 126 void UserMediaPermissionRequestManagerProxy::clearCachedState() 127 { 128 invalidateRequests(); 127 void UserMediaPermissionRequestManagerProxy::stopCapture() 128 { 129 invalidatePendingRequests(); 130 m_page.process().send(Messages::WebPage::StopMediaCapture(), m_page.pageID()); 129 131 } 130 132 … … 222 224 UNUSED_PARAM(videoDeviceUID); 223 225 #endif 226 } 227 228 void UserMediaPermissionRequestManagerProxy::rejectionTimerFired() 229 { 230 uint64_t userMediaID = m_pendingRejections[0]; 231 m_pendingRejections.remove(0); 232 233 denyRequest(userMediaID, UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::PermissionDenied, emptyString()); 234 if (!m_pendingRejections.isEmpty()) 235 scheduleNextRejection(); 236 } 237 238 void UserMediaPermissionRequestManagerProxy::scheduleNextRejection() 239 { 240 const double mimimumDelayBeforeReplying = .25; 241 if (!m_rejectionTimer.isActive()) 242 m_rejectionTimer.startOneShot(Seconds(mimimumDelayBeforeReplying + randomNumber())); 224 243 } 225 244 … … 273 292 }; 274 293 294 if (!UserMediaProcessManager::singleton().captureEnabled()) { 295 m_pendingRejections.append(userMediaID); 296 scheduleNextRejection(); 297 return; 298 } 299 275 300 auto audioConstraints = MediaConstraintsImpl::create(MediaConstraintsData(audioConstraintsData)); 276 301 auto videoConstraints = MediaConstraintsImpl::create(MediaConstraintsData(videoConstraintsData)); -
trunk/Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.h
r215537 r216160 18 18 */ 19 19 20 #ifndef UserMediaPermissionRequestManagerProxy_h 21 #define UserMediaPermissionRequestManagerProxy_h 20 #pragma once 22 21 23 22 #include "UserMediaPermissionCheckProxy.h" 24 23 #include "UserMediaPermissionRequestProxy.h" 25 24 #include <WebCore/SecurityOrigin.h> 25 #include <WebCore/Timer.h> 26 26 #include <WebCore/UserMediaRequest.h> 27 27 #include <wtf/HashMap.h> 28 #include <wtf/Seconds.h> 28 29 29 30 namespace WebCore { … … 58 59 WebPageProxy& page() const { return m_page; } 59 60 60 void invalidate Requests();61 void invalidatePendingRequests(); 61 62 62 63 void requestUserMediaPermissionForFrame(uint64_t userMediaID, uint64_t frameID, String userMediaDocumentOriginIdentifier, String topLevelDocumentOriginIdentifier, const WebCore::MediaConstraintsData& audioConstraintsData, const WebCore::MediaConstraintsData& videoConstraintsData); … … 70 71 void didCompleteUserMediaPermissionCheck(uint64_t, const String&, bool allow); 71 72 72 void clearCachedState(); 73 void stopCapture(); 74 void scheduleNextRejection(); 75 void rejectionTimerFired(); 73 76 74 77 void startedCaptureSession(); … … 86 89 87 90 WebPageProxy& m_page; 91 92 WebCore::Timer m_rejectionTimer; 93 Vector<uint64_t> m_pendingRejections; 88 94 }; 89 95 90 96 } // namespace WebKit 91 97 92 #endif // UserMediaPermissionRequestManagerProxy_h -
trunk/Source/WebKit2/UIProcess/UserMediaProcessManager.cpp
r215834 r216160 116 116 for (auto& manager : state.value->managers()) { 117 117 118 if (&manager->page() == &pageStartingCapture) 118 if (&manager->page() == &pageStartingCapture) { 119 #if PLATFORM(IOS) 120 manager->page().stopCapture(); 121 #endif 119 122 continue; 123 } 120 124 121 125 manager->page().setMuted(WebCore::MediaProducer::CaptureDevicesAreMuted); … … 231 235 } 232 236 237 void UserMediaProcessManager::setCaptureEnabled(bool enabled) 238 { 239 if (enabled == m_captureEnabled) 240 return; 241 242 m_captureEnabled = enabled; 243 244 if (enabled) 245 return; 246 247 for (auto& state : stateMap()) { 248 for (auto& manager : state.value->managers()) 249 manager->stopCapture(); 250 } 251 } 252 233 253 } // namespace WebKit 234 254 -
trunk/Source/WebKit2/UIProcess/UserMediaProcessManager.h
r215537 r216160 40 40 void startedCaptureSession(UserMediaPermissionRequestManagerProxy&); 41 41 void endedCaptureSession(UserMediaPermissionRequestManagerProxy&); 42 43 void setCaptureEnabled(bool); 44 bool captureEnabled() const { return m_captureEnabled; } 45 46 private: 47 bool m_captureEnabled { true }; 42 48 }; 43 49 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r216144 r216160 4207 4207 } 4208 4208 4209 void WebPageProxy::setMediaCaptureEnabled(bool enabled) 4210 { 4211 m_mediaCaptureEnabled = enabled; 4212 4213 if (!isValid()) 4214 return; 4215 4216 #if ENABLE(MEDIA_STREAM) 4217 UserMediaProcessManager::singleton().setCaptureEnabled(enabled); 4218 #endif 4219 } 4220 4209 4221 #if ENABLE(MEDIA_SESSION) 4210 4222 void WebPageProxy::handleMediaEvent(MediaEventType eventType) … … 5772 5784 } 5773 5785 5774 void WebPageProxy::clearUserMediaState()5775 {5776 #if ENABLE(MEDIA_STREAM)5777 userMediaPermissionRequestManager().clearCachedState();5778 #endif5779 }5780 5781 5786 void WebPageProxy::requestNotificationPermission(uint64_t requestID, const String& originString) 5782 5787 { -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r216129 r216160 980 980 void setMayStartMediaWhenInWindow(bool); 981 981 bool mayStartMediaWhenInWindow() const { return m_mayStartMediaWhenInWindow; } 982 void setMediaCaptureEnabled(bool); 983 bool mediaCaptureEnabled() const { return m_mediaCaptureEnabled; } 984 982 985 983 986 #if ENABLE(MEDIA_SESSION) … … 1192 1195 1193 1196 void isLoadingChanged() { activityStateDidChange(WebCore::ActivityState::IsLoading); } 1194 1195 void clearUserMediaState();1196 1197 1197 1198 void setShouldSkipWaitingForPaintAfterNextViewDidMoveToWindow(bool shouldSkip) { m_shouldSkipWaitingForPaintAfterNextViewDidMoveToWindow = shouldSkip; } … … 1936 1937 WebCore::MediaProducer::MutedStateFlags m_mutedState { WebCore::MediaProducer::NoneMuted }; 1937 1938 bool m_mayStartMediaWhenInWindow; 1939 bool m_mediaCaptureEnabled { true }; 1938 1940 1939 1941 bool m_waitingForDidUpdateActivityState; -
trunk/Source/WebKit2/WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp
r209864 r216160 57 57 } 58 58 59 void UserMediaPermissionRequestManager::cancelPendingRequests() 60 { 61 for (auto& request : m_idToUserMediaRequestMap.values()) 62 cancelUserMediaRequest(*request); 63 64 for (auto& request : m_idToMediaDevicesEnumerationRequestMap.values()) 65 cancelMediaDevicesEnumeration(*request); 66 } 67 59 68 void UserMediaPermissionRequestManager::startUserMediaRequest(UserMediaRequest& request) 60 69 { … … 105 114 if (!requestID) 106 115 return; 116 117 request.deny(UserMediaRequest::OtherFailure, emptyString()); 107 118 m_idToUserMediaRequestMap.remove(requestID); 108 119 removeMediaRequestFromMaps(request); … … 191 202 if (!requestID) 192 203 return; 204 request.setDeviceInfo(Vector<CaptureDevice>(), emptyString(), false); 193 205 m_idToMediaDevicesEnumerationRequestMap.remove(requestID); 194 206 } -
trunk/Source/WebKit2/WebProcess/MediaStream/UserMediaPermissionRequestManager.h
r209512 r216160 56 56 void revokeUserMediaDeviceSandboxExtensions(const Vector<String>&); 57 57 58 void cancelPendingRequests(); 59 58 60 private: 59 61 void sendUserMediaRequest(WebCore::UserMediaRequest&); -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r216047 r216160 4557 4557 } 4558 4558 4559 void WebPage::stopMediaCapture() 4560 { 4561 #if ENABLE(MEDIA_STREAM) 4562 m_userMediaPermissionRequestManager.cancelPendingRequests(); 4563 m_page->stopMediaCapture(); 4564 #endif 4565 } 4566 4559 4567 #if ENABLE(MEDIA_SESSION) 4560 4568 void WebPage::handleMediaEvent(uint32_t eventType) -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r216037 r216160 766 766 void setMuted(WebCore::MediaProducer::MutedStateFlags); 767 767 void setMayStartMediaWhenInWindow(bool); 768 void stopMediaCapture(); 768 769 769 770 #if ENABLE(MEDIA_SESSION) -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
r216037 r216160 339 339 SetMuted(WebCore::MediaProducer::MutedStateFlags muted) 340 340 SetMayStartMediaWhenInWindow(bool mayStartMedia) 341 StopMediaCapture() 341 342 342 343 #if ENABLE(MEDIA_SESSION) -
trunk/Tools/ChangeLog
r216157 r216160 1 2017-05-03 Eric Carlson <eric.carlson@apple.com> 2 3 [MediaStream] Allow host application to enable/disable media capture 4 https://bugs.webkit.org/show_bug.cgi?id=171292 5 <rdar://problem/31821492> 6 7 Reviewed by Jer Noble. 8 9 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 10 * TestWebKitAPI/Tests/WebKit2Cocoa/UserMediaDisabled.mm: Added. 11 (-[UserMediaMessageHandler userContentController:didReceiveScriptMessage:]): 12 (-[UserMediaUIDelegate _webView:requestUserMediaAuthorizationForDevices:url:mainFrameURL:decisionHandler:]): 13 (-[UserMediaUIDelegate _webView:checkUserMediaPermissionForURL:mainFrameURL:frameIdentifier:decisionHandler:]): 14 (MediaCaptureDisabledTest::SetUp): 15 (MediaCaptureDisabledTest::loadTestAndWaitForMessage): 16 (TEST_F): 17 * TestWebKitAPI/Tests/WebKit2Cocoa/disableGetUserMedia.html: Added. 18 1 19 2017-04-26 Jiewen Tan <jiewen_tan@apple.com> 2 20 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r216157 r216160 26 26 07492B3C1DF8B86600633DE1 /* enumerateMediaDevices.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 07492B391DF8ADA400633DE1 /* enumerateMediaDevices.html */; }; 27 27 074994421EA5034B000DA44E /* getUserMedia.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 4A410F4D19AF7BEF002EBAB5 /* getUserMedia.html */; }; 28 0799C3491EBA2D7B003B7532 /* UserMediaDisabled.mm in Sources */ = {isa = PBXBuildFile; fileRef = 07EDEFAC1EB9400C00D43292 /* UserMediaDisabled.mm */; }; 29 0799C34B1EBA3301003B7532 /* disableGetUserMedia.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 0799C34A1EBA32F4003B7532 /* disableGetUserMedia.html */; }; 28 30 07C046CA1E4262A8007201E7 /* CARingBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07C046C91E42573E007201E7 /* CARingBuffer.cpp */; }; 29 31 0F139E771A423A5B00F590F5 /* WeakObjCPtr.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F139E751A423A5300F590F5 /* WeakObjCPtr.mm */; }; … … 688 690 55226A2F1EBA44B900C36AD0 /* large-red-square-image.html in Copy Resources */, 689 691 5797FE331EB15AB100B2F4A0 /* navigation-client-default-crypto.html in Copy Resources */, 692 0799C34B1EBA3301003B7532 /* disableGetUserMedia.html in Copy Resources */, 690 693 074994421EA5034B000DA44E /* getUserMedia.html in Copy Resources */, 691 694 C9BF06EF1E9C132500595E3E /* autoplay-muted-with-controls.html in Copy Resources */, … … 880 883 07492B3A1DF8AE2D00633DE1 /* EnumerateMediaDevices.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EnumerateMediaDevices.cpp; sourceTree = "<group>"; }; 881 884 0766DD1F1A5AD5200023E3BB /* PendingAPIRequestURL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PendingAPIRequestURL.cpp; sourceTree = "<group>"; }; 885 0799C34A1EBA32F4003B7532 /* disableGetUserMedia.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = disableGetUserMedia.html; sourceTree = "<group>"; }; 882 886 07C046C91E42573E007201E7 /* CARingBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CARingBuffer.cpp; sourceTree = "<group>"; }; 887 07EDEFAC1EB9400C00D43292 /* UserMediaDisabled.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UserMediaDisabled.mm; sourceTree = "<group>"; }; 883 888 0BCD833414857CE400EA2003 /* HashMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HashMap.cpp; sourceTree = "<group>"; }; 884 889 0BCD85691485C98B00EA2003 /* SetForScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SetForScope.cpp; sourceTree = "<group>"; }; … … 1672 1677 A16F66B81C40E9E100BD4D24 /* Resources */, 1673 1678 7CEFA9641AC0B9E200B910FD /* _WKUserContentExtensionStore.mm */, 1679 07EDEFAC1EB9400C00D43292 /* UserMediaDisabled.mm */, 1674 1680 37E7DD631EA06FF2009B396D /* AdditionalReadAccessAllowedURLs.mm */, 1675 1681 37E7DD661EA071F3009B396D /* AdditionalReadAccessAllowedURLsPlugin.mm */, … … 1897 1903 A16F66B91C40EA2000BD4D24 /* ContentFiltering.html */, 1898 1904 5C2936941D5BFD1900DEAB1E /* CookieMessage.html */, 1905 0799C34A1EBA32F4003B7532 /* disableGetUserMedia.html */, 1899 1906 837A35F01D9A1E6400663C57 /* DownloadRequestBlobURL.html */, 1900 1907 5714ECB81CA8B58800051AC8 /* DownloadRequestOriginalURL.html */, … … 3080 3087 315231CA1EB3B3C700A22A16 /* GPUCommandQueue.mm in Sources */, 3081 3088 F4FA91811E61849B007B8C1D /* WKWebViewSelectionTests.mm in Sources */, 3089 0799C3491EBA2D7B003B7532 /* UserMediaDisabled.mm in Sources */, 3082 3090 93F56DA91E5F919D003EDE84 /* WKWebViewSnapshot.mm in Sources */, 3083 3091 9984FACC1CFFAF60008D198C /* WKWebViewTextInput.mm in Sources */,
Note:
See TracChangeset
for help on using the changeset viewer.