<!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>[206545] branches/safari-602-branch</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/206545">206545</a></dd>
<dt>Author</dt> <dd>bshafiei@apple.com</dd>
<dt>Date</dt> <dd>2016-09-28 13:48:35 -0700 (Wed, 28 Sep 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/206527">r206527</a>. rdar://problem/28499358</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari602branchSourceWebCoreChangeLog">branches/safari-602-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari602branchSourceWebCorehtmlMediaElementSessioncpp">branches/safari-602-branch/Source/WebCore/html/MediaElementSession.cpp</a></li>
<li><a href="#branchessafari602branchSourceWebCorepagePagecpp">branches/safari-602-branch/Source/WebCore/page/Page.cpp</a></li>
<li><a href="#branchessafari602branchSourceWebCoreplatformaudioPlatformMediaSessionManagerh">branches/safari-602-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h</a></li>
<li><a href="#branchessafari602branchSourceWebCoreplatformaudiomacMediaSessionManagerMach">branches/safari-602-branch/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.h</a></li>
<li><a href="#branchessafari602branchSourceWebCoreplatformaudiomacMediaSessionManagerMacmm">branches/safari-602-branch/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.mm</a></li>
<li><a href="#branchessafari602branchSourceWebCoreplatformmacMediaRemoteSoftLinkcpp">branches/safari-602-branch/Source/WebCore/platform/mac/MediaRemoteSoftLink.cpp</a></li>
<li><a href="#branchessafari602branchSourceWebCoreplatformmacMediaRemoteSoftLinkh">branches/safari-602-branch/Source/WebCore/platform/mac/MediaRemoteSoftLink.h</a></li>
<li><a href="#branchessafari602branchSourceWebCoreplatformspimacMediaRemoteSPIh">branches/safari-602-branch/Source/WebCore/platform/spi/mac/MediaRemoteSPI.h</a></li>
<li><a href="#branchessafari602branchSourceWebKit2ChangeLog">branches/safari-602-branch/Source/WebKit2/ChangeLog</a></li>
<li><a href="#branchessafari602branchSourceWebKit2UIProcessAPICocoaWKWebViewmm">branches/safari-602-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#branchessafari602branchSourceWebKit2UIProcessAPICocoaWKWebViewPrivateh">branches/safari-602-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h</a></li>
<li><a href="#branchessafari602branchSourceWebKit2UIProcessPageClienth">branches/safari-602-branch/Source/WebKit2/UIProcess/PageClient.h</a></li>
<li><a href="#branchessafari602branchSourceWebKit2UIProcessWebPageProxycpp">branches/safari-602-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#branchessafari602branchSourceWebKit2UIProcessWebPageProxyh">branches/safari-602-branch/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#branchessafari602branchSourceWebKit2UIProcessWebPageProxymessagesin">branches/safari-602-branch/Source/WebKit2/UIProcess/WebPageProxy.messages.in</a></li>
<li><a href="#branchessafari602branchSourceWebKit2UIProcessmacPageClientImplh">branches/safari-602-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.h</a></li>
<li><a href="#branchessafari602branchSourceWebKit2UIProcessmacPageClientImplmm">branches/safari-602-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.mm</a></li>
<li><a href="#branchessafari602branchSourceWebKit2WebProcessWebPageWebPageh">branches/safari-602-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#branchessafari602branchSourceWebKit2WebProcessWebPageWebPagemessagesin">branches/safari-602-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in</a></li>
<li><a href="#branchessafari602branchSourceWebKit2WebProcessWebPagemacWebPageMacmm">branches/safari-602-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm</a></li>
<li><a href="#branchessafari602branchToolsChangeLog">branches/safari-602-branch/Tools/ChangeLog</a></li>
<li><a href="#branchessafari602branchToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">branches/safari-602-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
<li><a href="#branchessafari602branchToolsTestWebKitAPImacTestWKWebViewMacmm">branches/safari-602-branch/Tools/TestWebKitAPI/mac/TestWKWebViewMac.mm</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari602branchToolsTestWebKitAPITestsWebKit2CocoaNowPlayingControlsTestsmm">branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/NowPlayingControlsTests.mm</a></li>
<li><a href="#branchessafari602branchToolsTestWebKitAPITestsWebKit2Cocoalargevideotestnowplayinghtml">branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-test-now-playing.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari602branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/ChangeLog (206544 => 206545)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebCore/ChangeLog        2016-09-28 20:48:27 UTC (rev 206544)
+++ branches/safari-602-branch/Source/WebCore/ChangeLog        2016-09-28 20:48:35 UTC (rev 206545)
</span><span class="lines">@@ -1,5 +1,35 @@
</span><span class="cx"> 2016-09-28 Babak Shafiei <bshafiei@apple.com>
</span><span class="cx">
</span><ins>+ Merge r206527. rdar://problem/28499358
+
+ 2016-09-27 Wenson Hsieh <wenson_hsieh@apple.com>
+
+ Adopt MediaRemote SPI to achieve desired Now Playing behavior
+ https://bugs.webkit.org/show_bug.cgi?id=162658
+ <rdar://problem/28499358>
+
+ Reviewed by Jer Noble.
+
+ Restores the changes previously rolled out in r206444, and adopts new MediaRemote SPI to achieve the desired
+ behavior for media in background tabs without breaking other features.
+
+ Introduces 2 new unit tests in NowPlayingControlsTests.
+
+ * html/MediaElementSession.cpp:
+ (WebCore::MediaElementSession::pageAllowsNowPlayingControls):
+ * page/Page.cpp:
+ (WebCore::Page::setViewState):
+ * platform/audio/PlatformMediaSessionManager.h:
+ (WebCore::PlatformMediaSessionManager::hasActiveNowPlayingSession):
+ * platform/audio/mac/MediaSessionManagerMac.h:
+ * platform/audio/mac/MediaSessionManagerMac.mm:
+ (WebCore::MediaSessionManagerMac::updateNowPlayingInfo):
+ * platform/mac/MediaRemoteSoftLink.cpp:
+ * platform/mac/MediaRemoteSoftLink.h:
+ * platform/spi/mac/MediaRemoteSPI.h:
+
+2016-09-28 Babak Shafiei <bshafiei@apple.com>
+
</ins><span class="cx"> Merge r206520. rdar://problem/28412512
</span><span class="cx">
</span><span class="cx"> 2016-09-28 Jer Noble <jer.noble@apple.com>
</span></span></pre></div>
<a id="branchessafari602branchSourceWebCorehtmlMediaElementSessioncpp"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/html/MediaElementSession.cpp (206544 => 206545)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebCore/html/MediaElementSession.cpp        2016-09-28 20:48:27 UTC (rev 206544)
+++ branches/safari-602-branch/Source/WebCore/html/MediaElementSession.cpp        2016-09-28 20:48:35 UTC (rev 206545)
</span><span class="lines">@@ -735,8 +735,8 @@
</span><span class="cx">
</span><span class="cx"> bool MediaElementSession::pageAllowsNowPlayingControls() const
</span><span class="cx"> {
</span><del>- // FIXME: Ideally, we should not allow Now Playing controls for the active tab in the main window.
- return true;
</del><ins>+ auto page = m_element.document().page();
+ return page && !page->isVisibleAndActive();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> }
</span></span></pre></div>
<a id="branchessafari602branchSourceWebCorepagePagecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/page/Page.cpp (206544 => 206545)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebCore/page/Page.cpp        2016-09-28 20:48:27 UTC (rev 206544)
+++ branches/safari-602-branch/Source/WebCore/page/Page.cpp        2016-09-28 20:48:35 UTC (rev 206545)
</span><span class="lines">@@ -1450,6 +1450,7 @@
</span><span class="cx">
</span><span class="cx"> ViewState::Flags oldViewState = m_viewState;
</span><span class="cx">
</span><ins>+ bool wasVisibleAndActive = isVisibleAndActive();
</ins><span class="cx"> m_viewState = viewState;
</span><span class="cx">
</span><span class="cx"> m_focusController->setViewState(viewState);
</span><span class="lines">@@ -1466,6 +1467,9 @@
</span><span class="cx">
</span><span class="cx"> for (auto* observer : m_viewStateChangeObservers)
</span><span class="cx"> observer->viewStateDidChange(oldViewState, m_viewState);
</span><ins>+
+ if (wasVisibleAndActive != isVisibleAndActive())
+ PlatformMediaSessionManager::updateNowPlayingInfoIfNecessary();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool Page::isVisibleAndActive() const
</span></span></pre></div>
<a id="branchessafari602branchSourceWebCoreplatformaudioPlatformMediaSessionManagerh"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h (206544 => 206545)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h        2016-09-28 20:48:27 UTC (rev 206544)
+++ branches/safari-602-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h        2016-09-28 20:48:35 UTC (rev 206545)
</span><span class="lines">@@ -57,6 +57,8 @@
</span><span class="cx"> bool activeAudioSessionRequired() const;
</span><span class="cx"> bool canProduceAudio() const;
</span><span class="cx">
</span><ins>+ WEBCORE_EXPORT virtual bool hasActiveNowPlayingSession() const { return false; }
+
</ins><span class="cx"> bool willIgnoreSystemInterruptions() const { return m_willIgnoreSystemInterruptions; }
</span><span class="cx"> void setWillIgnoreSystemInterruptions(bool ignore) { m_willIgnoreSystemInterruptions = ignore; }
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari602branchSourceWebCoreplatformaudiomacMediaSessionManagerMach"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.h (206544 => 206545)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.h        2016-09-28 20:48:27 UTC (rev 206544)
+++ branches/safari-602-branch/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.h        2016-09-28 20:48:35 UTC (rev 206545)
</span><span class="lines">@@ -37,6 +37,8 @@
</span><span class="cx"> public:
</span><span class="cx"> virtual ~MediaSessionManagerMac();
</span><span class="cx">
</span><ins>+ bool hasActiveNowPlayingSession() const override { return m_nowPlayingActive; }
+
</ins><span class="cx"> private:
</span><span class="cx"> friend class PlatformMediaSessionManager;
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari602branchSourceWebCoreplatformaudiomacMediaSessionManagerMacmm"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.mm (206544 => 206545)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.mm        2016-09-28 20:48:27 UTC (rev 206544)
+++ branches/safari-602-branch/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.mm        2016-09-28 20:48:35 UTC (rev 206545)
</span><span class="lines">@@ -130,7 +130,7 @@
</span><span class="cx">
</span><span class="cx"> if (!currentSession) {
</span><span class="cx"> if (m_nowPlayingActive) {
</span><del>- MRMediaRemoteSetCanBeNowPlayingApplication(false);
</del><ins>+ MRMediaRemoteSetNowPlayingVisibility(MRMediaRemoteGetLocalOrigin(), MRNowPlayingClientVisibilityNeverVisible);
</ins><span class="cx"> LOG(Media, "MediaSessionManagerMac::updateNowPlayingInfo - clearing now playing info");
</span><span class="cx"> MRMediaRemoteSetNowPlayingInfo(nullptr);
</span><span class="cx"> m_nowPlayingActive = false;
</span><span class="lines">@@ -146,11 +146,13 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (!MRMediaRemoteSetCanBeNowPlayingApplication(true)) {
- LOG(Media, "MediaSessionManagerMac::updateNowPlayingInfo - MRMediaRemoteSetCanBeNowPlayingApplication(true) failed");
- return;
- }
</del><ins>+ static dispatch_once_t enableNowPlayingToken;
+ dispatch_once(&enableNowPlayingToken, ^() {
+ MRMediaRemoteSetCanBeNowPlayingApplication(true);
+ });
</ins><span class="cx">
</span><ins>+ MRMediaRemoteSetNowPlayingVisibility(MRMediaRemoteGetLocalOrigin(), MRNowPlayingClientVisibilityAlwaysVisible);
+
</ins><span class="cx"> String title = currentSession->title();
</span><span class="cx"> double duration = currentSession->duration();
</span><span class="cx"> double rate = currentSession->state() == PlatformMediaSession::Playing ? 1 : 0;
</span></span></pre></div>
<a id="branchessafari602branchSourceWebCoreplatformmacMediaRemoteSoftLinkcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/platform/mac/MediaRemoteSoftLink.cpp (206544 => 206545)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebCore/platform/mac/MediaRemoteSoftLink.cpp        2016-09-28 20:48:27 UTC (rev 206544)
+++ branches/safari-602-branch/Source/WebCore/platform/mac/MediaRemoteSoftLink.cpp        2016-09-28 20:48:35 UTC (rev 206545)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, MediaRemote, MRMediaRemoteAddAsyncCommandHandlerBlock, void*, (MRMediaRemoteAsyncCommandHandlerBlock block), (block))
</span><span class="cx"> SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, MediaRemote, MRMediaRemoteRemoveCommandHandlerBlock, void, (void* observer), (observer))
</span><span class="cx"> SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, MediaRemote, MRMediaRemoteSetSupportedCommands, void, (CFArrayRef commands, MROriginRef origin, dispatch_queue_t replyQ, void(^completion)(MRMediaRemoteError err)), (commands, origin, replyQ, completion))
</span><ins>+SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, MediaRemote, MRMediaRemoteSetNowPlayingVisibility, void, (MROriginRef origin, MRNowPlayingClientVisibility visibility), (origin, visibility))
</ins><span class="cx"> SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, MediaRemote, MRMediaRemoteCommandInfoCreate, MRMediaRemoteCommandInfoRef, (CFAllocatorRef allocator), (allocator));
</span><span class="cx"> SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, MediaRemote, MRMediaRemoteCommandInfoSetCommand, void, (MRMediaRemoteCommandInfoRef commandInfo, MRMediaRemoteCommand command), (commandInfo, command))
</span><span class="cx"> SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, MediaRemote, MRMediaRemoteCommandInfoSetEnabled, void, (MRMediaRemoteCommandInfoRef commandInfo, Boolean enabled), (commandInfo, enabled))
</span></span></pre></div>
<a id="branchessafari602branchSourceWebCoreplatformmacMediaRemoteSoftLinkh"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/platform/mac/MediaRemoteSoftLink.h (206544 => 206545)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebCore/platform/mac/MediaRemoteSoftLink.h        2016-09-28 20:48:27 UTC (rev 206544)
+++ branches/safari-602-branch/Source/WebCore/platform/mac/MediaRemoteSoftLink.h        2016-09-28 20:48:35 UTC (rev 206545)
</span><span class="lines">@@ -39,6 +39,8 @@
</span><span class="cx"> #define MRMediaRemoteRemoveCommandHandlerBlock softLink_MediaRemote_MRMediaRemoteRemoveCommandHandlerBlock
</span><span class="cx"> SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, MediaRemote, MRMediaRemoteSetSupportedCommands, void, (CFArrayRef commands, MROriginRef origin, dispatch_queue_t replyQ, void(^completion)(MRMediaRemoteError err)), (commands, origin, replyQ, completion))
</span><span class="cx"> #define MRMediaRemoteSetSupportedCommands softLink_MediaRemote_MRMediaRemoteSetSupportedCommands
</span><ins>+SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, MediaRemote, MRMediaRemoteSetNowPlayingVisibility, void, (MROriginRef origin, MRNowPlayingClientVisibility visibility), (origin, visibility))
+#define MRMediaRemoteSetNowPlayingVisibility softLink_MediaRemote_MRMediaRemoteSetNowPlayingVisibility
</ins><span class="cx"> SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, MediaRemote, MRMediaRemoteCommandInfoCreate, MRMediaRemoteCommandInfoRef, (CFAllocatorRef allocator), (allocator));
</span><span class="cx"> #define MRMediaRemoteCommandInfoCreate softLink_MediaRemote_MRMediaRemoteCommandInfoCreate
</span><span class="cx"> SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, MediaRemote, MRMediaRemoteCommandInfoSetCommand, void, (MRMediaRemoteCommandInfoRef commandInfo, MRMediaRemoteCommand command), (commandInfo, command))
</span></span></pre></div>
<a id="branchessafari602branchSourceWebCoreplatformspimacMediaRemoteSPIh"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebCore/platform/spi/mac/MediaRemoteSPI.h (206544 => 206545)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebCore/platform/spi/mac/MediaRemoteSPI.h        2016-09-28 20:48:27 UTC (rev 206544)
+++ branches/safari-602-branch/Source/WebCore/platform/spi/mac/MediaRemoteSPI.h        2016-09-28 20:48:35 UTC (rev 206545)
</span><span class="lines">@@ -27,6 +27,22 @@
</span><span class="cx">
</span><span class="cx"> #if USE(MEDIAREMOTE)
</span><span class="cx">
</span><ins>+#if __has_include(<MediaRemote/MRNowPlayingTypes.h>)
+
+#include <MediaRemote/MRNowPlayingTypes.h>
+
+#else
+
+enum {
+ MRNowPlayingClientVisibilityUndefined = 0,
+ MRNowPlayingClientVisibilityAlwaysVisible,
+ MRNowPlayingClientVisibilityVisibleWhenBackgrounded,
+ MRNowPlayingClientVisibilityNeverVisible
+};
+typedef uint32_t MRNowPlayingClientVisibility;
+
+#endif
+
</ins><span class="cx"> #if USE(APPLE_INTERNAL_SDK)
</span><span class="cx">
</span><span class="cx"> #include <MediaRemote/MediaRemote.h>
</span><span class="lines">@@ -87,6 +103,7 @@
</span><span class="cx"> void* MRMediaRemoteAddAsyncCommandHandlerBlock(MRMediaRemoteAsyncCommandHandlerBlock);
</span><span class="cx"> void MRMediaRemoteRemoveCommandHandlerBlock(void *observer);
</span><span class="cx"> void MRMediaRemoteSetSupportedCommands(CFArrayRef commands, MROriginRef, dispatch_queue_t replyQ, void(^completion)(MRMediaRemoteError err));
</span><ins>+void MRMediaRemoteSetNowPlayingVisibility(MROriginRef, MRNowPlayingClientVisibility);
</ins><span class="cx">
</span><span class="cx"> #pragma mark - MROrigin
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/ChangeLog (206544 => 206545)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebKit2/ChangeLog        2016-09-28 20:48:27 UTC (rev 206544)
+++ branches/safari-602-branch/Source/WebKit2/ChangeLog        2016-09-28 20:48:35 UTC (rev 206545)
</span><span class="lines">@@ -1,5 +1,39 @@
</span><span class="cx"> 2016-09-28 Babak Shafiei <bshafiei@apple.com>
</span><span class="cx">
</span><ins>+ Merge r206527. rdar://problem/28499358
+
+ 2016-09-27 Wenson Hsieh <wenson_hsieh@apple.com>
+
+ Adopt MediaRemote SPI to achieve desired Now Playing behavior
+ https://bugs.webkit.org/show_bug.cgi?id=162658
+ <rdar://problem/28499358>
+
+ Reviewed by Jer Noble.
+
+ Plumbs Now Playing session information (for now, this is just a flag indicating whether or not there is an
+ active session) across from the web process to the UI process for testing in the form of asynchronous request/
+ handle-response messages on the WebPage and its proxy in the UI process.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _requestActiveNowPlayingSessionInfo]):
+ (-[WKWebView _handleActiveNowPlayingSessionInfoResponse:]):
+ * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+ * UIProcess/PageClient.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::requestActiveNowPlayingSessionInfo):
+ (WebKit::WebPageProxy::handleActiveNowPlayingSessionInfoResponse):
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebPageProxy.messages.in:
+ * UIProcess/mac/PageClientImpl.h:
+ * UIProcess/mac/PageClientImpl.mm:
+ (WebKit::PageClientImpl::handleActiveNowPlayingSessionInfoResponse):
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebPage.messages.in:
+ * WebProcess/WebPage/mac/WebPageMac.mm:
+ (WebKit::WebPage::requestActiveNowPlayingSessionInfo):
+
+2016-09-28 Babak Shafiei <bshafiei@apple.com>
+
</ins><span class="cx"> Merge r206135. rdar://problem/28499358
</span><span class="cx">
</span><span class="cx"> 2016-09-19 Wenson Hsieh <wenson_hsieh@apple.com>
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (206544 => 206545)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2016-09-28 20:48:27 UTC (rev 206544)
+++ branches/safari-602-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2016-09-28 20:48:35 UTC (rev 206545)
</span><span class="lines">@@ -4579,6 +4579,17 @@
</span><span class="cx"> {
</span><span class="cx"> return _impl->shouldRequestCandidates();
</span><span class="cx"> }
</span><ins>+
+- (void)_requestActiveNowPlayingSessionInfo
+{
+ if (_page)
+ _page->requestActiveNowPlayingSessionInfo();
+}
+
+- (void)_handleActiveNowPlayingSessionInfoResponse:(BOOL)hasActiveSession
+{
+ // Overridden by subclasses.
+}
</ins><span class="cx"> #endif // PLATFORM(MAC)
</span><span class="cx">
</span><span class="cx"> // Execute the supplied block after the next transaction from the WebProcess.
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2UIProcessAPICocoaWKWebViewPrivateh"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (206544 => 206545)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h        2016-09-28 20:48:27 UTC (rev 206544)
+++ branches/safari-602-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h        2016-09-28 20:48:35 UTC (rev 206545)
</span><span class="lines">@@ -275,6 +275,8 @@
</span><span class="cx"> - (void)_forceRequestCandidates WK_API_AVAILABLE(macosx(WK_MAC_TBA));
</span><span class="cx"> - (void)_didUpdateCandidateListVisibility:(BOOL)visible WK_API_AVAILABLE(macosx(WK_MAC_TBA));
</span><span class="cx"> @property (nonatomic, readonly) BOOL _shouldRequestCandidates WK_API_AVAILABLE(macosx(WK_MAC_TBA));
</span><ins>+- (void)_requestActiveNowPlayingSessionInfo WK_API_AVAILABLE(macosx(WK_MAC_TBA));
+- (void)_handleActiveNowPlayingSessionInfoResponse:(BOOL)hasActiveSession WK_API_AVAILABLE(macosx(WK_MAC_TBA));
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> - (void)_doAfterNextPresentationUpdate:(void (^)(void))updateBlock WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2UIProcessPageClienth"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/UIProcess/PageClient.h (206544 => 206545)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebKit2/UIProcess/PageClient.h        2016-09-28 20:48:27 UTC (rev 206544)
+++ branches/safari-602-branch/Source/WebKit2/UIProcess/PageClient.h        2016-09-28 20:48:35 UTC (rev 206545)
</span><span class="lines">@@ -249,6 +249,7 @@
</span><span class="cx"> virtual void recommendedScrollbarStyleDidChange(WebCore::ScrollbarStyle) = 0;
</span><span class="cx"> virtual void removeNavigationGestureSnapshot() = 0;
</span><span class="cx"> virtual void handleControlledElementIDResponse(const String&) = 0;
</span><ins>+ virtual void handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession) = 0;
</ins><span class="cx">
</span><span class="cx"> virtual CGRect boundsOfLayerInLayerBackedWindowCoordinates(CALayer *) const = 0;
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp (206544 => 206545)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp        2016-09-28 20:48:27 UTC (rev 206544)
+++ branches/safari-602-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp        2016-09-28 20:48:35 UTC (rev 206545)
</span><span class="lines">@@ -6304,6 +6304,16 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebPageProxy::requestActiveNowPlayingSessionInfo()
+{
+ m_process->send(Messages::WebPage::RequestActiveNowPlayingSessionInfo(), m_pageID);
+}
+
+void WebPageProxy::handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession) const
+{
+ m_pageClient.handleActiveNowPlayingSessionInfoResponse(hasActiveSession);
+}
+
</ins><span class="cx"> void WebPageProxy::handleControlledElementIDResponse(const String& identifier) const
</span><span class="cx"> {
</span><span class="cx"> m_pageClient.handleControlledElementIDResponse(identifier);
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/UIProcess/WebPageProxy.h (206544 => 206545)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebKit2/UIProcess/WebPageProxy.h        2016-09-28 20:48:27 UTC (rev 206544)
+++ branches/safari-602-branch/Source/WebKit2/UIProcess/WebPageProxy.h        2016-09-28 20:48:35 UTC (rev 206545)
</span><span class="lines">@@ -1034,6 +1034,8 @@
</span><span class="cx"> bool hasActiveVideoForControlsManager() const;
</span><span class="cx"> void requestControlledElementID() const;
</span><span class="cx"> void handleControlledElementIDResponse(const String&) const;
</span><ins>+ void requestActiveNowPlayingSessionInfo();
+ void handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession) const;
</ins><span class="cx"> bool isPlayingVideoInEnhancedFullscreen() const;
</span><span class="cx"> #endif
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2UIProcessWebPageProxymessagesin"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/UIProcess/WebPageProxy.messages.in (206544 => 206545)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2016-09-28 20:48:27 UTC (rev 206544)
+++ branches/safari-602-branch/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2016-09-28 20:48:35 UTC (rev 206545)
</span><span class="lines">@@ -462,5 +462,6 @@
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx"> DidHandleAcceptedCandidate()
</span><ins>+ HandleActiveNowPlayingSessionInfoResponse(bool hasActiveSession)
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2UIProcessmacPageClientImplh"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.h (206544 => 206545)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.h        2016-09-28 20:48:27 UTC (rev 206544)
+++ branches/safari-602-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.h        2016-09-28 20:48:35 UTC (rev 206545)
</span><span class="lines">@@ -208,6 +208,7 @@
</span><span class="cx"> void didSameDocumentNavigationForMainFrame(SameDocumentNavigationType) override;
</span><span class="cx"> void removeNavigationGestureSnapshot() override;
</span><span class="cx"> void handleControlledElementIDResponse(const String&) override;
</span><ins>+ void handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession) override;
</ins><span class="cx">
</span><span class="cx"> void didPerformImmediateActionHitTest(const WebHitTestResultData&, bool contentPreventsDefault, API::Object*) override;
</span><span class="cx"> void* immediateActionAnimationControllerForHitTestResult(RefPtr<API::HitTestResult>, uint64_t, RefPtr<API::Object>) override;
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2UIProcessmacPageClientImplmm"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.mm (206544 => 206545)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.mm        2016-09-28 20:48:27 UTC (rev 206544)
+++ branches/safari-602-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.mm        2016-09-28 20:48:35 UTC (rev 206545)
</span><span class="lines">@@ -763,6 +763,13 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void PageClientImpl::handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession)
+{
+#if WK_API_ENABLED
+ [m_webView _handleActiveNowPlayingSessionInfoResponse:hasActiveSession];
+#endif
+}
+
</ins><span class="cx"> void PageClientImpl::didChangeBackgroundColor()
</span><span class="cx"> {
</span><span class="cx"> notImplemented();
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2WebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h (206544 => 206545)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h        2016-09-28 20:48:27 UTC (rev 206544)
+++ branches/safari-602-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h        2016-09-28 20:48:35 UTC (rev 206545)
</span><span class="lines">@@ -1187,6 +1187,7 @@
</span><span class="cx"> void dataDetectorsDidHideUI(WebCore::PageOverlay::PageOverlayID);
</span><span class="cx">
</span><span class="cx"> void handleAcceptedCandidate(WebCore::TextCheckingResult);
</span><ins>+ void requestActiveNowPlayingSessionInfo();
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> void setShouldDispatchFakeMouseMoveEvents(bool dispatch) { m_shouldDispatchFakeMouseMoveEvents = dispatch; }
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2WebProcessWebPageWebPagemessagesin"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (206544 => 206545)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2016-09-28 20:48:27 UTC (rev 206544)
+++ branches/safari-602-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2016-09-28 20:48:35 UTC (rev 206545)
</span><span class="lines">@@ -413,6 +413,7 @@
</span><span class="cx"> DataDetectorsDidChangeUI(WebCore::PageOverlay::PageOverlayID pageOverlay)
</span><span class="cx"> DataDetectorsDidHideUI(WebCore::PageOverlay::PageOverlayID pageOverlay)
</span><span class="cx"> HandleAcceptedCandidate(struct WebCore::TextCheckingResult acceptedCandidate)
</span><ins>+ RequestActiveNowPlayingSessionInfo()
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> SetShouldDispatchFakeMouseMoveEvents(bool shouldDispatchFakeMouseMoveEvents)
</span></span></pre></div>
<a id="branchessafari602branchSourceWebKit2WebProcessWebPagemacWebPageMacmm"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (206544 => 206545)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2016-09-28 20:48:27 UTC (rev 206544)
+++ branches/safari-602-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2016-09-28 20:48:35 UTC (rev 206545)
</span><span class="lines">@@ -74,6 +74,7 @@
</span><span class="cx"> #import <WebCore/Page.h>
</span><span class="cx"> #import <WebCore/PageOverlayController.h>
</span><span class="cx"> #import <WebCore/PlatformKeyboardEvent.h>
</span><ins>+#import <WebCore/PlatformMediaSessionManager.h>
</ins><span class="cx"> #import <WebCore/PluginDocument.h>
</span><span class="cx"> #import <WebCore/RenderElement.h>
</span><span class="cx"> #import <WebCore/RenderObject.h>
</span><span class="lines">@@ -159,6 +160,15 @@
</span><span class="cx"> send(Messages::WebPageProxy::DidHandleAcceptedCandidate());
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebPage::requestActiveNowPlayingSessionInfo()
+{
+ bool hasActiveSession = false;
+ if (auto* sharedManager = WebCore::PlatformMediaSessionManager::sharedManagerIfExists())
+ hasActiveSession = sharedManager->hasActiveNowPlayingSession();
+
+ send(Messages::WebPageProxy::HandleActiveNowPlayingSessionInfoResponse(hasActiveSession));
+}
+
</ins><span class="cx"> NSObject *WebPage::accessibilityObjectForMainFramePlugin()
</span><span class="cx"> {
</span><span class="cx"> if (!m_page)
</span></span></pre></div>
<a id="branchessafari602branchToolsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Tools/ChangeLog (206544 => 206545)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Tools/ChangeLog        2016-09-28 20:48:27 UTC (rev 206544)
+++ branches/safari-602-branch/Tools/ChangeLog        2016-09-28 20:48:35 UTC (rev 206545)
</span><span class="lines">@@ -1,5 +1,32 @@
</span><span class="cx"> 2016-09-28 Babak Shafiei <bshafiei@apple.com>
</span><span class="cx">
</span><ins>+ Merge r206527. rdar://problem/28499358
+
+ 2016-09-27 Wenson Hsieh <wenson_hsieh@apple.com>
+
+ Adopt MediaRemote SPI to achieve desired Now Playing behavior
+ https://bugs.webkit.org/show_bug.cgi?id=162658
+ <rdar://problem/28499358>
+
+ Reviewed by Jer Noble.
+
+ Introduces 2 unit tests in the new NowPlayingControlsTests test suite. Also provides some basic support for
+ mocking key window status for TestWKWebViews.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKit2Cocoa/NowPlayingControlsTests.mm: Added.
+ (-[NowPlayingTestWebView hasActiveNowPlayingSession]):
+ (-[NowPlayingTestWebView expectHasActiveNowPlayingSession:]):
+ (-[NowPlayingTestWebView _handleActiveNowPlayingSessionInfoResponse:]):
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/Tests/WebKit2Cocoa/large-video-test-now-playing.html: Added.
+ * TestWebKitAPI/mac/TestWKWebViewMac.mm:
+ (-[TestWKWebViewHostWindow isKeyWindow]):
+ (-[TestWKWebViewHostWindow makeKeyWindow]):
+ (-[TestWKWebViewHostWindow resignKeyWindow]):
+
+2016-09-28 Babak Shafiei <bshafiei@apple.com>
+
</ins><span class="cx"> Merge r206335. rdar://problem/28499358
</span><span class="cx">
</span><span class="cx"> 2016-09-23 Wenson Hsieh <wenson_hsieh@apple.com>
</span></span></pre></div>
<a id="branchessafari602branchToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (206544 => 206545)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-09-28 20:48:27 UTC (rev 206544)
+++ branches/safari-602-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-09-28 20:48:35 UTC (rev 206545)
</span><span class="lines">@@ -73,6 +73,7 @@
</span><span class="cx">                 2E7765CD16C4D80A00BA2BB1 /* mainIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E7765CC16C4D80A00BA2BB1 /* mainIOS.mm */; };
</span><span class="cx">                 2E7765CF16C4D81100BA2BB1 /* mainMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E7765CE16C4D81100BA2BB1 /* mainMac.mm */; };
</span><span class="cx">                 2E9896151D8F093800739892 /* text-and-password-inputs.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E9896141D8F092B00739892 /* text-and-password-inputs.html */; };
</span><ins>+                2ECFF5551D9B12F800B55394 /* NowPlayingControlsTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2ECFF5541D9B12F800B55394 /* NowPlayingControlsTests.mm */; };
</ins><span class="cx">                 2EFF06C31D88621E0004BB30 /* large-video-offscreen.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2EFF06C21D8862120004BB30 /* large-video-offscreen.html */; };
</span><span class="cx">                 2EFF06C51D8867760004BB30 /* change-video-source-on-click.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2EFF06C41D8867700004BB30 /* change-video-source-on-click.html */; };
</span><span class="cx">                 2EFF06C71D886A580004BB30 /* change-video-source-on-end.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2EFF06C61D886A560004BB30 /* change-video-source-on-end.html */; };
</span><span class="lines">@@ -453,6 +454,7 @@
</span><span class="cx">                 E1220DCA155B28AA0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E1220DC9155B287D0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html */; };
</span><span class="cx">                 E194E1BD177E53C7009C4D4E /* StopLoadingFromDidReceiveResponse.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E194E1BC177E534A009C4D4E /* StopLoadingFromDidReceiveResponse.html */; };
</span><span class="cx">                 F42DA5161D8CEFE400336F40 /* large-input-field-focus-onload.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F42DA5151D8CEFDB00336F40 /* large-input-field-focus-onload.html */; };
</span><ins>+                F4F137921D9B683E002BEC57 /* large-video-test-now-playing.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4F137911D9B6832002BEC57 /* large-video-test-now-playing.html */; };
</ins><span class="cx">                 F4F405BC1D4C0D1C007A9707 /* full-size-autoplaying-video-with-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4F405BA1D4C0CF8007A9707 /* full-size-autoplaying-video-with-audio.html */; };
</span><span class="cx">                 F4F405BD1D4C0D1C007A9707 /* skinny-autoplaying-video-with-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4F405BB1D4C0CF8007A9707 /* skinny-autoplaying-video-with-audio.html */; };
</span><span class="cx">                 F660AA1115A5F631003A1243 /* GetInjectedBundleInitializationUserDataCallback_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F660AA0F15A5F624003A1243 /* GetInjectedBundleInitializationUserDataCallback_Bundle.cpp */; };
</span><span class="lines">@@ -580,6 +582,7 @@
</span><span class="cx">                                 7AE9E5091AE5AE8B00CF874B /* test.pdf in Copy Resources */,
</span><span class="cx">                                 7A1458FC1AD5C07000E06772 /* mouse-button-listener.html in Copy Resources */,
</span><span class="cx">                                 7C486BA11AA12567003F6F9B /* bundle-file.html in Copy Resources */,
</span><ins>+                                F4F137921D9B683E002BEC57 /* large-video-test-now-playing.html in Copy Resources */,
</ins><span class="cx">                                 2E9896151D8F093800739892 /* text-and-password-inputs.html in Copy Resources */,
</span><span class="cx">                                 F42DA5161D8CEFE400336F40 /* large-input-field-focus-onload.html in Copy Resources */,
</span><span class="cx">                                 2EFF06CD1D8A429A0004BB30 /* input-field-in-scrollable-document.html in Copy Resources */,
</span><span class="lines">@@ -767,6 +770,7 @@
</span><span class="cx">                 2E7765CC16C4D80A00BA2BB1 /* mainIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = mainIOS.mm; sourceTree = "<group>"; };
</span><span class="cx">                 2E7765CE16C4D81100BA2BB1 /* mainMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = mainMac.mm; sourceTree = "<group>"; };
</span><span class="cx">                 2E9896141D8F092B00739892 /* text-and-password-inputs.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "text-and-password-inputs.html"; sourceTree = "<group>"; };
</span><ins>+                2ECFF5541D9B12F800B55394 /* NowPlayingControlsTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NowPlayingControlsTests.mm; sourceTree = "<group>"; };
</ins><span class="cx">                 2EFF06C21D8862120004BB30 /* large-video-offscreen.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-video-offscreen.html"; sourceTree = "<group>"; };
</span><span class="cx">                 2EFF06C41D8867700004BB30 /* change-video-source-on-click.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "change-video-source-on-click.html"; sourceTree = "<group>"; };
</span><span class="cx">                 2EFF06C61D886A560004BB30 /* change-video-source-on-end.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "change-video-source-on-end.html"; sourceTree = "<group>"; };
</span><span class="lines">@@ -1138,6 +1142,7 @@
</span><span class="cx">                 E4C9ABC71B3DB1710040A987 /* RunLoop.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RunLoop.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 F3FC3EE213678B7300126A65 /* libgtest.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libgtest.a; sourceTree = BUILT_PRODUCTS_DIR; };
</span><span class="cx">                 F42DA5151D8CEFDB00336F40 /* large-input-field-focus-onload.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = "large-input-field-focus-onload.html"; path = "Tests/WebKit2Cocoa/large-input-field-focus-onload.html"; sourceTree = SOURCE_ROOT; };
</span><ins>+                F4F137911D9B6832002BEC57 /* large-video-test-now-playing.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-video-test-now-playing.html"; sourceTree = "<group>"; };
</ins><span class="cx">                 F4F405BA1D4C0CF8007A9707 /* full-size-autoplaying-video-with-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "full-size-autoplaying-video-with-audio.html"; sourceTree = "<group>"; };
</span><span class="cx">                 F4F405BB1D4C0CF8007A9707 /* skinny-autoplaying-video-with-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "skinny-autoplaying-video-with-audio.html"; sourceTree = "<group>"; };
</span><span class="cx">                 F660AA0C15A5F061003A1243 /* GetInjectedBundleInitializationUserDataCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GetInjectedBundleInitializationUserDataCallback.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -1315,6 +1320,7 @@
</span><span class="cx">                                 46C519D81D355A7300DAA51A /* LocalStorageNullEntries.mm */,
</span><span class="cx">                                 51CD1C6A1B38CE3600142CA5 /* ModalAlerts.mm */,
</span><span class="cx">                                 1ABC3DED1899BE6D004F0626 /* Navigation.mm */,
</span><ins>+                                2ECFF5541D9B12F800B55394 /* NowPlayingControlsTests.mm */,
</ins><span class="cx">                                 CEA6CF2219CCF5BD0064F5A7 /* OpenAndCloseWindow.mm */,
</span><span class="cx">                                 C95501BE19AD2FAF0049BE3E /* Preferences.mm */,
</span><span class="cx">                                 5798E2AF1CAF5C2800C5CBA0 /* ProvisionalURLNotChange.mm */,
</span><span class="lines">@@ -1419,6 +1425,7 @@
</span><span class="cx">                                 2E1DFDF01D42E14400714A00 /* large-video-seek-to-beginning-and-play-after-ending.html */,
</span><span class="cx">                                 2E1B7B011D41B1B3007558B4 /* large-video-hides-controls-after-seek-to-end.html */,
</span><span class="cx">                                 2E1DFDEE1D42A6EB00714A00 /* large-videos-with-audio-autoplay.html */,
</span><ins>+                                F4F137911D9B6832002BEC57 /* large-video-test-now-playing.html */,
</ins><span class="cx">                                 2E9896141D8F092B00739892 /* text-and-password-inputs.html */,
</span><span class="cx">                                 2EFF06CC1D8A42910004BB30 /* input-field-in-scrollable-document.html */,
</span><span class="cx">                                 2EFF06C61D886A560004BB30 /* change-video-source-on-end.html */,
</span><span class="lines">@@ -2246,6 +2253,7 @@
</span><span class="cx">                                 37BCA61C1B596BA9002012CA /* ShouldOpenExternalURLsInNewWindowActions.mm in Sources */,
</span><span class="cx">                                 7C83E0411D0A63F200FEBCF3 /* CandidateTests.mm in Sources */,
</span><span class="cx">                                 7CEFA9661AC0B9E200B910FD /* _WKUserContentExtensionStore.mm in Sources */,
</span><ins>+                                2ECFF5551D9B12F800B55394 /* NowPlayingControlsTests.mm in Sources */,
</ins><span class="cx">                                 7CCE7EE01A411A9A00447C4C /* EditorCommands.mm in Sources */,
</span><span class="cx">                                 7CCE7EBF1A411A7E00447C4C /* ElementAtPointInWebFrame.mm in Sources */,
</span><span class="cx">                                 5E4B1D2E1D404C6100053621 /* WKScrollViewDelegateCrash.mm in Sources */,
</span></span></pre></div>
<a id="branchessafari602branchToolsTestWebKitAPITestsWebKit2CocoaNowPlayingControlsTestsmm"></a>
<div class="addfile"><h4>Added: branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/NowPlayingControlsTests.mm (0 => 206545)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/NowPlayingControlsTests.mm         (rev 0)
+++ branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/NowPlayingControlsTests.mm        2016-09-28 20:48:35 UTC (rev 206545)
</span><span class="lines">@@ -0,0 +1,99 @@
</span><ins>+/*
+ * Copyright (C) 2016 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 "config.h"
+
+#import "PlatformUtilities.h"
+#import "TestWKWebViewMac.h"
+
+#import <WebKit/WKWebViewConfigurationPrivate.h>
+#import <WebKit/WKWebViewPrivate.h>
+
+#if WK_API_ENABLED && PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101201
+
+@interface NowPlayingTestWebView : TestWKWebView
+@property (nonatomic, readonly) BOOL hasActiveNowPlayingSession;
+@end
+
+@implementation NowPlayingTestWebView {
+ bool _receivedNowPlayingInfoResponse;
+ BOOL _hasActiveNowPlayingSession;
+}
+- (BOOL)hasActiveNowPlayingSession
+{
+ _receivedNowPlayingInfoResponse = false;
+ [self _requestActiveNowPlayingSessionInfo];
+ TestWebKitAPI::Util::run(&_receivedNowPlayingInfoResponse);
+
+ return _hasActiveNowPlayingSession;
+}
+
+- (void)expectHasActiveNowPlayingSession:(BOOL)hasActiveNowPlayingSession
+{
+ bool finishedWaiting = false;
+ while (!finishedWaiting) {
+ [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantPast]];
+ finishedWaiting = self.hasActiveNowPlayingSession == hasActiveNowPlayingSession;
+ }
+}
+
+- (void)_handleActiveNowPlayingSessionInfoResponse:(BOOL)hasActiveSession
+{
+ _hasActiveNowPlayingSession = hasActiveSession;
+ _receivedNowPlayingInfoResponse = true;
+}
+@end
+
+namespace TestWebKitAPI {
+
+TEST(NowPlayingControlsTests, NowPlayingControlsDoNotShowForForegroundPage)
+{
+ WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
+ configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
+ NowPlayingTestWebView *webView = [[NowPlayingTestWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration];
+ [webView loadTestPageNamed:@"large-video-test-now-playing"];
+ [webView waitForMessage:@"playing"];
+
+ [webView.window setIsVisible:YES];
+ [webView.window makeKeyWindow];
+ [webView expectHasActiveNowPlayingSession:NO];
+}
+
+TEST(NowPlayingControlsTests, NowPlayingControlsShowForBackgroundPage)
+{
+ WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
+ configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
+ NowPlayingTestWebView *webView = [[NowPlayingTestWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration];
+ [webView loadTestPageNamed:@"large-video-test-now-playing"];
+ [webView waitForMessage:@"playing"];
+
+ [webView.window setIsVisible:NO];
+ [webView.window resignKeyWindow];
+ [webView expectHasActiveNowPlayingSession:YES];
+}
+
+} // namespace TestWebKitAPI
+
+#endif // WK_API_ENABLED && PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101201
</ins></span></pre></div>
<a id="branchessafari602branchToolsTestWebKitAPITestsWebKit2Cocoalargevideotestnowplayinghtml"></a>
<div class="addfile"><h4>Added: branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-test-now-playing.html (0 => 206545)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-test-now-playing.html         (rev 0)
+++ branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-test-now-playing.html        2016-09-28 20:48:35 UTC (rev 206545)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+ <style>
+ video {
+ width: 480px;
+ height: 320px;
+ position: absolute;
+ }
+ </style>
+ <script>
+ function playing() {
+ setTimeout(function() {
+ try {
+ window.webkit.messageHandlers.testHandler.postMessage("playing");
+ } catch(e) {
+ }
+ }, 0);
+ }
+ </script>
+</head>
+<body>
+ <video autoplay onplaying=playing()><source src="large-video-with-audio.mp4"></video>
+</body>
+<html>
</ins></span></pre></div>
<a id="branchessafari602branchToolsTestWebKitAPImacTestWKWebViewMacmm"></a>
<div class="modfile"><h4>Modified: branches/safari-602-branch/Tools/TestWebKitAPI/mac/TestWKWebViewMac.mm (206544 => 206545)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602-branch/Tools/TestWebKitAPI/mac/TestWKWebViewMac.mm        2016-09-28 20:48:27 UTC (rev 206544)
+++ branches/safari-602-branch/Tools/TestWebKitAPI/mac/TestWKWebViewMac.mm        2016-09-28 20:48:35 UTC (rev 206545)
</span><span class="lines">@@ -63,7 +63,9 @@
</span><span class="cx"> @interface TestWKWebViewHostWindow : NSWindow
</span><span class="cx"> @end
</span><span class="cx">
</span><del>-@implementation TestWKWebViewHostWindow
</del><ins>+@implementation TestWKWebViewHostWindow {
+ BOOL _forceKeyWindow;
+}
</ins><span class="cx">
</span><span class="cx"> static int gEventNumber = 1;
</span><span class="cx">
</span><span class="lines">@@ -110,6 +112,26 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+- (BOOL)isKeyWindow
+{
+ return _forceKeyWindow || [super isKeyWindow];
+}
+
+- (void)makeKeyWindow
+{
+ if (_forceKeyWindow)
+ return;
+
+ _forceKeyWindow = YES;
+ [[NSNotificationCenter defaultCenter] postNotificationName:NSWindowDidBecomeKeyNotification object:self];
+}
+
+- (void)resignKeyWindow
+{
+ _forceKeyWindow = NO;
+ [super resignKeyWindow];
+}
+
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> @implementation TestWKWebView {
</span></span></pre>
</div>
</div>
</body>
</html>