<!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>[187660] branches/safari-601.1-branch/Source</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/187660">187660</a></dd>
<dt>Author</dt> <dd>lforschler@apple.com</dd>
<dt>Date</dt> <dd>2015-07-31 11:08:28 -0700 (Fri, 31 Jul 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merged <a href="http://trac.webkit.org/projects/webkit/changeset/187522">r187522</a>.  rdar://problem/19892014</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari6011branchSourceWebCoreChangeLog">branches/safari-601.1-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari6011branchSourceWebCoreplatformaudioPlatformMediaSessioncpp">branches/safari-601.1-branch/Source/WebCore/platform/audio/PlatformMediaSession.cpp</a></li>
<li><a href="#branchessafari6011branchSourceWebCoreplatformaudioPlatformMediaSessionh">branches/safari-601.1-branch/Source/WebCore/platform/audio/PlatformMediaSession.h</a></li>
<li><a href="#branchessafari6011branchSourceWebCoreplatformaudioPlatformMediaSessionManagercpp">branches/safari-601.1-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp</a></li>
<li><a href="#branchessafari6011branchSourceWebCoreplatformaudioPlatformMediaSessionManagerh">branches/safari-601.1-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h</a></li>
<li><a href="#branchessafari6011branchSourceWebCoreplatformaudioiosMediaSessionManagerIOSh">branches/safari-601.1-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h</a></li>
<li><a href="#branchessafari6011branchSourceWebCoreplatformaudioiosMediaSessionManagerIOSmm">branches/safari-601.1-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm</a></li>
<li><a href="#branchessafari6011branchSourceWebKit2ChangeLog">branches/safari-601.1-branch/Source/WebKit2/ChangeLog</a></li>
<li><a href="#branchessafari6011branchSourceWebKit2PlatformspiiosUIKitSPIh">branches/safari-601.1-branch/Source/WebKit2/Platform/spi/ios/UIKitSPI.h</a></li>
<li><a href="#branchessafari6011branchSourceWebKit2UIProcessiosWebPageProxyIOSmm">branches/safari-601.1-branch/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm</a></li>
<li><a href="#branchessafari6011branchSourceWebKit2WebProcessWebPageWebPageh">branches/safari-601.1-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#branchessafari6011branchSourceWebKit2WebProcessWebPageWebPagemessagesin">branches/safari-601.1-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in</a></li>
<li><a href="#branchessafari6011branchSourceWebKit2WebProcessWebPageiosWebPageIOSmm">branches/safari-601.1-branch/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari6011branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1-branch/Source/WebCore/ChangeLog (187659 => 187660)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/Source/WebCore/ChangeLog        2015-07-31 18:07:06 UTC (rev 187659)
+++ branches/safari-601.1-branch/Source/WebCore/ChangeLog        2015-07-31 18:08:28 UTC (rev 187660)
</span><span class="lines">@@ -1,5 +1,51 @@
</span><span class="cx"> 2015-07-31  Lucas Forschler  &lt;lforschler@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r187522
+
+    2015-07-28  Said Abou-Hallawa  &lt;sabouhallawa@apple.com&gt;
+
+            [iOS] REGRESSION(r168075): Fullscreen web video doesn't pause on screen lock
+            https://bugs.webkit.org/show_bug.cgi?id=147269
+
+            Reviewed by Andreas Kling.
+
+            Media elements should pause when the application is going to EnterBackground
+            under lock regardless whether it is in full screen or not.
+
+            * platform/audio/PlatformMediaSession.h:
+            * platform/audio/PlatformMediaSession.cpp:
+            (WebCore::PlatformMediaSession::doInterruption): This code was moved from 
+            beginInterruption().
+
+            (WebCore::PlatformMediaSession::shouldDoInterruption): Move the condition 
+            which allows the media session interruption to a separate function.
+
+            (WebCore::PlatformMediaSession::beginInterruption): Call the functions
+            shouldDoInterruption() and doInterruption().
+
+            (WebCore::PlatformMediaSession::forceInterruption): This function will
+            be called from PlatformMediaSessionManager::applicationDidEnterBackground()
+            to override the decision which is made by PlatformMediaSession::beginInterruption()
+            if the application isSuspendedUnderLock.
+
+            * platform/audio/PlatformMediaSessionManager.h:
+            * platform/audio/PlatformMediaSessionManager.cpp:
+            (WebCore::PlatformMediaSessionManager::applicationDidEnterBackground):
+            [UIApp isSuspendedUnderLock] is only valid when it is called when the
+            UIApplicationDidEnterBackgroundNotification is received. We need to force
+            interrupting the media sessions if the application isSuspendedUnderLock
+            and UIApplicationWillResignActiveNotification was ignored because of PiP.
+
+            * platform/audio/ios/MediaSessionManagerIOS.h:
+            * platform/audio/ios/MediaSessionManagerIOS.mm:
+            (-[WebMediaSessionHelper initWithCallback:]):
+            (-[WebMediaSessionHelper applicationDidEnterBackground:]): Listen to 
+            UIApplicationDidEnterBackgroundNotification and make a call on the web
+            thread to PlatformMediaSessionManager::applicationDidEnterBackground() 
+            and pass the isSuspendedUnderLock flag which is queried on the UIProcess.
+
+2015-07-31  Lucas Forschler  &lt;lforschler@apple.com&gt;
+
</ins><span class="cx">         Merge r187521
</span><span class="cx"> 
</span><span class="cx">     2015-07-28  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari6011branchSourceWebCoreplatformaudioPlatformMediaSessioncpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1-branch/Source/WebCore/platform/audio/PlatformMediaSession.cpp (187659 => 187660)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/Source/WebCore/platform/audio/PlatformMediaSession.cpp        2015-07-31 18:07:06 UTC (rev 187659)
+++ branches/safari-601.1-branch/Source/WebCore/platform/audio/PlatformMediaSession.cpp        2015-07-31 18:08:28 UTC (rev 187660)
</span><span class="lines">@@ -79,13 +79,8 @@
</span><span class="cx">     m_state = state;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PlatformMediaSession::beginInterruption(InterruptionType type)
</del><ins>+void PlatformMediaSession::doInterruption()
</ins><span class="cx"> {
</span><del>-    LOG(Media, &quot;PlatformMediaSession::beginInterruption(%p), state = %s, interruption count = %i&quot;, this, stateName(m_state), m_interruptionCount);
-
-    if (++m_interruptionCount &gt; 1 || (type == EnteringBackground &amp;&amp; client().overrideBackgroundPlaybackRestriction()))
-        return;
-
</del><span class="cx">     m_stateToRestore = state();
</span><span class="cx">     m_notifyingClient = true;
</span><span class="cx">     setState(Interrupted);
</span><span class="lines">@@ -93,6 +88,40 @@
</span><span class="cx">     m_notifyingClient = false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool PlatformMediaSession::shouldDoInterruption(InterruptionType type)
+{
+    return type != EnteringBackground || !client().overrideBackgroundPlaybackRestriction();
+}
+
+void PlatformMediaSession::beginInterruption(InterruptionType type)
+{
+    LOG(Media, &quot;PlatformMediaSession::beginInterruption(%p), state = %s, interruption count = %i&quot;, this, stateName(m_state), m_interruptionCount);
+
+    if (++m_interruptionCount &gt; 1 || !shouldDoInterruption(type))
+        return;
+
+    doInterruption();
+}
+
+void PlatformMediaSession::forceInterruption(InterruptionType type)
+{
+    LOG(Media, &quot;PlatformMediaSession::forceInterruption(%p), state = %s, interruption count = %i&quot;, this, stateName(m_state), m_interruptionCount);
+
+    // beginInterruption() must have been called before calling this function.
+    if (!m_interruptionCount) {
+        ASSERT_NOT_REACHED();
+        return;
+    }
+
+    // The purpose of this function is to override the decision which was made by
+    // beginInterruption(). If it was decided to interrupt the media session there,
+    // then nothing should be done here.
+    if (shouldDoInterruption(type))
+        return;
+
+    doInterruption();
+}
+
</ins><span class="cx"> void PlatformMediaSession::endInterruption(EndInterruptionFlags flags)
</span><span class="cx"> {
</span><span class="cx">     LOG(Media, &quot;PlatformMediaSession::endInterruption(%p) - flags = %i, stateToRestore = %s, interruption count = %i&quot;, this, (int)flags, stateName(m_stateToRestore), m_interruptionCount);
</span></span></pre></div>
<a id="branchessafari6011branchSourceWebCoreplatformaudioPlatformMediaSessionh"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1-branch/Source/WebCore/platform/audio/PlatformMediaSession.h (187659 => 187660)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/Source/WebCore/platform/audio/PlatformMediaSession.h        2015-07-31 18:07:06 UTC (rev 187659)
+++ branches/safari-601.1-branch/Source/WebCore/platform/audio/PlatformMediaSession.h        2015-07-31 18:08:28 UTC (rev 187660)
</span><span class="lines">@@ -79,11 +79,16 @@
</span><span class="cx">         NoFlags = 0,
</span><span class="cx">         MayResumePlaying = 1 &lt;&lt; 0,
</span><span class="cx">     };
</span><ins>+
+    void doInterruption();
+    bool shouldDoInterruption(InterruptionType);
</ins><span class="cx">     void beginInterruption(InterruptionType);
</span><ins>+    void forceInterruption(InterruptionType);
</ins><span class="cx">     void endInterruption(EndInterruptionFlags);
</span><span class="cx"> 
</span><span class="cx">     void applicationWillEnterForeground() const;
</span><span class="cx">     void applicationWillEnterBackground() const;
</span><ins>+    void applicationDidEnterBackground(bool isSuspendedUnderLock) const;
</ins><span class="cx"> 
</span><span class="cx">     bool clientWillBeginPlayback();
</span><span class="cx">     bool clientWillPausePlayback();
</span></span></pre></div>
<a id="branchessafari6011branchSourceWebCoreplatformaudioPlatformMediaSessionManagercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp (187659 => 187660)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp        2015-07-31 18:07:06 UTC (rev 187659)
+++ branches/safari-601.1-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp        2015-07-31 18:08:28 UTC (rev 187660)
</span><span class="lines">@@ -283,6 +283,20 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void PlatformMediaSessionManager::applicationDidEnterBackground(bool isSuspendedUnderLock) const
+{
+    LOG(Media, &quot;PlatformMediaSessionManager::applicationDidEnterBackground&quot;);
+
+    if (!isSuspendedUnderLock)
+        return;
+
+    Vector&lt;PlatformMediaSession*&gt; sessions = m_sessions;
+    for (auto* session : sessions) {
+        if (m_restrictions[session-&gt;mediaType()] &amp; BackgroundProcessPlaybackRestricted)
+            session-&gt;forceInterruption(PlatformMediaSession::EnteringBackground);
+    }
+}
+
</ins><span class="cx"> void PlatformMediaSessionManager::applicationWillEnterForeground() const
</span><span class="cx"> {
</span><span class="cx">     LOG(Media, &quot;PlatformMediaSessionManager::applicationWillEnterForeground&quot;);
</span></span></pre></div>
<a id="branchessafari6011branchSourceWebCoreplatformaudioPlatformMediaSessionManagerh"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h (187659 => 187660)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h        2015-07-31 18:07:06 UTC (rev 187659)
+++ branches/safari-601.1-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h        2015-07-31 18:08:28 UTC (rev 187660)
</span><span class="lines">@@ -56,6 +56,7 @@
</span><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT void applicationWillEnterForeground() const;
</span><span class="cx">     WEBCORE_EXPORT void applicationWillEnterBackground() const;
</span><ins>+    WEBCORE_EXPORT void applicationDidEnterBackground(bool isSuspendedUnderLock) const;
</ins><span class="cx"> 
</span><span class="cx">     void stopAllMediaPlaybackForDocument(const Document*);
</span><span class="cx">     WEBCORE_EXPORT void stopAllMediaPlaybackForProcess();
</span></span></pre></div>
<a id="branchessafari6011branchSourceWebCoreplatformaudioiosMediaSessionManagerIOSh"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h (187659 => 187660)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h        2015-07-31 18:07:06 UTC (rev 187659)
+++ branches/safari-601.1-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h        2015-07-31 18:08:28 UTC (rev 187660)
</span><span class="lines">@@ -37,6 +37,7 @@
</span><span class="cx"> extern NSString* WebUIApplicationWillResignActiveNotification;
</span><span class="cx"> extern NSString* WebUIApplicationWillEnterForegroundNotification;
</span><span class="cx"> extern NSString* WebUIApplicationDidBecomeActiveNotification;
</span><ins>+extern NSString* WebUIApplicationDidEnterBackgroundNotification;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span></span></pre></div>
<a id="branchessafari6011branchSourceWebCoreplatformaudioiosMediaSessionManagerIOSmm"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm (187659 => 187660)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm        2015-07-31 18:07:06 UTC (rev 187659)
+++ branches/safari-601.1-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm        2015-07-31 18:08:28 UTC (rev 187660)
</span><span class="lines">@@ -61,11 +61,13 @@
</span><span class="cx"> SOFT_LINK_POINTER(UIKit, UIApplicationWillResignActiveNotification, NSString *)
</span><span class="cx"> SOFT_LINK_POINTER(UIKit, UIApplicationWillEnterForegroundNotification, NSString *)
</span><span class="cx"> SOFT_LINK_POINTER(UIKit, UIApplicationDidBecomeActiveNotification, NSString *)
</span><ins>+SOFT_LINK_POINTER(UIKit, UIApplicationDidEnterBackgroundNotification, NSString *)
</ins><span class="cx"> 
</span><span class="cx"> #define UIApplication getUIApplicationClass()
</span><span class="cx"> #define UIApplicationWillResignActiveNotification getUIApplicationWillResignActiveNotification()
</span><span class="cx"> #define UIApplicationWillEnterForegroundNotification getUIApplicationWillEnterForegroundNotification()
</span><span class="cx"> #define UIApplicationDidBecomeActiveNotification getUIApplicationDidBecomeActiveNotification()
</span><ins>+#define UIApplicationDidEnterBackgroundNotification getUIApplicationDidEnterBackgroundNotification()
</ins><span class="cx"> 
</span><span class="cx"> SOFT_LINK_FRAMEWORK(MediaPlayer)
</span><span class="cx"> SOFT_LINK_CLASS(MediaPlayer, MPAVRoutingController)
</span><span class="lines">@@ -87,6 +89,7 @@
</span><span class="cx"> WEBCORE_EXPORT NSString* WebUIApplicationWillResignActiveNotification = @&quot;WebUIApplicationWillResignActiveNotification&quot;;
</span><span class="cx"> WEBCORE_EXPORT NSString* WebUIApplicationWillEnterForegroundNotification = @&quot;WebUIApplicationWillEnterForegroundNotification&quot;;
</span><span class="cx"> WEBCORE_EXPORT NSString* WebUIApplicationDidBecomeActiveNotification = @&quot;WebUIApplicationDidBecomeActiveNotification&quot;;
</span><ins>+WEBCORE_EXPORT NSString* WebUIApplicationDidEnterBackgroundNotification = @&quot;WebUIApplicationDidEnterBackgroundNotification&quot;;
</ins><span class="cx"> 
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><span class="lines">@@ -103,6 +106,7 @@
</span><span class="cx"> - (void)interruption:(NSNotification *)notification;
</span><span class="cx"> - (void)applicationWillEnterForeground:(NSNotification *)notification;
</span><span class="cx"> - (void)applicationWillResignActive:(NSNotification *)notification;
</span><ins>+- (void)applicationDidEnterBackground:(NSNotification *)notification;
</ins><span class="cx"> - (BOOL)hasWirelessTargetsAvailable;
</span><span class="cx"> - (void)startMonitoringAirPlayRoutes;
</span><span class="cx"> - (void)stopMonitoringAirPlayRoutes;
</span><span class="lines">@@ -293,6 +297,8 @@
</span><span class="cx">     [center addObserver:self selector:@selector(applicationDidBecomeActive:) name:WebUIApplicationDidBecomeActiveNotification object:nil];
</span><span class="cx">     [center addObserver:self selector:@selector(applicationWillResignActive:) name:UIApplicationWillResignActiveNotification object:nil];
</span><span class="cx">     [center addObserver:self selector:@selector(applicationWillResignActive:) name:WebUIApplicationWillResignActiveNotification object:nil];
</span><ins>+    [center addObserver:self selector:@selector(applicationDidEnterBackground:) name:UIApplicationDidEnterBackgroundNotification object:nil];
+    [center addObserver:self selector:@selector(applicationDidEnterBackground:) name:WebUIApplicationDidEnterBackgroundNotification object:nil];
</ins><span class="cx"> 
</span><span class="cx">     [self allocateVolumeView];
</span><span class="cx"> 
</span><span class="lines">@@ -448,7 +454,7 @@
</span><span class="cx">     WebThreadRun(^{
</span><span class="cx">         if (!_callback)
</span><span class="cx">             return;
</span><del>-        
</del><ins>+
</ins><span class="cx">         _callback-&gt;applicationWillEnterBackground();
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="lines">@@ -469,6 +475,23 @@
</span><span class="cx">         _callback-&gt;externalOutputDeviceAvailableDidChange();
</span><span class="cx">     });
</span><span class="cx"> }
</span><ins>+
+- (void)applicationDidEnterBackground:(NSNotification *)notification
+{
+    if (!_callback)
+        return;
+
+    LOG(Media, &quot;-[WebMediaSessionHelper applicationDidEnterBackground]&quot;);
+
+    BOOL isSuspendedUnderLock = [[[notification userInfo] objectForKey:@&quot;isSuspendedUnderLock&quot;] boolValue];
+
+    WebThreadRun(^{
+        if (!_callback)
+            return;
+
+        _callback-&gt;applicationDidEnterBackground(isSuspendedUnderLock);
+    });
+}
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> #endif // PLATFORM(IOS)
</span></span></pre></div>
<a id="branchessafari6011branchSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1-branch/Source/WebKit2/ChangeLog (187659 => 187660)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/Source/WebKit2/ChangeLog        2015-07-31 18:07:06 UTC (rev 187659)
+++ branches/safari-601.1-branch/Source/WebKit2/ChangeLog        2015-07-31 18:08:28 UTC (rev 187660)
</span><span class="lines">@@ -1,5 +1,36 @@
</span><span class="cx"> 2015-07-31  Lucas Forschler  &lt;lforschler@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r187522
+
+    2015-07-28  Said Abou-Hallawa  &lt;sabouhallawa@apple.com&gt;
+
+            [iOS] REGRESSION(r168075): Fullscreen web video doesn't pause on screen lock
+            https://bugs.webkit.org/show_bug.cgi?id=147269
+
+            Reviewed by Andreas Kling.
+
+            Media elements should pause when the application is going to EnterBackground
+            under lock regardless whether it is in full screen or not.
+
+            * Platform/spi/ios/UIKitSPI.h: Forward declare [UIApplication isSuspendedUnderLock].
+
+            * UIProcess/ios/WebPageProxyIOS.mm:
+            (WebKit::WebPageProxy::applicationDidEnterBackground):
+            [UIApp isSuspendedUnderLock] can only be called in the UIProcess. We need
+            to call it here and pass it to the WebPage in the WebProcess as part of the
+            ApplicationDidEnterBackground message.
+
+            * WebProcess/WebPage/WebPage.h:
+            * WebProcess/WebPage/WebPage.messages.in: Add the new parameter:
+            'isSuspendedUnderLock' to the ApplicationDidEnterBackground message.
+
+            * WebProcess/WebPage/ios/WebPageIOS.mm:
+            (WebKit::WebPage::applicationDidEnterBackground): On iOS, the WebPage needs
+            to notify the MediaSessionManagerIOS that it received the message 
+            ApplicationDidEnterBackground.
+
+2015-07-31  Lucas Forschler  &lt;lforschler@apple.com&gt;
+
</ins><span class="cx">         Merge r187491
</span><span class="cx"> 
</span><span class="cx">     2015-07-28  Jer Noble  &lt;jer.noble@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari6011branchSourceWebKit2PlatformspiiosUIKitSPIh"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1-branch/Source/WebKit2/Platform/spi/ios/UIKitSPI.h (187659 => 187660)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/Source/WebKit2/Platform/spi/ios/UIKitSPI.h        2015-07-31 18:07:06 UTC (rev 187659)
+++ branches/safari-601.1-branch/Source/WebKit2/Platform/spi/ios/UIKitSPI.h        2015-07-31 18:08:28 UTC (rev 187660)
</span><span class="lines">@@ -96,6 +96,7 @@
</span><span class="cx"> - (UIInterfaceOrientation)interfaceOrientation;
</span><span class="cx"> - (void)_cancelAllTouches;
</span><span class="cx"> - (CGFloat)statusBarHeight;
</span><ins>+- (BOOL)isSuspendedUnderLock;
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> typedef NS_ENUM(NSInteger, UIDatePickerPrivateMode)  {
</span></span></pre></div>
<a id="branchessafari6011branchSourceWebKit2UIProcessiosWebPageProxyIOSmm"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1-branch/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm (187659 => 187660)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm        2015-07-31 18:07:06 UTC (rev 187659)
+++ branches/safari-601.1-branch/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm        2015-07-31 18:08:28 UTC (rev 187660)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> #import &quot;RemoteLayerTreeDrawingAreaProxy.h&quot;
</span><span class="cx"> #import &quot;RemoteLayerTreeDrawingAreaProxyMessages.h&quot;
</span><span class="cx"> #import &quot;RemoteLayerTreeTransaction.h&quot;
</span><ins>+#import &quot;UIKitSPI.h&quot;
</ins><span class="cx"> #import &quot;UserData.h&quot;
</span><span class="cx"> #import &quot;ViewUpdateDispatcherMessages.h&quot;
</span><span class="cx"> #import &quot;WKBrowsingContextControllerInternal.h&quot;
</span><span class="lines">@@ -594,7 +595,8 @@
</span><span class="cx"> 
</span><span class="cx"> void WebPageProxy::applicationDidEnterBackground()
</span><span class="cx"> {
</span><del>-    m_process-&gt;send(Messages::WebPage::ApplicationDidEnterBackground(), m_pageID);
</del><ins>+    bool isSuspendedUnderLock = [UIApp isSuspendedUnderLock];
+    m_process-&gt;send(Messages::WebPage::ApplicationDidEnterBackground(isSuspendedUnderLock), m_pageID);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPageProxy::applicationWillEnterForeground()
</span></span></pre></div>
<a id="branchessafari6011branchSourceWebKit2WebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h (187659 => 187660)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h        2015-07-31 18:07:06 UTC (rev 187659)
+++ branches/safari-601.1-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h        2015-07-31 18:08:28 UTC (rev 187660)
</span><span class="lines">@@ -799,7 +799,7 @@
</span><span class="cx">     bool scaleWasSetByUIProcess() const { return m_scaleWasSetByUIProcess; }
</span><span class="cx">     void willStartUserTriggeredZooming();
</span><span class="cx">     void applicationWillResignActive();
</span><del>-    void applicationDidEnterBackground();
</del><ins>+    void applicationDidEnterBackground(bool isSuspendedUnderLock);
</ins><span class="cx">     void applicationWillEnterForeground();
</span><span class="cx">     void applicationDidBecomeActive();
</span><span class="cx">     void zoomToRect(WebCore::FloatRect, double minimumScale, double maximumScale);
</span></span></pre></div>
<a id="branchessafari6011branchSourceWebKit2WebProcessWebPageWebPagemessagesin"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (187659 => 187660)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2015-07-31 18:07:06 UTC (rev 187659)
+++ branches/safari-601.1-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2015-07-31 18:08:28 UTC (rev 187660)
</span><span class="lines">@@ -88,7 +88,7 @@
</span><span class="cx">     SetAssistedNodeValueAsNumber(double value)
</span><span class="cx">     SetAssistedNodeSelectedIndex(uint32_t index, bool allowMultipleSelection)
</span><span class="cx">     ApplicationWillResignActive()
</span><del>-    ApplicationDidEnterBackground()
</del><ins>+    ApplicationDidEnterBackground(bool isSuspendedUnderLock)
</ins><span class="cx">     ApplicationWillEnterForeground()
</span><span class="cx">     ApplicationDidBecomeActive()
</span><span class="cx">     ContentSizeCategoryDidChange(String contentSizeCategory)
</span></span></pre></div>
<a id="branchessafari6011branchSourceWebKit2WebProcessWebPageiosWebPageIOSmm"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1-branch/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (187659 => 187660)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm        2015-07-31 18:07:06 UTC (rev 187659)
+++ branches/safari-601.1-branch/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm        2015-07-31 18:08:28 UTC (rev 187660)
</span><span class="lines">@@ -2809,8 +2809,10 @@
</span><span class="cx">     m_volatilityTimer.stop();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPage::applicationDidEnterBackground()
</del><ins>+void WebPage::applicationDidEnterBackground(bool isSuspendedUnderLock)
</ins><span class="cx"> {
</span><ins>+    [[NSNotificationCenter defaultCenter] postNotificationName:WebUIApplicationDidEnterBackgroundNotification object:nil userInfo:@{@&quot;isSuspendedUnderLock&quot;: [NSNumber numberWithBool:isSuspendedUnderLock]}];
+
</ins><span class="cx">     setLayerTreeStateIsFrozen(true);
</span><span class="cx">     if (markLayersVolatileImmediatelyIfPossible())
</span><span class="cx">         return;
</span></span></pre>
</div>
</div>

</body>
</html>