<!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>[208802] trunk/Source/WebCore</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/208802">208802</a></dd>
<dt>Author</dt> <dd>bdakin@apple.com</dd>
<dt>Date</dt> <dd>2016-11-16 12:23:46 -0800 (Wed, 16 Nov 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Implement WebPlaybackControlsManager
https://bugs.webkit.org/show_bug.cgi?id=164789
-and corresponding-
rdar://problem/29275082

Reviewed by Dan Bernstein.

* platform/mac/WebPlaybackControlsManager.h:
* platform/mac/WebPlaybackControlsManager.mm:
(-[WebPlaybackControlsManager dealloc]):
(-[WebPlaybackControlsManager cancelThumbnailAndAudioAmplitudeSampleGeneration]):
(-[WebPlaybackControlsManager generateFunctionBarThumbnailsForTimes:size:completionHandler:]):
(-[WebPlaybackControlsManager generateFunctionBarAudioAmplitudeSamples:completionHandler:]):
(-[WebPlaybackControlsManager canBeginFunctionBarScrubbing]):
(-[WebPlaybackControlsManager beginFunctionBarScrubbing]):
(-[WebPlaybackControlsManager endFunctionBarScrubbing]):
(-[WebPlaybackControlsManager audioFunctionBarMediaSelectionOptions]):
(-[WebPlaybackControlsManager setAudioFunctionBarMediaSelectionOptions:]):
(-[WebPlaybackControlsManager currentAudioFunctionBarMediaSelectionOption]):
(-[WebPlaybackControlsManager setCurrentAudioFunctionBarMediaSelectionOption:]):
(-[WebPlaybackControlsManager legibleFunctionBarMediaSelectionOptions]):
(-[WebPlaybackControlsManager setLegibleFunctionBarMediaSelectionOptions:]):
(-[WebPlaybackControlsManager currentLegibleFunctionBarMediaSelectionOption]):
(-[WebPlaybackControlsManager setCurrentLegibleFunctionBarMediaSelectionOption:]):
(mediaSelectionOptions):
(-[WebPlaybackControlsManager setAudioMediaSelectionOptions:withSelectedIndex:]):
(-[WebPlaybackControlsManager setLegibleMediaSelectionOptions:withSelectedIndex:]):
(-[WebPlaybackControlsManager webPlaybackSessionInterfaceMac]):
(-[WebPlaybackControlsManager setWebPlaybackSessionInterfaceMac:]):
(-[WebPlaybackControlsManager togglePlayback]):
(-[WebPlaybackControlsManager setPlaying:]):
(-[WebPlaybackControlsManager isPlaying]):
* platform/mac/WebPlaybackSessionInterfaceMac.h:
* platform/mac/WebPlaybackSessionInterfaceMac.mm:
(WebCore::WebPlaybackSessionInterfaceMac::durationChanged):
(WebCore::WebPlaybackSessionInterfaceMac::currentTimeChanged):
(WebCore::WebPlaybackSessionInterfaceMac::rateChanged):
(WebCore::WebPlaybackSessionInterfaceMac::playBackControlsManager):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformmacWebPlaybackControlsManagerh">trunk/Source/WebCore/platform/mac/WebPlaybackControlsManager.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmacWebPlaybackControlsManagermm">trunk/Source/WebCore/platform/mac/WebPlaybackControlsManager.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformmacWebPlaybackSessionInterfaceMach">trunk/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmacWebPlaybackSessionInterfaceMacmm">trunk/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (208801 => 208802)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-11-16 20:18:45 UTC (rev 208801)
+++ trunk/Source/WebCore/ChangeLog        2016-11-16 20:23:46 UTC (rev 208802)
</span><span class="lines">@@ -1,3 +1,44 @@
</span><ins>+2016-11-16  Beth Dakin  &lt;bdakin@apple.com&gt;
+
+        Implement WebPlaybackControlsManager
+        https://bugs.webkit.org/show_bug.cgi?id=164789
+        -and corresponding-
+        rdar://problem/29275082
+
+        Reviewed by Dan Bernstein.
+
+        * platform/mac/WebPlaybackControlsManager.h:
+        * platform/mac/WebPlaybackControlsManager.mm:
+        (-[WebPlaybackControlsManager dealloc]):
+        (-[WebPlaybackControlsManager cancelThumbnailAndAudioAmplitudeSampleGeneration]):
+        (-[WebPlaybackControlsManager generateFunctionBarThumbnailsForTimes:size:completionHandler:]):
+        (-[WebPlaybackControlsManager generateFunctionBarAudioAmplitudeSamples:completionHandler:]):
+        (-[WebPlaybackControlsManager canBeginFunctionBarScrubbing]):
+        (-[WebPlaybackControlsManager beginFunctionBarScrubbing]):
+        (-[WebPlaybackControlsManager endFunctionBarScrubbing]):
+        (-[WebPlaybackControlsManager audioFunctionBarMediaSelectionOptions]):
+        (-[WebPlaybackControlsManager setAudioFunctionBarMediaSelectionOptions:]):
+        (-[WebPlaybackControlsManager currentAudioFunctionBarMediaSelectionOption]):
+        (-[WebPlaybackControlsManager setCurrentAudioFunctionBarMediaSelectionOption:]):
+        (-[WebPlaybackControlsManager legibleFunctionBarMediaSelectionOptions]):
+        (-[WebPlaybackControlsManager setLegibleFunctionBarMediaSelectionOptions:]):
+        (-[WebPlaybackControlsManager currentLegibleFunctionBarMediaSelectionOption]):
+        (-[WebPlaybackControlsManager setCurrentLegibleFunctionBarMediaSelectionOption:]):
+        (mediaSelectionOptions):
+        (-[WebPlaybackControlsManager setAudioMediaSelectionOptions:withSelectedIndex:]):
+        (-[WebPlaybackControlsManager setLegibleMediaSelectionOptions:withSelectedIndex:]):
+        (-[WebPlaybackControlsManager webPlaybackSessionInterfaceMac]):
+        (-[WebPlaybackControlsManager setWebPlaybackSessionInterfaceMac:]):
+        (-[WebPlaybackControlsManager togglePlayback]):
+        (-[WebPlaybackControlsManager setPlaying:]):
+        (-[WebPlaybackControlsManager isPlaying]):
+        * platform/mac/WebPlaybackSessionInterfaceMac.h:
+        * platform/mac/WebPlaybackSessionInterfaceMac.mm:
+        (WebCore::WebPlaybackSessionInterfaceMac::durationChanged):
+        (WebCore::WebPlaybackSessionInterfaceMac::currentTimeChanged):
+        (WebCore::WebPlaybackSessionInterfaceMac::rateChanged):
+        (WebCore::WebPlaybackSessionInterfaceMac::playBackControlsManager):
+
</ins><span class="cx"> 2016-11-16  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add more tests for SubtleCrypto::importKey and SubtleCrypto::exportKey
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacWebPlaybackControlsManagerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/WebPlaybackControlsManager.h (208801 => 208802)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/WebPlaybackControlsManager.h        2016-11-16 20:18:45 UTC (rev 208801)
+++ trunk/Source/WebCore/platform/mac/WebPlaybackControlsManager.h        2016-11-16 20:23:46 UTC (rev 208802)
</span><span class="lines">@@ -26,6 +26,10 @@
</span><span class="cx"> #ifndef WebPlaybackControlsManager_h
</span><span class="cx"> #define WebPlaybackControlsManager_h
</span><span class="cx"> 
</span><ins>+#import &lt;WebCore/AVKitSPI.h&gt;
+#import &lt;wtf/RetainPtr.h&gt;
+#import &lt;wtf/Vector.h&gt;
+
</ins><span class="cx"> #if PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE)
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -32,28 +36,21 @@
</span><span class="cx"> class WebPlaybackSessionInterfaceMac;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if USE(APPLE_INTERNAL_SDK) &amp;&amp; ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
-#import &lt;WebKitAdditions/WebPlaybackControlsControllerAdditions.h&gt;
-#else
-#import &lt;WebCore/AVKitSPI.h&gt;
-#import &lt;wtf/RetainPtr.h&gt;
-#import &lt;wtf/Vector.h&gt;
</del><ins>+#if ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
</ins><span class="cx"> 
</span><del>-OBJC_CLASS AVValueTiming;
-
</del><span class="cx"> WEBCORE_EXPORT
</span><del>-@interface WebPlaybackControlsManager : NSObject
-#if ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
-    &lt;AVFunctionBarPlaybackControlsControlling&gt;
-#endif
-{
</del><ins>+@interface WebPlaybackControlsManager : NSObject &lt;AVFunctionBarPlaybackControlsControlling&gt; {
</ins><span class="cx">     NSTimeInterval _contentDuration;
</span><del>-
</del><span class="cx">     RetainPtr&lt;AVValueTiming&gt; _timing;
</span><span class="cx">     NSTimeInterval _seekToTime;
</span><span class="cx">     RetainPtr&lt;NSArray&gt; _seekableTimeRanges;
</span><span class="cx">     BOOL _hasEnabledAudio;
</span><span class="cx">     BOOL _hasEnabledVideo;
</span><ins>+    RetainPtr&lt;NSArray&lt;AVFunctionBarMediaSelectionOption *&gt;&gt; _audioFunctionBarMediaSelectionOptions;
+    RetainPtr&lt;AVFunctionBarMediaSelectionOption&gt; _currentAudioFunctionBarMediaSelectionOption;
+    RetainPtr&lt;NSArray&lt;AVFunctionBarMediaSelectionOption *&gt;&gt; _legibleFunctionBarMediaSelectionOptions;
+    RetainPtr&lt;AVFunctionBarMediaSelectionOption&gt; _currentLegibleFunctionBarMediaSelectionOption;
+
</ins><span class="cx">     float _rate;
</span><span class="cx">     BOOL _playing;
</span><span class="cx">     BOOL _canTogglePlayback;
</span><span class="lines">@@ -65,19 +62,25 @@
</span><span class="cx"> @property (assign) WebCore::WebPlaybackSessionInterfaceMac* webPlaybackSessionInterfaceMac;
</span><span class="cx"> @property (readwrite) NSTimeInterval contentDuration;
</span><span class="cx"> @property (nonatomic, retain, readwrite) AVValueTiming *timing;
</span><ins>+@property (nonatomic) NSTimeInterval seekToTime;
</ins><span class="cx"> @property (nonatomic, retain, readwrite) NSArray *seekableTimeRanges;
</span><del>-@property (readwrite) BOOL hasEnabledAudio;
-@property (readwrite) BOOL hasEnabledVideo;
-@property (nonatomic) float rate;
</del><ins>+@property (nonatomic) BOOL hasEnabledAudio;
+@property (nonatomic) BOOL hasEnabledVideo;
</ins><span class="cx"> @property (getter=isPlaying) BOOL playing;
</span><span class="cx"> @property BOOL canTogglePlayback;
</span><span class="cx"> 
</span><ins>+@property (nonatomic) float rate;
+
+- (AVFunctionBarMediaSelectionOption *)currentAudioFunctionBarMediaSelectionOption;
+- (void)setCurrentAudioFunctionBarMediaSelectionOption:(AVFunctionBarMediaSelectionOption *)option;
+- (AVFunctionBarMediaSelectionOption *)currentLegibleFunctionBarMediaSelectionOption;
+- (void)setCurrentLegibleFunctionBarMediaSelectionOption:(AVFunctionBarMediaSelectionOption *)option;
</ins><span class="cx"> - (void)setAudioMediaSelectionOptions:(const Vector&lt;WTF::String&gt;&amp;)options withSelectedIndex:(NSUInteger)selectedIndex;
</span><span class="cx"> - (void)setLegibleMediaSelectionOptions:(const Vector&lt;WTF::String&gt;&amp;)options withSelectedIndex:(NSUInteger)selectedIndex;
</span><del>-
</del><span class="cx"> @end
</span><del>-#endif // USE(APPLE_INTERNAL_SDK) &amp;&amp; ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
</del><span class="cx"> 
</span><ins>+#endif // ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
+
</ins><span class="cx"> #endif // PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE)
</span><span class="cx"> 
</span><span class="cx"> #endif // WebPlaybackControlsManager_h
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacWebPlaybackControlsManagermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/WebPlaybackControlsManager.mm (208801 => 208802)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/WebPlaybackControlsManager.mm        2016-11-16 20:18:45 UTC (rev 208801)
+++ trunk/Source/WebCore/platform/mac/WebPlaybackControlsManager.mm        2016-11-16 20:23:46 UTC (rev 208802)
</span><span class="lines">@@ -26,38 +26,34 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;WebPlaybackControlsManager.h&quot;
</span><span class="cx"> 
</span><del>-#if PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE)
</del><ins>+#if PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE) &amp;&amp; ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
</ins><span class="cx"> 
</span><del>-#if USE(APPLE_INTERNAL_SDK) &amp;&amp; ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
-#import &lt;WebKitAdditions/WebPlaybackControlsControllerAdditions.mm&gt;
-#else
-
</del><ins>+#import &quot;SoftLinking.h&quot;
</ins><span class="cx"> #import &quot;WebPlaybackSessionInterfaceMac.h&quot;
</span><ins>+#import &quot;WebPlaybackSessionModel.h&quot;
+#import &lt;wtf/text/WTFString.h&gt;
</ins><span class="cx"> 
</span><ins>+#pragma clang diagnostic push
+#pragma clang diagnostic ignored &quot;-Wnullability-completeness&quot;
+SOFT_LINK_FRAMEWORK(AVKit)
+SOFT_LINK_CLASS_OPTIONAL(AVKit, AVFunctionBarMediaSelectionOption)
+
</ins><span class="cx"> @implementation WebPlaybackControlsManager
</span><span class="cx"> 
</span><del>-using namespace WebCore;
-
</del><span class="cx"> @synthesize contentDuration=_contentDuration;
</span><ins>+@synthesize seekToTime=_seekToTime;
</ins><span class="cx"> @synthesize hasEnabledAudio=_hasEnabledAudio;
</span><span class="cx"> @synthesize hasEnabledVideo=_hasEnabledVideo;
</span><span class="cx"> @synthesize rate=_rate;
</span><del>-@synthesize playing=_playing;
</del><span class="cx"> @synthesize canTogglePlayback=_canTogglePlayback;
</span><del>-#if ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
-@synthesize seekToTime=_seekToTime;
-#endif
</del><span class="cx"> 
</span><del>-- (WebPlaybackSessionInterfaceMac*)webPlaybackSessionInterfaceMac
</del><ins>+- (void)dealloc
</ins><span class="cx"> {
</span><del>-    return _webPlaybackSessionInterfaceMac.get();
</del><ins>+    if (_webPlaybackSessionInterfaceMac)
+        _webPlaybackSessionInterfaceMac-&gt;setPlayBackControlsManager(nullptr);
+    [super dealloc];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)setWebPlaybackSessionInterfaceMac:(WebPlaybackSessionInterfaceMac*)webPlaybackSessionInterfaceMac
-{
-    _webPlaybackSessionInterfaceMac = webPlaybackSessionInterfaceMac;
-}
-
</del><span class="cx"> - (AVValueTiming *)timing
</span><span class="cx"> {
</span><span class="cx">     return _timing.get();
</span><span class="lines">@@ -90,20 +86,175 @@
</span><span class="cx">     _webPlaybackSessionInterfaceMac-&gt;webPlaybackSessionModel()-&gt;seekToTime(time);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)cancelThumbnailAndAudioAmplitudeSampleGeneration
+{
+}
+
+- (void)generateFunctionBarThumbnailsForTimes:(NSArray&lt;NSNumber *&gt; *)thumbnailTimes size:(NSSize)size completionHandler:(void (^)(NSArray&lt;AVThumbnail *&gt; *thumbnails, NSError *error))completionHandler
+{
+    UNUSED_PARAM(thumbnailTimes);
+    UNUSED_PARAM(size);
+    completionHandler(@[ ], nil);
+}
+
+- (void)generateFunctionBarAudioAmplitudeSamples:(NSInteger)numberOfSamples completionHandler:(void (^)(NSArray&lt;NSNumber *&gt; *audioAmplitudeSamples,  NSError *error))completionHandler
+{
+    UNUSED_PARAM(numberOfSamples);
+    completionHandler(@[ ], nil);
+}
+
+-(BOOL)canBeginFunctionBarScrubbing
+{
+    // It's not ideal to return YES all the time here. The intent of the API is that we return NO when the
+    // media is being scrubbed via the on-screen scrubber. But we can only possibly get the right answer for
+    // media that uses the default controls.
+    return YES;
+}
+
+- (void)beginFunctionBarScrubbing
+{
+    _webPlaybackSessionInterfaceMac-&gt;beginScrubbing();
+}
+
+- (void)endFunctionBarScrubbing
+{
+    _webPlaybackSessionInterfaceMac-&gt;endScrubbing();
+}
+
+- (NSArray&lt;AVFunctionBarMediaSelectionOption *&gt; *)audioFunctionBarMediaSelectionOptions
+{
+    return _audioFunctionBarMediaSelectionOptions.get();
+}
+
+- (void)setAudioFunctionBarMediaSelectionOptions:(NSArray&lt;AVFunctionBarMediaSelectionOption *&gt; *)audioOptions
+{
+    _audioFunctionBarMediaSelectionOptions = audioOptions;
+}
+
+- (AVFunctionBarMediaSelectionOption *)currentAudioFunctionBarMediaSelectionOption
+{
+    return _currentAudioFunctionBarMediaSelectionOption.get();
+}
+
+- (void)setCurrentAudioFunctionBarMediaSelectionOption:(AVFunctionBarMediaSelectionOption *)audioMediaSelectionOption
+{
+    if (audioMediaSelectionOption == _currentAudioFunctionBarMediaSelectionOption)
+        return;
+
+    _currentAudioFunctionBarMediaSelectionOption = audioMediaSelectionOption;
+
+    NSInteger index = NSNotFound;
+
+    if (audioMediaSelectionOption &amp;&amp; _audioFunctionBarMediaSelectionOptions)
+        index = [_audioFunctionBarMediaSelectionOptions indexOfObject:audioMediaSelectionOption];
+
+    _webPlaybackSessionInterfaceMac-&gt;webPlaybackSessionModel()-&gt;selectAudioMediaOption(index != NSNotFound ? index : UINT64_MAX);
+}
+
+- (NSArray&lt;AVFunctionBarMediaSelectionOption *&gt; *)legibleFunctionBarMediaSelectionOptions
+{
+    return _legibleFunctionBarMediaSelectionOptions.get();
+}
+
+- (void)setLegibleFunctionBarMediaSelectionOptions:(NSArray&lt;AVFunctionBarMediaSelectionOption *&gt; *)legibleOptions
+{
+    _legibleFunctionBarMediaSelectionOptions = legibleOptions;
+}
+
+- (AVFunctionBarMediaSelectionOption *)currentLegibleFunctionBarMediaSelectionOption
+{
+    return _currentLegibleFunctionBarMediaSelectionOption.get();
+}
+
+- (void)setCurrentLegibleFunctionBarMediaSelectionOption:(AVFunctionBarMediaSelectionOption *)legibleMediaSelectionOption
+{
+    if (legibleMediaSelectionOption == _currentLegibleFunctionBarMediaSelectionOption)
+        return;
+
+    _currentLegibleFunctionBarMediaSelectionOption = legibleMediaSelectionOption;
+
+    NSInteger index = NSNotFound;
+
+    if (legibleMediaSelectionOption &amp;&amp; _legibleFunctionBarMediaSelectionOptions)
+        index = [_legibleFunctionBarMediaSelectionOptions indexOfObject:legibleMediaSelectionOption];
+
+    _webPlaybackSessionInterfaceMac-&gt;webPlaybackSessionModel()-&gt;selectLegibleMediaOption(index != NSNotFound ? index : UINT64_MAX);
+}
+
+static RetainPtr&lt;NSMutableArray&gt; mediaSelectionOptions(const Vector&lt;String&gt;&amp; options)
+{
+    RetainPtr&lt;NSMutableArray&gt; webOptions = adoptNS([[NSMutableArray alloc] initWithCapacity:options.size()]);
+    for (auto&amp; name : options) {
+        if (RetainPtr&lt;AVFunctionBarMediaSelectionOption&gt; webOption = adoptNS([allocAVFunctionBarMediaSelectionOptionInstance() initWithTitle:name]))
+            [webOptions addObject:webOption.get()];
+    }
+    return webOptions;
+}
+
</ins><span class="cx"> - (void)setAudioMediaSelectionOptions:(const Vector&lt;WTF::String&gt;&amp;)options withSelectedIndex:(NSUInteger)selectedIndex
</span><span class="cx"> {
</span><del>-    UNUSED_PARAM(options);
-    UNUSED_PARAM(selectedIndex);
</del><ins>+    RetainPtr&lt;NSMutableArray&gt; webOptions = mediaSelectionOptions(options);
+    [self setAudioFunctionBarMediaSelectionOptions:webOptions.get()];
+    if (selectedIndex &lt; [webOptions count])
+        [self setCurrentAudioFunctionBarMediaSelectionOption:[webOptions objectAtIndex:selectedIndex]];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)setLegibleMediaSelectionOptions:(const Vector&lt;WTF::String&gt;&amp;)options withSelectedIndex:(NSUInteger)selectedIndex
</span><span class="cx"> {
</span><del>-    UNUSED_PARAM(options);
-    UNUSED_PARAM(selectedIndex);
</del><ins>+    RetainPtr&lt;NSMutableArray&gt; webOptions = mediaSelectionOptions(options);
+    [self setLegibleFunctionBarMediaSelectionOptions:webOptions.get()];
+    if (selectedIndex &lt; [webOptions count])
+        [self setCurrentLegibleFunctionBarMediaSelectionOption:[webOptions objectAtIndex:selectedIndex]];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (WebCore::WebPlaybackSessionInterfaceMac*)webPlaybackSessionInterfaceMac
+{
+    return _webPlaybackSessionInterfaceMac.get();
+}
+
+- (void)setWebPlaybackSessionInterfaceMac:(WebCore::WebPlaybackSessionInterfaceMac*)webPlaybackSessionInterfaceMac
+{
+    if (_webPlaybackSessionInterfaceMac == webPlaybackSessionInterfaceMac)
+        return;
+
+    if (_webPlaybackSessionInterfaceMac)
+        _webPlaybackSessionInterfaceMac-&gt;setPlayBackControlsManager(nullptr);
+
+    _webPlaybackSessionInterfaceMac = webPlaybackSessionInterfaceMac;
+
+    if (_webPlaybackSessionInterfaceMac)
+        _webPlaybackSessionInterfaceMac-&gt;setPlayBackControlsManager(self);
+}
+
+- (void)togglePlayback
+{
+    if (_webPlaybackSessionInterfaceMac &amp;&amp; _webPlaybackSessionInterfaceMac-&gt;webPlaybackSessionModel())
+        _webPlaybackSessionInterfaceMac-&gt;webPlaybackSessionModel()-&gt;togglePlayState();
+}
+
+- (void)setPlaying:(BOOL)playing
+{
+    if (!_webPlaybackSessionInterfaceMac || !_webPlaybackSessionInterfaceMac-&gt;webPlaybackSessionModel())
+        return;
+
+    BOOL isCurrentlyPlaying = _playing;
+    if (!isCurrentlyPlaying &amp;&amp; playing)
+        _webPlaybackSessionInterfaceMac-&gt;webPlaybackSessionModel()-&gt;play();
+    else if (isCurrentlyPlaying &amp;&amp; !playing)
+        _webPlaybackSessionInterfaceMac-&gt;webPlaybackSessionModel()-&gt;pause();
+}
+
+- (BOOL)isPlaying
+{
+    if (_webPlaybackSessionInterfaceMac &amp;&amp; _webPlaybackSessionInterfaceMac-&gt;webPlaybackSessionModel())
+        return _webPlaybackSessionInterfaceMac-&gt;webPlaybackSessionModel()-&gt;isPlaying();
+
+    return NO;
+}
+
+#pragma clang diagnostic pop
+
</ins><span class="cx"> @end
</span><del>-#endif // USE(APPLE_INTERNAL_SDK) &amp;&amp; ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
</del><span class="cx"> 
</span><del>-#endif // PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE)
</del><ins>+#endif // PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE) &amp;&amp; ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacWebPlaybackSessionInterfaceMach"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.h (208801 => 208802)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.h        2016-11-16 20:18:45 UTC (rev 208801)
+++ trunk/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.h        2016-11-16 20:23:46 UTC (rev 208802)
</span><span class="lines">@@ -62,17 +62,22 @@
</span><span class="cx">     WEBCORE_EXPORT void legibleMediaSelectionOptionsChanged(const Vector&lt;String&gt;&amp; /*options*/, uint64_t /*selectedIndex*/) final;
</span><span class="cx">     WEBCORE_EXPORT void invalidate();
</span><span class="cx">     WEBCORE_EXPORT void ensureControlsManager();
</span><ins>+#if ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
</ins><span class="cx">     WEBCORE_EXPORT void setPlayBackControlsManager(WebPlaybackControlsManager *);
</span><ins>+    WEBCORE_EXPORT WebPlaybackControlsManager *playBackControlsManager();
+#endif
</ins><span class="cx">     WEBCORE_EXPORT void beginScrubbing();
</span><span class="cx">     WEBCORE_EXPORT void endScrubbing();
</span><del>-    WEBCORE_EXPORT WebPlaybackControlsManager *playBackControlsManager();
</del><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     WebPlaybackSessionInterfaceMac(WebPlaybackSessionModel&amp;);
</span><span class="cx">     WebPlaybackSessionModel* m_playbackSessionModel { nullptr };
</span><ins>+#if ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
</ins><span class="cx">     WebPlaybackControlsManager *m_playbackControlsManager  { nullptr };
</span><span class="cx"> 
</span><span class="cx">     void updatePlaybackControlsManagerTiming(double currentTime, double anchorTime, double playbackRate, bool isPlaying);
</span><ins>+#endif
+
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacWebPlaybackSessionInterfaceMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.mm (208801 => 208802)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.mm        2016-11-16 20:18:45 UTC (rev 208801)
+++ trunk/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.mm        2016-11-16 20:23:46 UTC (rev 208802)
</span><span class="lines">@@ -64,6 +64,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebPlaybackSessionInterfaceMac::durationChanged(double duration)
</span><span class="cx"> {
</span><ins>+#if ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
</ins><span class="cx">     WebPlaybackControlsManager* controlsManager = playBackControlsManager();
</span><span class="cx"> 
</span><span class="cx">     controlsManager.contentDuration = duration;
</span><span class="lines">@@ -71,20 +72,25 @@
</span><span class="cx">     // FIXME: We take this as an indication that playback is ready, but that is not necessarily true.
</span><span class="cx">     controlsManager.hasEnabledAudio = YES;
</span><span class="cx">     controlsManager.hasEnabledVideo = YES;
</span><ins>+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPlaybackSessionInterfaceMac::currentTimeChanged(double currentTime, double anchorTime)
</span><span class="cx"> {
</span><ins>+#if ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
</ins><span class="cx">     WebPlaybackControlsManager* controlsManager = playBackControlsManager();
</span><span class="cx">     updatePlaybackControlsManagerTiming(currentTime, anchorTime, controlsManager.rate, controlsManager.playing);
</span><ins>+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPlaybackSessionInterfaceMac::rateChanged(bool isPlaying, float playbackRate)
</span><span class="cx"> {
</span><ins>+#if ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
</ins><span class="cx">     WebPlaybackControlsManager* controlsManager = playBackControlsManager();
</span><span class="cx">     [controlsManager setRate:isPlaying ? playbackRate : 0.];
</span><span class="cx">     [controlsManager setPlaying:isPlaying];
</span><span class="cx">     updatePlaybackControlsManagerTiming(m_playbackSessionModel ? m_playbackSessionModel-&gt;currentTime() : 0, [[NSProcessInfo processInfo] systemUptime], playbackRate, isPlaying);
</span><ins>+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPlaybackSessionInterfaceMac::beginScrubbing()
</span><span class="lines">@@ -140,13 +146,11 @@
</span><span class="cx">     playBackControlsManager();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
+
</ins><span class="cx"> WebPlaybackControlsManager *WebPlaybackSessionInterfaceMac::playBackControlsManager()
</span><span class="cx"> {
</span><del>-#if __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200
</del><span class="cx">     return m_playbackControlsManager;
</span><del>-#else
-    return nil;
-#endif
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPlaybackSessionInterfaceMac::setPlayBackControlsManager(WebPlaybackControlsManager *manager)
</span><span class="lines">@@ -191,6 +195,8 @@
</span><span class="cx">     manager.timing = [getAVValueTimingClass() valueTimingWithAnchorValue:currentTime anchorTimeStamp:effectiveAnchorTime rate:effectivePlaybackRate];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#endif // ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
+
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #endif // PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE)
</span></span></pre>
</div>
</div>

</body>
</html>