<!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>[169545] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/169545">169545</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2014-06-02 14:13:12 -0700 (Mon, 02 Jun 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Send external playback properties to fullscreen.
https://bugs.webkit.org/show_bug.cgi?id=133366

Patch by Jeremy Jones &lt;jeremyj@apple.com&gt; on 2014-06-02
Reviewed by Simon Fraser.

Source/WebCore:
Refactor property updates in WebVideoFullscreenModelMediaElement and update
setExternalPlayback on webkitcurrentplaybacktargetiswirelesschangedEvent.

* WebCore.exp.in: Add export for setExternalPlayback.
* platform/ios/WebVideoFullscreenInterface.h: add setExternalPlayback
* platform/ios/WebVideoFullscreenInterfaceAVKit.h: add setExternalPlayback
* platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
(-[WebAVPlayerController isPlayingOnExternalScreen]): added
(+[WebAVPlayerController keyPathsForValuesAffectingPlayingOnExternalScreen]): added
(WebVideoFullscreenInterfaceAVKit::setExternalPlayback): added
(WebVideoFullscreenInterfaceAVKit::enterFullscreen): added
* platform/ios/WebVideoFullscreenModelMediaElement.h: add updateForEventName
* platform/ios/WebVideoFullscreenModelMediaElement.mm:
(WebVideoFullscreenModelMediaElement::setMediaElement): refactor property changes into updateForEventName()
(WebVideoFullscreenModelMediaElement::handleEvent): refactor property changes into updateForEventName()
(WebVideoFullscreenModelMediaElement::updateForEventName): remove duplicate code, implement for setExternalPlayback

Source/WebKit2:
Forward setExternalPlayback.

* UIProcess/ios/WebVideoFullscreenManagerProxy.messages.in: add setExternalPlaybackProperties
* WebProcess/ios/WebVideoFullscreenManager.h: add setExternalPlaybackProperties
* WebProcess/ios/WebVideoFullscreenManager.mm: add setExternalPlaybackProperties
(WebKit::WebVideoFullscreenManager::setExternalPlaybackProperties): added</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceh">trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterface.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceAVKith">trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceAVKitmm">trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebVideoFullscreenModelMediaElementh">trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelMediaElement.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebVideoFullscreenModelMediaElementmm">trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelMediaElement.mm</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWebVideoFullscreenManagerProxyh">trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWebVideoFullscreenManagerProxymessagesin">trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWebVideoFullscreenManagerProxymm">trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessiosWebVideoFullscreenManagerh">trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessiosWebVideoFullscreenManagermm">trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (169544 => 169545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-06-02 20:53:58 UTC (rev 169544)
+++ trunk/Source/WebCore/ChangeLog        2014-06-02 21:13:12 UTC (rev 169545)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2014-06-02  Jeremy Jones  &lt;jeremyj@apple.com&gt;
+
+        Send external playback properties to fullscreen.
+        https://bugs.webkit.org/show_bug.cgi?id=133366
+
+        Reviewed by Simon Fraser.
+
+        Refactor property updates in WebVideoFullscreenModelMediaElement and update
+        setExternalPlayback on webkitcurrentplaybacktargetiswirelesschangedEvent.
+
+        * WebCore.exp.in: Add export for setExternalPlayback.
+        * platform/ios/WebVideoFullscreenInterface.h: add setExternalPlayback
+        * platform/ios/WebVideoFullscreenInterfaceAVKit.h: add setExternalPlayback
+        * platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
+        (-[WebAVPlayerController isPlayingOnExternalScreen]): added
+        (+[WebAVPlayerController keyPathsForValuesAffectingPlayingOnExternalScreen]): added
+        (WebVideoFullscreenInterfaceAVKit::setExternalPlayback): added
+        (WebVideoFullscreenInterfaceAVKit::enterFullscreen): added
+        * platform/ios/WebVideoFullscreenModelMediaElement.h: add updateForEventName
+        * platform/ios/WebVideoFullscreenModelMediaElement.mm:
+        (WebVideoFullscreenModelMediaElement::setMediaElement): refactor property changes into updateForEventName()
+        (WebVideoFullscreenModelMediaElement::handleEvent): refactor property changes into updateForEventName()
+        (WebVideoFullscreenModelMediaElement::updateForEventName): remove duplicate code, implement for setExternalPlayback
+
</ins><span class="cx"> 2014-06-02  Zsolt Borbely  &lt;zsborbely.u-szeged@partner.samsung.com&gt;
</span><span class="cx"> 
</span><span class="cx">         WebCore build fix for webreplay
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (169544 => 169545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-06-02 20:53:58 UTC (rev 169544)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-06-02 21:13:12 UTC (rev 169545)
</span><span class="lines">@@ -3388,6 +3388,7 @@
</span><span class="cx"> __ZN7WebCore32WebVideoFullscreenInterfaceAVKit15enterFullscreenER7CALayerNS_7IntRectE
</span><span class="cx"> __ZN7WebCore32WebVideoFullscreenInterfaceAVKit17setSeekableRangesERKNS_10TimeRangesE
</span><span class="cx"> __ZN7WebCore32WebVideoFullscreenInterfaceAVKit18setVideoDimensionsEbff
</span><ins>+__ZN7WebCore32WebVideoFullscreenInterfaceAVKit19setExternalPlaybackEbNS_27WebVideoFullscreenInterface26ExternalPlaybackTargetTypeEN3WTF6StringE
</ins><span class="cx"> __ZN7WebCore32WebVideoFullscreenInterfaceAVKit26setWebVideoFullscreenModelEPNS_23WebVideoFullscreenModelE
</span><span class="cx"> __ZN7WebCore32WebVideoFullscreenInterfaceAVKit28requestHideAndExitFullscreenEv
</span><span class="cx"> __ZN7WebCore32WebVideoFullscreenInterfaceAVKit29setAudioMediaSelectionOptionsERKN3WTF6VectorINS1_6StringELm0ENS1_15CrashOnOverflowEEEy
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterface.h (169544 => 169545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterface.h        2014-06-02 20:53:58 UTC (rev 169544)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterface.h        2014-06-02 21:13:12 UTC (rev 169545)
</span><span class="lines">@@ -41,6 +41,8 @@
</span><span class="cx"> 
</span><span class="cx"> class WebVideoFullscreenInterface {
</span><span class="cx"> public:
</span><ins>+    enum ExternalPlaybackTargetType { TargetTypeNone, TargetTypeAirPlay, TargetTypeTVOut };
+    
</ins><span class="cx">     virtual ~WebVideoFullscreenInterface() { };
</span><span class="cx">     virtual void setDuration(double) = 0;
</span><span class="cx">     virtual void setCurrentTime(double currentTime, double anchorTime) = 0;
</span><span class="lines">@@ -49,6 +51,7 @@
</span><span class="cx">     virtual void setSeekableRanges(const TimeRanges&amp;) = 0;
</span><span class="cx">     virtual void setAudioMediaSelectionOptions(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex) = 0;
</span><span class="cx">     virtual void setLegibleMediaSelectionOptions(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex) = 0;
</span><ins>+    virtual void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, String localizedDeviceName) = 0;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceAVKith"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h (169544 => 169545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h        2014-06-02 20:53:58 UTC (rev 169544)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h        2014-06-02 21:13:12 UTC (rev 169545)
</span><span class="lines">@@ -83,6 +83,7 @@
</span><span class="cx">     virtual void setSeekableRanges(const TimeRanges&amp;) override;
</span><span class="cx">     virtual void setAudioMediaSelectionOptions(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex) override;
</span><span class="cx">     virtual void setLegibleMediaSelectionOptions(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex) override;
</span><ins>+    virtual void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, String localizedDeviceName) override;
</ins><span class="cx"> 
</span><span class="cx">     virtual void enterFullscreen(PlatformLayer&amp;, WebCore::IntRect initialRect);
</span><span class="cx">     virtual void exitFullscreen(WebCore::IntRect finalRect);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceAVKitmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm (169544 => 169545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm        2014-06-02 20:53:58 UTC (rev 169544)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm        2014-06-02 21:13:12 UTC (rev 169545)
</span><span class="lines">@@ -121,6 +121,11 @@
</span><span class="cx"> @property (retain) NSArray *legibleMediaSelectionOptions;
</span><span class="cx"> @property (retain) WebAVMediaSelectionOption *currentLegibleMediaSelectionOption;
</span><span class="cx"> 
</span><ins>+@property (readonly, getter=isPlayingOnExternalScreen) BOOL playingOnExternalScreen;
+@property (getter=isExternalPlaybackActive) BOOL externalPlaybackActive;
+@property AVPlayerControllerExternalPlaybackType externalPlaybackType;
+@property (retain) NSString *externalPlaybackAirPlayDeviceLocalizedName;
+
</ins><span class="cx"> - (BOOL)playerViewController:(AVPlayerViewController *)playerViewController shouldExitFullScreenWithReason:(AVPlayerViewControllerExitFullScreenReason)reason;
</span><span class="cx"> @end
</span><span class="cx"> 
</span><span class="lines">@@ -442,6 +447,16 @@
</span><span class="cx">     self.delegate-&gt;selectLegibleMediaOption(index != NSNotFound ? index : UINT64_MAX);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (BOOL)isPlayingOnExternalScreen
+{
+    return [self isExternalPlaybackActive];
+}
+
++ (NSSet *)keyPathsForValuesAffectingPlayingOnExternalScreen
+{
+    return [NSSet setWithObjects:@&quot;externalPlaybackActive&quot;, nil];
+}
+
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> @interface WebAVMediaSelectionOption : NSObject
</span><span class="lines">@@ -659,6 +674,20 @@
</span><span class="cx">         playerController().currentLegibleMediaSelectionOption = webOptions[(size_t)selectedIndex];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebVideoFullscreenInterfaceAVKit::setExternalPlayback(bool enabled, ExternalPlaybackTargetType targetType, String localizedDeviceName)
+{
+    AVPlayerControllerExternalPlaybackType externalPlaybackType = AVPlayerControllerExternalPlaybackTypeNone;
+    if (targetType == TargetTypeAirPlay)
+        externalPlaybackType = AVPlayerControllerExternalPlaybackTypeAirPlay;
+    else if (targetType == TargetTypeTVOut)
+        externalPlaybackType = AVPlayerControllerExternalPlaybackTypeTVOut;
+
+    playerController().externalPlaybackAirPlayDeviceLocalizedName = localizedDeviceName;
+    playerController().externalPlaybackType = externalPlaybackType;
+    playerController().externalPlaybackActive = enabled;
+    [m_videoLayerContainer.get() setHidden:enabled];
+}
+
</ins><span class="cx"> void WebVideoFullscreenInterfaceAVKit::enterFullscreen(PlatformLayer&amp; videoLayer, WebCore::IntRect initialRect)
</span><span class="cx"> {
</span><span class="cx">     __block RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; protect(this);
</span><span class="lines">@@ -673,6 +702,7 @@
</span><span class="cx">         [m_videoLayer removeFromSuperlayer];
</span><span class="cx">         
</span><span class="cx">         m_videoLayerContainer = [WebAVVideoLayer videoLayer];
</span><ins>+        [m_videoLayerContainer setHidden:playerController().externalPlaybackActive];
</ins><span class="cx">         [m_videoLayerContainer addSublayer:m_videoLayer.get()];
</span><span class="cx">         
</span><span class="cx">         CGSize videoSize = playerController().contentDimensions;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenModelMediaElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelMediaElement.h (169544 => 169545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelMediaElement.h        2014-06-02 20:53:58 UTC (rev 169544)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelMediaElement.h        2014-06-02 21:13:12 UTC (rev 169545)
</span><span class="lines">@@ -51,6 +51,7 @@
</span><span class="cx">     void setVideoFullscreenLayer(PlatformLayer*);
</span><span class="cx">     
</span><span class="cx">     virtual void handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event*) override;
</span><ins>+    void updateForEventName(const WTF::AtomicString&amp;);
</ins><span class="cx">     bool operator==(const EventListener&amp; rhs) override
</span><span class="cx">         {return static_cast&lt;WebCore::EventListener*&gt;(this) == &amp;rhs;}
</span><span class="cx"> 
</span><span class="lines">@@ -71,6 +72,9 @@
</span><span class="cx">     virtual void selectLegibleMediaOption(uint64_t index) override;
</span><span class="cx"> 
</span><span class="cx"> private:
</span><ins>+    static const Vector&lt;WTF::AtomicString&gt;&amp; observedEventNames();
+    const WTF::AtomicString&amp; eventNameAll();
+    
</ins><span class="cx">     RefPtr&lt;HTMLMediaElement&gt; m_mediaElement;
</span><span class="cx">     RetainPtr&lt;PlatformLayer&gt; m_videoFullscreenLayer;
</span><span class="cx">     bool m_isListening;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenModelMediaElementmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelMediaElement.mm (169544 => 169545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelMediaElement.mm        2014-06-02 20:53:58 UTC (rev 169544)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelMediaElement.mm        2014-06-02 21:13:12 UTC (rev 169545)
</span><span class="lines">@@ -47,8 +47,10 @@
</span><span class="cx"> #import &lt;WebCore/TimeRanges.h&gt;
</span><span class="cx"> #import &lt;WebCore/WebCoreThreadRun.h&gt;
</span><span class="cx"> #import &lt;QuartzCore/CoreAnimation.h&gt;
</span><ins>+#import &lt;wtf/NeverDestroyed.h&gt;
</ins><span class="cx"> #import &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> 
</span><ins>+
</ins><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><span class="cx"> WebVideoFullscreenModelMediaElement::WebVideoFullscreenModelMediaElement()
</span><span class="lines">@@ -67,13 +69,8 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (m_mediaElement &amp;&amp; m_isListening) {
</span><del>-        m_mediaElement-&gt;removeEventListener(eventNames().durationchangeEvent, this, false);
-        m_mediaElement-&gt;removeEventListener(eventNames().pauseEvent, this, false);
-        m_mediaElement-&gt;removeEventListener(eventNames().playEvent, this, false);
-        m_mediaElement-&gt;removeEventListener(eventNames().ratechangeEvent, this, false);
-        m_mediaElement-&gt;removeEventListener(eventNames().timeupdateEvent, this, false);
-        m_mediaElement-&gt;removeEventListener(eventNames().addtrackEvent, this, false);
-        m_mediaElement-&gt;removeEventListener(eventNames().removetrackEvent, this, false);
</del><ins>+        for (auto eventName : observedEventNames())
+            m_mediaElement-&gt;removeEventListener(eventName, this, false);
</ins><span class="cx">     }
</span><span class="cx">     m_isListening = false;
</span><span class="cx"> 
</span><span class="lines">@@ -82,23 +79,12 @@
</span><span class="cx">     if (!m_mediaElement)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    m_mediaElement-&gt;addEventListener(eventNames().durationchangeEvent, this, false);
-    m_mediaElement-&gt;addEventListener(eventNames().pauseEvent, this, false);
-    m_mediaElement-&gt;addEventListener(eventNames().playEvent, this, false);
-    m_mediaElement-&gt;addEventListener(eventNames().ratechangeEvent, this, false);
-    m_mediaElement-&gt;addEventListener(eventNames().timeupdateEvent, this, false);
-    m_mediaElement-&gt;addEventListener(eventNames().addtrackEvent, this, false);
-    m_mediaElement-&gt;addEventListener(eventNames().removetrackEvent, this, false);
</del><ins>+    for (auto eventName : observedEventNames())
+        m_mediaElement-&gt;addEventListener(eventName, this, false);
</ins><span class="cx">     m_isListening = true;
</span><span class="cx"> 
</span><del>-    m_videoFullscreenInterface-&gt;setDuration(m_mediaElement-&gt;duration());
-    m_videoFullscreenInterface-&gt;setSeekableRanges(*m_mediaElement-&gt;seekable());
-    m_videoFullscreenInterface-&gt;setRate(!m_mediaElement-&gt;paused(), m_mediaElement-&gt;playbackRate());
</del><ins>+    updateForEventName(eventNameAll());
</ins><span class="cx"> 
</span><del>-    updateLegibleOptions();
-
-    m_videoFullscreenInterface-&gt;setCurrentTime(m_mediaElement-&gt;currentTime(), [[NSProcessInfo processInfo] systemUptime]);
-
</del><span class="cx">     if (isHTMLVideoElement(m_mediaElement.get())) {
</span><span class="cx">         HTMLVideoElement *videoElement = toHTMLVideoElement(m_mediaElement.get());
</span><span class="cx">         m_videoFullscreenInterface-&gt;setVideoDimensions(true, videoElement-&gt;videoWidth(), videoElement-&gt;videoHeight());
</span><span class="lines">@@ -108,23 +94,58 @@
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelMediaElement::handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event* event)
</span><span class="cx"> {
</span><ins>+    LOG(Media, &quot;handleEvent %s&quot;, event-&gt;type().characters8());
+    updateForEventName(event-&gt;type());
+}
+
+void WebVideoFullscreenModelMediaElement::updateForEventName(const WTF::AtomicString&amp; eventName)
+{
</ins><span class="cx">     if (!m_mediaElement || !m_videoFullscreenInterface)
</span><span class="cx">         return;
</span><ins>+    
+    bool all = eventName == eventNameAll();
</ins><span class="cx"> 
</span><del>-    LOG(Media, &quot;handleEvent %s&quot;, event-&gt;type().characters8());
-    
-    if (event-&gt;type() == eventNames().durationchangeEvent)
</del><ins>+    if (all
+        || eventName == eventNames().durationchangeEvent)
</ins><span class="cx">         m_videoFullscreenInterface-&gt;setDuration(m_mediaElement-&gt;duration());
</span><del>-    else if (event-&gt;type() == eventNames().pauseEvent
-        || event-&gt;type() == eventNames().playEvent
-        || event-&gt;type() == eventNames().ratechangeEvent)
</del><ins>+
+    if (all
+        || eventName == eventNames().pauseEvent
+        || eventName == eventNames().playEvent
+        || eventName == eventNames().ratechangeEvent)
</ins><span class="cx">         m_videoFullscreenInterface-&gt;setRate(!m_mediaElement-&gt;paused(), m_mediaElement-&gt;playbackRate());
</span><del>-    else if (event-&gt;type() == eventNames().timeupdateEvent) {
</del><ins>+
+    if (all
+        || eventName == eventNames().timeupdateEvent) {
</ins><span class="cx">         m_videoFullscreenInterface-&gt;setCurrentTime(m_mediaElement-&gt;currentTime(), [[NSProcessInfo processInfo] systemUptime]);
</span><span class="cx">         // FIXME: 130788 - find a better event to update seekable ranges from.
</span><span class="cx">         m_videoFullscreenInterface-&gt;setSeekableRanges(*m_mediaElement-&gt;seekable());
</span><del>-    } else if (event-&gt;type() == eventNames().addtrackEvent || event-&gt;type() == eventNames().removetrackEvent)
</del><ins>+    }
+
+    if (all
+        || eventName == eventNames().addtrackEvent
+        || eventName == eventNames().removetrackEvent)
</ins><span class="cx">         updateLegibleOptions();
</span><ins>+
+    if (all
+        || eventName == eventNames().webkitcurrentplaybacktargetiswirelesschangedEvent) {
+        bool enabled = m_mediaElement-&gt;mediaSession().currentPlaybackTargetIsWireless(*m_mediaElement);
+        WebVideoFullscreenInterface::ExternalPlaybackTargetType targetType = WebVideoFullscreenInterface::TargetTypeNone;
+        String localizedDeviceName;
+
+        if (m_mediaElement-&gt;mediaControlsHost()) {
+            DEPRECATED_DEFINE_STATIC_LOCAL(String, airplay, (ASCIILiteral(&quot;airplay&quot;)));
+            DEPRECATED_DEFINE_STATIC_LOCAL(String, tvout, (ASCIILiteral(&quot;tvout&quot;)));
+            
+            String type = m_mediaElement-&gt;mediaControlsHost()-&gt;externalDeviceType();
+            if (type == airplay)
+                targetType = WebVideoFullscreenInterface::TargetTypeAirPlay;
+            else if (type == tvout)
+                targetType = WebVideoFullscreenInterface::TargetTypeTVOut;
+            localizedDeviceName = m_mediaElement-&gt;mediaControlsHost()-&gt;externalDeviceDisplayName();
+        }
+        m_videoFullscreenInterface-&gt;setExternalPlayback(enabled, targetType, localizedDeviceName);
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelMediaElement::setVideoFullscreenLayer(PlatformLayer* videoLayer)
</span><span class="lines">@@ -333,4 +354,27 @@
</span><span class="cx">     m_videoFullscreenInterface-&gt;setLegibleMediaSelectionOptions(trackDisplayNames, selectedIndex);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+const Vector&lt;AtomicString&gt;&amp; WebVideoFullscreenModelMediaElement::observedEventNames()
+{
+    static NeverDestroyed&lt;Vector&lt;AtomicString&gt;&gt; sEventNames;
+
+    if (!sEventNames.get().size()) {
+        sEventNames.get().append(eventNames().durationchangeEvent);
+        sEventNames.get().append(eventNames().pauseEvent);
+        sEventNames.get().append(eventNames().playEvent);
+        sEventNames.get().append(eventNames().ratechangeEvent);
+        sEventNames.get().append(eventNames().timeupdateEvent);
+        sEventNames.get().append(eventNames().addtrackEvent);
+        sEventNames.get().append(eventNames().removetrackEvent);
+        sEventNames.get().append(eventNames().webkitcurrentplaybacktargetiswirelesschangedEvent);
+    }
+    return sEventNames.get();
+}
+
+const AtomicString&amp; WebVideoFullscreenModelMediaElement::eventNameAll()
+{
+    static NeverDestroyed&lt;AtomicString&gt; sEventNameAll = &quot;allEvents&quot;;
+    return sEventNameAll;
+}
+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (169544 => 169545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-06-02 20:53:58 UTC (rev 169544)
+++ trunk/Source/WebKit2/ChangeLog        2014-06-02 21:13:12 UTC (rev 169545)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2014-06-02  Jeremy Jones  &lt;jeremyj@apple.com&gt;
+
+        Send external playback properties to fullscreen.
+        https://bugs.webkit.org/show_bug.cgi?id=133366
+
+        Reviewed by Simon Fraser.
+
+        Forward setExternalPlayback.
+
+        * UIProcess/ios/WebVideoFullscreenManagerProxy.messages.in: add setExternalPlaybackProperties
+        * WebProcess/ios/WebVideoFullscreenManager.h: add setExternalPlaybackProperties
+        * WebProcess/ios/WebVideoFullscreenManager.mm: add setExternalPlaybackProperties
+        (WebKit::WebVideoFullscreenManager::setExternalPlaybackProperties): added
+
</ins><span class="cx"> 2014-06-02  Enrica Casucci  &lt;enrica@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove unintentional changes to WKContentViewInteraction.mm
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWebVideoFullscreenManagerProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.h (169544 => 169545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.h        2014-06-02 20:53:58 UTC (rev 169544)
+++ trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.h        2014-06-02 21:13:12 UTC (rev 169545)
</span><span class="lines">@@ -57,7 +57,8 @@
</span><span class="cx">     // Translate to FullscreenInterface
</span><span class="cx">     void enterFullscreenWithID(uint32_t, WebCore::IntRect initialRect);
</span><span class="cx">     void setSeekableRangesVector(Vector&lt;std::pair&lt;double, double&gt;&gt;&amp;);
</span><del>-
</del><ins>+    void setExternalPlaybackProperties(bool enabled, uint32_t targetType, String localizedDeviceName);
+    
</ins><span class="cx">     // Fullscreen Observer
</span><span class="cx">     virtual void didExitFullscreen() override;
</span><span class="cx">     virtual void didEnterFullscreen() override;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWebVideoFullscreenManagerProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.messages.in (169544 => 169545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.messages.in        2014-06-02 20:53:58 UTC (rev 169544)
+++ trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.messages.in        2014-06-02 21:13:12 UTC (rev 169545)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx">     SetSeekableRangesVector(Vector&lt;std::pair&lt;double, double&gt;&gt; ranges);
</span><span class="cx">     SetAudioMediaSelectionOptions(Vector&lt;String&gt; options, uint64_t selectedIndex);
</span><span class="cx">     SetLegibleMediaSelectionOptions(Vector&lt;String&gt; options, uint64_t selectedIndex);
</span><ins>+    SetExternalPlaybackProperties(bool enabled, uint32_t targetType, String localizedDeviceName);
</ins><span class="cx">     SetDuration(double duration)
</span><span class="cx">     SetRate(bool isPlaying, double rate)
</span><span class="cx">     EnterFullscreenWithID(uint32_t videoLayerID, WebCore::IntRect initialRect)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWebVideoFullscreenManagerProxymm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.mm (169544 => 169545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.mm        2014-06-02 20:53:58 UTC (rev 169544)
+++ trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.mm        2014-06-02 21:13:12 UTC (rev 169545)
</span><span class="lines">@@ -92,6 +92,15 @@
</span><span class="cx">     setSeekableRanges(*timeRanges);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebVideoFullscreenManagerProxy::setExternalPlaybackProperties(bool enabled, uint32_t targetType, String localizedDeviceName)
+{
+    WebVideoFullscreenInterface::ExternalPlaybackTargetType type = static_cast&lt;WebVideoFullscreenInterface::ExternalPlaybackTargetType&gt;(targetType);
+    
+    ASSERT(type == WebVideoFullscreenInterface::TargetTypeAirPlay || type == WebVideoFullscreenInterface::TargetTypeTVOut || type == WebVideoFullscreenInterface::TargetTypeNone);
+    
+    setExternalPlayback(enabled, type, localizedDeviceName);
+}
+    
</ins><span class="cx"> void WebVideoFullscreenManagerProxy::requestExitFullscreen()
</span><span class="cx"> {
</span><span class="cx">     m_page-&gt;send(Messages::WebVideoFullscreenManager::RequestExitFullscreen(), m_page-&gt;pageID());
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessiosWebVideoFullscreenManagerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.h (169544 => 169545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.h        2014-06-02 20:53:58 UTC (rev 169544)
+++ trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.h        2014-06-02 21:13:12 UTC (rev 169545)
</span><span class="lines">@@ -73,7 +73,8 @@
</span><span class="cx">     virtual void setSeekableRanges(const WebCore::TimeRanges&amp;) override;
</span><span class="cx">     virtual void setAudioMediaSelectionOptions(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex) override;
</span><span class="cx">     virtual void setLegibleMediaSelectionOptions(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex) override;
</span><del>-    
</del><ins>+    virtual void setExternalPlayback(bool enabled, WebVideoFullscreenInterface::ExternalPlaybackTargetType, String localizedDeviceName) override;
+
</ins><span class="cx">     // additional incoming
</span><span class="cx">     virtual void didEnterFullscreen();
</span><span class="cx">     virtual void didExitFullscreen();
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessiosWebVideoFullscreenManagermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.mm (169544 => 169545)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.mm        2014-06-02 20:53:58 UTC (rev 169544)
+++ trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.mm        2014-06-02 21:13:12 UTC (rev 169545)
</span><span class="lines">@@ -160,7 +160,12 @@
</span><span class="cx"> {
</span><span class="cx">     m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::SetLegibleMediaSelectionOptions(options, selectedIndex), m_page-&gt;pageID());
</span><span class="cx"> }
</span><del>-    
</del><ins>+
+void WebVideoFullscreenManager::setExternalPlayback(bool enabled, WebVideoFullscreenInterface::ExternalPlaybackTargetType targetType, String localizedDeviceName)
+{
+    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::SetExternalPlaybackProperties(enabled, static_cast&lt;uint32_t&gt;(targetType), localizedDeviceName), m_page-&gt;pageID());
+}
+
</ins><span class="cx"> void WebVideoFullscreenManager::didEnterFullscreen()
</span><span class="cx"> {
</span><span class="cx">     m_isAnimating = false;
</span></span></pre>
</div>
</div>

</body>
</html>