<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[183428] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/183428">183428</a></dd>
<dt>Author</dt> <dd>jer.noble@apple.com</dd>
<dt>Date</dt> <dd>2015-04-27 15:08:43 -0700 (Mon, 27 Apr 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Add a setting & restriction which prevents non-interactivte playback of audible media elements.
https://bugs.webkit.org/show_bug.cgi?id=143486
Reviewed by Eric Carlson.
Source/WebCore:
Tests: media/audio-playback-restriction-autoplay.html
media/audio-playback-restriction-play.html
To allow clients who want to allow non-user-interactive video-only playback, but still
restrict playback of audible media elements, add a new setting and matching restriction
which disallows playback of media elements containing audible characteristics.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement): Set the RequireUserGestureForAudioRateChange
restriction if the audioPlaybackRequiresUserGesture() setting is set.
(WebCore::HTMLMediaElement::parseAttribute): Drive-by fix. Move the opening brace
out of the #if, as this confuses the heck out of diff and makes all subsequent
changes appear to be within HTMLMediaElement::parseAttribute.
(WebCore::HTMLMediaElement::autoplay): Remove the restriction check from within autoplay().
It is checked again immediately after every autoplay() call site.
(WebCore::HTMLMediaElement::pauseInternal): Remove the iOS-only #if.
(WebCore::HTMLMediaElement::mediaPlayerDidAddAudioTrack): Check whether playback
is permitted, and if not, pause.
(WebCore::HTMLMediaElement::mediaPlayerCharacteristicChanged): Ditto.
(WebCore::HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture): Ditto.
* html/HTMLMediaSession.cpp:
(WebCore::restrictionName): Since BehaviorRestrictions is a bitfield, check each bit
individually.
(WebCore::HTMLMediaSession::removeBehaviorRestriction): Handle RequireUserGestureForAudioRateChange.
(WebCore::HTMLMediaSession::playbackPermitted): Check whether the element has audio and
audio playback is restricted, and return false if so.
* html/HTMLMediaSession.h:
* page/Settings.cpp:
* page/Settings.in:
* testing/Internals.cpp:
(WebCore::Internals::setMediaSessionRestrictions): Added.
(WebCore::Internals::setMediaElementRestrictions): Added.
* testing/Internals.h:
* testing/Internals.idl:
LayoutTests:
* media/audio-playback-restriction-autoplay.html: Added.
* media/audio-playback-restriction-play.html: Added.
* media/video-test.js:
(setCaptionDisplayMode):
(runWithKeyDown.eventName.window.testRunner.eventSender.keyDown.string_appeared_here.string_appeared_here.thunk):
(runWithKeyDown):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsmediavideotestjs">trunk/LayoutTests/media/video-test.js</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementcpp">trunk/Source/WebCore/html/HTMLMediaElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaSessioncpp">trunk/Source/WebCore/html/HTMLMediaSession.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaSessionh">trunk/Source/WebCore/html/HTMLMediaSession.h</a></li>
<li><a href="#trunkSourceWebCorepageSettingscpp">trunk/Source/WebCore/page/Settings.cpp</a></li>
<li><a href="#trunkSourceWebCorepageSettingsin">trunk/Source/WebCore/page/Settings.in</a></li>
<li><a href="#trunkSourceWebCoretestingInternalscpp">trunk/Source/WebCore/testing/Internals.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsh">trunk/Source/WebCore/testing/Internals.h</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsidl">trunk/Source/WebCore/testing/Internals.idl</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsmediaaudioplaybackrestrictionautoplayhtml">trunk/LayoutTests/media/audio-playback-restriction-autoplay.html</a></li>
<li><a href="#trunkLayoutTestsmediaaudioplaybackrestrictionplayhtml">trunk/LayoutTests/media/audio-playback-restriction-play.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (183427 => 183428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-04-27 22:04:04 UTC (rev 183427)
+++ trunk/LayoutTests/ChangeLog        2015-04-27 22:08:43 UTC (rev 183428)
</span><span class="lines">@@ -1,5 +1,19 @@
</span><span class="cx"> 2015-04-27 Jer Noble <jer.noble@apple.com>
</span><span class="cx">
</span><ins>+ Add a setting & restriction which prevents non-interactivte playback of audible media elements.
+ https://bugs.webkit.org/show_bug.cgi?id=143486
+
+ Reviewed by Eric Carlson.
+
+ * media/audio-playback-restriction-autoplay.html: Added.
+ * media/audio-playback-restriction-play.html: Added.
+ * media/video-test.js:
+ (setCaptionDisplayMode):
+ (runWithKeyDown.eventName.window.testRunner.eventSender.keyDown.string_appeared_here.string_appeared_here.thunk):
+ (runWithKeyDown):
+
+2015-04-27 Jer Noble <jer.noble@apple.com>
+
</ins><span class="cx"> [WebAudio] AudioContext does not remove user-gesture restriction during resume()
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=144211
</span><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestsmediaaudioplaybackrestrictionautoplayhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/media/audio-playback-restriction-autoplay.html (0 => 183428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/audio-playback-restriction-autoplay.html         (rev 0)
+++ trunk/LayoutTests/media/audio-playback-restriction-autoplay.html        2015-04-27 22:08:43 UTC (rev 183428)
</span><span class="lines">@@ -0,0 +1,39 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+ <title>audio-playback-restriction</title>
+ <script src=media-file.js></script>
+ <script src=video-test.js></script>
+
+ <script>
+ function runTest()
+ {
+ video = document.getElementsByTagName('audio')[0];
+
+ if (window.internals)
+ run('internals.setMediaElementRestrictions(video, "RequireUserGestureForAudioRateChange")');
+
+ waitForEventAndFail('error');
+ waitForEvent('canplaythrough', canplaythrough);
+ run("video.src = findMediaFile('audio', 'content/test')");
+ }
+
+ function canplaythrough()
+ {
+ run("setTimeout(timeout, 100)");
+ }
+
+ function timeout()
+ {
+ testExpected('video.paused', true);
+ endTest();
+ }
+ </script>
+</head>
+
+<body onload="runTest()">
+ <p>Test that, when RequireUserGestureForAudioRateChange is set, starting playback of an audio file requires a user gesture.</p>
+ <audio controls autoplay></audio>
+</body>
+</html>
+
</ins></span></pre></div>
<a id="trunkLayoutTestsmediaaudioplaybackrestrictionplayhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/media/audio-playback-restriction-play.html (0 => 183428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/audio-playback-restriction-play.html         (rev 0)
+++ trunk/LayoutTests/media/audio-playback-restriction-play.html        2015-04-27 22:08:43 UTC (rev 183428)
</span><span class="lines">@@ -0,0 +1,43 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+ <title>audio-playback-restriction</title>
+ <script src=media-file.js></script>
+ <script src=video-test.js></script>
+
+ <script>
+ function runTest()
+ {
+ video = document.getElementsByTagName('audio')[0];
+
+ if (window.internals)
+ run('internals.setMediaElementRestrictions(video, "RequireUserGestureForAudioRateChange")');
+
+ waitForEventAndFail('error');
+ waitForEvent('canplaythrough', canplaythrough);
+ run("video.src = findMediaFile('audio', 'content/test')");
+ }
+
+ function canplaythrough()
+ {
+ run("video.play()");
+ testExpected('video.paused', true);
+ runWithKeyDown(playWithKeyDown);
+ }
+
+ function playWithKeyDown()
+ {
+ consoleWrite('Running with keyDown.');
+ run("video.play()");
+ testExpected('video.paused', false);
+ endTest();
+ }
+ </script>
+</head>
+
+<body onload="runTest()">
+ <p>Test that, when RequireUserGestureForAudioRateChange is set, starting playback of an audio file requires a user gesture.</p>
+ <audio controls autoplay></audio>
+</body>
+</html>
+
</ins></span></pre></div>
<a id="trunkLayoutTestsmediavideotestjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/media/video-test.js (183427 => 183428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/video-test.js        2015-04-27 22:04:04 UTC (rev 183427)
+++ trunk/LayoutTests/media/video-test.js        2015-04-27 22:08:43 UTC (rev 183428)
</span><span class="lines">@@ -382,5 +382,24 @@
</span><span class="cx"> internals.setCaptionDisplayMode(mode);
</span><span class="cx"> else
</span><span class="cx"> consoleWrite("<br><b>** This test only works in DRT! **<" + "/b><br>");
</span><ins>+}
</ins><span class="cx">
</span><del>-}
</del><span class="cx">\ No newline at end of file
</span><ins>+function runWithKeyDown(fn)
+{
+ // FIXME: WKTR does not yet support the keyDown() message. Do a mouseDown here
+ // instead until keyDown support is added.
+ var eventName = !window.testRunner || eventSender.keyDown ? 'keypress' : 'mousedown'
+
+ function thunk() {
+ document.removeEventListener(eventName, thunk, false);
+ fn();
+ }
+ document.addEventListener(eventName, thunk, false);
+
+ if (window.testRunner) {
+ if (eventSender.keyDown)
+ eventSender.keyDown(" ", []);
+ else
+ eventSender.mouseDown();
+ }
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (183427 => 183428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-04-27 22:04:04 UTC (rev 183427)
+++ trunk/Source/WebCore/ChangeLog        2015-04-27 22:08:43 UTC (rev 183428)
</span><span class="lines">@@ -1,5 +1,47 @@
</span><span class="cx"> 2015-04-27 Jer Noble <jer.noble@apple.com>
</span><span class="cx">
</span><ins>+ Add a setting & restriction which prevents non-interactivte playback of audible media elements.
+ https://bugs.webkit.org/show_bug.cgi?id=143486
+
+ Reviewed by Eric Carlson.
+
+ Tests: media/audio-playback-restriction-autoplay.html
+ media/audio-playback-restriction-play.html
+
+ To allow clients who want to allow non-user-interactive video-only playback, but still
+ restrict playback of audible media elements, add a new setting and matching restriction
+ which disallows playback of media elements containing audible characteristics.
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::HTMLMediaElement): Set the RequireUserGestureForAudioRateChange
+ restriction if the audioPlaybackRequiresUserGesture() setting is set.
+ (WebCore::HTMLMediaElement::parseAttribute): Drive-by fix. Move the opening brace
+ out of the #if, as this confuses the heck out of diff and makes all subsequent
+ changes appear to be within HTMLMediaElement::parseAttribute.
+ (WebCore::HTMLMediaElement::autoplay): Remove the restriction check from within autoplay().
+ It is checked again immediately after every autoplay() call site.
+ (WebCore::HTMLMediaElement::pauseInternal): Remove the iOS-only #if.
+ (WebCore::HTMLMediaElement::mediaPlayerDidAddAudioTrack): Check whether playback
+ is permitted, and if not, pause.
+ (WebCore::HTMLMediaElement::mediaPlayerCharacteristicChanged): Ditto.
+ (WebCore::HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture): Ditto.
+ * html/HTMLMediaSession.cpp:
+ (WebCore::restrictionName): Since BehaviorRestrictions is a bitfield, check each bit
+ individually.
+ (WebCore::HTMLMediaSession::removeBehaviorRestriction): Handle RequireUserGestureForAudioRateChange.
+ (WebCore::HTMLMediaSession::playbackPermitted): Check whether the element has audio and
+ audio playback is restricted, and return false if so.
+ * html/HTMLMediaSession.h:
+ * page/Settings.cpp:
+ * page/Settings.in:
+ * testing/Internals.cpp:
+ (WebCore::Internals::setMediaSessionRestrictions): Added.
+ (WebCore::Internals::setMediaElementRestrictions): Added.
+ * testing/Internals.h:
+ * testing/Internals.idl:
+
+2015-04-27 Jer Noble <jer.noble@apple.com>
+
</ins><span class="cx"> [WebAudio] AudioContext does not remove user-gesture restriction during resume()
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=144211
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (183427 => 183428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.cpp        2015-04-27 22:04:04 UTC (rev 183427)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp        2015-04-27 22:08:43 UTC (rev 183428)
</span><span class="lines">@@ -364,6 +364,9 @@
</span><span class="cx"> }
</span><span class="cx"> #endif // !PLATFORM(IOS)
</span><span class="cx">
</span><ins>+ if (settings && settings->audioPlaybackRequiresUserGesture())
+ m_mediaSession->addBehaviorRestriction(HTMLMediaSession::RequireUserGestureForAudioRateChange);
+
</ins><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><span class="cx"> if (document.page())
</span><span class="cx"> m_captionDisplayMode = document.page()->group().captionPreferences()->captionDisplayMode();
</span><span class="lines">@@ -524,11 +527,12 @@
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> // Note, unless the restriction on requiring user action has been removed,
</span><span class="cx"> // do not begin downloading data on iOS.
</span><del>- if (!value.isNull() && m_mediaSession->dataLoadingPermitted(*this)) {
</del><ins>+ if (!value.isNull() && m_mediaSession->dataLoadingPermitted(*this))
</ins><span class="cx"> #else
</span><span class="cx"> // Trigger a reload, as long as the 'src' attribute is present.
</span><del>- if (!value.isNull()) {
</del><ins>+ if (!value.isNull())
</ins><span class="cx"> #endif
</span><ins>+ {
</ins><span class="cx"> clearMediaPlayer(LoadMediaResource);
</span><span class="cx"> scheduleDelayedAction(LoadMediaResource);
</span><span class="cx"> }
</span><span class="lines">@@ -2708,16 +2712,6 @@
</span><span class="cx">
</span><span class="cx"> bool HTMLMediaElement::autoplay() const
</span><span class="cx"> {
</span><del>-#if PLATFORM(IOS)
- // Unless the restriction on requiring user actions has been lifted, we do not
- // allow playback to start just because the page has "autoplay". They are either
- // lifted through Settings, or once the user explictly calls load() or play()
- // because they have OK'ed us loading data. This allows playback to continue if
- // the URL is changed while the movie is playing.
- if (!m_mediaSession->playbackPermitted(*this) || !m_mediaSession->dataLoadingPermitted(*this))
- return false;
-#endif
-
</del><span class="cx"> return fastHasAttribute(autoplayAttr);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2810,12 +2804,10 @@
</span><span class="cx">
</span><span class="cx"> // 4.8.10.9. Playing the media resource
</span><span class="cx"> if (!m_player || m_networkState == NETWORK_EMPTY) {
</span><del>-#if PLATFORM(IOS)
</del><span class="cx"> // Unless the restriction on media requiring user action has been lifted
</span><span class="cx"> // don't trigger loading if a script calls pause().
</span><span class="cx"> if (!m_mediaSession->playbackPermitted(*this))
</span><span class="cx"> return;
</span><del>-#endif
</del><span class="cx"> scheduleDelayedAction(LoadMediaResource);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -3212,6 +3204,9 @@
</span><span class="cx">
</span><span class="cx"> void HTMLMediaElement::mediaPlayerDidAddAudioTrack(PassRefPtr<AudioTrackPrivate> prpTrack)
</span><span class="cx"> {
</span><ins>+ if (isPlaying() && !m_mediaSession->playbackPermitted(*this))
+ pauseInternal();
+
</ins><span class="cx"> if (!RuntimeEnabledFeatures::sharedFeatures().webkitVideoTrackEnabled())
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="lines">@@ -4350,6 +4345,9 @@
</span><span class="cx"> if (renderer())
</span><span class="cx"> renderer()->updateFromElement();
</span><span class="cx">
</span><ins>+ if (isPlaying() && !m_mediaSession->playbackPermitted(*this))
+ pauseInternal();
+
</ins><span class="cx"> document().updateIsPlayingMedia();
</span><span class="cx">
</span><span class="cx"> endProcessingMediaPlayerCallback();
</span><span class="lines">@@ -5883,12 +5881,15 @@
</span><span class="cx">
</span><span class="cx"> void HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture()
</span><span class="cx"> {
</span><del>- m_mediaSession->removeBehaviorRestriction(HTMLMediaSession::RequireUserGestureForLoad);
- m_mediaSession->removeBehaviorRestriction(HTMLMediaSession::RequireUserGestureForRateChange);
- m_mediaSession->removeBehaviorRestriction(HTMLMediaSession::RequireUserGestureForFullscreen);
</del><ins>+ HTMLMediaSession::BehaviorRestrictions restrictionsToRemove = HTMLMediaSession::RequireUserGestureForLoad
</ins><span class="cx"> #if ENABLE(WIRELESS_PLAYBACK_TARGET)
</span><del>- m_mediaSession->removeBehaviorRestriction(HTMLMediaSession::RequireUserGestureToShowPlaybackTargetPicker);
</del><ins>+ | HTMLMediaSession::RequireUserGestureToShowPlaybackTargetPicker
</ins><span class="cx"> #endif
</span><ins>+ | HTMLMediaSession::RequireUserGestureForLoad
+ | HTMLMediaSession::RequireUserGestureForRateChange
+ | HTMLMediaSession::RequireUserGestureForAudioRateChange
+ | HTMLMediaSession::RequireUserGestureForFullscreen;
+ m_mediaSession->removeBehaviorRestriction(restrictionsToRemove);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if ENABLE(MEDIA_SOURCE)
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaSessioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaSession.cpp (183427 => 183428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaSession.cpp        2015-04-27 22:04:04 UTC (rev 183427)
+++ trunk/Source/WebCore/html/HTMLMediaSession.cpp        2015-04-27 22:08:43 UTC (rev 183428)
</span><span class="lines">@@ -51,13 +51,20 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="cx"> #if !LOG_DISABLED
</span><del>-static const char* restrictionName(HTMLMediaSession::BehaviorRestrictions restriction)
</del><ins>+static String restrictionName(HTMLMediaSession::BehaviorRestrictions restriction)
</ins><span class="cx"> {
</span><del>-#define CASE(restriction) case HTMLMediaSession::restriction: return #restriction
- switch (restriction) {
</del><ins>+ StringBuilder restrictionBuilder;
+#define CASE(restrictionType) \
+ if (restriction & HTMLMediaSession::restrictionType) { \
+ if (!restrictionBuilder.isEmpty()) \
+ restrictionBuilder.append(", "); \
+ restrictionBuilder.append(#restrictionType); \
+ } \
+
</ins><span class="cx"> CASE(NoRestrictions);
</span><span class="cx"> CASE(RequireUserGestureForLoad);
</span><span class="cx"> CASE(RequireUserGestureForRateChange);
</span><ins>+ CASE(RequireUserGestureForAudioRateChange);
</ins><span class="cx"> CASE(RequireUserGestureForFullscreen);
</span><span class="cx"> CASE(RequirePageConsentToLoadMedia);
</span><span class="cx"> CASE(RequirePageConsentToResumeMedia);
</span><span class="lines">@@ -65,10 +72,9 @@
</span><span class="cx"> CASE(RequireUserGestureToShowPlaybackTargetPicker);
</span><span class="cx"> CASE(WirelessVideoPlaybackDisabled);
</span><span class="cx"> #endif
</span><del>- }
</del><ins>+ CASE(RequireUserGestureForAudioRateChange);
</ins><span class="cx">
</span><del>- ASSERT_NOT_REACHED();
- return "";
</del><ins>+ return restrictionBuilder.toString();
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="lines">@@ -101,23 +107,28 @@
</span><span class="cx">
</span><span class="cx"> void HTMLMediaSession::addBehaviorRestriction(BehaviorRestrictions restriction)
</span><span class="cx"> {
</span><del>- LOG(Media, "HTMLMediaSession::addBehaviorRestriction - adding %s", restrictionName(restriction));
</del><ins>+ LOG(Media, "HTMLMediaSession::addBehaviorRestriction - adding %s", restrictionName(restriction).utf8().data());
</ins><span class="cx"> m_restrictions |= restriction;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void HTMLMediaSession::removeBehaviorRestriction(BehaviorRestrictions restriction)
</span><span class="cx"> {
</span><del>- LOG(Media, "HTMLMediaSession::removeBehaviorRestriction - removing %s", restrictionName(restriction));
</del><ins>+ LOG(Media, "HTMLMediaSession::removeBehaviorRestriction - removing %s", restrictionName(restriction).utf8().data());
</ins><span class="cx"> m_restrictions &= ~restriction;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool HTMLMediaSession::playbackPermitted(const HTMLMediaElement&) const
</del><ins>+bool HTMLMediaSession::playbackPermitted(const HTMLMediaElement& element) const
</ins><span class="cx"> {
</span><span class="cx"> if (m_restrictions & RequireUserGestureForRateChange && !ScriptController::processingUserGesture()) {
</span><span class="cx"> LOG(Media, "HTMLMediaSession::playbackPermitted - returning FALSE");
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ if (m_restrictions & RequireUserGestureForAudioRateChange && element.hasAudio() && !ScriptController::processingUserGesture()) {
+ LOG(Media, "HTMLMediaSession::playbackPermitted - returning FALSE");
+ return false;
+ }
+
</ins><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaSessionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaSession.h (183427 => 183428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaSession.h        2015-04-27 22:04:04 UTC (rev 183427)
+++ trunk/Source/WebCore/html/HTMLMediaSession.h        2015-04-27 22:08:43 UTC (rev 183428)
</span><span class="lines">@@ -88,11 +88,13 @@
</span><span class="cx"> RequireUserGestureToShowPlaybackTargetPicker = 1 << 5,
</span><span class="cx"> WirelessVideoPlaybackDisabled = 1 << 6,
</span><span class="cx"> #endif
</span><ins>+ RequireUserGestureForAudioRateChange = 1 << 7,
</ins><span class="cx"> };
</span><span class="cx"> typedef unsigned BehaviorRestrictions;
</span><span class="cx">
</span><del>- void addBehaviorRestriction(BehaviorRestrictions);
- void removeBehaviorRestriction(BehaviorRestrictions);
</del><ins>+ WEBCORE_EXPORT BehaviorRestrictions behaviorRestrictions() const { return m_restrictions; }
+ WEBCORE_EXPORT void addBehaviorRestriction(BehaviorRestrictions);
+ WEBCORE_EXPORT void removeBehaviorRestriction(BehaviorRestrictions);
</ins><span class="cx">
</span><span class="cx"> #if ENABLE(MEDIA_SOURCE)
</span><span class="cx"> size_t maximumMediaSourceBufferSize(const SourceBuffer&) const;
</span></span></pre></div>
<a id="trunkSourceWebCorepageSettingscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Settings.cpp (183427 => 183428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Settings.cpp        2015-04-27 22:04:04 UTC (rev 183427)
+++ trunk/Source/WebCore/page/Settings.cpp        2015-04-27 22:08:43 UTC (rev 183428)
</span><span class="lines">@@ -127,6 +127,7 @@
</span><span class="cx"> static const bool defaultAcceleratedCompositingForFixedPositionEnabled = true;
</span><span class="cx"> static const bool defaultMediaPlaybackAllowsInline = false;
</span><span class="cx"> static const bool defaultMediaPlaybackRequiresUserGesture = true;
</span><ins>+static const bool defaultAudioPlaybackRequiresUserGesture = true;
</ins><span class="cx"> static const bool defaultShouldRespectImageOrientation = true;
</span><span class="cx"> static const bool defaultImageSubsamplingEnabled = true;
</span><span class="cx"> static const bool defaultScrollingTreeIncludesFrames = true;
</span><span class="lines">@@ -136,6 +137,7 @@
</span><span class="cx"> static const bool defaultAcceleratedCompositingForFixedPositionEnabled = false;
</span><span class="cx"> static const bool defaultMediaPlaybackAllowsInline = true;
</span><span class="cx"> static const bool defaultMediaPlaybackRequiresUserGesture = false;
</span><ins>+static const bool defaultAudioPlaybackRequiresUserGesture = false;
</ins><span class="cx"> static const bool defaultShouldRespectImageOrientation = false;
</span><span class="cx"> static const bool defaultImageSubsamplingEnabled = false;
</span><span class="cx"> static const bool defaultScrollingTreeIncludesFrames = false;
</span></span></pre></div>
<a id="trunkSourceWebCorepageSettingsin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Settings.in (183427 => 183428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Settings.in        2015-04-27 22:04:04 UTC (rev 183427)
+++ trunk/Source/WebCore/page/Settings.in        2015-04-27 22:08:43 UTC (rev 183428)
</span><span class="lines">@@ -126,6 +126,7 @@
</span><span class="cx"> allowDisplayOfInsecureContent initial=false
</span><span class="cx"> allowRunningOfInsecureContent initial=false
</span><span class="cx"> mediaPlaybackRequiresUserGesture initial=defaultMediaPlaybackRequiresUserGesture
</span><ins>+audioPlaybackRequiresUserGesture initial=defaultAudioPlaybackRequiresUserGesture
</ins><span class="cx"> mediaPlaybackAllowsInline initial=defaultMediaPlaybackAllowsInline
</span><span class="cx"> allowsAlternateFullscreen initial=defaultAllowsAlternateFullscreen
</span><span class="cx"> passwordEchoEnabled initial=false
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.cpp (183427 => 183428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.cpp        2015-04-27 22:04:04 UTC (rev 183427)
+++ trunk/Source/WebCore/testing/Internals.cpp        2015-04-27 22:08:43 UTC (rev 183428)
</span><span class="lines">@@ -2536,25 +2536,67 @@
</span><span class="cx"> MediaSessionManager::sharedManager().removeRestriction(mediaType, restrictions);
</span><span class="cx">
</span><span class="cx"> restrictions = MediaSessionManager::NoRestrictions;
</span><del>-
- if (equalIgnoringCase(restrictionsString, "ConcurrentPlaybackNotPermitted"))
- restrictions = MediaSessionManager::ConcurrentPlaybackNotPermitted;
- if (equalIgnoringCase(restrictionsString, "InlineVideoPlaybackRestricted"))
- restrictions += MediaSessionManager::InlineVideoPlaybackRestricted;
- if (equalIgnoringCase(restrictionsString, "MetadataPreloadingNotPermitted"))
- restrictions += MediaSessionManager::MetadataPreloadingNotPermitted;
- if (equalIgnoringCase(restrictionsString, "AutoPreloadingNotPermitted"))
- restrictions += MediaSessionManager::AutoPreloadingNotPermitted;
- if (equalIgnoringCase(restrictionsString, "BackgroundProcessPlaybackRestricted"))
- restrictions += MediaSessionManager::BackgroundProcessPlaybackRestricted;
- if (equalIgnoringCase(restrictionsString, "BackgroundTabPlaybackRestricted"))
- restrictions += MediaSessionManager::BackgroundTabPlaybackRestricted;
- if (equalIgnoringCase(restrictionsString, "InterruptedPlaybackNotPermitted"))
- restrictions += MediaSessionManager::InterruptedPlaybackNotPermitted;
</del><span class="cx">
</span><ins>+ Vector<String> restrictionsArray;
+ restrictionsString.split(',', false, restrictionsArray);
+ for (auto& restrictionString : restrictionsArray) {
+ if (equalIgnoringCase(restrictionString, "ConcurrentPlaybackNotPermitted"))
+ restrictions |= MediaSessionManager::ConcurrentPlaybackNotPermitted;
+ if (equalIgnoringCase(restrictionString, "InlineVideoPlaybackRestricted"))
+ restrictions |= MediaSessionManager::InlineVideoPlaybackRestricted;
+ if (equalIgnoringCase(restrictionString, "MetadataPreloadingNotPermitted"))
+ restrictions |= MediaSessionManager::MetadataPreloadingNotPermitted;
+ if (equalIgnoringCase(restrictionString, "AutoPreloadingNotPermitted"))
+ restrictions |= MediaSessionManager::AutoPreloadingNotPermitted;
+ if (equalIgnoringCase(restrictionString, "BackgroundProcessPlaybackRestricted"))
+ restrictions |= MediaSessionManager::BackgroundProcessPlaybackRestricted;
+ if (equalIgnoringCase(restrictionString, "BackgroundTabPlaybackRestricted"))
+ restrictions |= MediaSessionManager::BackgroundTabPlaybackRestricted;
+ if (equalIgnoringCase(restrictionString, "InterruptedPlaybackNotPermitted"))
+ restrictions |= MediaSessionManager::InterruptedPlaybackNotPermitted;
+ }
</ins><span class="cx"> MediaSessionManager::sharedManager().addRestriction(mediaType, restrictions);
</span><span class="cx"> }
</span><del>-
</del><ins>+
+void Internals::setMediaElementRestrictions(HTMLMediaElement* element, const String& restrictionsString, ExceptionCode& ec)
+{
+ if (!element) {
+ ec = INVALID_ACCESS_ERR;
+ return;
+ }
+
+ HTMLMediaSession::BehaviorRestrictions restrictions = element->mediaSession().behaviorRestrictions();
+ element->mediaSession().removeBehaviorRestriction(restrictions);
+
+ restrictions = HTMLMediaSession::NoRestrictions;
+
+ Vector<String> restrictionsArray;
+ restrictionsString.split(',', false, restrictionsArray);
+ for (auto& restrictionString : restrictionsArray) {
+ if (equalIgnoringCase(restrictionString, "NoRestrictions"))
+ restrictions |= HTMLMediaSession::NoRestrictions;
+ if (equalIgnoringCase(restrictionString, "RequireUserGestureForLoad"))
+ restrictions |= HTMLMediaSession::RequireUserGestureForLoad;
+ if (equalIgnoringCase(restrictionString, "RequireUserGestureForRateChange"))
+ restrictions |= HTMLMediaSession::RequireUserGestureForRateChange;
+ if (equalIgnoringCase(restrictionString, "RequireUserGestureForFullscreen"))
+ restrictions |= HTMLMediaSession::RequireUserGestureForFullscreen;
+ if (equalIgnoringCase(restrictionString, "RequirePageConsentToLoadMedia"))
+ restrictions |= HTMLMediaSession::RequirePageConsentToLoadMedia;
+ if (equalIgnoringCase(restrictionString, "RequirePageConsentToResumeMedia"))
+ restrictions |= HTMLMediaSession::RequirePageConsentToResumeMedia;
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+ if (equalIgnoringCase(restrictionString, "RequireUserGestureToShowPlaybackTargetPicker"))
+ restrictions |= HTMLMediaSession::RequireUserGestureToShowPlaybackTargetPicker;
+ if (equalIgnoringCase(restrictionString, "WirelessVideoPlaybackDisabled"))
+ restrictions |= HTMLMediaSession::WirelessVideoPlaybackDisabled;
+#endif
+ if (equalIgnoringCase(restrictionString, "RequireUserGestureForAudioRateChange"))
+ restrictions |= HTMLMediaSession::RequireUserGestureForAudioRateChange;
+ }
+ element->mediaSession().addBehaviorRestriction(restrictions);
+}
+
</ins><span class="cx"> void Internals::postRemoteControlCommand(const String& commandString, ExceptionCode& ec)
</span><span class="cx"> {
</span><span class="cx"> MediaSession::RemoteControlCommandType command;
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.h (183427 => 183428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.h        2015-04-27 22:04:04 UTC (rev 183427)
+++ trunk/Source/WebCore/testing/Internals.h        2015-04-27 22:08:43 UTC (rev 183428)
</span><span class="lines">@@ -50,6 +50,7 @@
</span><span class="cx"> class Element;
</span><span class="cx"> class File;
</span><span class="cx"> class Frame;
</span><ins>+class HTMLMediaElement;
</ins><span class="cx"> class InspectorFrontendChannelDummy;
</span><span class="cx"> class InspectorFrontendClientDummy;
</span><span class="cx"> class InternalSettings;
</span><span class="lines">@@ -369,6 +370,7 @@
</span><span class="cx"> void applicationWillEnterForeground() const;
</span><span class="cx"> void applicationWillEnterBackground() const;
</span><span class="cx"> void setMediaSessionRestrictions(const String& mediaType, const String& restrictions, ExceptionCode&);
</span><ins>+ void setMediaElementRestrictions(HTMLMediaElement*, const String& restrictions, ExceptionCode&);
</ins><span class="cx"> void postRemoteControlCommand(const String&, ExceptionCode&);
</span><span class="cx"> bool elementIsBlockingDisplaySleep(Element*) const;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.idl (183427 => 183428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.idl        2015-04-27 22:04:04 UTC (rev 183427)
+++ trunk/Source/WebCore/testing/Internals.idl        2015-04-27 22:08:43 UTC (rev 183428)
</span><span class="lines">@@ -336,6 +336,7 @@
</span><span class="cx"> [Conditional=VIDEO] void applicationWillEnterForeground();
</span><span class="cx"> [Conditional=VIDEO] void applicationWillEnterBackground();
</span><span class="cx"> [Conditional=VIDEO, RaisesException] void setMediaSessionRestrictions(DOMString mediaType, DOMString restrictions);
</span><ins>+ [Conditional=VIDEO, RaisesException] void setMediaElementRestrictions(HTMLMediaElement element, DOMString restrictions);
</ins><span class="cx"> [Conditional=WEB_AUDIO, RaisesException] void setAudioContextRestrictions(AudioContext context, DOMString restrictions);
</span><span class="cx"> [Conditional=VIDEO, RaisesException] void postRemoteControlCommand(DOMString command);
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>