[MediaStream] defer resolution of getUserMedia promise made in a background tab
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Nov 2016 21:45:21 +0000 (21:45 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Nov 2016 21:45:21 +0000 (21:45 +0000)
commit22d3267424f39dfb53f3c5ba5f3494c5cdec0a65
tree1fe1f77ee0c8791cd273a7794429c675e72b1d97
parent94dc990a30358f9d183169f86b67e8f6cee62ac7
[MediaStream] defer resolution of getUserMedia promise made in a background tab
https://bugs.webkit.org/show_bug.cgi?id=164643
<rdar://problem/29048317>

Reviewed by Brady Eidson.

Source/WebCore:

Test: fast/mediastream/get-user-media-background-tab.html

Do not start producing data when the document does not allow media
to start playing. Instead, register with the document for a callback
when playback is allowed and start then.
* Modules/mediastream/MediaStream.cpp:
(WebCore::MediaStream::~MediaStream):
(WebCore::MediaStream::mediaCanStart):
(WebCore::MediaStream::startProducingData):
(WebCore::MediaStream::stopProducingData):
(WebCore::MediaStream::pageMutedStateDidChange):
* Modules/mediastream/MediaStream.h:

* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::mediaCanStart): Deal with API change.
* Modules/webaudio/AudioContext.h:

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::mediaCanStart): Ditto.
* html/HTMLMediaElement.h:
* page/MediaCanStartListener.h:

* page/Page.cpp:
(WebCore::Page::takeAnyMediaCanStartListener): Return the listener and document.
(WebCore::Page::setCanStartMedia): Pass the document to the listener.
* page/Page.h:

Source/WebKit2:

Do not ask for user for access to capture devices when the document does not
allow media to play, wait until playback is allowed.

* WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp:
(WebKit::UserMediaPermissionRequestManager::startUserMediaRequest):
(WebKit::UserMediaPermissionRequestManager::sendUserMediaRequest):
(WebKit::UserMediaPermissionRequestManager::mediaCanStart):
(WebKit::UserMediaPermissionRequestManager::grantUserMediaDevicesSandboxExtension):
* WebProcess/MediaStream/UserMediaPermissionRequestManager.h:
* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::mediaCanStart):
* WebProcess/Plugins/PluginView.h:

LayoutTests:

* fast/mediastream/get-user-media-background-tab-expected.txt: Added.
* fast/mediastream/get-user-media-background-tab.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208606 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/mediastream/get-user-media-background-tab-expected.txt [new file with mode: 0644]
LayoutTests/fast/mediastream/get-user-media-background-tab.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/MediaStream.cpp
Source/WebCore/Modules/mediastream/MediaStream.h
Source/WebCore/Modules/webaudio/AudioContext.cpp
Source/WebCore/Modules/webaudio/AudioContext.h
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/page/MediaCanStartListener.h
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp
Source/WebKit2/WebProcess/MediaStream/UserMediaPermissionRequestManager.h
Source/WebKit2/WebProcess/Plugins/PluginView.cpp
Source/WebKit2/WebProcess/Plugins/PluginView.h