<!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>[161899] 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/161899">161899</a></dd>
<dt>Author</dt> <dd>eric.carlson@apple.com</dd>
<dt>Date</dt> <dd>2014-01-13 11:42:27 -0800 (Mon, 13 Jan 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Allow MediaSessionManager to restrict media playback
https://bugs.webkit.org/show_bug.cgi?id=126780

Reviewed by Jer Noble.

Source/WebCore: 

Test: media/video-concurrent-playback.html

* WebCore.exp.in: Export functions needed by Internals.

Add HTMLMediaSession.
* WebCore.xcodeproj/project.pbxproj:
* CMakeLists.txt:
* GNUmakefile.list.am:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:

Add a media session object to manage HTMLMediaElement restrictions.
* html/HTMLMediaSession.cpp: Added.
* html/HTMLMediaSession.h: Added.

Move media restriction management to a MediaSession.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement): Use the media session to manage restrictions.
(WebCore::HTMLMediaElement::parseAttribute): Ditto.
(WebCore::HTMLMediaElement::insertedInto): Ditto.
(WebCore::HTMLMediaElement::parseAttribute): Ditto.
(WebCore::HTMLMediaElement::loadInternal): Ditto.
(WebCore::HTMLMediaElement::loadResource): Ditto.
(WebCore::HTMLMediaElement::setReadyState): Ditto.
(WebCore::HTMLMediaElement::autoplay): Ditto.
(WebCore::HTMLMediaElement::play): Ditto.
(WebCore::HTMLMediaElement::pause): Ditto
(WebCore::HTMLMediaElement::pauseInternal): Ditto
(WebCore::HTMLMediaElement::suspend): Ditto
(WebCore::HTMLMediaElement::resume): Ditto.
(WebCore::HTMLMediaElement::updatePlayState): Tell media session playback is about to start.
(WebCore::HTMLMediaElement::deliverNotification): Ditto.
(WebCore::HTMLMediaElement::webkitShowPlaybackTargetPicker): Ditto.
(WebCore::HTMLMediaElement::mediaPlayerIsFullscreenPermitted): Ditto.
(WebCore::HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture): Ditto.
(WebCore::HTMLMediaElement::pausePlayback): New, allows the media session to pause playback.
* html/HTMLMediaElement.h:

* html/HTMLVideoElement.cpp:
(WebCore::HTMLVideoElement::webkitEnterFullscreen): Use the media session to manage restrictions.

* platform/audio/MediaSession.cpp:
(WebCore::MediaSession::beginInterruption): Add logging.
(WebCore::MediaSession::endInterruption): Ditto.
(WebCore::MediaSession::pauseSession): New, allows the session manager to pause playback.
* platform/audio/MediaSession.h:

Add per-media type restrictions.
* platform/audio/MediaSessionManager.cpp:
(WebCore::MediaSessionManager::MediaSessionManager): Initialize restrictions.
(WebCore::MediaSessionManager::addRestriction): New.
(WebCore::MediaSessionManager::removeRestriction): New.
(WebCore::MediaSessionManager::restrictions): New.
(WebCore::MediaSessionManager::sessionWillBeginPlayback): New. If only one session if the same
    type is allowed to play, pause all others.
* platform/audio/MediaSessionManager.h:

* platform/audio/ios/MediaSessionManagerIOS.h: Added.
* platform/audio/ios/MediaSessionManagerIOS.mm: Added.
(WebCore::MediaSessionManager::sharedManager):
(WebCore::m_objcObserver):
(-[WebAVAudioSessionHelper initWithCallback:]):
(-[WebAVAudioSessionHelper dealloc]):
(-[WebAVAudioSessionHelper interruption:]):

* platform/audio/mac/AudioDestinationMac.h: Add pausePlayback.

Allow tests to set media session restrictions.
* testing/Internals.cpp:
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests: 

* media/video-concurrent-playback-expected.txt: Added.
* media/video-concurrent-playback.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreGNUmakefilelistam">trunk/Source/WebCore/GNUmakefile.list.am</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxproj">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementcpp">trunk/Source/WebCore/html/HTMLMediaElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementh">trunk/Source/WebCore/html/HTMLMediaElement.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLVideoElementcpp">trunk/Source/WebCore/html/HTMLVideoElement.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformaudioMediaSessioncpp">trunk/Source/WebCore/platform/audio/MediaSession.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformaudioMediaSessionh">trunk/Source/WebCore/platform/audio/MediaSession.h</a></li>
<li><a href="#trunkSourceWebCoreplatformaudioMediaSessionManagercpp">trunk/Source/WebCore/platform/audio/MediaSessionManager.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformaudioMediaSessionManagerh">trunk/Source/WebCore/platform/audio/MediaSessionManager.h</a></li>
<li><a href="#trunkSourceWebCoreplatformaudiomacAudioDestinationMach">trunk/Source/WebCore/platform/audio/mac/AudioDestinationMac.h</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="#trunkLayoutTestsmediavideoconcurrentplaybackexpectedtxt">trunk/LayoutTests/media/video-concurrent-playback-expected.txt</a></li>
<li><a href="#trunkLayoutTestsmediavideoconcurrentplaybackhtml">trunk/LayoutTests/media/video-concurrent-playback.html</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="#trunkSourceWebCoreplatformaudioiosMediaSessionManagerIOSh">trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h</a></li>
<li><a href="#trunkSourceWebCoreplatformaudioiosMediaSessionManagerIOSmm">trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (161898 => 161899)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-01-13 19:34:06 UTC (rev 161898)
+++ trunk/LayoutTests/ChangeLog        2014-01-13 19:42:27 UTC (rev 161899)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2014-01-13  Eric Carlson  &lt;eric.carlson@apple.com&gt;
+
+        Allow MediaSessionManager to restrict media playback
+        https://bugs.webkit.org/show_bug.cgi?id=126780
+
+        Reviewed by Jer Noble.
+
+        * media/video-concurrent-playback-expected.txt: Added.
+        * media/video-concurrent-playback.html: Added.
+
</ins><span class="cx"> 2014-01-13  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed Mac WK2 gardering after r161882.
</span></span></pre></div>
<a id="trunkLayoutTestsmediavideoconcurrentplaybackexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/media/video-concurrent-playback-expected.txt (0 => 161899)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/video-concurrent-playback-expected.txt                                (rev 0)
+++ trunk/LayoutTests/media/video-concurrent-playback-expected.txt        2014-01-13 19:42:27 UTC (rev 161899)
</span><span class="lines">@@ -0,0 +1,21 @@
</span><ins>+  
+Test play() when concurrent playback not allowed.
+
+RUN(internals.setMediaSessionRestrictions('video', 'ConcurrentPlaybackNotPermitted'))
+
+EVENT(canplaythrough)
+EVENT(canplaythrough)
+
+** Play first video...
+RUN(videos[0].play())
+EVENT(playing)
+
+** Starting the second video, the first one should pause.
+RUN(videos[1].play())
+EVENT(playing)
+
+EXPECTED (videos[0].paused == 'true') OK
+EXPECTED (videos[1].paused == 'false') OK
+
+END OF TEST
+
</ins></span></pre></div>
<a id="trunkLayoutTestsmediavideoconcurrentplaybackhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/media/video-concurrent-playback.html (0 => 161899)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/video-concurrent-playback.html                                (rev 0)
+++ trunk/LayoutTests/media/video-concurrent-playback.html        2014-01-13 19:42:27 UTC (rev 161899)
</span><span class="lines">@@ -0,0 +1,73 @@
</span><ins>+&lt;html&gt;
+    &lt;head&gt;
+        &lt;script src=media-file.js&gt;&lt;/script&gt;
+        &lt;script src=video-test.js&gt;&lt;/script&gt;
+        &lt;script&gt;
+            var playCount = 0;
+            var playThroughCount = 0;
+            var videos = [];
+
+            function logEvent(evt)
+            {
+                consoleWrite(&quot;EVENT(&quot; + evt.type + &quot;)&quot;);
+            }
+
+            function playing(evt)
+            {
+                logEvent(evt);
+                consoleWrite(&quot;&quot;);
+
+                switch (++playCount)
+                {
+                case 1:
+                    consoleWrite(&quot;** Starting the second video, the first one should pause.&quot;);
+                    run(&quot;videos[1].play()&quot;);
+                    setTimeout(endTest, 100);
+                    break;
+                case 2:
+                    testExpected(&quot;videos[0].paused&quot;, true);
+                    testExpected(&quot;videos[1].paused&quot;, false);
+
+                    consoleWrite(&quot;&quot;);
+                    endTest();
+                    break;
+                }
+            }
+
+            function canplaythrough(evt)
+            {
+                logEvent(evt);
+
+                if (++playThroughCount &lt; 2)
+                    return;
+
+                consoleWrite(&quot;&lt;br&gt;** Play first video...&quot;);
+                run(&quot;videos[0].play()&quot;);
+            }
+
+            function start()
+            {
+                if (!window.internals) {
+                    failTest('This test requires window.internals.');
+                    return;
+                }
+
+                videos = document.getElementsByTagName('video');
+                for (var i = 0; i &lt; videos.length; ++i) {
+                    video = videos[i];
+                    video.addEventListener(&quot;canplaythrough&quot;, canplaythrough);
+                    video.addEventListener('playing', playing);
+                    video.src = findMediaFile(&quot;video&quot;, &quot;content/test&quot;);
+                }
+                run(&quot;internals.setMediaSessionRestrictions('video', 'ConcurrentPlaybackNotPermitted')&quot;);
+                consoleWrite(&quot;&quot;);
+            }
+        &lt;/script&gt;
+    &lt;/head&gt;
+
+    &lt;body onload=&quot;start()&quot;&gt;
+        &lt;video controls id=&quot;one&quot;&gt;&lt;/video&gt;
+        &lt;video controls id=&quot;two&quot;&gt;&lt;/video&gt;
+        &lt;p&gt;Test play() when concurrent playback not allowed.&lt;/p&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (161898 => 161899)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2014-01-13 19:34:06 UTC (rev 161898)
+++ trunk/Source/WebCore/CMakeLists.txt        2014-01-13 19:42:27 UTC (rev 161899)
</span><span class="lines">@@ -1415,6 +1415,7 @@
</span><span class="cx">     html/HTMLMapElement.cpp
</span><span class="cx">     html/HTMLMarqueeElement.cpp
</span><span class="cx">     html/HTMLMediaElement.cpp
</span><ins>+    html/HTMLMediaSession.cpp
</ins><span class="cx">     html/HTMLMediaSource.cpp
</span><span class="cx">     html/HTMLMenuElement.cpp
</span><span class="cx">     html/HTMLMetaElement.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (161898 => 161899)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-01-13 19:34:06 UTC (rev 161898)
+++ trunk/Source/WebCore/ChangeLog        2014-01-13 19:42:27 UTC (rev 161899)
</span><span class="lines">@@ -1,3 +1,83 @@
</span><ins>+2014-01-13  Eric Carlson  &lt;eric.carlson@apple.com&gt;
+
+        Allow MediaSessionManager to restrict media playback
+        https://bugs.webkit.org/show_bug.cgi?id=126780
+
+        Reviewed by Jer Noble.
+
+        Test: media/video-concurrent-playback.html
+
+        * WebCore.exp.in: Export functions needed by Internals.
+
+        Add HTMLMediaSession.
+        * WebCore.xcodeproj/project.pbxproj:
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * WebCore.vcxproj/WebCore.vcxproj:
+        * WebCore.vcxproj/WebCore.vcxproj.filters:
+        * WebCore.xcodeproj/project.pbxproj:
+
+        Add a media session object to manage HTMLMediaElement restrictions.
+        * html/HTMLMediaSession.cpp: Added.
+        * html/HTMLMediaSession.h: Added.
+
+        Move media restriction management to a MediaSession.
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::HTMLMediaElement): Use the media session to manage restrictions.
+        (WebCore::HTMLMediaElement::parseAttribute): Ditto.
+        (WebCore::HTMLMediaElement::insertedInto): Ditto.
+        (WebCore::HTMLMediaElement::parseAttribute): Ditto.
+        (WebCore::HTMLMediaElement::loadInternal): Ditto.
+        (WebCore::HTMLMediaElement::loadResource): Ditto.
+        (WebCore::HTMLMediaElement::setReadyState): Ditto.
+        (WebCore::HTMLMediaElement::autoplay): Ditto.
+        (WebCore::HTMLMediaElement::play): Ditto.
+        (WebCore::HTMLMediaElement::pause): Ditto
+        (WebCore::HTMLMediaElement::pauseInternal): Ditto
+        (WebCore::HTMLMediaElement::suspend): Ditto
+        (WebCore::HTMLMediaElement::resume): Ditto.
+        (WebCore::HTMLMediaElement::updatePlayState): Tell media session playback is about to start.
+        (WebCore::HTMLMediaElement::deliverNotification): Ditto.
+        (WebCore::HTMLMediaElement::webkitShowPlaybackTargetPicker): Ditto.
+        (WebCore::HTMLMediaElement::mediaPlayerIsFullscreenPermitted): Ditto.
+        (WebCore::HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture): Ditto.
+        (WebCore::HTMLMediaElement::pausePlayback): New, allows the media session to pause playback.
+        * html/HTMLMediaElement.h:
+
+        * html/HTMLVideoElement.cpp:
+        (WebCore::HTMLVideoElement::webkitEnterFullscreen): Use the media session to manage restrictions.
+
+        * platform/audio/MediaSession.cpp:
+        (WebCore::MediaSession::beginInterruption): Add logging.
+        (WebCore::MediaSession::endInterruption): Ditto.
+        (WebCore::MediaSession::pauseSession): New, allows the session manager to pause playback.
+        * platform/audio/MediaSession.h:
+
+        Add per-media type restrictions.
+        * platform/audio/MediaSessionManager.cpp:
+        (WebCore::MediaSessionManager::MediaSessionManager): Initialize restrictions.
+        (WebCore::MediaSessionManager::addRestriction): New.
+        (WebCore::MediaSessionManager::removeRestriction): New.
+        (WebCore::MediaSessionManager::restrictions): New.
+        (WebCore::MediaSessionManager::sessionWillBeginPlayback): New. If only one session if the same
+            type is allowed to play, pause all others.
+        * platform/audio/MediaSessionManager.h:
+
+        * platform/audio/ios/MediaSessionManagerIOS.h: Added.
+        * platform/audio/ios/MediaSessionManagerIOS.mm: Added.
+        (WebCore::MediaSessionManager::sharedManager):
+        (WebCore::m_objcObserver):
+        (-[WebAVAudioSessionHelper initWithCallback:]):
+        (-[WebAVAudioSessionHelper dealloc]):
+        (-[WebAVAudioSessionHelper interruption:]):
+
+        * platform/audio/mac/AudioDestinationMac.h: Add pausePlayback.
+
+        Allow tests to set media session restrictions.
+        * testing/Internals.cpp:
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
</ins><span class="cx"> 2014-01-13  Alexey Proskuryakov  &lt;ap@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix the build more.
</span></span></pre></div>
<a id="trunkSourceWebCoreGNUmakefilelistam"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/GNUmakefile.list.am (161898 => 161899)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/GNUmakefile.list.am        2014-01-13 19:34:06 UTC (rev 161898)
+++ trunk/Source/WebCore/GNUmakefile.list.am        2014-01-13 19:42:27 UTC (rev 161899)
</span><span class="lines">@@ -3457,6 +3457,8 @@
</span><span class="cx">         Source/WebCore/html/HTMLMediaSource.h \
</span><span class="cx">         Source/WebCore/html/HTMLMediaElement.cpp \
</span><span class="cx">         Source/WebCore/html/HTMLMediaElement.h \
</span><ins>+        Source/WebCore/html/HTMLMediaSession.cpp \
+        Source/WebCore/html/HTMLMediaSession.h \
</ins><span class="cx">         Source/WebCore/html/HTMLMenuElement.cpp \
</span><span class="cx">         Source/WebCore/html/HTMLMenuElement.h \
</span><span class="cx">         Source/WebCore/html/HTMLMetaElement.cpp \
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (161898 => 161899)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-01-13 19:34:06 UTC (rev 161898)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-01-13 19:42:27 UTC (rev 161899)
</span><span class="lines">@@ -753,9 +753,12 @@
</span><span class="cx"> __ZN7WebCore19LayerFlushSchedulerC2EPNS_25LayerFlushSchedulerClientE
</span><span class="cx"> __ZN7WebCore19LayerFlushSchedulerD1Ev
</span><span class="cx"> __ZN7WebCore19LayerFlushSchedulerD2Ev
</span><ins>+__ZN7WebCore19MediaSessionManager12restrictionsENS_12MediaSession9MediaTypeE
</ins><span class="cx"> __ZN7WebCore19MediaSessionManager13sharedManagerEv
</span><ins>+__ZN7WebCore19MediaSessionManager14addRestrictionENS_12MediaSession9MediaTypeEj
</ins><span class="cx"> __ZN7WebCore19MediaSessionManager15endInterruptionENS_12MediaSession20EndInterruptionFlagsE
</span><span class="cx"> __ZN7WebCore19MediaSessionManager17beginInterruptionEv
</span><ins>+__ZN7WebCore19MediaSessionManager17removeRestrictionENS_12MediaSession9MediaTypeEj
</ins><span class="cx"> __ZN7WebCore19ResourceRequestBase11setHTTPBodyEN3WTF10PassRefPtrINS_8FormDataEEE
</span><span class="cx"> __ZN7WebCore19ResourceRequestBase13setHTTPMethodERKN3WTF6StringE
</span><span class="cx"> __ZN7WebCore19ResourceRequestBase18setHTTPHeaderFieldEPKcRKN3WTF6StringE
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (161898 => 161899)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2014-01-13 19:34:06 UTC (rev 161898)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2014-01-13 19:42:27 UTC (rev 161899)
</span><span class="lines">@@ -14583,6 +14583,7 @@
</span><span class="cx">     &lt;ClCompile Include=&quot;..\html\DOMSettableTokenList.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\html\DOMTokenList.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\html\DOMURL.cpp&quot; /&gt;
</span><ins>+    &lt;ClCompile Include=&quot;..\html\HTMLMediaSession.cpp&quot; /&gt;
</ins><span class="cx">     &lt;ClCompile Include=&quot;..\html\EmailInputType.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\fileapi\File.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\fileapi\FileException.cpp&quot; /&gt;
</span><span class="lines">@@ -20439,6 +20440,7 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\html\DOMSettableTokenList.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\html\DOMTokenList.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\html\DOMURL.h&quot; /&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\html\ElementMediaSession.h&quot; /&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\html\EmailInputType.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\fileapi\File.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\fileapi\FileException.h&quot; /&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (161898 => 161899)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-01-13 19:34:06 UTC (rev 161898)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-01-13 19:42:27 UTC (rev 161899)
</span><span class="lines">@@ -185,6 +185,8 @@
</span><span class="cx">                 076306E017E16089005A7C4E /* JSSourceInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 076306DE17E16089005A7C4E /* JSSourceInfo.cpp */; };
</span><span class="cx">                 076306E117E16089005A7C4E /* JSSourceInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 076306DF17E16089005A7C4E /* JSSourceInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 076306E317E22A43005A7C4E /* MediaStreamTrackSourcesRequestClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 076306E217E22A43005A7C4E /* MediaStreamTrackSourcesRequestClient.h */; };
</span><ins>+                07638A991884487200E15A1B /* MediaSessionManagerIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 07638A971884487200E15A1B /* MediaSessionManagerIOS.h */; };
+                07638A9A1884487200E15A1B /* MediaSessionManagerIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 07638A981884487200E15A1B /* MediaSessionManagerIOS.mm */; };
</ins><span class="cx">                 076970861463AD8700F502CF /* TextTrackList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 076970841463AD8700F502CF /* TextTrackList.cpp */; };
</span><span class="cx">                 076970871463AD8700F502CF /* TextTrackList.h in Headers */ = {isa = PBXBuildFile; fileRef = 076970851463AD8700F502CF /* TextTrackList.h */; };
</span><span class="cx">                 076F0D0E12B8192700C26AA4 /* MediaPlayerPrivateAVFoundation.h in Headers */ = {isa = PBXBuildFile; fileRef = 076F0D0A12B8192700C26AA4 /* MediaPlayerPrivateAVFoundation.h */; };
</span><span class="lines">@@ -339,6 +341,8 @@
</span><span class="cx">                 07ED35A216D6DCC9002248F3 /* InbandTextTrackPrivateAVFIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 07357C7716D2DF0D00ED99E7 /* InbandTextTrackPrivateAVFIOS.mm */; };
</span><span class="cx">                 07ED35A316D6DCE2002248F3 /* InbandTextTrackPrivateAVFIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 07357C7616D2DF0D00ED99E7 /* InbandTextTrackPrivateAVFIOS.h */; };
</span><span class="cx">                 07F944161864D046005D31CB /* MediaSessionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = CDAE8C081746B95700532D78 /* MediaSessionManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                07FE99DC18807A7D00256648 /* HTMLMediaSession.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07FE99DA18807A7D00256648 /* HTMLMediaSession.cpp */; };
+                07FE99DD18807A7D00256648 /* HTMLMediaSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 07FE99DB18807A7D00256648 /* HTMLMediaSession.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 07FFDE68181AED420072D409 /* MediaStreamTrackPrivate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07FFDE66181AED420072D409 /* MediaStreamTrackPrivate.cpp */; };
</span><span class="cx">                 07FFDE69181AED420072D409 /* MediaStreamTrackPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 07FFDE67181AED420072D409 /* MediaStreamTrackPrivate.h */; };
</span><span class="cx">                 0806E57A12893045007CED32 /* SVGMatrix.h in Headers */ = {isa = PBXBuildFile; fileRef = 0806E57912893045007CED32 /* SVGMatrix.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -7034,6 +7038,8 @@
</span><span class="cx">                 076306DE17E16089005A7C4E /* JSSourceInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSourceInfo.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 076306DF17E16089005A7C4E /* JSSourceInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSourceInfo.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 076306E217E22A43005A7C4E /* MediaStreamTrackSourcesRequestClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaStreamTrackSourcesRequestClient.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                07638A971884487200E15A1B /* MediaSessionManagerIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MediaSessionManagerIOS.h; path = ios/MediaSessionManagerIOS.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                07638A981884487200E15A1B /* MediaSessionManagerIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MediaSessionManagerIOS.mm; path = ios/MediaSessionManagerIOS.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 076970841463AD8700F502CF /* TextTrackList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextTrackList.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 076970851463AD8700F502CF /* TextTrackList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextTrackList.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 076F0D0912B8192700C26AA4 /* MediaPlayerPrivateAVFoundation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaPlayerPrivateAVFoundation.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -7123,6 +7129,8 @@
</span><span class="cx">                 07DC5FD317D3EEE90099F890 /* JSRTCStatsResponseCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSRTCStatsResponseCustom.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 07E116B01489C9A100EC5ACE /* JSTextTrackCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTextTrackCustom.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 07E117061489EBEB00EC5ACE /* JSTextTrackCueCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTextTrackCueCustom.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                07FE99DA18807A7D00256648 /* HTMLMediaSession.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLMediaSession.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                07FE99DB18807A7D00256648 /* HTMLMediaSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLMediaSession.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 07FFDE66181AED420072D409 /* MediaStreamTrackPrivate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaStreamTrackPrivate.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 07FFDE67181AED420072D409 /* MediaStreamTrackPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaStreamTrackPrivate.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 0806E57912893045007CED32 /* SVGMatrix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGMatrix.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -17172,6 +17180,8 @@
</span><span class="cx">                 93EEC1EC09C2877700C515D1 /* html */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                07FE99DA18807A7D00256648 /* HTMLMediaSession.cpp */,
+                                07FE99DB18807A7D00256648 /* HTMLMediaSession.h */,
</ins><span class="cx">                                 49484FAE102CF01E00187DD3 /* canvas */,
</span><span class="cx">                                 1A88A90117553CD7000C74F9 /* forms */,
</span><span class="cx">                                 97C1F5511228558800EDE616 /* parser */,
</span><span class="lines">@@ -20998,6 +21008,8 @@
</span><span class="cx">                 CD0EEE0D14743E48003EAFA2 /* ios */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                07638A971884487200E15A1B /* MediaSessionManagerIOS.h */,
+                                07638A981884487200E15A1B /* MediaSessionManagerIOS.mm */,
</ins><span class="cx">                                 CD0EEE0B14743E35003EAFA2 /* AudioDestinationIOS.cpp */,
</span><span class="cx">                                 CD0EEE0A14743E34003EAFA2 /* AudioDestinationIOS.h */,
</span><span class="cx">                                 CD55968F1475B678001D0BD0 /* AudioFileReaderIOS.cpp */,
</span><span class="lines">@@ -24340,6 +24352,7 @@
</span><span class="cx">                                 1A85B1E90A1B240500D8C87C /* JSHTMLDListElement.h in Headers */,
</span><span class="cx">                                 1A494E350A12358B00FDAFC1 /* JSHTMLDocument.h in Headers */,
</span><span class="cx">                                 1A494BFB0A122F4400FDAFC1 /* JSHTMLElement.h in Headers */,
</span><ins>+                                07638A991884487200E15A1B /* MediaSessionManagerIOS.h in Headers */,
</ins><span class="cx">                                 938E65F109F09840008A48EC /* JSHTMLElementWrapperFactory.h in Headers */,
</span><span class="cx">                                 BC6D44ED0C07F2ED0072D2C9 /* JSHTMLEmbedElement.h in Headers */,
</span><span class="cx">                                 1AE2AA270A1CDAB400B42B25 /* JSHTMLFieldSetElement.h in Headers */,
</span><span class="lines">@@ -25355,6 +25368,7 @@
</span><span class="cx">                                 931CBD0D161A44E900E4C874 /* ScrollingStateNode.h in Headers */,
</span><span class="cx">                                 931CBD0F161A44E900E4C874 /* ScrollingStateScrollingNode.h in Headers */,
</span><span class="cx">                                 0FB8890F167D30160010CDA5 /* ScrollingStateStickyNode.h in Headers */,
</span><ins>+                                07FE99DD18807A7D00256648 /* HTMLMediaSession.h in Headers */,
</ins><span class="cx">                                 931CBD11161A44E900E4C874 /* ScrollingStateTree.h in Headers */,
</span><span class="cx">                                 1AF62F2614DAFEA10041556C /* ScrollingThread.h in Headers */,
</span><span class="cx">                                 1AAADDA414DB409F00AF64B3 /* ScrollingTree.h in Headers */,
</span><span class="lines">@@ -28485,6 +28499,7 @@
</span><span class="cx">                                 B2C3DA2C0D006C1D00EF6F26 /* RegularExpression.cpp in Sources */,
</span><span class="cx">                                 93309E00099E64920056E581 /* RemoveCSSPropertyCommand.cpp in Sources */,
</span><span class="cx">                                 D06C0D900CFD11460065F43F /* RemoveFormatCommand.cpp in Sources */,
</span><ins>+                                07638A9A1884487200E15A1B /* MediaSessionManagerIOS.mm in Sources */,
</ins><span class="cx">                                 93309E04099E64920056E581 /* RemoveNodeCommand.cpp in Sources */,
</span><span class="cx">                                 93309E06099E64920056E581 /* RemoveNodePreservingChildrenCommand.cpp in Sources */,
</span><span class="cx">                                 BCEA485F097D93020094C9E4 /* RenderBlock.cpp in Sources */,
</span><span class="lines">@@ -29237,6 +29252,7 @@
</span><span class="cx">                                 77A17A7712F28642004E02F6 /* WebGLVertexArrayObjectOES.cpp in Sources */,
</span><span class="cx">                                 FE6938B61045D67E008EABB6 /* EventHandlerIOS.mm in Sources */,
</span><span class="cx">                                 31C0FF210E4CEB6E007D6FE5 /* WebKitAnimationEvent.cpp in Sources */,
</span><ins>+                                07FE99DC18807A7D00256648 /* HTMLMediaSession.cpp in Sources */,
</ins><span class="cx">                                 976D6C7B122B8A3D001FD1F7 /* WebKitBlobBuilder.cpp in Sources */,
</span><span class="cx">                                 150B923915F08DC400E10986 /* WebKitCSSArrayFunctionValue.cpp in Sources */,
</span><span class="cx">                                 A2E8AE3016A48E1C006BB3AA /* WebKitCSSFilterRule.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (161898 => 161899)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.cpp        2014-01-13 19:34:06 UTC (rev 161898)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp        2014-01-13 19:42:27 UTC (rev 161899)
</span><span class="lines">@@ -282,7 +282,6 @@
</span><span class="cx"> #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
</span><span class="cx">     , m_proxyWidget(0)
</span><span class="cx"> #endif
</span><del>-    , m_restrictions(RequireUserGestureForFullscreenRestriction | RequirePageConsentToLoadMediaRestriction)
</del><span class="cx">     , m_preload(MediaPlayer::Auto)
</span><span class="cx">     , m_displayMode(Unknown)
</span><span class="cx">     , m_processingMediaPlayerCallback(0)
</span><span class="lines">@@ -337,7 +336,7 @@
</span><span class="cx"> #if ENABLE(WEB_AUDIO)
</span><span class="cx">     , m_audioSourceNode(0)
</span><span class="cx"> #endif
</span><del>-    , m_mediaSession(MediaSession::create(*this))
</del><ins>+    , m_mediaSession(HTMLMediaSession::create(*this))
</ins><span class="cx">     , m_reportedExtraMemoryCost(0)
</span><span class="cx"> #if ENABLE(MEDIA_STREAM)
</span><span class="cx">     , m_mediaStreamSrcObject(nullptr)
</span><span class="lines">@@ -346,6 +345,9 @@
</span><span class="cx">     LOG(Media, &quot;HTMLMediaElement::HTMLMediaElement&quot;);
</span><span class="cx">     setHasCustomStyleResolveCallbacks();
</span><span class="cx"> 
</span><ins>+    m_mediaSession-&gt;addBehaviorRestriction(HTMLMediaSession::RequireUserGestureForFullscreen);
+    m_mediaSession-&gt;addBehaviorRestriction(HTMLMediaSession::RequirePageConsentToLoadMedia);
+
</ins><span class="cx">     // FIXME: We should clean up and look to better merge the iOS and non-iOS code below.
</span><span class="cx">     Settings* settings = document.settings();
</span><span class="cx"> #if !PLATFORM(IOS)
</span><span class="lines">@@ -357,15 +359,15 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     if (settings &amp;&amp; settings-&gt;mediaPlaybackRequiresUserGesture()) {
</span><del>-        addBehaviorRestriction(RequireUserGestureForRateChangeRestriction);
-        addBehaviorRestriction(RequireUserGestureForLoadRestriction);
</del><ins>+        m_mediaSession-&gt;addBehaviorRestriction(HTMLMediaSession::RequireUserGestureForRateChange);
+        m_mediaSession-&gt;addBehaviorRestriction(HTMLMediaSession::RequireUserGestureForLoad);
</ins><span class="cx">     }
</span><span class="cx"> #else
</span><span class="cx">     m_sendProgressEvents = false;
</span><span class="cx">     if (!settings || settings-&gt;mediaPlaybackRequiresUserGesture()) {
</span><del>-        addBehaviorRestriction(RequireUserGestureForRateChangeRestriction);
</del><ins>+        m_mediaSession-&gt;addBehaviorRestriction(HTMLMediaSession::RequireUserGestureForRateChange);
</ins><span class="cx"> #if ENABLE(IOS_AIRPLAY)
</span><del>-        addBehaviorRestriction(RequireUserGestureToShowPlaybackTargetPickerRestriction);
</del><ins>+        m_mediaSession-&gt;addBehaviorRestriction(HTMLMediaSession::RequireUserGestureToShowPlaybackTargetPicker);
</ins><span class="cx"> #endif
</span><span class="cx">     }
</span><span class="cx"> #endif // !PLATFORM(IOS)
</span><span class="lines">@@ -519,7 +521,7 @@
</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 (!userGestureRequiredForLoad() &amp;&amp; !value.isNull()) {
</del><ins>+        if (!value.isNull() &amp;&amp; m_mediaSession-&gt;dataLoadingPermitted(*this)) {
</ins><span class="cx"> #else
</span><span class="cx">         // Trigger a reload, as long as the 'src' attribute is present.
</span><span class="cx">         if (!value.isNull()) {
</span><span class="lines">@@ -686,7 +688,7 @@
</span><span class="cx">         m_inActiveDocument = true;
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><del>-        if (!userGestureRequiredForLoad() &amp;&amp; m_networkState == NETWORK_EMPTY &amp;&amp; !fastGetAttribute(srcAttr).isEmpty())
</del><ins>+        if (m_networkState == NETWORK_EMPTY &amp;&amp; !fastGetAttribute(srcAttr).isEmpty() &amp;&amp; m_mediaSession-&gt;dataLoadingPermitted(*this))
</ins><span class="cx"> #else
</span><span class="cx">         if (m_networkState == NETWORK_EMPTY &amp;&amp; !fastGetAttribute(srcAttr).isEmpty())
</span><span class="cx"> #endif
</span><span class="lines">@@ -893,7 +895,7 @@
</span><span class="cx">     
</span><span class="cx">     LOG(Media, &quot;HTMLMediaElement::load()&quot;);
</span><span class="cx">     
</span><del>-    if (userGestureRequiredForLoad() &amp;&amp; !ScriptController::processingUserGesture())
</del><ins>+    if (!m_mediaSession-&gt;dataLoadingPermitted(*this))
</ins><span class="cx">         return;
</span><span class="cx">     if (ScriptController::processingUserGesture())
</span><span class="cx">         removeBehaviorsRestrictionsAfterFirstUserGesture();
</span><span class="lines">@@ -1005,8 +1007,7 @@
</span><span class="cx">     ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
</span><span class="cx"> 
</span><span class="cx">     // If we can't start a load right away, start it later.
</span><del>-    Page* page = document().page();
-    if (pageConsentRequiredForLoad() &amp;&amp; page &amp;&amp; !page-&gt;canStartMedia()) {
</del><ins>+    if (!m_mediaSession-&gt;pageAllowsDataLoading(*this)) {
</ins><span class="cx">         setShouldDelayLoadEvent(false);
</span><span class="cx">         if (m_isWaitingUntilMediaCanStart)
</span><span class="cx">             return;
</span><span class="lines">@@ -1019,8 +1020,8 @@
</span><span class="cx"> 
</span><span class="cx">     // Once the page has allowed an element to load media, it is free to load at will. This allows a 
</span><span class="cx">     // playlist that starts in a foreground tab to continue automatically if the tab is subsequently 
</span><del>-    // put in the the background.
-    removeBehaviorRestriction(RequirePageConsentToLoadMediaRestriction);
</del><ins>+    // put into the background.
+    m_mediaSession-&gt;removeBehaviorRestriction(HTMLMediaSession::RequirePageConsentToLoadMedia);
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><span class="cx">     if (hasMediaControls())
</span><span class="lines">@@ -1196,7 +1197,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(MEDIA_STREAM)
</span><span class="cx">     if (MediaStreamRegistry::registry().lookup(url.string()))
</span><del>-        removeBehaviorRestriction(RequireUserGestureForRateChangeRestriction);
</del><ins>+        m_mediaSession-&gt;removeBehaviorRestriction(HTMLMediaSession::RequireUserGestureForRateChange);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     if (m_sendProgressEvents) 
</span><span class="lines">@@ -2047,7 +2048,7 @@
</span><span class="cx">         if (isPotentiallyPlaying &amp;&amp; oldState &lt;= HAVE_CURRENT_DATA)
</span><span class="cx">             scheduleEvent(eventNames().playingEvent);
</span><span class="cx"> 
</span><del>-        if (m_autoplaying &amp;&amp; m_paused &amp;&amp; autoplay() &amp;&amp; !document().isSandboxed(SandboxAutomaticFeatures) &amp;&amp; !userGestureRequiredForRateChange()) {
</del><ins>+        if (m_autoplaying &amp;&amp; m_paused &amp;&amp; autoplay() &amp;&amp; !document().isSandboxed(SandboxAutomaticFeatures) &amp;&amp; m_mediaSession-&gt;playbackPermitted(*this)) {
</ins><span class="cx">             m_paused = false;
</span><span class="cx">             invalidateCachedTime();
</span><span class="cx">             scheduleEvent(eventNames().playEvent);
</span><span class="lines">@@ -2599,7 +2600,7 @@
</span><span class="cx">     // lifted through Settings, or once the user explictly calls load() or play()
</span><span class="cx">     // because they have OK'ed us loading data. This allows playback to continue if
</span><span class="cx">     // the URL is changed while the movie is playing.
</span><del>-    if (userGestureRequiredForRateChange() || userGestureRequiredForLoad())
</del><ins>+    if (!m_mediaSession-&gt;playbackPermitted(*this) || !m_mediaSession-&gt;dataLoadingPermitted(*this))
</ins><span class="cx">         return false;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -2634,7 +2635,7 @@
</span><span class="cx"> {
</span><span class="cx">     LOG(Media, &quot;HTMLMediaElement::play()&quot;);
</span><span class="cx"> 
</span><del>-    if (userGestureRequiredForRateChange() &amp;&amp; !ScriptController::processingUserGesture())
</del><ins>+    if (!m_mediaSession-&gt;playbackPermitted(*this))
</ins><span class="cx">         return;
</span><span class="cx">     if (ScriptController::processingUserGesture())
</span><span class="cx">         removeBehaviorsRestrictionsAfterFirstUserGesture();
</span><span class="lines">@@ -2683,7 +2684,7 @@
</span><span class="cx"> {
</span><span class="cx">     LOG(Media, &quot;HTMLMediaElement::pause()&quot;);
</span><span class="cx"> 
</span><del>-    if (userGestureRequiredForRateChange() &amp;&amp; !ScriptController::processingUserGesture())
</del><ins>+    if (!m_mediaSession-&gt;playbackPermitted(*this))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (m_mediaSession-&gt;state() == MediaSession::Interrupted) {
</span><span class="lines">@@ -2704,7 +2705,7 @@
</span><span class="cx"> #if PLATFORM(IOS)
</span><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><del>-        if (userGestureRequiredForRateChange())
</del><ins>+        if (!m_mediaSession-&gt;playbackPermitted(*this))
</ins><span class="cx">             return;
</span><span class="cx"> #endif
</span><span class="cx">         scheduleDelayedAction(LoadMediaResource);
</span><span class="lines">@@ -4258,6 +4259,8 @@
</span><span class="cx">         setDisplayMode(Video);
</span><span class="cx">         invalidateCachedTime();
</span><span class="cx"> 
</span><ins>+        m_mediaSession-&gt;clientWillBeginPlayback();
+
</ins><span class="cx">         if (playerPaused) {
</span><span class="cx">             if (!m_isFullscreen &amp;&amp; isVideo() &amp;&amp; document().page() &amp;&amp; document().page()-&gt;chrome().requiresFullscreenForVideoPlayback())
</span><span class="cx">                 enterFullscreen();
</span><span class="lines">@@ -4451,7 +4454,7 @@
</span><span class="cx">     {
</span><span class="cx">         case DocumentWillBecomeInactive:
</span><span class="cx">             stop();
</span><del>-            addBehaviorRestriction(RequirePageConsentToResumeMediaRestriction);
</del><ins>+            m_mediaSession-&gt;addBehaviorRestriction(HTMLMediaSession::RequirePageConsentToResumeMedia);
</ins><span class="cx">             break;
</span><span class="cx">         case DocumentWillBePaused:
</span><span class="cx">         case JavaScriptDebuggerPaused:
</span><span class="lines">@@ -4468,13 +4471,12 @@
</span><span class="cx"> 
</span><span class="cx">     m_inActiveDocument = true;
</span><span class="cx"> 
</span><del>-    Page* page = document().page();
-    if (pageConsentRequiredForResume() &amp;&amp; page &amp;&amp; !page-&gt;canStartMedia())
</del><ins>+    if (!m_mediaSession-&gt;pageAllowsPlaybackAfterResuming(*this))
</ins><span class="cx">         document().addMediaCanStartListener(this);
</span><span class="cx">     else
</span><span class="cx">         setPausedInternal(false);
</span><span class="cx"> 
</span><del>-    removeBehaviorRestriction(RequirePageConsentToResumeMediaRestriction);
</del><ins>+    m_mediaSession-&gt;removeBehaviorRestriction(HTMLMediaSession::RequirePageConsentToResumeMedia);
</ins><span class="cx"> 
</span><span class="cx">     if (m_error &amp;&amp; m_error-&gt;code() == MediaError::MEDIA_ERR_ABORTED) {
</span><span class="cx">         // Restart the load if it was aborted in the middle by moving the document to the page cache.
</span><span class="lines">@@ -4745,7 +4747,7 @@
</span><span class="cx">     if (!m_player)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (userGestureRequiredToShowPlaybackTargetPicker() &amp;&amp; !ScriptController::processingUserGesture())
</del><ins>+    if (!m_mediaSession-&gt;showingPlaybackTargetPickerPermitted(*this))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (document().settings()-&gt;mediaPlaybackAllowsAirPlay())
</span><span class="lines">@@ -5513,7 +5515,7 @@
</span><span class="cx"> 
</span><span class="cx"> bool HTMLMediaElement::mediaPlayerIsFullscreenPermitted() const
</span><span class="cx"> {
</span><del>-    return !userGestureRequiredForFullscreen() || ScriptController::processingUserGesture();
</del><ins>+    return m_mediaSession-&gt;fullscreenPermitted(*this);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool HTMLMediaElement::mediaPlayerIsVideo() const
</span><span class="lines">@@ -5597,11 +5599,11 @@
</span><span class="cx"> 
</span><span class="cx"> void HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture()
</span><span class="cx"> {
</span><del>-    removeBehaviorRestriction(RequireUserGestureForLoadRestriction);
-    removeBehaviorRestriction(RequireUserGestureForRateChangeRestriction);
-    removeBehaviorRestriction(RequireUserGestureForFullscreenRestriction);
</del><ins>+    m_mediaSession-&gt;removeBehaviorRestriction(HTMLMediaSession::RequireUserGestureForLoad);
+    m_mediaSession-&gt;removeBehaviorRestriction(HTMLMediaSession::RequireUserGestureForRateChange);
+    m_mediaSession-&gt;removeBehaviorRestriction(HTMLMediaSession::RequireUserGestureForFullscreen);
</ins><span class="cx"> #if ENABLE(IOS_AIRPLAY)
</span><del>-    removeBehaviorRestriction(RequireUserGestureToShowPlaybackTargetPickerRestriction);
</del><ins>+    m_mediaSession-&gt;removeBehaviorRestriction(HTMLMediaSession::RequireUserGestureToShowPlaybackTargetPicker);
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -5754,6 +5756,12 @@
</span><span class="cx">         play();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void HTMLMediaElement::pausePlayback()
+{
+    if (!paused())
+        pause();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+}
+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (161898 => 161899)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.h        2014-01-13 19:34:06 UTC (rev 161898)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h        2014-01-13 19:42:27 UTC (rev 161899)
</span><span class="lines">@@ -30,10 +30,10 @@
</span><span class="cx"> #include &quot;HTMLElement.h&quot;
</span><span class="cx"> #include &quot;ActiveDOMObject.h&quot;
</span><span class="cx"> #include &quot;GenericEventQueue.h&quot;
</span><ins>+#include &quot;HTMLMediaSession.h&quot;
</ins><span class="cx"> #include &quot;MediaCanStartListener.h&quot;
</span><span class="cx"> #include &quot;MediaControllerInterface.h&quot;
</span><span class="cx"> #include &quot;MediaPlayer.h&quot;
</span><del>-#include &quot;MediaSession.h&quot;
</del><span class="cx"> 
</span><span class="cx"> #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
</span><span class="cx"> #include &quot;HTMLFrameOwnerElement.h&quot;
</span><span class="lines">@@ -442,32 +442,6 @@
</span><span class="cx">     
</span><span class="cx">     virtual bool isMediaElement() const OVERRIDE { return true; }
</span><span class="cx"> 
</span><del>-    // Restrictions to change default behaviors.
-    enum BehaviorRestrictionFlags {
-        NoRestrictions = 0,
-        RequireUserGestureForLoadRestriction = 1 &lt;&lt; 0,
-        RequireUserGestureForRateChangeRestriction = 1 &lt;&lt; 1,
-        RequireUserGestureForFullscreenRestriction = 1 &lt;&lt; 2,
-        RequirePageConsentToLoadMediaRestriction = 1 &lt;&lt; 3,
-        RequirePageConsentToResumeMediaRestriction = 1 &lt;&lt; 4,
-#if ENABLE(IOS_AIRPLAY)
-        RequireUserGestureToShowPlaybackTargetPickerRestriction = 1 &lt;&lt; 5,
-#endif
-    };
-    typedef unsigned BehaviorRestrictions;
-    
-    bool userGestureRequiredForLoad() const { return m_restrictions &amp; RequireUserGestureForLoadRestriction; }
-    bool userGestureRequiredForRateChange() const { return m_restrictions &amp; RequireUserGestureForRateChangeRestriction; }
-    bool userGestureRequiredForFullscreen() const { return m_restrictions &amp; RequireUserGestureForFullscreenRestriction; }
-    bool pageConsentRequiredForLoad() const { return m_restrictions &amp; RequirePageConsentToLoadMediaRestriction; }
-    bool pageConsentRequiredForResume() const { return m_restrictions &amp; RequirePageConsentToResumeMediaRestriction; }
-#if ENABLE(IOS_AIRPLAY)
-    bool userGestureRequiredToShowPlaybackTargetPicker() const { return m_restrictions &amp; RequireUserGestureToShowPlaybackTargetPickerRestriction; }
-#endif
-    
-    void addBehaviorRestriction(BehaviorRestrictions restriction) { m_restrictions |= restriction; }
-    void removeBehaviorRestriction(BehaviorRestrictions restriction) { m_restrictions &amp;= ~restriction; }
-
</del><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><span class="cx">     bool ignoreTrackDisplayUpdateRequests() const { return m_ignoreTrackDisplayUpdate &gt; 0 || !m_textTracks || !m_cueTree.size(); }
</span><span class="cx">     void beginIgnoringTrackDisplayUpdateRequests();
</span><span class="lines">@@ -476,7 +450,7 @@
</span><span class="cx"> 
</span><span class="cx">     virtual RenderPtr&lt;RenderElement&gt; createElementRenderer(PassRef&lt;RenderStyle&gt;) OVERRIDE;
</span><span class="cx"> 
</span><del>-    MediaSession&amp; mediaSession() const { return *m_mediaSession; }
</del><ins>+    HTMLMediaSession&amp; mediaSession() const { return *m_mediaSession; }
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     void createMediaPlayer();
</span><span class="lines">@@ -697,6 +671,7 @@
</span><span class="cx"> 
</span><span class="cx">     virtual void beginInterruption() OVERRIDE;
</span><span class="cx">     virtual void endInterruption(MediaSession::EndInterruptionFlags) OVERRIDE;
</span><ins>+    virtual void pausePlayback() OVERRIDE;
</ins><span class="cx"> 
</span><span class="cx">     Timer&lt;HTMLMediaElement&gt; m_loadTimer;
</span><span class="cx">     Timer&lt;HTMLMediaElement&gt; m_progressEventTimer;
</span><span class="lines">@@ -738,8 +713,6 @@
</span><span class="cx">     RefPtr&lt;Widget&gt; m_proxyWidget;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    BehaviorRestrictions m_restrictions;
-    
</del><span class="cx">     MediaPlayer::Preload m_preload;
</span><span class="cx"> 
</span><span class="cx">     DisplayMode m_displayMode;
</span><span class="lines">@@ -852,7 +825,7 @@
</span><span class="cx">     RefPtr&lt;PlatformTextTrackMenuInterface&gt; m_platformMenu;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    std::unique_ptr&lt;MediaSession&gt; m_mediaSession;
</del><ins>+    std::unique_ptr&lt;HTMLMediaSession&gt; m_mediaSession;
</ins><span class="cx">     std::unique_ptr&lt;PageActivityAssertionToken&gt; m_activityToken;
</span><span class="cx">     size_t m_reportedExtraMemoryCost;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaSessioncpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/html/HTMLMediaSession.cpp (0 => 161899)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaSession.cpp                                (rev 0)
+++ trunk/Source/WebCore/html/HTMLMediaSession.cpp        2014-01-13 19:42:27 UTC (rev 161899)
</span><span class="lines">@@ -0,0 +1,132 @@
</span><ins>+/*
+ * Copyright (C) 2014 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.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;HTMLMediaSession.h&quot;
+
+#include &quot;HTMLMediaElement.h&quot;
+#include &quot;Logging.h&quot;
+#include &quot;MediaSessionManager.h&quot;
+#include &quot;Page.h&quot;
+#include &quot;ScriptController.h&quot;
+
+namespace WebCore {
+
+std::unique_ptr&lt;HTMLMediaSession&gt; HTMLMediaSession::create(MediaSessionClient&amp; client)
+{
+    return std::make_unique&lt;HTMLMediaSession&gt;(client);
+}
+
+HTMLMediaSession::HTMLMediaSession(MediaSessionClient&amp; client)
+    : MediaSession(client)
+    , m_restrictions(NoRestrictions)
+{
+}
+
+void HTMLMediaSession::addBehaviorRestriction(BehaviorRestrictions restriction)
+{
+    m_restrictions |= restriction;
+}
+
+void HTMLMediaSession::removeBehaviorRestriction(BehaviorRestrictions restriction)
+{
+    m_restrictions &amp;= ~restriction;
+}
+
+bool HTMLMediaSession::playbackPermitted(const HTMLMediaElement&amp;) const
+{
+    if (m_restrictions &amp; RequireUserGestureForRateChange &amp;&amp; !ScriptController::processingUserGesture()) {
+        LOG(Media, &quot;HTMLMediaSession::playbackPermitted - returning FALSE&quot;);
+        return false;
+    }
+
+    return true;
+}
+
+bool HTMLMediaSession::dataLoadingPermitted(const HTMLMediaElement&amp;) const
+{
+    if (m_restrictions &amp; RequireUserGestureForLoad &amp;&amp; !ScriptController::processingUserGesture()) {
+        LOG(Media, &quot;HTMLMediaSession::dataLoadingPermitted - returning FALSE&quot;);
+        return false;
+    }
+
+    return true;
+}
+
+bool HTMLMediaSession::fullscreenPermitted(const HTMLMediaElement&amp;) const
+{
+    if (m_restrictions &amp; RequireUserGestureForFullscreen &amp;&amp; !ScriptController::processingUserGesture()) {
+        LOG(Media, &quot;HTMLMediaSession::fullscreenPermitted - returning FALSE&quot;);
+        return false;
+    }
+
+    return true;
+}
+
+bool HTMLMediaSession::pageAllowsDataLoading(const HTMLMediaElement&amp; element) const
+{
+    Page* page = element.document().page();
+    if (m_restrictions &amp; RequirePageConsentToLoadMedia &amp;&amp; page &amp;&amp; !page-&gt;canStartMedia()) {
+        LOG(Media, &quot;HTMLMediaSession::pageAllowsDataLoading - returning FALSE&quot;);
+        return false;
+    }
+    
+    return true;
+}
+
+bool HTMLMediaSession::pageAllowsPlaybackAfterResuming(const HTMLMediaElement&amp; element) const
+{
+    Page* page = element.document().page();
+    if (m_restrictions &amp; RequirePageConsentToResumeMedia &amp;&amp; page &amp;&amp; !page-&gt;canStartMedia()) {
+        LOG(Media, &quot;HTMLMediaSession::pageAllowsPlaybackAfterResuming - returning FALSE&quot;);
+        return false;
+    }
+    
+    return true;
+}
+
+#if ENABLE(IOS_AIRPLAY)
+bool HTMLMediaSession::showingPlaybackTargetPickerPermitted(const HTMLMediaElement&amp;) const
+{
+    if (m_restrictions &amp; RequireUserGestureToShowPlaybackTargetPicker &amp;&amp; !ScriptController::processingUserGesture()) {
+        LOG(Media, &quot;HTMLMediaSession::showingPlaybackTargetPickerPermitted - returning FALSE&quot;);
+        return false;
+    }
+    
+    return true;
+}
+#endif
+
+void HTMLMediaSession::clientWillBeginPlayback()
+{
+    MediaSessionManager::sharedManager().sessionWillBeginPlayback(*this);
+}
+
+void HTMLMediaSession::pauseSession()
+{
+    client().pausePlayback();
+}

+}
</ins></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaSessionh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/html/HTMLMediaSession.h (0 => 161899)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaSession.h                                (rev 0)
+++ trunk/Source/WebCore/html/HTMLMediaSession.h        2014-01-13 19:42:27 UTC (rev 161899)
</span><span class="lines">@@ -0,0 +1,78 @@
</span><ins>+/*
+ * Copyright (C) 2014 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.
+ */
+
+#ifndef HTMLMediaSession_h
+#define HTMLMediaSession_h
+
+#include &quot;MediaSession.h&quot;
+
+namespace WebCore {
+
+class HTMLMediaElement;
+
+class HTMLMediaSession : public MediaSession {
+public:
+    static std::unique_ptr&lt;HTMLMediaSession&gt; create(MediaSessionClient&amp;);
+
+    HTMLMediaSession(MediaSessionClient&amp;);
+    virtual ~HTMLMediaSession() { }
+
+    void clientWillBeginPlayback();
+
+    virtual void pauseSession() OVERRIDE;
+
+    bool playbackPermitted(const HTMLMediaElement&amp;) const;
+    bool dataLoadingPermitted(const HTMLMediaElement&amp;) const;
+    bool fullscreenPermitted(const HTMLMediaElement&amp;) const;
+    bool pageAllowsDataLoading(const HTMLMediaElement&amp;) const;
+    bool pageAllowsPlaybackAfterResuming(const HTMLMediaElement&amp;) const;
+#if ENABLE(IOS_AIRPLAY)
+    bool showingPlaybackTargetPickerPermitted(const HTMLMediaElement&amp;) const;
+#endif
+
+    // Restrictions to modify default behaviors.
+    enum BehaviorRestrictionFlags {
+        NoRestrictions = 0,
+        RequireUserGestureForLoad = 1 &lt;&lt; 0,
+        RequireUserGestureForRateChange = 1 &lt;&lt; 1,
+        RequireUserGestureForFullscreen = 1 &lt;&lt; 2,
+        RequirePageConsentToLoadMedia = 1 &lt;&lt; 3,
+        RequirePageConsentToResumeMedia = 1 &lt;&lt; 4,
+#if ENABLE(IOS_AIRPLAY)
+        RequireUserGestureToShowPlaybackTargetPicker = 1 &lt;&lt; 5,
+#endif
+    };
+    typedef unsigned BehaviorRestrictions;
+
+    void addBehaviorRestriction(BehaviorRestrictions);
+    void removeBehaviorRestriction(BehaviorRestrictions);
+
+private:
+    BehaviorRestrictions m_restrictions;
+};
+
+}
+
+#endif // MediaSession_h
</ins></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLVideoElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLVideoElement.cpp (161898 => 161899)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLVideoElement.cpp        2014-01-13 19:34:06 UTC (rev 161898)
+++ trunk/Source/WebCore/html/HTMLVideoElement.cpp        2014-01-13 19:42:27 UTC (rev 161899)
</span><span class="lines">@@ -289,7 +289,7 @@
</span><span class="cx"> 
</span><span class="cx">     // Generate an exception if this isn't called in response to a user gesture, or if the 
</span><span class="cx">     // element does not support fullscreen.
</span><del>-    if ((userGestureRequiredForFullscreen() &amp;&amp; !ScriptController::processingUserGesture()) || !supportsFullscreen()) {
</del><ins>+    if (!mediaSession().fullscreenPermitted(*this) || !supportsFullscreen()) {
</ins><span class="cx">         ec = INVALID_STATE_ERR;
</span><span class="cx">         return;
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudioMediaSessioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/MediaSession.cpp (161898 => 161899)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/MediaSession.cpp        2014-01-13 19:34:06 UTC (rev 161898)
+++ trunk/Source/WebCore/platform/audio/MediaSession.cpp        2014-01-13 19:42:27 UTC (rev 161899)
</span><span class="lines">@@ -29,8 +29,6 @@
</span><span class="cx"> #include &quot;HTMLMediaElement.h&quot;
</span><span class="cx"> #include &quot;Logging.h&quot;
</span><span class="cx"> #include &quot;MediaSessionManager.h&quot;
</span><del>-#include &quot;Page.h&quot;
-#include &quot;ScriptController.h&quot;
</del><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -55,14 +53,22 @@
</span><span class="cx"> 
</span><span class="cx"> void MediaSession::beginInterruption()
</span><span class="cx"> {
</span><ins>+    LOG(Media, &quot;MediaSession::beginInterruption&quot;);
</ins><span class="cx">     m_state = Interrupted;
</span><span class="cx">     m_client.beginInterruption();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MediaSession::endInterruption(EndInterruptionFlags flags)
</span><span class="cx"> {
</span><ins>+    LOG(Media, &quot;MediaSession::endInterruption&quot;);
</ins><span class="cx">     m_state = Running;
</span><span class="cx">     m_client.endInterruption(flags);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void MediaSession::pauseSession()
+{
+    LOG(Media, &quot;MediaSession::pauseSession&quot;);
+    m_client.pausePlayback();
</ins><span class="cx"> }
</span><ins>+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformaudioMediaSessionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/MediaSession.h (161898 => 161899)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/MediaSession.h        2014-01-13 19:34:06 UTC (rev 161898)
+++ trunk/Source/WebCore/platform/audio/MediaSession.h        2014-01-13 19:42:27 UTC (rev 161899)
</span><span class="lines">@@ -31,14 +31,13 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class MediaSessionClient;
</span><del>-class HTMLMediaElement;
</del><span class="cx"> 
</span><span class="cx"> class MediaSession {
</span><span class="cx"> public:
</span><span class="cx">     static std::unique_ptr&lt;MediaSession&gt; create(MediaSessionClient&amp;);
</span><span class="cx"> 
</span><span class="cx">     MediaSession(MediaSessionClient&amp;);
</span><del>-    ~MediaSession();
</del><ins>+    virtual ~MediaSession();
</ins><span class="cx"> 
</span><span class="cx">     enum MediaType {
</span><span class="cx">         None,
</span><span class="lines">@@ -63,6 +62,11 @@
</span><span class="cx">     void beginInterruption();
</span><span class="cx">     void endInterruption(EndInterruptionFlags);
</span><span class="cx"> 
</span><ins>+    virtual void pauseSession();
+
+protected:
+    MediaSessionClient&amp; client() const { return m_client; }
+
</ins><span class="cx"> private:
</span><span class="cx">     MediaSessionClient&amp; m_client;
</span><span class="cx">     MediaType m_type;
</span><span class="lines">@@ -78,7 +82,9 @@
</span><span class="cx">     
</span><span class="cx">     virtual void beginInterruption() { }
</span><span class="cx">     virtual void endInterruption(MediaSession::EndInterruptionFlags) { }
</span><del>-    
</del><ins>+
+    virtual void pausePlayback() = 0;
+
</ins><span class="cx"> protected:
</span><span class="cx">     virtual ~MediaSessionClient() { }
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudioMediaSessionManagercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/MediaSessionManager.cpp (161898 => 161899)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/MediaSessionManager.cpp        2014-01-13 19:34:06 UTC (rev 161898)
+++ trunk/Source/WebCore/platform/audio/MediaSessionManager.cpp        2014-01-13 19:42:27 UTC (rev 161899)
</span><span class="lines">@@ -30,15 +30,20 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+#if !PLATFORM(IOS)
</ins><span class="cx"> MediaSessionManager&amp; MediaSessionManager::sharedManager()
</span><span class="cx"> {
</span><span class="cx">     DEFINE_STATIC_LOCAL(MediaSessionManager, manager, ());
</span><span class="cx">     return manager;
</span><span class="cx"> }
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx"> MediaSessionManager::MediaSessionManager()
</span><span class="cx">     : m_interruptions(0)
</span><span class="cx"> {
</span><ins>+    m_restrictions[MediaSession::Video] = NoRestrictions;
+    m_restrictions[MediaSession::Audio] = NoRestrictions;
+    m_restrictions[MediaSession::WebAudio] = NoRestrictions;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool MediaSessionManager::has(MediaSession::MediaType type) const
</span><span class="lines">@@ -103,6 +108,40 @@
</span><span class="cx">     updateSessionState();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void MediaSessionManager::addRestriction(MediaSession::MediaType type, SessionRestrictions restriction)
+{
+    ASSERT(type &gt; MediaSession::None &amp;&amp; type &lt;= MediaSession::WebAudio);
+    m_restrictions[type] = m_restrictions[type] | restriction;
+}
+
+void MediaSessionManager::removeRestriction(MediaSession::MediaType type, SessionRestrictions restriction)
+{
+    ASSERT(type &gt; MediaSession::None &amp;&amp; type &lt;= MediaSession::WebAudio);
+    m_restrictions[type] = m_restrictions[type] &amp; ~restriction;
+}
+
+MediaSessionManager::SessionRestrictions MediaSessionManager::restrictions(MediaSession::MediaType sessionType)
+{
+    return m_restrictions[sessionType];
+}
+
+void MediaSessionManager::sessionWillBeginPlayback(MediaSession&amp; session)
+{
+    MediaSession::MediaType sessionType = session.mediaType();
+    SessionRestrictions restrictions = m_restrictions[sessionType];
+    if (restrictions == NoRestrictions)
+        return;
+
+    for (auto* oneSession : m_sessions) {
+        if (oneSession == &amp;session)
+            continue;
+        if (oneSession-&gt;mediaType() != sessionType)
+            continue;
+        if (restrictions &amp; ConcurrentPlaybackNotPermitted)
+            oneSession-&gt;pauseSession();
+    }
+}
+
</ins><span class="cx"> #if !PLATFORM(MAC)
</span><span class="cx"> void MediaSessionManager::updateSessionState()
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudioMediaSessionManagerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/MediaSessionManager.h (161898 => 161899)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/MediaSessionManager.h        2014-01-13 19:34:06 UTC (rev 161898)
+++ trunk/Source/WebCore/platform/audio/MediaSessionManager.h        2014-01-13 19:42:27 UTC (rev 161899)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;MediaSession.h&quot;
</span><span class="cx"> #include &quot;Settings.h&quot;
</span><ins>+#include &lt;map&gt;
</ins><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -45,16 +46,30 @@
</span><span class="cx">     void beginInterruption();
</span><span class="cx">     void endInterruption(MediaSession::EndInterruptionFlags);
</span><span class="cx"> 
</span><ins>+    enum SessionRestrictionFlags {
+        NoRestrictions = 0,
+        ConcurrentPlaybackNotPermitted = 1 &lt;&lt; 0,
+    };
+    typedef unsigned SessionRestrictions;
+    
+    void addRestriction(MediaSession::MediaType, SessionRestrictions);
+    void removeRestriction(MediaSession::MediaType, SessionRestrictions);
+    SessionRestrictions restrictions(MediaSession::MediaType);
+
+    void sessionWillBeginPlayback(MediaSession&amp;);
+
</ins><span class="cx"> protected:
</span><span class="cx">     friend class MediaSession;
</span><ins>+    explicit MediaSessionManager();
+
</ins><span class="cx">     void addSession(MediaSession&amp;);
</span><span class="cx">     void removeSession(MediaSession&amp;);
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    MediaSessionManager();
-
</del><span class="cx">     void updateSessionState();
</span><span class="cx"> 
</span><ins>+    std::map&lt;MediaSession::MediaType, SessionRestrictions&gt; m_restrictions;
+
</ins><span class="cx">     Vector&lt;MediaSession*&gt; m_sessions;
</span><span class="cx">     int m_interruptions;
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudioiosMediaSessionManagerIOSh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h (0 => 161899)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h                                (rev 0)
+++ trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h        2014-01-13 19:42:27 UTC (rev 161899)
</span><span class="lines">@@ -0,0 +1,53 @@
</span><ins>+/*
+ * Copyright (C) 2014 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.
+ */
+
+#ifndef MediaSessionManageriOS_h
+#define MediaSessionManageriOS_h
+
+#if PLATFORM(IOS)
+
+#include &quot;MediaSessionManager.h&quot;
+#include &lt;wtf/RetainPtr.h&gt;
+
+OBJC_CLASS WebMediaSessionHelper;
+
+namespace WebCore {
+
+class MediaSessionManageriOS : public MediaSessionManager {
+public:
+    virtual ~MediaSessionManageriOS() { }
+
+private:
+    friend class MediaSessionManager;
+
+    MediaSessionManageriOS();
+    RetainPtr&lt;WebMediaSessionHelper&gt; m_objcObserver;
+};
+
+} // namespace WebCore
+
+#endif // MediaSessionManageriOS_h
+
+#endif // PLATFORM(IOS)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformaudioiosMediaSessionManagerIOSmm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm (0 => 161899)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm                                (rev 0)
+++ trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm        2014-01-13 19:42:27 UTC (rev 161899)
</span><span class="lines">@@ -0,0 +1,126 @@
</span><ins>+/*
+ * Copyright (C) 2014 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 &quot;config.h&quot;
+#import &quot;MediaSessionManagerIOS.h&quot;
+
+#if PLATFORM(IOS)
+
+#import &quot;Logging.h&quot;
+#import &quot;MediaSession.h&quot;
+#import &quot;SoftLinking.h&quot;
+#import &quot;WebCoreThreadRun.h&quot;
+#import &lt;AVFoundation/AVAudioSession.h&gt;
+#import &lt;objc/runtime.h&gt;
+#import &lt;wtf/RetainPtr.h&gt;
+
+SOFT_LINK_FRAMEWORK(AVFoundation)
+
+SOFT_LINK_CLASS(AVFoundation, AVAudioSession)
+
+SOFT_LINK_POINTER(AVFoundation, AVAudioSessionInterruptionNotification, NSString *)
+SOFT_LINK_POINTER(AVFoundation, AVAudioSessionInterruptionTypeKey, NSString *)
+SOFT_LINK_POINTER(AVFoundation, AVAudioSessionInterruptionOptionKey, NSString *)
+
+#define AVAudioSession getAVAudioSessionClass()
+#define AVAudioSessionInterruptionNotification getAVAudioSessionInterruptionNotification()
+#define AVAudioSessionInterruptionTypeKey getAVAudioSessionInterruptionTypeKey()
+#define AVAudioSessionInterruptionOptionKey getAVAudioSessionInterruptionOptionKey()
+
+using namespace WebCore;
+
+@interface WebMediaSessionHelper : NSObject {
+    MediaSessionManageriOS* _callback;
+}
+
+- (id)initWithCallback:(MediaSessionManageriOS*)callback;
+- (void)interruption:(NSNotification*)notification;
+@end
+
+
+namespace WebCore {
+
+MediaSessionManager&amp; MediaSessionManager::sharedManager()
+{
+    DEFINE_STATIC_LOCAL(MediaSessionManageriOS, manager, ());
+    return manager;
+}
+
+MediaSessionManageriOS::MediaSessionManageriOS()
+    :MediaSessionManager()
+    , m_objcObserver(adoptNS([[WebMediaSessionHelper alloc] initWithCallback:this]))
+{
+    addRestriction(MediaSession::Video, ConcurrentPlaybackNotPermitted);
+}
+
+}
+
+@implementation WebMediaSessionHelper
+
+- (id)initWithCallback:(MediaSessionManageriOS*)callback
+{
+    if (!(self = [super init]))
+        return nil;
+    
+    _callback = callback;
+
+    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
+    [center addObserver:self selector:@selector(interruption:) name:AVAudioSessionInterruptionNotification object:[AVAudioSession sharedInstance]];
+    
+    return self;
+}
+
+- (void)dealloc
+{
+    [[NSNotificationCenter defaultCenter] removeObserver:self];
+    [super dealloc];
+}
+
+- (void)interruption:(NSNotification *)notification
+{
+    if (!_callback)
+        return;
+
+    NSUInteger type = [[[notification userInfo] objectForKey:AVAudioSessionInterruptionTypeKey] unsignedIntegerValue];
+    MediaSession::EndInterruptionFlags flags = MediaSession::NoFlags;
+
+    if (type == AVAudioSessionInterruptionTypeEnded &amp;&amp; [[[notification userInfo] objectForKey:AVAudioSessionInterruptionOptionKey] unsignedIntegerValue] == AVAudioSessionInterruptionOptionShouldResume)
+        flags = MediaSession::MayResumePlaying;
+
+    WebThreadRun(^{
+        if (!_callback)
+            return;
+
+        if (type == AVAudioSessionInterruptionTypeBegan)
+            _callback-&gt;beginInterruption();
+        else
+            _callback-&gt;endInterruption(flags);
+
+    });
+}
+
+@end
+
+#endif // PLATFORM(IOS)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformaudiomacAudioDestinationMach"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/mac/AudioDestinationMac.h (161898 => 161899)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/mac/AudioDestinationMac.h        2014-01-13 19:34:06 UTC (rev 161898)
+++ trunk/Source/WebCore/platform/audio/mac/AudioDestinationMac.h        2014-01-13 19:42:27 UTC (rev 161899)
</span><span class="lines">@@ -48,6 +48,7 @@
</span><span class="cx">     virtual void start() OVERRIDE;
</span><span class="cx">     virtual void stop() OVERRIDE;
</span><span class="cx">     virtual bool isPlaying() OVERRIDE { return m_isPlaying; }
</span><ins>+    virtual void pausePlayback() OVERRIDE { stop(); }
</ins><span class="cx"> 
</span><span class="cx">     virtual float sampleRate() const OVERRIDE { return m_sampleRate; }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.cpp (161898 => 161899)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.cpp        2014-01-13 19:34:06 UTC (rev 161898)
+++ trunk/Source/WebCore/testing/Internals.cpp        2014-01-13 19:42:27 UTC (rev 161899)
</span><span class="lines">@@ -2291,4 +2291,29 @@
</span><span class="cx">     MediaSessionManager::sharedManager().endInterruption(flags);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Internals::setMediaSessionRestrictions(const String&amp; mediaTypeString, const String&amp; restrictionsString, ExceptionCode&amp; ec)
+{
+    MediaSession::MediaType mediaType = MediaSession::None;
+    if (equalIgnoringCase(mediaTypeString, &quot;Video&quot;))
+        mediaType = MediaSession::Video;
+    else if (equalIgnoringCase(mediaTypeString, &quot;Audio&quot;))
+        mediaType = MediaSession::Audio;
+    else if (equalIgnoringCase(mediaTypeString, &quot;WebAudio&quot;))
+        mediaType = MediaSession::WebAudio;
+    else {
+        ec = INVALID_ACCESS_ERR;
+        return;
+    }
+
+    MediaSessionManager::SessionRestrictions restrictions = MediaSessionManager::sharedManager().restrictions(mediaType);
+    MediaSessionManager::sharedManager().removeRestriction(mediaType, restrictions);
+
+    restrictions = MediaSessionManager::NoRestrictions;
+    
+    if (equalIgnoringCase(restrictionsString, &quot;ConcurrentPlaybackNotPermitted&quot;))
+        restrictions = MediaSessionManager::ConcurrentPlaybackNotPermitted;
+    
+    MediaSessionManager::sharedManager().addRestriction(mediaType, restrictions);
</ins><span class="cx"> }
</span><ins>+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.h (161898 => 161899)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.h        2014-01-13 19:34:06 UTC (rev 161898)
+++ trunk/Source/WebCore/testing/Internals.h        2014-01-13 19:42:27 UTC (rev 161899)
</span><span class="lines">@@ -334,6 +334,7 @@
</span><span class="cx"> 
</span><span class="cx">     void beginMediaSessionInterruption();
</span><span class="cx">     void endMediaSessionInterruption(const String&amp;);
</span><ins>+    void setMediaSessionRestrictions(const String&amp; mediaType, const String&amp; restrictions, ExceptionCode&amp; ec);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     explicit Internals(Document*);
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.idl (161898 => 161899)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.idl        2014-01-13 19:34:06 UTC (rev 161898)
+++ trunk/Source/WebCore/testing/Internals.idl        2014-01-13 19:42:27 UTC (rev 161899)
</span><span class="lines">@@ -281,4 +281,5 @@
</span><span class="cx"> 
</span><span class="cx">     void beginMediaSessionInterruption();
</span><span class="cx">     void endMediaSessionInterruption(DOMString flags);
</span><ins>+    [RaisesException] void setMediaSessionRestrictions(DOMString mediaType, DOMString restrictions);
</ins><span class="cx"> };
</span></span></pre>
</div>
</div>

</body>
</html>