<!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>[206527] 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/206527">206527</a></dd>
<dt>Author</dt> <dd>wenson_hsieh@apple.com</dd>
<dt>Date</dt> <dd>2016-09-28 11:17:49 -0700 (Wed, 28 Sep 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>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.
Source/WebCore:
Restores the changes previously rolled out in <a href="http://trac.webkit.org/projects/webkit/changeset/206444">r206444</a>, 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:
Source/WebKit2:
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):
Tools:
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]):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlMediaElementSessioncpp">trunk/Source/WebCore/html/MediaElementSession.cpp</a></li>
<li><a href="#trunkSourceWebCorepagePagecpp">trunk/Source/WebCore/page/Page.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformaudioPlatformMediaSessionManagerh">trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h</a></li>
<li><a href="#trunkSourceWebCoreplatformaudiomacMediaSessionManagerMach">trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.h</a></li>
<li><a href="#trunkSourceWebCoreplatformaudiomacMediaSessionManagerMacmm">trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformmacMediaRemoteSoftLinkcpp">trunk/Source/WebCore/platform/mac/MediaRemoteSoftLink.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmacMediaRemoteSoftLinkh">trunk/Source/WebCore/platform/mac/MediaRemoteSoftLink.h</a></li>
<li><a href="#trunkSourceWebCoreplatformspimacMediaRemoteSPIh">trunk/Source/WebCore/platform/spi/mac/MediaRemoteSPI.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewPrivateh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessPageClienth">trunk/Source/WebKit2/UIProcess/PageClient.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxycpp">trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxyh">trunk/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxymessagesin">trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacPageClientImplh">trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacPageClientImplmm">trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPageh">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagemessagesin">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacWebPageMacmm">trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkToolsTestWebKitAPImacTestWKWebViewMacmm">trunk/Tools/TestWebKitAPI/mac/TestWKWebViewMac.mm</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2CocoaNowPlayingControlsTestsmm">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/NowPlayingControlsTests.mm</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2Cocoalargevideotestnowplayinghtml">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-test-now-playing.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (206526 => 206527)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-09-28 17:33:41 UTC (rev 206526)
+++ trunk/Source/WebCore/ChangeLog        2016-09-28 18:17:49 UTC (rev 206527)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+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:
+
</ins><span class="cx"> 2016-09-28 Said Abou-Hallawa <sabouhallawa@apple.com>
</span><span class="cx">
</span><span class="cx"> REGRESSION(r206481): ASSERTION FAILED: isDecoderAvailable()
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlMediaElementSessioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/MediaElementSession.cpp (206526 => 206527)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/MediaElementSession.cpp        2016-09-28 17:33:41 UTC (rev 206526)
+++ trunk/Source/WebCore/html/MediaElementSession.cpp        2016-09-28 18:17:49 UTC (rev 206527)
</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="trunkSourceWebCorepagePagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Page.cpp (206526 => 206527)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Page.cpp        2016-09-28 17:33:41 UTC (rev 206526)
+++ trunk/Source/WebCore/page/Page.cpp        2016-09-28 18:17:49 UTC (rev 206527)
</span><span class="lines">@@ -1451,6 +1451,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">@@ -1467,6 +1468,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="trunkSourceWebCoreplatformaudioPlatformMediaSessionManagerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h (206526 => 206527)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h        2016-09-28 17:33:41 UTC (rev 206526)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h        2016-09-28 18:17:49 UTC (rev 206527)
</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="trunkSourceWebCoreplatformaudiomacMediaSessionManagerMach"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.h (206526 => 206527)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.h        2016-09-28 17:33:41 UTC (rev 206526)
+++ trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.h        2016-09-28 18:17:49 UTC (rev 206527)
</span><span class="lines">@@ -36,6 +36,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="trunkSourceWebCoreplatformaudiomacMediaSessionManagerMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.mm (206526 => 206527)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.mm        2016-09-28 17:33:41 UTC (rev 206526)
+++ trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.mm        2016-09-28 18:17:49 UTC (rev 206527)
</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="trunkSourceWebCoreplatformmacMediaRemoteSoftLinkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/MediaRemoteSoftLink.cpp (206526 => 206527)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/MediaRemoteSoftLink.cpp        2016-09-28 17:33:41 UTC (rev 206526)
+++ trunk/Source/WebCore/platform/mac/MediaRemoteSoftLink.cpp        2016-09-28 18:17:49 UTC (rev 206527)
</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="trunkSourceWebCoreplatformmacMediaRemoteSoftLinkh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/MediaRemoteSoftLink.h (206526 => 206527)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/MediaRemoteSoftLink.h        2016-09-28 17:33:41 UTC (rev 206526)
+++ trunk/Source/WebCore/platform/mac/MediaRemoteSoftLink.h        2016-09-28 18:17:49 UTC (rev 206527)
</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="trunkSourceWebCoreplatformspimacMediaRemoteSPIh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/spi/mac/MediaRemoteSPI.h (206526 => 206527)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/spi/mac/MediaRemoteSPI.h        2016-09-28 17:33:41 UTC (rev 206526)
+++ trunk/Source/WebCore/platform/spi/mac/MediaRemoteSPI.h        2016-09-28 18:17:49 UTC (rev 206527)
</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">@@ -96,6 +112,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="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (206526 => 206527)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-09-28 17:33:41 UTC (rev 206526)
+++ trunk/Source/WebKit2/ChangeLog        2016-09-28 18:17:49 UTC (rev 206527)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+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):
+
</ins><span class="cx"> 2016-09-28 Carlos Garcia Campos <cgarcia@igalia.com>
</span><span class="cx">
</span><span class="cx"> [GTK] Switch to use GMenu internally in the context menu implementation
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (206526 => 206527)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2016-09-28 17:33:41 UTC (rev 206526)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2016-09-28 18:17:49 UTC (rev 206527)
</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="trunkSourceWebKit2UIProcessAPICocoaWKWebViewPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (206526 => 206527)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h        2016-09-28 17:33:41 UTC (rev 206526)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h        2016-09-28 18:17:49 UTC (rev 206527)
</span><span class="lines">@@ -280,6 +280,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(10.12), ios(10.0));
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessPageClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (206526 => 206527)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/PageClient.h        2016-09-28 17:33:41 UTC (rev 206526)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h        2016-09-28 18:17:49 UTC (rev 206527)
</span><span class="lines">@@ -248,6 +248,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="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (206526 => 206527)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2016-09-28 17:33:41 UTC (rev 206526)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2016-09-28 18:17:49 UTC (rev 206527)
</span><span class="lines">@@ -6386,6 +6386,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="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (206526 => 206527)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2016-09-28 17:33:41 UTC (rev 206526)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2016-09-28 18:17:49 UTC (rev 206527)
</span><span class="lines">@@ -1035,6 +1035,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="trunkSourceWebKit2UIProcessWebPageProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (206526 => 206527)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2016-09-28 17:33:41 UTC (rev 206526)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2016-09-28 18:17:49 UTC (rev 206527)
</span><span class="lines">@@ -470,5 +470,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="trunkSourceWebKit2UIProcessmacPageClientImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h (206526 => 206527)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h        2016-09-28 17:33:41 UTC (rev 206526)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h        2016-09-28 18:17:49 UTC (rev 206527)
</span><span class="lines">@@ -207,6 +207,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="trunkSourceWebKit2UIProcessmacPageClientImplmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm (206526 => 206527)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm        2016-09-28 17:33:41 UTC (rev 206526)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm        2016-09-28 18:17:49 UTC (rev 206527)
</span><span class="lines">@@ -759,6 +759,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="trunkSourceWebKit2WebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (206526 => 206527)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2016-09-28 17:33:41 UTC (rev 206526)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2016-09-28 18:17:49 UTC (rev 206527)
</span><span class="lines">@@ -1201,6 +1201,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="trunkSourceWebKit2WebProcessWebPageWebPagemessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (206526 => 206527)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2016-09-28 17:33:41 UTC (rev 206526)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2016-09-28 18:17:49 UTC (rev 206527)
</span><span class="lines">@@ -417,6 +417,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="trunkSourceWebKit2WebProcessWebPagemacWebPageMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (206526 => 206527)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2016-09-28 17:33:41 UTC (rev 206526)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2016-09-28 18:17:49 UTC (rev 206527)
</span><span class="lines">@@ -75,6 +75,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">@@ -160,6 +161,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="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (206526 => 206527)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-09-28 17:33:41 UTC (rev 206526)
+++ trunk/Tools/ChangeLog        2016-09-28 18:17:49 UTC (rev 206527)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+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]):
+
</ins><span class="cx"> 2016-09-28 Per Arne Vollan <pvollan@apple.com>
</span><span class="cx">
</span><span class="cx"> [Win] Compile fix.
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (206526 => 206527)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-09-28 17:33:41 UTC (rev 206526)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-09-28 18:17:49 UTC (rev 206527)
</span><span class="lines">@@ -77,6 +77,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">@@ -478,6 +479,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">@@ -549,6 +551,7 @@
</span><span class="cx">                         dstPath = TestWebKitAPI.resources;
</span><span class="cx">                         dstSubfolderSpec = 7;
</span><span class="cx">                         files = (
</span><ins>+                                F4F137921D9B683E002BEC57 /* large-video-test-now-playing.html in Copy Resources */,
</ins><span class="cx">                                 837A35F11D9A1E7D00663C57 /* DownloadRequestBlobURL.html in Copy Resources */,
</span><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="lines">@@ -799,6 +802,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">@@ -1190,6 +1194,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">@@ -1372,6 +1377,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">@@ -1485,6 +1491,7 @@
</span><span class="cx">                 A16F66B81C40E9E100BD4D24 /* Resources */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</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">@@ -2337,6 +2344,7 @@
</span><span class="cx">                                 7CCE7F231A411AF600447C4C /* Download.mm in Sources */,
</span><span class="cx">                                 7CCE7EEE1A411AE600447C4C /* DownloadDecideDestinationCrash.cpp in Sources */,
</span><span class="cx">                                 7CCE7EBE1A411A7E00447C4C /* DynamicDeviceScaleFactor.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">                                 7A909A831D877480007E10F8 /* IntSize.cpp in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2CocoaNowPlayingControlsTestsmm"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/NowPlayingControlsTests.mm (0 => 206527)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/NowPlayingControlsTests.mm         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/NowPlayingControlsTests.mm        2016-09-28 18:17:49 UTC (rev 206527)
</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="trunkToolsTestWebKitAPITestsWebKit2Cocoalargevideotestnowplayinghtml"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-test-now-playing.html (0 => 206527)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-test-now-playing.html         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-test-now-playing.html        2016-09-28 18:17:49 UTC (rev 206527)
</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="trunkToolsTestWebKitAPImacTestWKWebViewMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/mac/TestWKWebViewMac.mm (206526 => 206527)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/mac/TestWKWebViewMac.mm        2016-09-28 17:33:41 UTC (rev 206526)
+++ trunk/Tools/TestWebKitAPI/mac/TestWKWebViewMac.mm        2016-09-28 18:17:49 UTC (rev 206527)
</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">@@ -114,6 +116,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>