<!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>[199593] 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/199593">199593</a></dd>
<dt>Author</dt> <dd>jer.noble@apple.com</dd>
<dt>Date</dt> <dd>2016-04-15 10:50:26 -0700 (Fri, 15 Apr 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Allow WebVideoFullscreenManager and Proxy to be used by audio elements.
https://bugs.webkit.org/show_bug.cgi?id=156564

Reviewed by Beth Dakin.

Source/WebCore:

No new tests; this refactors existing functionality into new classes.

Tease apart the various WebVideoFullscreen{Interface,Model}{AVKit,Mac,VideoElement} into new
WebPlaybackSession… classes dealing exclusively with playback state and commands, leaving
fullscreen state and commands in the WebVideoFullscreen… classes. Specifically, create the
following new classes:

- WebPlaybackSessionInterface (copied from WebVideoFullscreenInterface)
- WebPlaybackSessionModelMediaElement (copied from WebVideoFullscreenModelMediaElement)
- WebPlaybackSessionModel (copied from WebVideoFullscreenModel)
- WebPlaybackSessionInterfaceAVKit (copied from WebVideoFullscreenInterfaceAVKit)
- WebPlaybackSessionInterfaceMac (copied from WebVideoFullscreenInterfaceMac)

WebVideoFullscreenInterface and WebVideoFullscreenModel now inherit from
WebPlaybackSessionInterface and WebPlaybackSessionModel, respectively. The concrete
WebVideoFullscreen… subclasses each take their respective WebPlaybackSession… subclasses and
fulfill their WebPlaybackSession interfaces through composition.

As part of this big tease-apart, the WebAVPlayerController class needs to be exposed in a
header (as it's accessed by two different classes now), so that class is moved into its own
implementation and header files.

The one case where a change in a WebPlaybackSession… class needs to be reflected in a
WebVideoFullscreen… class is in WebPlaybackSessionInterfaceAVKit, where
WebVideoFullscreenInterfaceAVKit needs to be notified when external playback becomes dis/en-
abled, so a new WebPlaybackSessionInterfaceAVKitClient interface has been added to allow the
WebPlaybackSession… to notify the WebVideoFullscreen….

The responsibility for the &quot;controls manager&quot; has moved from the WebVideoFullscreen… classes
to the WebPlaybackSession… classes, so the ChromeClient interface for creating and destroying
those controls is similarly renamed from setUpVideoControlsManager() to
setUpPlaybackControlsManager().

* WebCore.xcodeproj/project.pbxproj:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::updatePlayState):
* page/ChromeClient.h:
* platform/cocoa/WebPlaybackSessionInterface.h: Copied from Source/WebCore/platform/cocoa/WebVideoFullscreenInterface.h.
(WebCore::WebPlaybackSessionInterface::~WebPlaybackSessionInterface):
* platform/cocoa/WebPlaybackSessionModel.h: Added.
(WebCore::WebPlaybackSessionModel::~WebPlaybackSessionModel):
* platform/cocoa/WebPlaybackSessionModelMediaElement.h: Added.
(WebCore::WebPlaybackSessionModelMediaElement::create):
(WebCore::WebPlaybackSessionModelMediaElement::mediaElement):
* platform/cocoa/WebPlaybackSessionModelMediaElement.mm: Added.
(WebPlaybackSessionModelMediaElement::WebPlaybackSessionModelMediaElement):
(WebPlaybackSessionModelMediaElement::~WebPlaybackSessionModelMediaElement):
(WebPlaybackSessionModelMediaElement::setWebPlaybackSessionInterface):
(WebPlaybackSessionModelMediaElement::setMediaElement):
(WebPlaybackSessionModelMediaElement::handleEvent):
(WebPlaybackSessionModelMediaElement::updateForEventName):
(WebPlaybackSessionModelMediaElement::play):
(WebPlaybackSessionModelMediaElement::pause):
(WebPlaybackSessionModelMediaElement::togglePlayState):
(WebPlaybackSessionModelMediaElement::beginScrubbing):
(WebPlaybackSessionModelMediaElement::endScrubbing):
(WebPlaybackSessionModelMediaElement::seekToTime):
(WebPlaybackSessionModelMediaElement::fastSeek):
(WebPlaybackSessionModelMediaElement::beginScanningForward):
(WebPlaybackSessionModelMediaElement::beginScanningBackward):
(WebPlaybackSessionModelMediaElement::endScanning):
(WebPlaybackSessionModelMediaElement::selectAudioMediaOption):
(WebPlaybackSessionModelMediaElement::selectLegibleMediaOption):
(WebPlaybackSessionModelMediaElement::updateLegibleOptions):
(WebPlaybackSessionModelMediaElement::observedEventNames):
(WebPlaybackSessionModelMediaElement::eventNameAll):
* platform/cocoa/WebPlaybackSessionModelVideoElement.cpp: Copied from Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.mm.
(WebPlaybackSessionModelVideoElement::WebPlaybackSessionModelVideoElement):
(WebPlaybackSessionModelVideoElement::~WebPlaybackSessionModelVideoElement):
(WebPlaybackSessionModelVideoElement::setWebVideoFullscreenInterface):
(WebPlaybackSessionModelVideoElement::setVideoElement):
(WebPlaybackSessionModelVideoElement::handleEvent):
(WebPlaybackSessionModelVideoElement::updateForEventName):
(WebPlaybackSessionModelVideoElement::play):
(WebPlaybackSessionModelVideoElement::pause):
(WebPlaybackSessionModelVideoElement::togglePlayState):
(WebPlaybackSessionModelVideoElement::beginScrubbing):
(WebPlaybackSessionModelVideoElement::endScrubbing):
(WebPlaybackSessionModelVideoElement::seekToTime):
(WebPlaybackSessionModelVideoElement::fastSeek):
(WebPlaybackSessionModelVideoElement::beginScanningForward):
(WebPlaybackSessionModelVideoElement::beginScanningBackward):
(WebPlaybackSessionModelVideoElement::endScanning):
(WebPlaybackSessionModelVideoElement::selectAudioMediaOption):
(WebPlaybackSessionModelVideoElement::selectLegibleMediaOption):
(WebPlaybackSessionModelVideoElement::updateLegibleOptions):
(WebPlaybackSessionModelVideoElement::observedEventNames):
(WebPlaybackSessionModelVideoElement::eventNameAll):
* platform/cocoa/WebVideoFullscreenInterface.h:
* platform/cocoa/WebVideoFullscreenModel.h:
(WebCore::WebVideoFullscreenModel::~WebVideoFullscreenModel): Deleted.
* platform/cocoa/WebVideoFullscreenModelVideoElement.h:
(WebCore::WebVideoFullscreenModelVideoElement::create):
* platform/cocoa/WebVideoFullscreenModelVideoElement.mm:
(WebVideoFullscreenModelVideoElement::WebVideoFullscreenModelVideoElement):
(WebVideoFullscreenModelVideoElement::setWebVideoFullscreenInterface):
(WebVideoFullscreenModelVideoElement::setVideoElement):
(WebVideoFullscreenModelVideoElement::play):
(WebVideoFullscreenModelVideoElement::pause):
(WebVideoFullscreenModelVideoElement::togglePlayState):
(WebVideoFullscreenModelVideoElement::beginScrubbing):
(WebVideoFullscreenModelVideoElement::endScrubbing):
(WebVideoFullscreenModelVideoElement::seekToTime):
(WebVideoFullscreenModelVideoElement::fastSeek):
(WebVideoFullscreenModelVideoElement::beginScanningForward):
(WebVideoFullscreenModelVideoElement::beginScanningBackward):
(WebVideoFullscreenModelVideoElement::endScanning):
(WebVideoFullscreenModelVideoElement::selectAudioMediaOption):
(WebVideoFullscreenModelVideoElement::selectLegibleMediaOption):
(WebVideoFullscreenModelVideoElement::handleEvent): Deleted.
(WebVideoFullscreenModelVideoElement::setVideoFullscreenLayer): Deleted.
(WebVideoFullscreenModelVideoElement::setVideoLayerFrame): Deleted.
(WebVideoFullscreenModelVideoElement::setVideoLayerGravity): Deleted.
(WebVideoFullscreenModelVideoElement::observedEventNames): Deleted.
(WebVideoFullscreenModelVideoElement::eventNameAll): Deleted.
(WebVideoFullscreenModelVideoElement::fullscreenModeChanged): Deleted.
(WebVideoFullscreenModelVideoElement::isVisible): Deleted.
* platform/ios/WebAVPlayerController.h: Added.
* platform/ios/WebAVPlayerController.mm: Added.
(-[WebAVPlayerController dealloc]):
(-[WebAVPlayerController resetState]):
(-[WebAVPlayerController player]):
(-[WebAVPlayerController forwardingTargetForSelector:]):
(-[WebAVPlayerController play:]):
(-[WebAVPlayerController pause:]):
(-[WebAVPlayerController togglePlayback:]):
(-[WebAVPlayerController togglePlaybackEvenWhenInBackground:]):
(-[WebAVPlayerController isPlaying]):
(-[WebAVPlayerController setPlaying:]):
(+[WebAVPlayerController keyPathsForValuesAffectingPlaying]):
(-[WebAVPlayerController beginScrubbing:]):
(-[WebAVPlayerController endScrubbing:]):
(-[WebAVPlayerController seekToTime:]):
(-[WebAVPlayerController currentTimeWithinEndTimes]):
(-[WebAVPlayerController setCurrentTimeWithinEndTimes:]):
(+[WebAVPlayerController keyPathsForValuesAffectingCurrentTimeWithinEndTimes]):
(-[WebAVPlayerController hasLiveStreamingContent]):
(+[WebAVPlayerController keyPathsForValuesAffectingHasLiveStreamingContent]):
(-[WebAVPlayerController skipBackwardThirtySeconds:]):
(-[WebAVPlayerController gotoEndOfSeekableRanges:]):
(-[WebAVPlayerController canScanForward]):
(+[WebAVPlayerController keyPathsForValuesAffectingCanScanForward]):
(-[WebAVPlayerController beginScanningForward:]):
(-[WebAVPlayerController endScanningForward:]):
(-[WebAVPlayerController beginScanningBackward:]):
(-[WebAVPlayerController endScanningBackward:]):
(-[WebAVPlayerController canSeekToBeginning]):
(+[WebAVPlayerController keyPathsForValuesAffectingCanSeekToBeginning]):
(-[WebAVPlayerController seekToBeginning:]):
(-[WebAVPlayerController seekChapterBackward:]):
(-[WebAVPlayerController canSeekToEnd]):
(+[WebAVPlayerController keyPathsForValuesAffectingCanSeekToEnd]):
(-[WebAVPlayerController seekToEnd:]):
(-[WebAVPlayerController seekChapterForward:]):
(-[WebAVPlayerController hasMediaSelectionOptions]):
(+[WebAVPlayerController keyPathsForValuesAffectingHasMediaSelectionOptions]):
(-[WebAVPlayerController hasAudioMediaSelectionOptions]):
(+[WebAVPlayerController keyPathsForValuesAffectingHasAudioMediaSelectionOptions]):
(-[WebAVPlayerController hasLegibleMediaSelectionOptions]):
(+[WebAVPlayerController keyPathsForValuesAffectingHasLegibleMediaSelectionOptions]):
(-[WebAVPlayerController currentAudioMediaSelectionOption]):
(-[WebAVPlayerController setCurrentAudioMediaSelectionOption:]):
(-[WebAVPlayerController currentLegibleMediaSelectionOption]):
(-[WebAVPlayerController setCurrentLegibleMediaSelectionOption:]):
(-[WebAVPlayerController isPlayingOnExternalScreen]):
(+[WebAVPlayerController keyPathsForValuesAffectingPlayingOnExternalScreen]):
(-[WebAVPlayerController isPictureInPictureInterrupted]):
(-[WebAVPlayerController setPictureInPictureInterrupted:]):
* platform/ios/WebPlaybackSessionInterfaceAVKit.h: Added.
(WebCore::WebPlaybackSessionInterfaceAVKitClient::~WebPlaybackSessionInterfaceAVKitClient):
* platform/ios/WebPlaybackSessionInterfaceAVKit.mm: Added.
(WebCore::WebPlaybackSessionInterfaceAVKit::WebPlaybackSessionInterfaceAVKit):
(WebCore::WebPlaybackSessionInterfaceAVKit::~WebPlaybackSessionInterfaceAVKit):
(WebCore::WebPlaybackSessionInterfaceAVKit::resetMediaState):
(WebCore::WebPlaybackSessionInterfaceAVKit::setWebPlaybackSessionModel):
(WebCore::WebPlaybackSessionInterfaceAVKit::setDuration):
(WebCore::WebPlaybackSessionInterfaceAVKit::setCurrentTime):
(WebCore::WebPlaybackSessionInterfaceAVKit::setBufferedTime):
(WebCore::WebPlaybackSessionInterfaceAVKit::setRate):
(WebCore::WebPlaybackSessionInterfaceAVKit::setSeekableRanges):
(WebCore::WebPlaybackSessionInterfaceAVKit::setCanPlayFastReverse):
(WebCore::mediaSelectionOptions):
(WebCore::WebPlaybackSessionInterfaceAVKit::setAudioMediaSelectionOptions):
(WebCore::WebPlaybackSessionInterfaceAVKit::setLegibleMediaSelectionOptions):
(WebCore::WebPlaybackSessionInterfaceAVKit::setExternalPlayback):
(WebCore::WebPlaybackSessionInterfaceAVKit::setWirelessVideoPlaybackDisabled):
(WebCore::WebPlaybackSessionInterfaceAVKit::wirelessVideoPlaybackDisabled):
(WebCore::WebPlaybackSessionInterfaceAVKit::invalidate):
* platform/ios/WebVideoFullscreenControllerAVKit.mm:
(WebVideoFullscreenControllerContext::setUpFullscreen):
* platform/ios/WebVideoFullscreenInterfaceAVKit.h:
* platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
(-[WebAVPlayerViewControllerDelegate fullscreenInterface]):
(-[WebAVPlayerViewControllerDelegate setFullscreenInterface:]):
(-[WebAVPlayerLayer fullscreenInterface]):
(-[WebAVPlayerLayer setFullscreenInterface:]):
(-[WebAVPlayerLayer layoutSublayers]):
(-[WebAVPlayerLayer resolveBounds]):
(-[WebAVPlayerLayer setVideoGravity:]):
(WebVideoFullscreenInterfaceAVKit::create):
(WebVideoFullscreenInterfaceAVKit::WebVideoFullscreenInterfaceAVKit):
(WebVideoFullscreenInterfaceAVKit::~WebVideoFullscreenInterfaceAVKit):
(WebVideoFullscreenInterfaceAVKit::playerController):
(WebVideoFullscreenInterfaceAVKit::resetMediaState):
(WebVideoFullscreenInterfaceAVKit::setDuration):
(WebVideoFullscreenInterfaceAVKit::setCurrentTime):
(WebVideoFullscreenInterfaceAVKit::setBufferedTime):
(WebVideoFullscreenInterfaceAVKit::setRate):
(WebVideoFullscreenInterfaceAVKit::setVideoDimensions):
(WebVideoFullscreenInterfaceAVKit::setSeekableRanges):
(WebVideoFullscreenInterfaceAVKit::setCanPlayFastReverse):
(WebVideoFullscreenInterfaceAVKit::setAudioMediaSelectionOptions):
(WebVideoFullscreenInterfaceAVKit::setLegibleMediaSelectionOptions):
(WebVideoFullscreenInterfaceAVKit::setExternalPlayback):
(WebVideoFullscreenInterfaceAVKit::externalPlaybackEnabledChanged):
(WebVideoFullscreenInterfaceAVKit::setWirelessVideoPlaybackDisabled):
(WebVideoFullscreenInterfaceAVKit::wirelessVideoPlaybackDisabled):
(WebVideoFullscreenInterfaceAVKit::setupFullscreen):
(WebVideoFullscreenInterfaceAVKit::cleanupFullscreen):
(WebVideoFullscreenInterfaceAVKit::mayAutomaticallyShowVideoPictureInPicture):
(-[WebAVPlayerViewControllerDelegate playerViewControllerWillStartPictureInPicture:]): Deleted.
(-[WebAVPlayerViewControllerDelegate playerViewControllerDidStartPictureInPicture:]): Deleted.
(-[WebAVPlayerViewControllerDelegate playerViewControllerFailedToStartPictureInPicture:withError:]): Deleted.
(-[WebAVPlayerViewControllerDelegate playerViewControllerWillStopPictureInPicture:]): Deleted.
(-[WebAVPlayerViewControllerDelegate playerViewControllerDidStopPictureInPicture:]): Deleted.
(convertToExitFullScreenReason): Deleted.
(-[WebAVPlayerViewControllerDelegate playerViewController:shouldExitFullScreenWithReason:]): Deleted.
(-[WebAVPlayerViewControllerDelegate playerViewController:restoreUserInterfaceForPictureInPictureStopWithCompletionHandler:]): Deleted.
(-[WebAVPlayerLayer init]): Deleted.
(-[WebAVPlayerLayer dealloc]): Deleted.
(-[WebAVPlayerLayer videoGravity]): Deleted.
(-[WebAVPlayerLayer videoRect]): Deleted.
(+[WebAVPlayerLayer keyPathsForValuesAffectingVideoRect]): Deleted.
(WebAVPictureInPicturePlayerLayerView_layerClass): Deleted.
(getWebAVPictureInPicturePlayerLayerViewClass): Deleted.
(WebAVPlayerLayerView_layerClass): Deleted.
(WebAVPlayerLayerView_playerController): Deleted.
(WebAVPlayerLayerView_setPlayerController): Deleted.
(WebAVPlayerLayerView_videoView): Deleted.
(WebAVPlayerLayerView_setVideoView): Deleted.
(WebAVPlayerLayerView_startRoutingVideoToPictureInPicturePlayerLayerView): Deleted.
(WebAVPlayerLayerView_stopRoutingVideoToPictureInPicturePlayerLayerView): Deleted.
(WebAVPlayerLayerView_pictureInPicturePlayerLayerView): Deleted.
(WebAVPlayerLayerView_dealloc): Deleted.
(getWebAVPlayerLayerViewClass): Deleted.
(WebVideoFullscreenInterfaceAVKit::setWebVideoFullscreenModel): Deleted.
(WebVideoFullscreenInterfaceAVKit::setWebVideoFullscreenChangeObserver): Deleted.
(WebVideoFullscreenInterfaceAVKit::applicationDidBecomeActive): Deleted.
(WebVideoFullscreenInterfaceAVKit::enterFullscreen): Deleted.
(WebVideoFullscreenInterfaceAVKit::enterFullscreenStandard): Deleted.
(WebVideoFullscreenInterfaceAVKit::exitFullscreen): Deleted.
(WebVideoFullscreenInterfaceAVKit::didStartPictureInPicture): Deleted.
(WebVideoFullscreenInterfaceAVKit::failedToStartPictureInPicture): Deleted.
(WebVideoFullscreenInterfaceAVKit::willStopPictureInPicture): Deleted.
(WebVideoFullscreenInterfaceAVKit::didStopPictureInPicture): Deleted.
(WebVideoFullscreenInterfaceAVKit::prepareForPictureInPictureStopWithCompletionHandler): Deleted.
(WebVideoFullscreenInterfaceAVKit::shouldExitFullscreenWithReason): Deleted.
(WebVideoFullscreenInterfaceAVKit::watchdogTimerFired): Deleted.
(WebVideoFullscreenInterfaceAVKit::setMode): Deleted.
(WebVideoFullscreenInterfaceAVKit::clearMode): Deleted.
(WebCore::supportsPictureInPicture): Deleted.
* platform/mac/WebPlaybackSessionInterfaceMac.h: Added.
* platform/mac/WebPlaybackSessionInterfaceMac.mm: Copied from Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.mm.
(-[WebAVMediaSelectionOptionMac localizedDisplayName]):
(-[WebAVMediaSelectionOptionMac setLocalizedDisplayName:]):
(-[WebPlaybackControlsManager initWithWebPlaybackSessionInterfaceMac:]):
(-[WebPlaybackControlsManager timing]):
(-[WebPlaybackControlsManager setTiming:]):
(-[WebPlaybackControlsManager seekableTimeRanges]):
(-[WebPlaybackControlsManager setSeekableTimeRanges:]):
(-[WebPlaybackControlsManager isSeeking]):
(-[WebPlaybackControlsManager seekToTime:toleranceBefore:toleranceAfter:]):
(-[WebPlaybackControlsManager audioMediaSelectionOptions]):
(-[WebPlaybackControlsManager setAudioMediaSelectionOptions:]):
(-[WebPlaybackControlsManager currentAudioMediaSelectionOption]):
(-[WebPlaybackControlsManager setCurrentAudioMediaSelectionOption:]):
(-[WebPlaybackControlsManager legibleMediaSelectionOptions]):
(-[WebPlaybackControlsManager setLegibleMediaSelectionOptions:]):
(-[WebPlaybackControlsManager currentLegibleMediaSelectionOption]):
(-[WebPlaybackControlsManager setCurrentLegibleMediaSelectionOption:]):
(-[WebPlaybackControlsManager cancelThumbnailAndAudioAmplitudeSampleGeneration]):
(WebCore::WebPlaybackSessionInterfaceMac::~WebPlaybackSessionInterfaceMac):
(WebCore::WebPlaybackSessionInterfaceMac::setWebPlaybackSessionModel):
(WebCore::WebPlaybackSessionInterfaceMac::setDuration):
(WebCore::WebPlaybackSessionInterfaceMac::setCurrentTime):
(WebCore::WebPlaybackSessionInterfaceMac::setRate):
(WebCore::WebPlaybackSessionInterfaceMac::setSeekableRanges):
(WebCore::mediaSelectionOptions):
(WebCore::WebPlaybackSessionInterfaceMac::setAudioMediaSelectionOptions):
(WebCore::WebPlaybackSessionInterfaceMac::setLegibleMediaSelectionOptions):
(WebCore::WebPlaybackSessionInterfaceMac::invalidate):
(WebCore::WebPlaybackSessionInterfaceMac::ensureControlsManager):
(WebCore::WebPlaybackSessionInterfaceMac::playBackControlsManager):
* platform/mac/WebVideoFullscreenInterfaceMac.h:
* platform/mac/WebVideoFullscreenInterfaceMac.mm:
(WebCore::WebVideoFullscreenInterfaceMac::WebVideoFullscreenInterfaceMac):
(WebCore::WebVideoFullscreenInterfaceMac::setWebVideoFullscreenModel):
(WebCore::WebVideoFullscreenInterfaceMac::setDuration):
(WebCore::WebVideoFullscreenInterfaceMac::setCurrentTime):
(WebCore::WebVideoFullscreenInterfaceMac::setRate):
(WebCore::WebVideoFullscreenInterfaceMac::setSeekableRanges):
(WebCore::WebVideoFullscreenInterfaceMac::setAudioMediaSelectionOptions):
(WebCore::WebVideoFullscreenInterfaceMac::setLegibleMediaSelectionOptions):
(WebCore::WebVideoFullscreenInterfaceMac::ensureControlsManager):
(WebCore::WebVideoFullscreenInterfaceMac::~WebVideoFullscreenInterfaceMac): Deleted.
(WebCore::WebVideoFullscreenInterfaceMac::setWebVideoFullscreenChangeObserver): Deleted.
(WebCore::WebVideoFullscreenInterfaceMac::setMode): Deleted.
(WebCore::WebVideoFullscreenInterfaceMac::clearMode): Deleted.
(WebCore::WebVideoFullscreenInterfaceMac::setupFullscreen): Deleted.
(WebCore::WebVideoFullscreenInterfaceMac::enterFullscreen): Deleted.
(WebCore::WebVideoFullscreenInterfaceMac::exitFullscreen): Deleted.
(WebCore::WebVideoFullscreenInterfaceMac::exitFullscreenWithoutAnimationToMode): Deleted.
(WebCore::WebVideoFullscreenInterfaceMac::cleanupFullscreen): Deleted.
(WebCore::WebVideoFullscreenInterfaceMac::invalidate): Deleted.
(WebCore::WebVideoFullscreenInterfaceMac::preparedToReturnToInline): Deleted.
(WebCore::WebVideoFullscreenInterfaceMac::setVideoDimensions): Deleted.
(WebCore::supportsPictureInPicture): Deleted.

Source/WebKit2:

Tease apart WebVideoFullscreenManager and …Proxy into WebPlaybackSessionManager and …Proxy
classes dealing exclusively with playback state and commands, leaving fullscreen state and
commands in the WebVideoFullscreenManager… classes.

WebVideoFullscreenManager and …Proxy will now require an associated
WebPlaybackSessionManager and …Proxy class. The WebPlaybackSessionManager classes can be
used separately and without the WebVideoFullscreenManager classes.

* DerivedSources.make:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _mayAutomaticallyShowVideoPictureInPicture]):
* UIProcess/Cocoa/WebPlaybackSessionManagerProxy.h: Copied from Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.h.
* UIProcess/Cocoa/WebPlaybackSessionManagerProxy.messages.in: Copied from Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.messages.in.
* UIProcess/Cocoa/WebPlaybackSessionManagerProxy.mm: Added.
(WebKit::WebPlaybackSessionModelContext::play):
(WebKit::WebPlaybackSessionModelContext::pause):
(WebKit::WebPlaybackSessionModelContext::togglePlayState):
(WebKit::WebPlaybackSessionModelContext::beginScrubbing):
(WebKit::WebPlaybackSessionModelContext::endScrubbing):
(WebKit::WebPlaybackSessionModelContext::seekToTime):
(WebKit::WebPlaybackSessionModelContext::fastSeek):
(WebKit::WebPlaybackSessionModelContext::beginScanningForward):
(WebKit::WebPlaybackSessionModelContext::beginScanningBackward):
(WebKit::WebPlaybackSessionModelContext::endScanning):
(WebKit::WebPlaybackSessionModelContext::selectAudioMediaOption):
(WebKit::WebPlaybackSessionModelContext::selectLegibleMediaOption):
(WebKit::WebPlaybackSessionManagerProxy::create):
(WebKit::WebPlaybackSessionManagerProxy::WebPlaybackSessionManagerProxy):
(WebKit::WebPlaybackSessionManagerProxy::~WebPlaybackSessionManagerProxy):
(WebKit::WebPlaybackSessionManagerProxy::invalidate):
(WebKit::WebPlaybackSessionManagerProxy::createModelAndInterface):
(WebKit::WebPlaybackSessionManagerProxy::ensureModelAndInterface):
(WebKit::WebPlaybackSessionManagerProxy::ensureModel):
(WebKit::WebPlaybackSessionManagerProxy::ensureInterface):
(WebKit::WebPlaybackSessionManagerProxy::addClientForContext):
(WebKit::WebPlaybackSessionManagerProxy::removeClientForContext):
(WebKit::WebPlaybackSessionManagerProxy::setUpPlaybackControlsManagerWithID):
(WebKit::WebPlaybackSessionManagerProxy::clearPlaybackControlsManager):
(WebKit::WebPlaybackSessionManagerProxy::resetMediaState):
(WebKit::WebPlaybackSessionManagerProxy::setCurrentTime):
(WebKit::WebPlaybackSessionManagerProxy::setBufferedTime):
(WebKit::WebPlaybackSessionManagerProxy::setSeekableRangesVector):
(WebKit::WebPlaybackSessionManagerProxy::setCanPlayFastReverse):
(WebKit::WebPlaybackSessionManagerProxy::setAudioMediaSelectionOptions):
(WebKit::WebPlaybackSessionManagerProxy::setLegibleMediaSelectionOptions):
(WebKit::WebPlaybackSessionManagerProxy::setExternalPlaybackProperties):
(WebKit::WebPlaybackSessionManagerProxy::setWirelessVideoPlaybackDisabled):
(WebKit::WebPlaybackSessionManagerProxy::setDuration):
(WebKit::WebPlaybackSessionManagerProxy::setRate):
(WebKit::WebPlaybackSessionManagerProxy::play):
(WebKit::WebPlaybackSessionManagerProxy::pause):
(WebKit::WebPlaybackSessionManagerProxy::togglePlayState):
(WebKit::WebPlaybackSessionManagerProxy::beginScrubbing):
(WebKit::WebPlaybackSessionManagerProxy::endScrubbing):
(WebKit::WebPlaybackSessionManagerProxy::seekToTime):
(WebKit::WebPlaybackSessionManagerProxy::fastSeek):
(WebKit::WebPlaybackSessionManagerProxy::beginScanningForward):
(WebKit::WebPlaybackSessionManagerProxy::beginScanningBackward):
(WebKit::WebPlaybackSessionManagerProxy::endScanning):
(WebKit::WebPlaybackSessionManagerProxy::selectAudioMediaOption):
(WebKit::WebPlaybackSessionManagerProxy::selectLegibleMediaOption):
(WebKit::WebPlaybackSessionManagerProxy::controlsManagerInterface):
* UIProcess/Cocoa/WebVideoFullscreenManagerProxy.h:
* UIProcess/Cocoa/WebVideoFullscreenManagerProxy.messages.in:
* UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm:
(WebKit::WebVideoFullscreenModelContext::WebVideoFullscreenModelContext):
(WebKit::WebVideoFullscreenModelContext::~WebVideoFullscreenModelContext):
(WebKit::WebVideoFullscreenModelContext::play):
(WebKit::WebVideoFullscreenModelContext::pause):
(WebKit::WebVideoFullscreenModelContext::togglePlayState):
(WebKit::WebVideoFullscreenModelContext::beginScrubbing):
(WebKit::WebVideoFullscreenModelContext::endScrubbing):
(WebKit::WebVideoFullscreenModelContext::seekToTime):
(WebKit::WebVideoFullscreenModelContext::fastSeek):
(WebKit::WebVideoFullscreenModelContext::beginScanningForward):
(WebKit::WebVideoFullscreenModelContext::beginScanningBackward):
(WebKit::WebVideoFullscreenModelContext::endScanning):
(WebKit::WebVideoFullscreenModelContext::selectAudioMediaOption):
(WebKit::WebVideoFullscreenModelContext::selectLegibleMediaOption):
(WebKit::WebVideoFullscreenManagerProxy::create):
(WebKit::WebVideoFullscreenManagerProxy::WebVideoFullscreenManagerProxy):
(WebKit::WebVideoFullscreenManagerProxy::createModelAndInterface):
(WebKit::WebVideoFullscreenManagerProxy::setupFullscreenWithID): Deleted.
(WebKit::WebVideoFullscreenManagerProxy::setVideoDimensions): Deleted.
(WebKit::WebVideoFullscreenManagerProxy::enterFullscreen): Deleted.
(WebKit::WebVideoFullscreenManagerProxy::exitFullscreen): Deleted.
(WebKit::WebVideoFullscreenManagerProxy::exitFullscreenWithoutAnimationToMode): Deleted.
(WebKit::WebVideoFullscreenManagerProxy::cleanupFullscreen): Deleted.
(WebKit::WebVideoFullscreenManagerProxy::preparedToReturnToInline): Deleted.
(WebKit::WebVideoFullscreenManagerProxy::requestFullscreenMode): Deleted.
(WebKit::WebVideoFullscreenManagerProxy::didSetupFullscreen): Deleted.
(WebKit::WebVideoFullscreenManagerProxy::didExitFullscreen): Deleted.
(WebKit::WebVideoFullscreenManagerProxy::didEnterFullscreen): Deleted.
(WebKit::WebVideoFullscreenManagerProxy::didCleanupFullscreen): Deleted.
(WebKit::WebVideoFullscreenManagerProxy::setVideoLayerFrame): Deleted.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::reattachToWebProcess):
(WebKit::WebPageProxy::playbackSessionManager):
(WebKit::WebPageProxy::videoFullscreenManager):
(WebKit::WebPageProxy::resetState):
(WebKit::WebPageProxy::hasActiveVideoForControlsManager):
(WebKit::WebPageProxy::isPlayingMediaDidChange): Deleted.
* UIProcess/WebPageProxy.h:
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::supportsVideoFullscreen):
(WebKit::WebChromeClient::setUpPlaybackControlsManager):
(WebKit::WebChromeClient::clearPlaybackControlsManager):
(WebKit::WebChromeClient::enterVideoFullscreenForVideoElement):
(WebKit::WebChromeClient::exitVideoFullscreenForVideoElement):
(WebKit::WebChromeClient::exitVideoFullscreenToModeWithoutAnimation):
* WebProcess/WebCoreSupport/WebChromeClient.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::playbackSessionManager):
(WebKit::WebPage::videoFullscreenManager):
* WebProcess/WebPage/WebPage.h:
* WebProcess/cocoa/WebPlaybackSessionManager.h: Copied from Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.h.
(WebKit::WebPlaybackSessionInterfaceContext::create):
(WebKit::WebPlaybackSessionInterfaceContext::invalidate):
* WebProcess/cocoa/WebPlaybackSessionManager.messages.in: Added.
* WebProcess/cocoa/WebPlaybackSessionManager.mm: Added.
(WebKit::nextContextId):
(WebKit::WebPlaybackSessionInterfaceContext::WebPlaybackSessionInterfaceContext):
(WebKit::WebPlaybackSessionInterfaceContext::~WebPlaybackSessionInterfaceContext):
(WebKit::WebPlaybackSessionInterfaceContext::resetMediaState):
(WebKit::WebPlaybackSessionInterfaceContext::setDuration):
(WebKit::WebPlaybackSessionInterfaceContext::setCurrentTime):
(WebKit::WebPlaybackSessionInterfaceContext::setBufferedTime):
(WebKit::WebPlaybackSessionInterfaceContext::setRate):
(WebKit::WebPlaybackSessionInterfaceContext::setSeekableRanges):
(WebKit::WebPlaybackSessionInterfaceContext::setCanPlayFastReverse):
(WebKit::WebPlaybackSessionInterfaceContext::setAudioMediaSelectionOptions):
(WebKit::WebPlaybackSessionInterfaceContext::setLegibleMediaSelectionOptions):
(WebKit::WebPlaybackSessionInterfaceContext::setExternalPlayback):
(WebKit::WebPlaybackSessionInterfaceContext::setWirelessVideoPlaybackDisabled):
(WebKit::WebPlaybackSessionManager::create):
(WebKit::WebPlaybackSessionManager::WebPlaybackSessionManager):
(WebKit::WebPlaybackSessionManager::~WebPlaybackSessionManager):
(WebKit::WebPlaybackSessionManager::createModelAndInterface):
(WebKit::WebPlaybackSessionManager::ensureModelAndInterface):
(WebKit::WebPlaybackSessionManager::ensureModel):
(WebKit::WebPlaybackSessionManager::ensureInterface):
(WebKit::WebPlaybackSessionManager::removeContext):
(WebKit::WebPlaybackSessionManager::addClientForContext):
(WebKit::WebPlaybackSessionManager::removeClientForContext):
(WebKit::WebPlaybackSessionManager::setUpPlaybackControlsManager):
(WebKit::WebPlaybackSessionManager::clearPlaybackControlsManager):
(WebKit::WebPlaybackSessionManager::contextIdForMediaElement):
(WebKit::WebPlaybackSessionManager::resetMediaState):
(WebKit::WebPlaybackSessionManager::setDuration):
(WebKit::WebPlaybackSessionManager::setCurrentTime):
(WebKit::WebPlaybackSessionManager::setBufferedTime):
(WebKit::WebPlaybackSessionManager::setRate):
(WebKit::WebPlaybackSessionManager::setSeekableRanges):
(WebKit::WebPlaybackSessionManager::setCanPlayFastReverse):
(WebKit::WebPlaybackSessionManager::setAudioMediaSelectionOptions):
(WebKit::WebPlaybackSessionManager::setLegibleMediaSelectionOptions):
(WebKit::WebPlaybackSessionManager::setExternalPlayback):
(WebKit::WebPlaybackSessionManager::setWirelessVideoPlaybackDisabled):
(WebKit::WebPlaybackSessionManager::play):
(WebKit::WebPlaybackSessionManager::pause):
(WebKit::WebPlaybackSessionManager::togglePlayState):
(WebKit::WebPlaybackSessionManager::beginScrubbing):
(WebKit::WebPlaybackSessionManager::endScrubbing):
(WebKit::WebPlaybackSessionManager::seekToTime):
(WebKit::WebPlaybackSessionManager::fastSeek):
(WebKit::WebPlaybackSessionManager::beginScanningForward):
(WebKit::WebPlaybackSessionManager::beginScanningBackward):
(WebKit::WebPlaybackSessionManager::endScanning):
(WebKit::WebPlaybackSessionManager::selectAudioMediaOption):
(WebKit::WebPlaybackSessionManager::selectLegibleMediaOption):
* WebProcess/cocoa/WebVideoFullscreenManager.h:
(WebKit::WebVideoFullscreenInterfaceContext::create):
* WebProcess/cocoa/WebVideoFullscreenManager.messages.in:
* WebProcess/cocoa/WebVideoFullscreenManager.mm:
(WebKit::WebVideoFullscreenInterfaceContext::WebVideoFullscreenInterfaceContext):
(WebKit::WebVideoFullscreenInterfaceContext::resetMediaState):
(WebKit::WebVideoFullscreenInterfaceContext::setDuration):
(WebKit::WebVideoFullscreenInterfaceContext::setCurrentTime):
(WebKit::WebVideoFullscreenInterfaceContext::setBufferedTime):
(WebKit::WebVideoFullscreenInterfaceContext::setRate):
(WebKit::WebVideoFullscreenInterfaceContext::setSeekableRanges):
(WebKit::WebVideoFullscreenInterfaceContext::setCanPlayFastReverse):
(WebKit::WebVideoFullscreenInterfaceContext::setAudioMediaSelectionOptions):
(WebKit::WebVideoFullscreenInterfaceContext::setLegibleMediaSelectionOptions):
(WebKit::WebVideoFullscreenInterfaceContext::setExternalPlayback):
(WebKit::WebVideoFullscreenInterfaceContext::setWirelessVideoPlaybackDisabled):
(WebKit::WebVideoFullscreenManager::create):
(WebKit::WebVideoFullscreenManager::WebVideoFullscreenManager):
(WebKit::WebVideoFullscreenManager::createModelAndInterface):
(WebKit::WebVideoFullscreenManager::enterVideoFullscreenForVideoElement):
(WebKit::WebVideoFullscreenInterfaceContext::setVideoDimensions): Deleted.
(WebKit::WebVideoFullscreenManager::~WebVideoFullscreenManager): Deleted.
(WebKit::WebVideoFullscreenManager::ensureModelAndInterface): Deleted.
(WebKit::WebVideoFullscreenManager::exitVideoFullscreenToModeWithoutAnimation): Deleted.
(WebKit::WebVideoFullscreenManager::setVideoDimensions): Deleted.
(WebKit::WebVideoFullscreenManager::requestFullscreenMode): Deleted.
(WebKit::WebVideoFullscreenManager::fullscreenModeChanged): Deleted.
(WebKit::WebVideoFullscreenManager::didSetupFullscreen): Deleted.
(WebKit::WebVideoFullscreenManager::didEnterFullscreen): Deleted.
(WebKit::WebVideoFullscreenManager::didExitFullscreen): Deleted.
(WebKit::WebVideoFullscreenManager::didCleanupFullscreen): Deleted.
(WebKit::WebVideoFullscreenManager::setVideoLayerGravityEnum): Deleted.
(WebKit::WebVideoFullscreenManager::fullscreenMayReturnToInline): Deleted.
(WebKit::WebVideoFullscreenManager::setVideoLayerFrameFenced): Deleted.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementcpp">trunk/Source/WebCore/html/HTMLMediaElement.cpp</a></li>
<li><a href="#trunkSourceWebCorepageChromeClienth">trunk/Source/WebCore/page/ChromeClient.h</a></li>
<li><a href="#trunkSourceWebCoreplatformcocoaWebVideoFullscreenInterfaceh">trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenInterface.h</a></li>
<li><a href="#trunkSourceWebCoreplatformcocoaWebVideoFullscreenModelh">trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModel.h</a></li>
<li><a href="#trunkSourceWebCoreplatformcocoaWebVideoFullscreenModelVideoElementh">trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.h</a></li>
<li><a href="#trunkSourceWebCoreplatformcocoaWebVideoFullscreenModelVideoElementmm">trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebVideoFullscreenControllerAVKitmm">trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm</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="#trunkSourceWebCoreplatformmacWebVideoFullscreenInterfaceMach">trunk/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmacWebVideoFullscreenInterfaceMacmm">trunk/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.mm</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2DerivedSourcesmake">trunk/Source/WebKit2/DerivedSources.make</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebVideoFullscreenManagerProxyh">trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebVideoFullscreenManagerProxymessagesin">trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebVideoFullscreenManagerProxymm">trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm</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="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebChromeClientcpp">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebChromeClienth">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagecpp">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPageh">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcesscocoaWebVideoFullscreenManagerh">trunk/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcesscocoaWebVideoFullscreenManagermessagesin">trunk/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.messages.in</a></li>
<li><a href="#trunkSourceWebKit2WebProcesscocoaWebVideoFullscreenManagermm">trunk/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformcocoaWebPlaybackSessionInterfaceh">trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionInterface.h</a></li>
<li><a href="#trunkSourceWebCoreplatformcocoaWebPlaybackSessionModelh">trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModel.h</a></li>
<li><a href="#trunkSourceWebCoreplatformcocoaWebPlaybackSessionModelMediaElementh">trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.h</a></li>
<li><a href="#trunkSourceWebCoreplatformcocoaWebPlaybackSessionModelMediaElementmm">trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebAVPlayerControllerh">trunk/Source/WebCore/platform/ios/WebAVPlayerController.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebAVPlayerControllermm">trunk/Source/WebCore/platform/ios/WebAVPlayerController.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebPlaybackSessionInterfaceAVKith">trunk/Source/WebCore/platform/ios/WebPlaybackSessionInterfaceAVKit.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebPlaybackSessionInterfaceAVKitmm">trunk/Source/WebCore/platform/ios/WebPlaybackSessionInterfaceAVKit.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>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebPlaybackSessionManagerProxyh">trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebPlaybackSessionManagerProxymessagesin">trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebPlaybackSessionManagerProxymm">trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcesscocoaWebPlaybackSessionManagerh">trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcesscocoaWebPlaybackSessionManagermessagesin">trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.messages.in</a></li>
<li><a href="#trunkSourceWebKit2WebProcesscocoaWebPlaybackSessionManagermm">trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (199592 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-04-15 17:18:12 UTC (rev 199592)
+++ trunk/Source/WebCore/ChangeLog        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -1,3 +1,328 @@
</span><ins>+2016-04-14  Jer Noble  &lt;jer.noble@apple.com&gt;
+
+        Allow WebVideoFullscreenManager and Proxy to be used by audio elements.
+        https://bugs.webkit.org/show_bug.cgi?id=156564
+
+        Reviewed by Beth Dakin.
+
+        No new tests; this refactors existing functionality into new classes.
+
+        Tease apart the various WebVideoFullscreen{Interface,Model}{AVKit,Mac,VideoElement} into new
+        WebPlaybackSession… classes dealing exclusively with playback state and commands, leaving
+        fullscreen state and commands in the WebVideoFullscreen… classes. Specifically, create the
+        following new classes:
+
+        - WebPlaybackSessionInterface (copied from WebVideoFullscreenInterface)
+        - WebPlaybackSessionModelMediaElement (copied from WebVideoFullscreenModelMediaElement)
+        - WebPlaybackSessionModel (copied from WebVideoFullscreenModel)
+        - WebPlaybackSessionInterfaceAVKit (copied from WebVideoFullscreenInterfaceAVKit)
+        - WebPlaybackSessionInterfaceMac (copied from WebVideoFullscreenInterfaceMac)
+
+        WebVideoFullscreenInterface and WebVideoFullscreenModel now inherit from
+        WebPlaybackSessionInterface and WebPlaybackSessionModel, respectively. The concrete
+        WebVideoFullscreen… subclasses each take their respective WebPlaybackSession… subclasses and
+        fulfill their WebPlaybackSession interfaces through composition.
+
+        As part of this big tease-apart, the WebAVPlayerController class needs to be exposed in a
+        header (as it's accessed by two different classes now), so that class is moved into its own
+        implementation and header files.
+
+        The one case where a change in a WebPlaybackSession… class needs to be reflected in a
+        WebVideoFullscreen… class is in WebPlaybackSessionInterfaceAVKit, where
+        WebVideoFullscreenInterfaceAVKit needs to be notified when external playback becomes dis/en-
+        abled, so a new WebPlaybackSessionInterfaceAVKitClient interface has been added to allow the
+        WebPlaybackSession… to notify the WebVideoFullscreen….
+
+        The responsibility for the &quot;controls manager&quot; has moved from the WebVideoFullscreen… classes
+        to the WebPlaybackSession… classes, so the ChromeClient interface for creating and destroying
+        those controls is similarly renamed from setUpVideoControlsManager() to
+        setUpPlaybackControlsManager().
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::updatePlayState):
+        * page/ChromeClient.h:
+        * platform/cocoa/WebPlaybackSessionInterface.h: Copied from Source/WebCore/platform/cocoa/WebVideoFullscreenInterface.h.
+        (WebCore::WebPlaybackSessionInterface::~WebPlaybackSessionInterface):
+        * platform/cocoa/WebPlaybackSessionModel.h: Added.
+        (WebCore::WebPlaybackSessionModel::~WebPlaybackSessionModel):
+        * platform/cocoa/WebPlaybackSessionModelMediaElement.h: Added.
+        (WebCore::WebPlaybackSessionModelMediaElement::create):
+        (WebCore::WebPlaybackSessionModelMediaElement::mediaElement):
+        * platform/cocoa/WebPlaybackSessionModelMediaElement.mm: Added.
+        (WebPlaybackSessionModelMediaElement::WebPlaybackSessionModelMediaElement):
+        (WebPlaybackSessionModelMediaElement::~WebPlaybackSessionModelMediaElement):
+        (WebPlaybackSessionModelMediaElement::setWebPlaybackSessionInterface):
+        (WebPlaybackSessionModelMediaElement::setMediaElement):
+        (WebPlaybackSessionModelMediaElement::handleEvent):
+        (WebPlaybackSessionModelMediaElement::updateForEventName):
+        (WebPlaybackSessionModelMediaElement::play):
+        (WebPlaybackSessionModelMediaElement::pause):
+        (WebPlaybackSessionModelMediaElement::togglePlayState):
+        (WebPlaybackSessionModelMediaElement::beginScrubbing):
+        (WebPlaybackSessionModelMediaElement::endScrubbing):
+        (WebPlaybackSessionModelMediaElement::seekToTime):
+        (WebPlaybackSessionModelMediaElement::fastSeek):
+        (WebPlaybackSessionModelMediaElement::beginScanningForward):
+        (WebPlaybackSessionModelMediaElement::beginScanningBackward):
+        (WebPlaybackSessionModelMediaElement::endScanning):
+        (WebPlaybackSessionModelMediaElement::selectAudioMediaOption):
+        (WebPlaybackSessionModelMediaElement::selectLegibleMediaOption):
+        (WebPlaybackSessionModelMediaElement::updateLegibleOptions):
+        (WebPlaybackSessionModelMediaElement::observedEventNames):
+        (WebPlaybackSessionModelMediaElement::eventNameAll):
+        * platform/cocoa/WebPlaybackSessionModelVideoElement.cpp: Copied from Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.mm.
+        (WebPlaybackSessionModelVideoElement::WebPlaybackSessionModelVideoElement):
+        (WebPlaybackSessionModelVideoElement::~WebPlaybackSessionModelVideoElement):
+        (WebPlaybackSessionModelVideoElement::setWebVideoFullscreenInterface):
+        (WebPlaybackSessionModelVideoElement::setVideoElement):
+        (WebPlaybackSessionModelVideoElement::handleEvent):
+        (WebPlaybackSessionModelVideoElement::updateForEventName):
+        (WebPlaybackSessionModelVideoElement::play):
+        (WebPlaybackSessionModelVideoElement::pause):
+        (WebPlaybackSessionModelVideoElement::togglePlayState):
+        (WebPlaybackSessionModelVideoElement::beginScrubbing):
+        (WebPlaybackSessionModelVideoElement::endScrubbing):
+        (WebPlaybackSessionModelVideoElement::seekToTime):
+        (WebPlaybackSessionModelVideoElement::fastSeek):
+        (WebPlaybackSessionModelVideoElement::beginScanningForward):
+        (WebPlaybackSessionModelVideoElement::beginScanningBackward):
+        (WebPlaybackSessionModelVideoElement::endScanning):
+        (WebPlaybackSessionModelVideoElement::selectAudioMediaOption):
+        (WebPlaybackSessionModelVideoElement::selectLegibleMediaOption):
+        (WebPlaybackSessionModelVideoElement::updateLegibleOptions):
+        (WebPlaybackSessionModelVideoElement::observedEventNames):
+        (WebPlaybackSessionModelVideoElement::eventNameAll):
+        * platform/cocoa/WebVideoFullscreenInterface.h:
+        * platform/cocoa/WebVideoFullscreenModel.h:
+        (WebCore::WebVideoFullscreenModel::~WebVideoFullscreenModel): Deleted.
+        * platform/cocoa/WebVideoFullscreenModelVideoElement.h:
+        (WebCore::WebVideoFullscreenModelVideoElement::create):
+        * platform/cocoa/WebVideoFullscreenModelVideoElement.mm:
+        (WebVideoFullscreenModelVideoElement::WebVideoFullscreenModelVideoElement):
+        (WebVideoFullscreenModelVideoElement::setWebVideoFullscreenInterface):
+        (WebVideoFullscreenModelVideoElement::setVideoElement):
+        (WebVideoFullscreenModelVideoElement::play):
+        (WebVideoFullscreenModelVideoElement::pause):
+        (WebVideoFullscreenModelVideoElement::togglePlayState):
+        (WebVideoFullscreenModelVideoElement::beginScrubbing):
+        (WebVideoFullscreenModelVideoElement::endScrubbing):
+        (WebVideoFullscreenModelVideoElement::seekToTime):
+        (WebVideoFullscreenModelVideoElement::fastSeek):
+        (WebVideoFullscreenModelVideoElement::beginScanningForward):
+        (WebVideoFullscreenModelVideoElement::beginScanningBackward):
+        (WebVideoFullscreenModelVideoElement::endScanning):
+        (WebVideoFullscreenModelVideoElement::selectAudioMediaOption):
+        (WebVideoFullscreenModelVideoElement::selectLegibleMediaOption):
+        (WebVideoFullscreenModelVideoElement::handleEvent): Deleted.
+        (WebVideoFullscreenModelVideoElement::setVideoFullscreenLayer): Deleted.
+        (WebVideoFullscreenModelVideoElement::setVideoLayerFrame): Deleted.
+        (WebVideoFullscreenModelVideoElement::setVideoLayerGravity): Deleted.
+        (WebVideoFullscreenModelVideoElement::observedEventNames): Deleted.
+        (WebVideoFullscreenModelVideoElement::eventNameAll): Deleted.
+        (WebVideoFullscreenModelVideoElement::fullscreenModeChanged): Deleted.
+        (WebVideoFullscreenModelVideoElement::isVisible): Deleted.
+        * platform/ios/WebAVPlayerController.h: Added.
+        * platform/ios/WebAVPlayerController.mm: Added.
+        (-[WebAVPlayerController dealloc]):
+        (-[WebAVPlayerController resetState]):
+        (-[WebAVPlayerController player]):
+        (-[WebAVPlayerController forwardingTargetForSelector:]):
+        (-[WebAVPlayerController play:]):
+        (-[WebAVPlayerController pause:]):
+        (-[WebAVPlayerController togglePlayback:]):
+        (-[WebAVPlayerController togglePlaybackEvenWhenInBackground:]):
+        (-[WebAVPlayerController isPlaying]):
+        (-[WebAVPlayerController setPlaying:]):
+        (+[WebAVPlayerController keyPathsForValuesAffectingPlaying]):
+        (-[WebAVPlayerController beginScrubbing:]):
+        (-[WebAVPlayerController endScrubbing:]):
+        (-[WebAVPlayerController seekToTime:]):
+        (-[WebAVPlayerController currentTimeWithinEndTimes]):
+        (-[WebAVPlayerController setCurrentTimeWithinEndTimes:]):
+        (+[WebAVPlayerController keyPathsForValuesAffectingCurrentTimeWithinEndTimes]):
+        (-[WebAVPlayerController hasLiveStreamingContent]):
+        (+[WebAVPlayerController keyPathsForValuesAffectingHasLiveStreamingContent]):
+        (-[WebAVPlayerController skipBackwardThirtySeconds:]):
+        (-[WebAVPlayerController gotoEndOfSeekableRanges:]):
+        (-[WebAVPlayerController canScanForward]):
+        (+[WebAVPlayerController keyPathsForValuesAffectingCanScanForward]):
+        (-[WebAVPlayerController beginScanningForward:]):
+        (-[WebAVPlayerController endScanningForward:]):
+        (-[WebAVPlayerController beginScanningBackward:]):
+        (-[WebAVPlayerController endScanningBackward:]):
+        (-[WebAVPlayerController canSeekToBeginning]):
+        (+[WebAVPlayerController keyPathsForValuesAffectingCanSeekToBeginning]):
+        (-[WebAVPlayerController seekToBeginning:]):
+        (-[WebAVPlayerController seekChapterBackward:]):
+        (-[WebAVPlayerController canSeekToEnd]):
+        (+[WebAVPlayerController keyPathsForValuesAffectingCanSeekToEnd]):
+        (-[WebAVPlayerController seekToEnd:]):
+        (-[WebAVPlayerController seekChapterForward:]):
+        (-[WebAVPlayerController hasMediaSelectionOptions]):
+        (+[WebAVPlayerController keyPathsForValuesAffectingHasMediaSelectionOptions]):
+        (-[WebAVPlayerController hasAudioMediaSelectionOptions]):
+        (+[WebAVPlayerController keyPathsForValuesAffectingHasAudioMediaSelectionOptions]):
+        (-[WebAVPlayerController hasLegibleMediaSelectionOptions]):
+        (+[WebAVPlayerController keyPathsForValuesAffectingHasLegibleMediaSelectionOptions]):
+        (-[WebAVPlayerController currentAudioMediaSelectionOption]):
+        (-[WebAVPlayerController setCurrentAudioMediaSelectionOption:]):
+        (-[WebAVPlayerController currentLegibleMediaSelectionOption]):
+        (-[WebAVPlayerController setCurrentLegibleMediaSelectionOption:]):
+        (-[WebAVPlayerController isPlayingOnExternalScreen]):
+        (+[WebAVPlayerController keyPathsForValuesAffectingPlayingOnExternalScreen]):
+        (-[WebAVPlayerController isPictureInPictureInterrupted]):
+        (-[WebAVPlayerController setPictureInPictureInterrupted:]):
+        * platform/ios/WebPlaybackSessionInterfaceAVKit.h: Added.
+        (WebCore::WebPlaybackSessionInterfaceAVKitClient::~WebPlaybackSessionInterfaceAVKitClient):
+        * platform/ios/WebPlaybackSessionInterfaceAVKit.mm: Added.
+        (WebCore::WebPlaybackSessionInterfaceAVKit::WebPlaybackSessionInterfaceAVKit):
+        (WebCore::WebPlaybackSessionInterfaceAVKit::~WebPlaybackSessionInterfaceAVKit):
+        (WebCore::WebPlaybackSessionInterfaceAVKit::resetMediaState):
+        (WebCore::WebPlaybackSessionInterfaceAVKit::setWebPlaybackSessionModel):
+        (WebCore::WebPlaybackSessionInterfaceAVKit::setDuration):
+        (WebCore::WebPlaybackSessionInterfaceAVKit::setCurrentTime):
+        (WebCore::WebPlaybackSessionInterfaceAVKit::setBufferedTime):
+        (WebCore::WebPlaybackSessionInterfaceAVKit::setRate):
+        (WebCore::WebPlaybackSessionInterfaceAVKit::setSeekableRanges):
+        (WebCore::WebPlaybackSessionInterfaceAVKit::setCanPlayFastReverse):
+        (WebCore::mediaSelectionOptions):
+        (WebCore::WebPlaybackSessionInterfaceAVKit::setAudioMediaSelectionOptions):
+        (WebCore::WebPlaybackSessionInterfaceAVKit::setLegibleMediaSelectionOptions):
+        (WebCore::WebPlaybackSessionInterfaceAVKit::setExternalPlayback):
+        (WebCore::WebPlaybackSessionInterfaceAVKit::setWirelessVideoPlaybackDisabled):
+        (WebCore::WebPlaybackSessionInterfaceAVKit::wirelessVideoPlaybackDisabled):
+        (WebCore::WebPlaybackSessionInterfaceAVKit::invalidate):
+        * platform/ios/WebVideoFullscreenControllerAVKit.mm:
+        (WebVideoFullscreenControllerContext::setUpFullscreen):
+        * platform/ios/WebVideoFullscreenInterfaceAVKit.h:
+        * platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
+        (-[WebAVPlayerViewControllerDelegate fullscreenInterface]):
+        (-[WebAVPlayerViewControllerDelegate setFullscreenInterface:]):
+        (-[WebAVPlayerLayer fullscreenInterface]):
+        (-[WebAVPlayerLayer setFullscreenInterface:]):
+        (-[WebAVPlayerLayer layoutSublayers]):
+        (-[WebAVPlayerLayer resolveBounds]):
+        (-[WebAVPlayerLayer setVideoGravity:]):
+        (WebVideoFullscreenInterfaceAVKit::create):
+        (WebVideoFullscreenInterfaceAVKit::WebVideoFullscreenInterfaceAVKit):
+        (WebVideoFullscreenInterfaceAVKit::~WebVideoFullscreenInterfaceAVKit):
+        (WebVideoFullscreenInterfaceAVKit::playerController):
+        (WebVideoFullscreenInterfaceAVKit::resetMediaState):
+        (WebVideoFullscreenInterfaceAVKit::setDuration):
+        (WebVideoFullscreenInterfaceAVKit::setCurrentTime):
+        (WebVideoFullscreenInterfaceAVKit::setBufferedTime):
+        (WebVideoFullscreenInterfaceAVKit::setRate):
+        (WebVideoFullscreenInterfaceAVKit::setVideoDimensions):
+        (WebVideoFullscreenInterfaceAVKit::setSeekableRanges):
+        (WebVideoFullscreenInterfaceAVKit::setCanPlayFastReverse):
+        (WebVideoFullscreenInterfaceAVKit::setAudioMediaSelectionOptions):
+        (WebVideoFullscreenInterfaceAVKit::setLegibleMediaSelectionOptions):
+        (WebVideoFullscreenInterfaceAVKit::setExternalPlayback):
+        (WebVideoFullscreenInterfaceAVKit::externalPlaybackEnabledChanged):
+        (WebVideoFullscreenInterfaceAVKit::setWirelessVideoPlaybackDisabled):
+        (WebVideoFullscreenInterfaceAVKit::wirelessVideoPlaybackDisabled):
+        (WebVideoFullscreenInterfaceAVKit::setupFullscreen):
+        (WebVideoFullscreenInterfaceAVKit::cleanupFullscreen):
+        (WebVideoFullscreenInterfaceAVKit::mayAutomaticallyShowVideoPictureInPicture):
+        (-[WebAVPlayerViewControllerDelegate playerViewControllerWillStartPictureInPicture:]): Deleted.
+        (-[WebAVPlayerViewControllerDelegate playerViewControllerDidStartPictureInPicture:]): Deleted.
+        (-[WebAVPlayerViewControllerDelegate playerViewControllerFailedToStartPictureInPicture:withError:]): Deleted.
+        (-[WebAVPlayerViewControllerDelegate playerViewControllerWillStopPictureInPicture:]): Deleted.
+        (-[WebAVPlayerViewControllerDelegate playerViewControllerDidStopPictureInPicture:]): Deleted.
+        (convertToExitFullScreenReason): Deleted.
+        (-[WebAVPlayerViewControllerDelegate playerViewController:shouldExitFullScreenWithReason:]): Deleted.
+        (-[WebAVPlayerViewControllerDelegate playerViewController:restoreUserInterfaceForPictureInPictureStopWithCompletionHandler:]): Deleted.
+        (-[WebAVPlayerLayer init]): Deleted.
+        (-[WebAVPlayerLayer dealloc]): Deleted.
+        (-[WebAVPlayerLayer videoGravity]): Deleted.
+        (-[WebAVPlayerLayer videoRect]): Deleted.
+        (+[WebAVPlayerLayer keyPathsForValuesAffectingVideoRect]): Deleted.
+        (WebAVPictureInPicturePlayerLayerView_layerClass): Deleted.
+        (getWebAVPictureInPicturePlayerLayerViewClass): Deleted.
+        (WebAVPlayerLayerView_layerClass): Deleted.
+        (WebAVPlayerLayerView_playerController): Deleted.
+        (WebAVPlayerLayerView_setPlayerController): Deleted.
+        (WebAVPlayerLayerView_videoView): Deleted.
+        (WebAVPlayerLayerView_setVideoView): Deleted.
+        (WebAVPlayerLayerView_startRoutingVideoToPictureInPicturePlayerLayerView): Deleted.
+        (WebAVPlayerLayerView_stopRoutingVideoToPictureInPicturePlayerLayerView): Deleted.
+        (WebAVPlayerLayerView_pictureInPicturePlayerLayerView): Deleted.
+        (WebAVPlayerLayerView_dealloc): Deleted.
+        (getWebAVPlayerLayerViewClass): Deleted.
+        (WebVideoFullscreenInterfaceAVKit::setWebVideoFullscreenModel): Deleted.
+        (WebVideoFullscreenInterfaceAVKit::setWebVideoFullscreenChangeObserver): Deleted.
+        (WebVideoFullscreenInterfaceAVKit::applicationDidBecomeActive): Deleted.
+        (WebVideoFullscreenInterfaceAVKit::enterFullscreen): Deleted.
+        (WebVideoFullscreenInterfaceAVKit::enterFullscreenStandard): Deleted.
+        (WebVideoFullscreenInterfaceAVKit::exitFullscreen): Deleted.
+        (WebVideoFullscreenInterfaceAVKit::didStartPictureInPicture): Deleted.
+        (WebVideoFullscreenInterfaceAVKit::failedToStartPictureInPicture): Deleted.
+        (WebVideoFullscreenInterfaceAVKit::willStopPictureInPicture): Deleted.
+        (WebVideoFullscreenInterfaceAVKit::didStopPictureInPicture): Deleted.
+        (WebVideoFullscreenInterfaceAVKit::prepareForPictureInPictureStopWithCompletionHandler): Deleted.
+        (WebVideoFullscreenInterfaceAVKit::shouldExitFullscreenWithReason): Deleted.
+        (WebVideoFullscreenInterfaceAVKit::watchdogTimerFired): Deleted.
+        (WebVideoFullscreenInterfaceAVKit::setMode): Deleted.
+        (WebVideoFullscreenInterfaceAVKit::clearMode): Deleted.
+        (WebCore::supportsPictureInPicture): Deleted.
+        * platform/mac/WebPlaybackSessionInterfaceMac.h: Added.
+        * platform/mac/WebPlaybackSessionInterfaceMac.mm: Copied from Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.mm.
+        (-[WebAVMediaSelectionOptionMac localizedDisplayName]):
+        (-[WebAVMediaSelectionOptionMac setLocalizedDisplayName:]):
+        (-[WebPlaybackControlsManager initWithWebPlaybackSessionInterfaceMac:]):
+        (-[WebPlaybackControlsManager timing]):
+        (-[WebPlaybackControlsManager setTiming:]):
+        (-[WebPlaybackControlsManager seekableTimeRanges]):
+        (-[WebPlaybackControlsManager setSeekableTimeRanges:]):
+        (-[WebPlaybackControlsManager isSeeking]):
+        (-[WebPlaybackControlsManager seekToTime:toleranceBefore:toleranceAfter:]):
+        (-[WebPlaybackControlsManager audioMediaSelectionOptions]):
+        (-[WebPlaybackControlsManager setAudioMediaSelectionOptions:]):
+        (-[WebPlaybackControlsManager currentAudioMediaSelectionOption]):
+        (-[WebPlaybackControlsManager setCurrentAudioMediaSelectionOption:]):
+        (-[WebPlaybackControlsManager legibleMediaSelectionOptions]):
+        (-[WebPlaybackControlsManager setLegibleMediaSelectionOptions:]):
+        (-[WebPlaybackControlsManager currentLegibleMediaSelectionOption]):
+        (-[WebPlaybackControlsManager setCurrentLegibleMediaSelectionOption:]):
+        (-[WebPlaybackControlsManager cancelThumbnailAndAudioAmplitudeSampleGeneration]):
+        (WebCore::WebPlaybackSessionInterfaceMac::~WebPlaybackSessionInterfaceMac):
+        (WebCore::WebPlaybackSessionInterfaceMac::setWebPlaybackSessionModel):
+        (WebCore::WebPlaybackSessionInterfaceMac::setDuration):
+        (WebCore::WebPlaybackSessionInterfaceMac::setCurrentTime):
+        (WebCore::WebPlaybackSessionInterfaceMac::setRate):
+        (WebCore::WebPlaybackSessionInterfaceMac::setSeekableRanges):
+        (WebCore::mediaSelectionOptions):
+        (WebCore::WebPlaybackSessionInterfaceMac::setAudioMediaSelectionOptions):
+        (WebCore::WebPlaybackSessionInterfaceMac::setLegibleMediaSelectionOptions):
+        (WebCore::WebPlaybackSessionInterfaceMac::invalidate):
+        (WebCore::WebPlaybackSessionInterfaceMac::ensureControlsManager):
+        (WebCore::WebPlaybackSessionInterfaceMac::playBackControlsManager):
+        * platform/mac/WebVideoFullscreenInterfaceMac.h:
+        * platform/mac/WebVideoFullscreenInterfaceMac.mm:
+        (WebCore::WebVideoFullscreenInterfaceMac::WebVideoFullscreenInterfaceMac):
+        (WebCore::WebVideoFullscreenInterfaceMac::setWebVideoFullscreenModel):
+        (WebCore::WebVideoFullscreenInterfaceMac::setDuration):
+        (WebCore::WebVideoFullscreenInterfaceMac::setCurrentTime):
+        (WebCore::WebVideoFullscreenInterfaceMac::setRate):
+        (WebCore::WebVideoFullscreenInterfaceMac::setSeekableRanges):
+        (WebCore::WebVideoFullscreenInterfaceMac::setAudioMediaSelectionOptions):
+        (WebCore::WebVideoFullscreenInterfaceMac::setLegibleMediaSelectionOptions):
+        (WebCore::WebVideoFullscreenInterfaceMac::ensureControlsManager):
+        (WebCore::WebVideoFullscreenInterfaceMac::~WebVideoFullscreenInterfaceMac): Deleted.
+        (WebCore::WebVideoFullscreenInterfaceMac::setWebVideoFullscreenChangeObserver): Deleted.
+        (WebCore::WebVideoFullscreenInterfaceMac::setMode): Deleted.
+        (WebCore::WebVideoFullscreenInterfaceMac::clearMode): Deleted.
+        (WebCore::WebVideoFullscreenInterfaceMac::setupFullscreen): Deleted.
+        (WebCore::WebVideoFullscreenInterfaceMac::enterFullscreen): Deleted.
+        (WebCore::WebVideoFullscreenInterfaceMac::exitFullscreen): Deleted.
+        (WebCore::WebVideoFullscreenInterfaceMac::exitFullscreenWithoutAnimationToMode): Deleted.
+        (WebCore::WebVideoFullscreenInterfaceMac::cleanupFullscreen): Deleted.
+        (WebCore::WebVideoFullscreenInterfaceMac::invalidate): Deleted.
+        (WebCore::WebVideoFullscreenInterfaceMac::preparedToReturnToInline): Deleted.
+        (WebCore::WebVideoFullscreenInterfaceMac::setVideoDimensions): Deleted.
+        (WebCore::supportsPictureInPicture): Deleted.
+
</ins><span class="cx"> 2016-04-15  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [COCOA] Do not unnecessarily initialize ResourceResponse::m_httpVersion as part of common fields
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (199592 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-04-15 17:18:12 UTC (rev 199592)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -6083,6 +6083,15 @@
</span><span class="cx">                 CDA07FBE18E0A16A004699FA /* SystemSleepListener.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA07FBC18E0A16A004699FA /* SystemSleepListener.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 CDA07FC118E0A22B004699FA /* SystemSleepListenerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDA07FBF18E0A22B004699FA /* SystemSleepListenerMac.mm */; };
</span><span class="cx">                 CDA07FC218E0A22B004699FA /* SystemSleepListenerMac.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA07FC018E0A22B004699FA /* SystemSleepListenerMac.h */; };
</span><ins>+                CDA29A091CBD99F400901CCF /* WebPlaybackSessionInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA29A081CBD99F400901CCF /* WebPlaybackSessionInterface.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                CDA29A0B1CBD9A7400901CCF /* WebPlaybackSessionModel.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA29A0A1CBD9A7400901CCF /* WebPlaybackSessionModel.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                CDA29A0E1CBD9CFE00901CCF /* WebPlaybackSessionModelMediaElement.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDA29A0C1CBD9CFE00901CCF /* WebPlaybackSessionModelMediaElement.mm */; };
+                CDA29A0F1CBD9CFE00901CCF /* WebPlaybackSessionModelMediaElement.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA29A0D1CBD9CFE00901CCF /* WebPlaybackSessionModelMediaElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                CDA29A161CBDA56C00901CCF /* WebPlaybackSessionInterfaceMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDA29A141CBDA56C00901CCF /* WebPlaybackSessionInterfaceMac.mm */; };
+                CDA29A171CBDA56C00901CCF /* WebPlaybackSessionInterfaceMac.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA29A151CBDA56C00901CCF /* WebPlaybackSessionInterfaceMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                CDA29A301CBF74D400901CCF /* WebPlaybackSessionInterfaceAVKit.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDA29A2F1CBF73FC00901CCF /* WebPlaybackSessionInterfaceAVKit.mm */; };
+                CDA29A311CBF74DA00901CCF /* WebAVPlayerController.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDA29A2D1CBF73FC00901CCF /* WebAVPlayerController.mm */; };
+                CDA29A321CC01A9500901CCF /* WebPlaybackSessionInterfaceAVKit.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA29A2E1CBF73FC00901CCF /* WebPlaybackSessionInterfaceAVKit.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 CDA79824170A258300D45C55 /* AudioSession.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDA79823170A258300D45C55 /* AudioSession.cpp */; };
</span><span class="cx">                 CDA79827170A279100D45C55 /* AudioSessionIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDA79825170A279000D45C55 /* AudioSessionIOS.mm */; };
</span><span class="cx">                 CDA7982A170A3D0000D45C55 /* AudioSession.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA79821170A22DC00D45C55 /* AudioSession.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -14051,6 +14060,16 @@
</span><span class="cx">                 CDA07FBC18E0A16A004699FA /* SystemSleepListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SystemSleepListener.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CDA07FBF18E0A22B004699FA /* SystemSleepListenerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SystemSleepListenerMac.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CDA07FC018E0A22B004699FA /* SystemSleepListenerMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SystemSleepListenerMac.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                CDA29A081CBD99F400901CCF /* WebPlaybackSessionInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPlaybackSessionInterface.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CDA29A0A1CBD9A7400901CCF /* WebPlaybackSessionModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPlaybackSessionModel.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CDA29A0C1CBD9CFE00901CCF /* WebPlaybackSessionModelMediaElement.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPlaybackSessionModelMediaElement.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CDA29A0D1CBD9CFE00901CCF /* WebPlaybackSessionModelMediaElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPlaybackSessionModelMediaElement.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CDA29A141CBDA56C00901CCF /* WebPlaybackSessionInterfaceMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPlaybackSessionInterfaceMac.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CDA29A151CBDA56C00901CCF /* WebPlaybackSessionInterfaceMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPlaybackSessionInterfaceMac.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CDA29A2C1CBF73FC00901CCF /* WebAVPlayerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAVPlayerController.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CDA29A2D1CBF73FC00901CCF /* WebAVPlayerController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebAVPlayerController.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CDA29A2E1CBF73FC00901CCF /* WebPlaybackSessionInterfaceAVKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPlaybackSessionInterfaceAVKit.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CDA29A2F1CBF73FC00901CCF /* WebPlaybackSessionInterfaceAVKit.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPlaybackSessionInterfaceAVKit.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 CDA79821170A22DC00D45C55 /* AudioSession.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AudioSession.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CDA79823170A258300D45C55 /* AudioSession.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudioSession.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CDA79825170A279000D45C55 /* AudioSessionIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AudioSessionIOS.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -17871,6 +17890,8 @@
</span><span class="cx">                                 BE8560510701F91100239769 /* WebCoreView.m */,
</span><span class="cx">                                 E1A3162B134BC32D007C9A4F /* WebNSAttributedStringExtras.h */,
</span><span class="cx">                                 E1A3162C134BC32D007C9A4F /* WebNSAttributedStringExtras.mm */,
</span><ins>+                                CDA29A151CBDA56C00901CCF /* WebPlaybackSessionInterfaceMac.h */,
+                                CDA29A141CBDA56C00901CCF /* WebPlaybackSessionInterfaceMac.mm */,
</ins><span class="cx">                                 CD8203061395AB6A00F956C6 /* WebVideoFullscreenController.h */,
</span><span class="cx">                                 CD8203071395AB6A00F956C6 /* WebVideoFullscreenController.mm */,
</span><span class="cx">                                 CD8203081395AB6A00F956C6 /* WebVideoFullscreenHUDWindowController.h */,
</span><span class="lines">@@ -19955,11 +19976,15 @@
</span><span class="cx">                                 44C9919E0F3D210E00586670 /* ThemeIOS.mm */,
</span><span class="cx">                                 1F72BF08187FD4270009BCB3 /* TileControllerMemoryHandlerIOS.cpp */,
</span><span class="cx">                                 1F72BF09187FD4270009BCB3 /* TileControllerMemoryHandlerIOS.h */,
</span><ins>+                                CDA29A2C1CBF73FC00901CCF /* WebAVPlayerController.h */,
+                                CDA29A2D1CBF73FC00901CCF /* WebAVPlayerController.mm */,
</ins><span class="cx">                                 31403797124BEA7F00AF40E4 /* WebCoreMotionManager.h */,
</span><span class="cx">                                 31403798124BEA7F00AF40E4 /* WebCoreMotionManager.mm */,
</span><span class="cx">                                 E45390380EAFD637003695C8 /* WebCoreSystemInterfaceIOS.mm */,
</span><span class="cx">                                 FE0D84E810484348001A179E /* WebEvent.h */,
</span><span class="cx">                                 FE0D84EA1048436E001A179E /* WebEvent.mm */,
</span><ins>+                                CDA29A2E1CBF73FC00901CCF /* WebPlaybackSessionInterfaceAVKit.h */,
+                                CDA29A2F1CBF73FC00901CCF /* WebPlaybackSessionInterfaceAVKit.mm */,
</ins><span class="cx">                                 A502C5DD13049B3500FC7D53 /* WebSafeGCActivityCallbackIOS.h */,
</span><span class="cx">                                 C2C4CB1D161A131200D214DA /* WebSafeIncrementalSweeperIOS.h */,
</span><span class="cx">                                 3F42B31B1881191B00278AAC /* WebVideoFullscreenControllerAVKit.h */,
</span><span class="lines">@@ -20008,6 +20033,10 @@
</span><span class="cx">                                 CDC979F31C498C0900DB50D4 /* WebCoreNSErrorExtras.h */,
</span><span class="cx">                                 CDC979F21C498C0900DB50D4 /* WebCoreNSErrorExtras.mm */,
</span><span class="cx">                                 1A7E19441C5863BE00CCDDF3 /* WebKitAdditions.mm */,
</span><ins>+                                CDA29A081CBD99F400901CCF /* WebPlaybackSessionInterface.h */,
+                                CDA29A0A1CBD9A7400901CCF /* WebPlaybackSessionModel.h */,
+                                CDA29A0C1CBD9CFE00901CCF /* WebPlaybackSessionModelMediaElement.mm */,
+                                CDA29A0D1CBD9CFE00901CCF /* WebPlaybackSessionModelMediaElement.h */,
</ins><span class="cx">                                 52B0D4BF1C57FD660077CE53 /* WebVideoFullscreenChangeObserver.h */,
</span><span class="cx">                                 52131E581C4F15220033F802 /* WebVideoFullscreenInterface.h */,
</span><span class="cx">                                 52D5A1A41C57488900DE34A3 /* WebVideoFullscreenModel.h */,
</span><span class="lines">@@ -25224,6 +25253,7 @@
</span><span class="cx">                                 C37CDEBD149EF2030042090D /* ColorChooserClient.h in Headers */,
</span><span class="cx">                                 F55B3DB41251F12D003EF269 /* ColorInputType.h in Headers */,
</span><span class="cx">                                 EDE3A5000C7A430600956A37 /* ColorMac.h in Headers */,
</span><ins>+                                CDA29A0F1CBD9CFE00901CCF /* WebPlaybackSessionModelMediaElement.h in Headers */,
</ins><span class="cx">                                 9382DF5810A8D5C900925652 /* ColorSpace.h in Headers */,
</span><span class="cx">                                 BCDD454E1236C95C009A7985 /* ColumnInfo.h in Headers */,
</span><span class="cx">                                 43EDD67F1B485DBF00640E75 /* CombinedFiltersAlphabet.h in Headers */,
</span><span class="lines">@@ -25378,6 +25408,7 @@
</span><span class="cx">                                 A80E6CFA0A1989CA007FB8C5 /* CSSImageValue.h in Headers */,
</span><span class="cx">                                 A80E6CF60A1989CA007FB8C5 /* CSSImportRule.h in Headers */,
</span><span class="cx">                                 A80E6D010A1989CA007FB8C5 /* CSSInheritedValue.h in Headers */,
</span><ins>+                                CDA29A091CBD99F400901CCF /* WebPlaybackSessionInterface.h in Headers */,
</ins><span class="cx">                                 A80E6D080A1989CA007FB8C5 /* CSSInitialValue.h in Headers */,
</span><span class="cx">                                 31288E730E3005D6003619AE /* CSSKeyframeRule.h in Headers */,
</span><span class="cx">                                 31288E750E3005D6003619AE /* CSSKeyframesRule.h in Headers */,
</span><span class="lines">@@ -27495,6 +27526,7 @@
</span><span class="cx">                                 4A0FFAA61AAF5EF60062803B /* RealtimeMediaSourceCenterMac.h in Headers */,
</span><span class="cx">                                 4A4F65741AA997F100E38CDD /* RealtimeMediaSourceSettings.h in Headers */,
</span><span class="cx">                                 07C1C0E51BFB60ED00BD2256 /* RealtimeMediaSourceSupportedConstraints.h in Headers */,
</span><ins>+                                CDA29A0B1CBD9A7400901CCF /* WebPlaybackSessionModel.h in Headers */,
</ins><span class="cx">                                 BC4368E80C226E32005EFB5F /* Rect.h in Headers */,
</span><span class="cx">                                 FD45A958175D414C00C21EC8 /* RectangleShape.h in Headers */,
</span><span class="cx">                                 9831AE4A154225C900FE2644 /* ReferrerPolicy.h in Headers */,
</span><span class="lines">@@ -28265,6 +28297,7 @@
</span><span class="cx">                                 B2C3DA400D006C1D00EF6F26 /* TextCodecUserDefined.h in Headers */,
</span><span class="cx">                                 B2C3DA420D006C1D00EF6F26 /* TextCodecUTF16.h in Headers */,
</span><span class="cx">                                 9343CB8212F25E510033C5EE /* TextCodecUTF8.h in Headers */,
</span><ins>+                                CDA29A171CBDA56C00901CCF /* WebPlaybackSessionInterfaceMac.h in Headers */,
</ins><span class="cx">                                 142B97CA13138943008BEF4B /* TextControlInnerElements.h in Headers */,
</span><span class="cx">                                 582DE3251C30C85400BE02A8 /* TextDecorationPainter.h in Headers */,
</span><span class="cx">                                 97BC84B412371180000C6161 /* TextDocument.h in Headers */,
</span><span class="lines">@@ -28542,6 +28575,7 @@
</span><span class="cx">                                 1CAF34810A6C405200ABE06E /* WebScriptObject.h in Headers */,
</span><span class="cx">                                 1CAF34830A6C405200ABE06E /* WebScriptObjectPrivate.h in Headers */,
</span><span class="cx">                                 1A569D1B0D7E2B82007C3983 /* WebScriptObjectProtocol.h in Headers */,
</span><ins>+                                CDA29A321CC01A9500901CCF /* WebPlaybackSessionInterfaceAVKit.h in Headers */,
</ins><span class="cx">                                 97AABD1B14FA09D5007457AE /* WebSocket.h in Headers */,
</span><span class="cx">                                 97AABD1E14FA09D5007457AE /* WebSocketChannel.h in Headers */,
</span><span class="cx">                                 97AABD1F14FA09D5007457AE /* WebSocketChannelClient.h in Headers */,
</span><span class="lines">@@ -28966,6 +29000,7 @@
</span><span class="cx">                                 31A795C81888BCB500382F90 /* ANGLEInstancedArrays.cpp in Sources */,
</span><span class="cx">                                 490707E61219C04300D90E51 /* ANGLEWebKitBridge.cpp in Sources */,
</span><span class="cx">                                 49E912AA0EFAC906009D0CAF /* Animation.cpp in Sources */,
</span><ins>+                                CDA29A0E1CBD9CFE00901CCF /* WebPlaybackSessionModelMediaElement.mm in Sources */,
</ins><span class="cx">                                 316FE1110E6E1DA700BF6088 /* AnimationBase.cpp in Sources */,
</span><span class="cx">                                 316FE1130E6E1DA700BF6088 /* AnimationController.cpp in Sources */,
</span><span class="cx">                                 319848021A1D818100A13318 /* AnimationEvent.cpp in Sources */,
</span><span class="lines">@@ -31039,6 +31074,7 @@
</span><span class="cx">                                 FE9E89FB16E2DC0500A908F8 /* OriginLock.cpp in Sources */,
</span><span class="cx">                                 FD581FAE1520F91F003A7A75 /* OscillatorNode.cpp in Sources */,
</span><span class="cx">                                 1A0D57360A5C77FE007EDD4C /* OverflowEvent.cpp in Sources */,
</span><ins>+                                CDA29A301CBF74D400901CCF /* WebPlaybackSessionInterfaceAVKit.mm in Sources */,
</ins><span class="cx">                                 65FEA86909833ADE00BED4AB /* Page.cpp in Sources */,
</span><span class="cx">                                 1477E7760BF4134A00152872 /* PageCache.cpp in Sources */,
</span><span class="cx">                                 CD5E5B611A15F156000C609E /* PageConfiguration.cpp in Sources */,
</span><span class="lines">@@ -31657,6 +31693,7 @@
</span><span class="cx">                                 B2227A140D00BF220071B782 /* SVGFontFaceElement.cpp in Sources */,
</span><span class="cx">                                 B2227A170D00BF220071B782 /* SVGFontFaceFormatElement.cpp in Sources */,
</span><span class="cx">                                 B2227A1A0D00BF220071B782 /* SVGFontFaceNameElement.cpp in Sources */,
</span><ins>+                                CDA29A161CBDA56C00901CCF /* WebPlaybackSessionInterfaceMac.mm in Sources */,
</ins><span class="cx">                                 B2227A1D0D00BF220071B782 /* SVGFontFaceSrcElement.cpp in Sources */,
</span><span class="cx">                                 B2227A200D00BF220071B782 /* SVGFontFaceUriElement.cpp in Sources */,
</span><span class="cx">                                 B2227A230D00BF220071B782 /* SVGForeignObjectElement.cpp in Sources */,
</span><span class="lines">@@ -31791,6 +31828,7 @@
</span><span class="cx">                                 9759E93F14EF1CF80026A2DD /* TextTrack.cpp in Sources */,
</span><span class="cx">                                 516103B01CADBA7A0016B4C7 /* IDBValue.cpp in Sources */,
</span><span class="cx">                                 9759E94214EF1CF80026A2DD /* TextTrackCue.cpp in Sources */,
</span><ins>+                                CDA29A311CBF74DA00901CCF /* WebAVPlayerController.mm in Sources */,
</ins><span class="cx">                                 071A9EC2168FBC43002629F9 /* TextTrackCueGeneric.cpp in Sources */,
</span><span class="cx">                                 9759E94514EF1CF80026A2DD /* TextTrackCueList.cpp in Sources */,
</span><span class="cx">                                 076970861463AD8700F502CF /* TextTrackList.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (199592 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.cpp        2016-04-15 17:18:12 UTC (rev 199592)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -4826,7 +4826,7 @@
</span><span class="cx">     if (shouldBePlaying) {
</span><span class="cx">         if (document().page() &amp;&amp; m_mediaSession-&gt;canControlControlsManager(*this)) {
</span><span class="cx">             HTMLVideoElement&amp; asVideo = downcast&lt;HTMLVideoElement&gt;(*this);
</span><del>-            document().page()-&gt;chrome().client().setUpVideoControlsManager(asVideo);
</del><ins>+            document().page()-&gt;chrome().client().setUpPlaybackControlsManager(asVideo);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         setDisplayMode(Video);
</span><span class="lines">@@ -4862,7 +4862,7 @@
</span><span class="cx">         setPlaying(true);
</span><span class="cx">     } else {
</span><span class="cx">         if (endedPlayback() &amp;&amp; document().page() &amp;&amp; is&lt;HTMLVideoElement&gt;(*this))
</span><del>-            document().page()-&gt;chrome().client().clearVideoControlsManager();
</del><ins>+            document().page()-&gt;chrome().client().clearPlaybackControlsManager(*this);
</ins><span class="cx"> 
</span><span class="cx">         if (!playerPaused)
</span><span class="cx">             m_player-&gt;pause();
</span></span></pre></div>
<a id="trunkSourceWebCorepageChromeClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/ChromeClient.h (199592 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/ChromeClient.h        2016-04-15 17:18:12 UTC (rev 199592)
+++ trunk/Source/WebCore/page/ChromeClient.h        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -341,8 +341,8 @@
</span><span class="cx">     virtual bool supportsVideoFullscreen(HTMLMediaElementEnums::VideoFullscreenMode) { return false; }
</span><span class="cx"> #if ENABLE(VIDEO)
</span><span class="cx">     virtual void enterVideoFullscreenForVideoElement(HTMLVideoElement&amp;, HTMLMediaElementEnums::VideoFullscreenMode) { }
</span><del>-    virtual void setUpVideoControlsManager(HTMLVideoElement&amp;) { }
-    virtual void clearVideoControlsManager() { }
</del><ins>+    virtual void setUpPlaybackControlsManager(HTMLMediaElement&amp;) { }
+    virtual void clearPlaybackControlsManager(HTMLMediaElement&amp;) { }
</ins><span class="cx"> #endif
</span><span class="cx">     virtual void exitVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&amp;) { }
</span><span class="cx">     virtual void exitVideoFullscreenToModeWithoutAnimation(WebCore::HTMLVideoElement&amp;, HTMLMediaElementEnums::VideoFullscreenMode /*targetMode*/) { }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaWebPlaybackSessionInterfacehfromrev199592trunkSourceWebCoreplatformcocoaWebVideoFullscreenInterfaceh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionInterface.h (from rev 199592, trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenInterface.h) (0 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionInterface.h                                (rev 0)
+++ trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionInterface.h        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -0,0 +1,63 @@
</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.
+ */
+
+#ifndef WebPlaybackSessionInterface_h
+#define WebPlaybackSessionInterface_h
+
+#if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
+
+#include &lt;wtf/Vector.h&gt;
+
+namespace WTF {
+class String;
+}
+
+namespace WebCore {
+
+class TimeRanges;
+
+class WebPlaybackSessionInterface {
+public:
+    enum ExternalPlaybackTargetType { TargetTypeNone, TargetTypeAirPlay, TargetTypeTVOut };
+
+    virtual ~WebPlaybackSessionInterface() { };
+    virtual void resetMediaState() = 0;
+    virtual void setDuration(double) = 0;
+    virtual void setCurrentTime(double currentTime, double anchorTime) = 0;
+    virtual void setBufferedTime(double) = 0;
+    virtual void setRate(bool isPlaying, float playbackRate) = 0;
+    virtual void setSeekableRanges(const TimeRanges&amp;) = 0;
+    virtual void setCanPlayFastReverse(bool) = 0;
+    virtual void setAudioMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex) = 0;
+    virtual void setLegibleMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex) = 0;
+    virtual void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, WTF::String localizedDeviceName) = 0;
+    virtual void setWirelessVideoPlaybackDisabled(bool) = 0;
+};
+
+}
+
+#endif // PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaWebPlaybackSessionModelh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModel.h (0 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModel.h                                (rev 0)
+++ trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModel.h        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -0,0 +1,54 @@
</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.
+ */
+
+#ifndef WebPlaybackSessionModel_h
+#define WebPlaybackSessionModel_h
+
+#if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
+
+namespace WebCore {
+
+class WebPlaybackSessionModel {
+public:
+    virtual ~WebPlaybackSessionModel() { };
+    virtual void play() = 0;
+    virtual void pause() = 0;
+    virtual void togglePlayState() = 0;
+    virtual void beginScrubbing() = 0;
+    virtual void endScrubbing() = 0;
+    virtual void seekToTime(double time) = 0;
+    virtual void fastSeek(double time) = 0;
+    virtual void beginScanningForward() = 0;
+    virtual void beginScanningBackward() = 0;
+    virtual void endScanning() = 0;
+    virtual void selectAudioMediaOption(uint64_t index) = 0;
+    virtual void selectLegibleMediaOption(uint64_t index) = 0;
+};
+
+}
+
+#endif // PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaWebPlaybackSessionModelMediaElementh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.h (0 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.h                                (rev 0)
+++ trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.h        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -0,0 +1,91 @@
</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.
+ */
+
+#ifndef WebPlaybackSessionModelMediaElement_h
+#define WebPlaybackSessionModelMediaElement_h
+#if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
+
+#include &quot;EventListener.h&quot;
+#include &quot;HTMLMediaElementEnums.h&quot;
+#include &quot;WebPlaybackSessionModel.h&quot;
+#include &lt;wtf/RefPtr.h&gt;
+#include &lt;wtf/RetainPtr.h&gt;
+#include &lt;wtf/Vector.h&gt;
+
+namespace WebCore {
+class AudioTrack;
+class HTMLMediaElement;
+class TextTrack;
+class WebPlaybackSessionInterface;
+
+class WebPlaybackSessionModelMediaElement final : public WebPlaybackSessionModel, public EventListener {
+public:
+    static Ref&lt;WebPlaybackSessionModelMediaElement&gt; create()
+    {
+        return adoptRef(*new WebPlaybackSessionModelMediaElement());
+    }
+    WEBCORE_EXPORT virtual ~WebPlaybackSessionModelMediaElement();
+    WEBCORE_EXPORT void setWebPlaybackSessionInterface(WebPlaybackSessionInterface*);
+    WEBCORE_EXPORT void setMediaElement(HTMLMediaElement*);
+    WEBCORE_EXPORT HTMLMediaElement* mediaElement() const { return m_mediaElement.get(); }
+
+    WEBCORE_EXPORT void handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event*) final;
+    void updateForEventName(const WTF::AtomicString&amp;);
+    bool operator==(const EventListener&amp; rhs) final { return static_cast&lt;WebCore::EventListener*&gt;(this) == &amp;rhs; }
+
+    WEBCORE_EXPORT void play() final;
+    WEBCORE_EXPORT void pause() final;
+    WEBCORE_EXPORT void togglePlayState() final;
+    WEBCORE_EXPORT void beginScrubbing() final;
+    WEBCORE_EXPORT void endScrubbing() final;
+    WEBCORE_EXPORT void seekToTime(double time) final;
+    WEBCORE_EXPORT void fastSeek(double time) final;
+    WEBCORE_EXPORT void beginScanningForward() final;
+    WEBCORE_EXPORT void beginScanningBackward() final;
+    WEBCORE_EXPORT void endScanning() final;
+    WEBCORE_EXPORT void selectAudioMediaOption(uint64_t index) final;
+    WEBCORE_EXPORT void selectLegibleMediaOption(uint64_t index) final;
+
+protected:
+    WEBCORE_EXPORT WebPlaybackSessionModelMediaElement();
+
+private:
+    static const Vector&lt;WTF::AtomicString&gt;&amp; observedEventNames();
+    const WTF::AtomicString&amp; eventNameAll();
+
+    RefPtr&lt;HTMLMediaElement&gt; m_mediaElement;
+    bool m_isListening { false };
+    WebPlaybackSessionInterface* m_playbackSessionInterface { nullptr };
+    Vector&lt;RefPtr&lt;TextTrack&gt;&gt; m_legibleTracksForMenu;
+    Vector&lt;RefPtr&lt;AudioTrack&gt;&gt; m_audioTracksForMenu;
+    
+    void updateLegibleOptions();
+};
+    
+}
+
+#endif
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaWebPlaybackSessionModelMediaElementmm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.mm (0 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.mm                                (rev 0)
+++ trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.mm        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -0,0 +1,336 @@
</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.
+ */
+
+#import &quot;config.h&quot;
+#import &quot;WebPlaybackSessionModelMediaElement.h&quot;
+
+#if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
+
+#import &quot;DOMEventInternal.h&quot;
+#import &quot;Logging.h&quot;
+#import &quot;MediaControlsHost.h&quot;
+#import &quot;WebVideoFullscreenInterface.h&quot;
+#import &lt;QuartzCore/CoreAnimation.h&gt;
+#import &lt;WebCore/DOMEventListener.h&gt;
+#import &lt;WebCore/Event.h&gt;
+#import &lt;WebCore/EventListener.h&gt;
+#import &lt;WebCore/EventNames.h&gt;
+#import &lt;WebCore/HTMLElement.h&gt;
+#import &lt;WebCore/HTMLMediaElement.h&gt;
+#import &lt;WebCore/Page.h&gt;
+#import &lt;WebCore/PageGroup.h&gt;
+#import &lt;WebCore/SoftLinking.h&gt;
+#import &lt;WebCore/TextTrackList.h&gt;
+#import &lt;WebCore/TimeRanges.h&gt;
+#import &lt;wtf/NeverDestroyed.h&gt;
+#import &lt;wtf/RetainPtr.h&gt;
+
+using namespace WebCore;
+
+WebPlaybackSessionModelMediaElement::WebPlaybackSessionModelMediaElement()
+    : EventListener(EventListener::CPPEventListenerType)
+{
+}
+
+WebPlaybackSessionModelMediaElement::~WebPlaybackSessionModelMediaElement()
+{
+}
+
+void WebPlaybackSessionModelMediaElement::setWebPlaybackSessionInterface(WebPlaybackSessionInterface* interface)
+{
+    if (interface == m_playbackSessionInterface)
+        return;
+
+    m_playbackSessionInterface = interface;
+
+    if (m_playbackSessionInterface) {
+        m_playbackSessionInterface-&gt;resetMediaState();
+        if (m_mediaElement)
+            m_playbackSessionInterface-&gt;setWirelessVideoPlaybackDisabled(m_mediaElement-&gt;mediaSession().wirelessVideoPlaybackDisabled(*m_mediaElement));
+    }
+}
+
+void WebPlaybackSessionModelMediaElement::setMediaElement(HTMLMediaElement* mediaElement)
+{
+    if (m_mediaElement == mediaElement)
+        return;
+
+    if (m_playbackSessionInterface)
+        m_playbackSessionInterface-&gt;resetMediaState();
+
+    if (m_mediaElement &amp;&amp; m_isListening) {
+        for (auto&amp; eventName : observedEventNames())
+            m_mediaElement-&gt;removeEventListener(eventName, this, false);
+    }
+    m_isListening = false;
+
+    m_mediaElement = mediaElement;
+
+    if (!m_mediaElement)
+        return;
+
+    for (auto&amp; eventName : observedEventNames())
+        m_mediaElement-&gt;addEventListener(eventName, this, false);
+    m_isListening = true;
+
+    updateForEventName(eventNameAll());
+
+    if (m_playbackSessionInterface)
+        m_playbackSessionInterface-&gt;setWirelessVideoPlaybackDisabled(m_mediaElement-&gt;mediaSession().wirelessVideoPlaybackDisabled(*m_mediaElement));
+}
+
+void WebPlaybackSessionModelMediaElement::handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event* event)
+{
+    updateForEventName(event-&gt;type());
+}
+
+void WebPlaybackSessionModelMediaElement::updateForEventName(const WTF::AtomicString&amp; eventName)
+{
+    if (!m_mediaElement || !m_playbackSessionInterface)
+        return;
+
+    bool all = eventName == eventNameAll();
+
+    if (all
+        || eventName == eventNames().durationchangeEvent) {
+        m_playbackSessionInterface-&gt;setDuration(m_mediaElement-&gt;duration());
+        // These is no standard event for minFastReverseRateChange; duration change is a reasonable proxy for it.
+        // It happens every time a new item becomes ready to play.
+        m_playbackSessionInterface-&gt;setCanPlayFastReverse(m_mediaElement-&gt;minFastReverseRate() &lt; 0.0);
+    }
+
+    if (all
+        || eventName == eventNames().pauseEvent
+        || eventName == eventNames().playEvent
+        || eventName == eventNames().ratechangeEvent)
+        m_playbackSessionInterface-&gt;setRate(!m_mediaElement-&gt;paused(), m_mediaElement-&gt;playbackRate());
+
+    if (all
+        || eventName == eventNames().timeupdateEvent) {
+        m_playbackSessionInterface-&gt;setCurrentTime(m_mediaElement-&gt;currentTime(), [[NSProcessInfo processInfo] systemUptime]);
+        m_playbackSessionInterface-&gt;setBufferedTime(m_mediaElement-&gt;maxBufferedTime());
+        // FIXME: 130788 - find a better event to update seekable ranges from.
+        m_playbackSessionInterface-&gt;setSeekableRanges(*m_mediaElement-&gt;seekable());
+    }
+
+    if (all
+        || eventName == eventNames().addtrackEvent
+        || eventName == eventNames().removetrackEvent)
+        updateLegibleOptions();
+
+    if (all
+        || eventName == eventNames().webkitcurrentplaybacktargetiswirelesschangedEvent) {
+        bool enabled = m_mediaElement-&gt;webkitCurrentPlaybackTargetIsWireless();
+        WebPlaybackSessionInterface::ExternalPlaybackTargetType targetType = WebPlaybackSessionInterface::TargetTypeNone;
+        String localizedDeviceName;
+
+        if (m_mediaElement-&gt;mediaControlsHost()) {
+            static NeverDestroyed&lt;String&gt; airplay(ASCIILiteral(&quot;airplay&quot;));
+            static NeverDestroyed&lt;String&gt; tvout(ASCIILiteral(&quot;tvout&quot;));
+
+            String type = m_mediaElement-&gt;mediaControlsHost()-&gt;externalDeviceType();
+            if (type == airplay)
+                targetType = WebPlaybackSessionInterface::TargetTypeAirPlay;
+            else if (type == tvout)
+                targetType = WebPlaybackSessionInterface::TargetTypeTVOut;
+            localizedDeviceName = m_mediaElement-&gt;mediaControlsHost()-&gt;externalDeviceDisplayName();
+        }
+        m_playbackSessionInterface-&gt;setExternalPlayback(enabled, targetType, localizedDeviceName);
+        m_playbackSessionInterface-&gt;setWirelessVideoPlaybackDisabled(m_mediaElement-&gt;mediaSession().wirelessVideoPlaybackDisabled(*m_mediaElement));
+    }
+}
+
+void WebPlaybackSessionModelMediaElement::play()
+{
+    if (m_mediaElement)
+        m_mediaElement-&gt;play();
+}
+
+void WebPlaybackSessionModelMediaElement::pause()
+{
+    if (m_mediaElement)
+        m_mediaElement-&gt;pause();
+}
+
+void WebPlaybackSessionModelMediaElement::togglePlayState()
+{
+    if (m_mediaElement)
+        m_mediaElement-&gt;togglePlayState();
+}
+
+void WebPlaybackSessionModelMediaElement::beginScrubbing()
+{
+    if (m_mediaElement)
+        m_mediaElement-&gt;beginScrubbing();
+}
+
+void WebPlaybackSessionModelMediaElement::endScrubbing()
+{
+    if (m_mediaElement)
+        m_mediaElement-&gt;endScrubbing();
+}
+
+void WebPlaybackSessionModelMediaElement::seekToTime(double time)
+{
+    if (m_mediaElement)
+        m_mediaElement-&gt;setCurrentTime(time);
+}
+
+void WebPlaybackSessionModelMediaElement::fastSeek(double time)
+{
+    if (m_mediaElement)
+        m_mediaElement-&gt;fastSeek(time);
+}
+
+void WebPlaybackSessionModelMediaElement::beginScanningForward()
+{
+    if (m_mediaElement)
+        m_mediaElement-&gt;beginScanning(MediaControllerInterface::Forward);
+}
+
+void WebPlaybackSessionModelMediaElement::beginScanningBackward()
+{
+    if (m_mediaElement)
+        m_mediaElement-&gt;beginScanning(MediaControllerInterface::Backward);
+}
+
+void WebPlaybackSessionModelMediaElement::endScanning()
+{
+    if (m_mediaElement)
+        m_mediaElement-&gt;endScanning();
+}
+
+void WebPlaybackSessionModelMediaElement::selectAudioMediaOption(uint64_t selectedAudioIndex)
+{
+    ASSERT(selectedAudioIndex &lt; std::numeric_limits&lt;size_t&gt;::max());
+    AudioTrack* selectedAudioTrack = nullptr;
+
+    for (size_t index = 0; index &lt; m_audioTracksForMenu.size(); ++index) {
+        auto&amp; audioTrack = m_audioTracksForMenu[index];
+        audioTrack-&gt;setEnabled(index == static_cast&lt;size_t&gt;(selectedAudioIndex));
+        if (audioTrack-&gt;enabled())
+            selectedAudioTrack = audioTrack.get();
+    }
+
+    m_mediaElement-&gt;audioTrackEnabledChanged(selectedAudioTrack);
+}
+
+void WebPlaybackSessionModelMediaElement::selectLegibleMediaOption(uint64_t index)
+{
+    ASSERT(index &lt; std::numeric_limits&lt;size_t&gt;::max());
+    TextTrack* textTrack = nullptr;
+
+    if (index &lt; m_legibleTracksForMenu.size())
+        textTrack = m_legibleTracksForMenu[static_cast&lt;size_t&gt;(index)].get();
+    else
+        textTrack = TextTrack::captionMenuOffItem();
+
+    m_mediaElement-&gt;setSelectedTextTrack(textTrack);
+}
+
+void WebPlaybackSessionModelMediaElement::updateLegibleOptions()
+{
+    AudioTrackList* audioTrackList = m_mediaElement-&gt;audioTracks();
+    TextTrackList* trackList = m_mediaElement-&gt;textTracks();
+
+    if ((!trackList &amp;&amp; !audioTrackList) || !m_mediaElement-&gt;document().page() || !m_mediaElement-&gt;mediaControlsHost())
+        return;
+
+    AtomicString displayMode = m_mediaElement-&gt;mediaControlsHost()-&gt;captionDisplayMode();
+    TextTrack* offItem = m_mediaElement-&gt;mediaControlsHost()-&gt;captionMenuOffItem();
+    TextTrack* automaticItem = m_mediaElement-&gt;mediaControlsHost()-&gt;captionMenuAutomaticItem();
+
+    auto&amp; captionPreferences = m_mediaElement-&gt;document().page()-&gt;group().captionPreferences();
+    m_legibleTracksForMenu = captionPreferences.sortedTrackListForMenu(trackList);
+    m_audioTracksForMenu = captionPreferences.sortedTrackListForMenu(audioTrackList);
+
+    Vector&lt;String&gt; audioTrackDisplayNames;
+    uint64_t selectedAudioIndex = 0;
+
+    for (size_t index = 0; index &lt; m_audioTracksForMenu.size(); ++index) {
+        auto&amp; track = m_audioTracksForMenu[index];
+        audioTrackDisplayNames.append(captionPreferences.displayNameForTrack(track.get()));
+
+        if (track-&gt;enabled())
+            selectedAudioIndex = index;
+    }
+
+    m_playbackSessionInterface-&gt;setAudioMediaSelectionOptions(audioTrackDisplayNames, selectedAudioIndex);
+
+    Vector&lt;String&gt; trackDisplayNames;
+    uint64_t selectedIndex = 0;
+    uint64_t offIndex = 0;
+    bool trackMenuItemSelected = false;
+
+    for (size_t index = 0; index &lt; m_legibleTracksForMenu.size(); index++) {
+        auto&amp; track = m_legibleTracksForMenu[index];
+        trackDisplayNames.append(captionPreferences.displayNameForTrack(track.get()));
+
+        if (track == offItem)
+            offIndex = index;
+
+        if (track == automaticItem &amp;&amp; displayMode == MediaControlsHost::automaticKeyword()) {
+            selectedIndex = index;
+            trackMenuItemSelected = true;
+        }
+
+        if (displayMode != MediaControlsHost::automaticKeyword() &amp;&amp; track-&gt;mode() == TextTrack::showingKeyword()) {
+            selectedIndex = index;
+            trackMenuItemSelected = true;
+        }
+    }
+
+    if (offIndex &amp;&amp; !trackMenuItemSelected &amp;&amp; displayMode == MediaControlsHost::forcedOnlyKeyword()) {
+        selectedIndex = offIndex;
+        trackMenuItemSelected = true;
+    }
+
+    m_playbackSessionInterface-&gt;setLegibleMediaSelectionOptions(trackDisplayNames, selectedIndex);
+}
+
+const Vector&lt;AtomicString&gt;&amp;  WebPlaybackSessionModelMediaElement::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;  WebPlaybackSessionModelMediaElement::eventNameAll()
+{
+    static NeverDestroyed&lt;AtomicString&gt; sEventNameAll = &quot;allEvents&quot;;
+    return sEventNameAll;
+}
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaWebVideoFullscreenInterfaceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenInterface.h (199592 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenInterface.h        2016-04-15 17:18:12 UTC (rev 199592)
+++ trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenInterface.h        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -28,35 +28,18 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
</span><span class="cx"> 
</span><del>-#include &lt;wtf/Vector.h&gt;
</del><ins>+#include &quot;WebPlaybackSessionInterface.h&quot;
</ins><span class="cx"> 
</span><del>-namespace WTF {
-class String;
-}
-
</del><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> WEBCORE_EXPORT bool supportsPictureInPicture();
</span><span class="cx"> 
</span><span class="cx"> class TimeRanges;
</span><span class="cx"> 
</span><del>-class WebVideoFullscreenInterface {
</del><ins>+class WebVideoFullscreenInterface : public WebPlaybackSessionInterface {
</ins><span class="cx"> public:
</span><del>-    enum ExternalPlaybackTargetType { TargetTypeNone, TargetTypeAirPlay, TargetTypeTVOut };
-    
</del><span class="cx">     virtual ~WebVideoFullscreenInterface() { };
</span><del>-    virtual void resetMediaState() = 0;
-    virtual void setDuration(double) = 0;
-    virtual void setCurrentTime(double currentTime, double anchorTime) = 0;
-    virtual void setBufferedTime(double) = 0;
-    virtual void setRate(bool isPlaying, float playbackRate) = 0;
</del><span class="cx">     virtual void setVideoDimensions(bool hasVideo, float width, float height) = 0;
</span><del>-    virtual void setSeekableRanges(const TimeRanges&amp;) = 0;
-    virtual void setCanPlayFastReverse(bool) = 0;
-    virtual void setAudioMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex) = 0;
-    virtual void setLegibleMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex) = 0;
-    virtual void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, WTF::String localizedDeviceName) = 0;
-    virtual void setWirelessVideoPlaybackDisabled(bool) = 0;
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaWebVideoFullscreenModelh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModel.h (199592 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModel.h        2016-04-15 17:18:12 UTC (rev 199592)
+++ trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModel.h        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -31,28 +31,17 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;FloatRect.h&quot;
</span><span class="cx"> #include &quot;HTMLMediaElementEnums.h&quot;
</span><ins>+#include &quot;WebPlaybackSessionModel.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class WebVideoFullscreenModel {
</del><ins>+class WebVideoFullscreenModel : public WebPlaybackSessionModel {
</ins><span class="cx"> public:
</span><span class="cx">     virtual ~WebVideoFullscreenModel() { };
</span><del>-    virtual void play() = 0;
-    virtual void pause() = 0;
-    virtual void togglePlayState() = 0;
-    virtual void beginScrubbing() = 0;
-    virtual void endScrubbing() = 0;
-    virtual void seekToTime(double time) = 0;
-    virtual void fastSeek(double time) = 0;
-    virtual void beginScanningForward() = 0;
-    virtual void beginScanningBackward() = 0;
-    virtual void endScanning() = 0;
</del><span class="cx">     virtual void requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenMode) = 0;
</span><span class="cx">     virtual void setVideoLayerFrame(FloatRect) = 0;
</span><span class="cx">     enum VideoGravity { VideoGravityResize, VideoGravityResizeAspect, VideoGravityResizeAspectFill };
</span><span class="cx">     virtual void setVideoLayerGravity(VideoGravity) = 0;
</span><del>-    virtual void selectAudioMediaOption(uint64_t index) = 0;
-    virtual void selectLegibleMediaOption(uint64_t index) = 0;
</del><span class="cx">     virtual void fullscreenModeChanged(HTMLMediaElementEnums::VideoFullscreenMode) = 0;
</span><span class="cx">     virtual bool isVisible() const = 0;
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaWebVideoFullscreenModelVideoElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.h (199592 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.h        2016-04-15 17:18:12 UTC (rev 199592)
+++ trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.h        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -42,13 +42,14 @@
</span><span class="cx"> class AudioTrack;
</span><span class="cx"> class HTMLVideoElement;
</span><span class="cx"> class TextTrack;
</span><ins>+class WebPlaybackSessionModelMediaElement;
</ins><span class="cx"> class WebVideoFullscreenInterface;
</span><span class="cx"> 
</span><span class="cx"> class WebVideoFullscreenModelVideoElement : public WebVideoFullscreenModel, public EventListener {
</span><span class="cx"> public:
</span><del>-    static RefPtr&lt;WebVideoFullscreenModelVideoElement&gt; create()
</del><ins>+    static RefPtr&lt;WebVideoFullscreenModelVideoElement&gt; create(WebPlaybackSessionModelMediaElement&amp; playbackSessionModel)
</ins><span class="cx">     {
</span><del>-        return adoptRef(*new WebVideoFullscreenModelVideoElement());
</del><ins>+        return adoptRef(*new WebVideoFullscreenModelVideoElement(playbackSessionModel));
</ins><span class="cx">     }
</span><span class="cx">     WEBCORE_EXPORT virtual ~WebVideoFullscreenModelVideoElement();
</span><span class="cx">     WEBCORE_EXPORT void setWebVideoFullscreenInterface(WebVideoFullscreenInterface*);
</span><span class="lines">@@ -80,12 +81,13 @@
</span><span class="cx">     WEBCORE_EXPORT bool isVisible() const override;
</span><span class="cx"> 
</span><span class="cx"> protected:
</span><del>-    WEBCORE_EXPORT WebVideoFullscreenModelVideoElement();
</del><ins>+    WEBCORE_EXPORT WebVideoFullscreenModelVideoElement(WebPlaybackSessionModelMediaElement&amp;);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     static const Vector&lt;WTF::AtomicString&gt;&amp; observedEventNames();
</span><span class="cx">     const WTF::AtomicString&amp; eventNameAll();
</span><del>-    
</del><ins>+
+    Ref&lt;WebPlaybackSessionModelMediaElement&gt; m_playbackSessionModel;
</ins><span class="cx">     RefPtr&lt;HTMLVideoElement&gt; m_videoElement;
</span><span class="cx">     RetainPtr&lt;PlatformLayer&gt; m_videoFullscreenLayer;
</span><span class="cx">     bool m_isListening { false };
</span><span class="lines">@@ -93,8 +95,6 @@
</span><span class="cx">     FloatRect m_videoFrame;
</span><span class="cx">     Vector&lt;RefPtr&lt;TextTrack&gt;&gt; m_legibleTracksForMenu;
</span><span class="cx">     Vector&lt;RefPtr&lt;AudioTrack&gt;&gt; m_audioTracksForMenu;
</span><del>-
-    void updateLegibleOptions();
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaWebVideoFullscreenModelVideoElementmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.mm (199592 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.mm        2016-04-15 17:18:12 UTC (rev 199592)
+++ trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.mm        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #import &quot;DOMEventInternal.h&quot;
</span><span class="cx"> #import &quot;Logging.h&quot;
</span><span class="cx"> #import &quot;MediaControlsHost.h&quot;
</span><ins>+#import &quot;WebPlaybackSessionModelMediaElement.h&quot;
</ins><span class="cx"> #import &quot;WebVideoFullscreenInterface.h&quot;
</span><span class="cx"> #import &lt;QuartzCore/CoreAnimation.h&gt;
</span><span class="cx"> #import &lt;WebCore/DOMEventListener.h&gt;
</span><span class="lines">@@ -50,8 +51,9 @@
</span><span class="cx"> 
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><del>-WebVideoFullscreenModelVideoElement::WebVideoFullscreenModelVideoElement()
</del><ins>+WebVideoFullscreenModelVideoElement::WebVideoFullscreenModelVideoElement(WebPlaybackSessionModelMediaElement&amp; playbackSessionModel)
</ins><span class="cx">     : EventListener(EventListener::CPPEventListenerType)
</span><ins>+    , m_playbackSessionModel(playbackSessionModel)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -65,24 +67,18 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_videoFullscreenInterface = interface;
</span><ins>+    m_playbackSessionModel-&gt;setWebPlaybackSessionInterface(interface);
</ins><span class="cx"> 
</span><del>-    if (m_videoFullscreenInterface) {
-        m_videoFullscreenInterface-&gt;resetMediaState();
-        if (m_videoElement) {
-            m_videoFullscreenInterface-&gt;setVideoDimensions(true, m_videoElement-&gt;videoWidth(), m_videoElement-&gt;videoHeight());
-            m_videoFullscreenInterface-&gt;setWirelessVideoPlaybackDisabled(m_videoElement-&gt;mediaSession().wirelessVideoPlaybackDisabled(*m_videoElement));
-        }
-    }
</del><ins>+    if (m_videoFullscreenInterface &amp;&amp; m_videoElement)
+        m_videoFullscreenInterface-&gt;setVideoDimensions(true, m_videoElement-&gt;videoWidth(), m_videoElement-&gt;videoHeight());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::setVideoElement(HTMLVideoElement* videoElement)
</span><span class="cx"> {
</span><ins>+    m_playbackSessionModel-&gt;setMediaElement(videoElement);
</ins><span class="cx">     if (m_videoElement == videoElement)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (m_videoFullscreenInterface)
-        m_videoFullscreenInterface-&gt;resetMediaState();
-
</del><span class="cx">     if (m_videoElement &amp;&amp; m_videoElement-&gt;videoFullscreenLayer())
</span><span class="cx">         m_videoElement-&gt;setVideoFullscreenLayer(nullptr);
</span><span class="cx"> 
</span><span class="lines">@@ -103,10 +99,8 @@
</span><span class="cx"> 
</span><span class="cx">     updateForEventName(eventNameAll());
</span><span class="cx"> 
</span><del>-    if (m_videoFullscreenInterface) {
</del><ins>+    if (m_videoFullscreenInterface)
</ins><span class="cx">         m_videoFullscreenInterface-&gt;setVideoDimensions(true, videoElement-&gt;videoWidth(), videoElement-&gt;videoHeight());
</span><del>-        m_videoFullscreenInterface-&gt;setWirelessVideoPlaybackDisabled(m_videoElement-&gt;mediaSession().wirelessVideoPlaybackDisabled(*m_videoElement));
-    }
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event* event)
</span><span class="lines">@@ -122,56 +116,8 @@
</span><span class="cx">     bool all = eventName == eventNameAll();
</span><span class="cx"> 
</span><span class="cx">     if (all
</span><del>-        || eventName == eventNames().durationchangeEvent) {
-        m_videoFullscreenInterface-&gt;setDuration(m_videoElement-&gt;duration());
-        // These is no standard event for minFastReverseRateChange; duration change is a reasonable proxy for it.
-        // It happens every time a new item becomes ready to play.
-        m_videoFullscreenInterface-&gt;setCanPlayFastReverse(m_videoElement-&gt;minFastReverseRate() &lt; 0.0);
-    }
-
-    if (all
-        || eventName == eventNames().pauseEvent
-        || eventName == eventNames().playEvent
-        || eventName == eventNames().ratechangeEvent)
-        m_videoFullscreenInterface-&gt;setRate(!m_videoElement-&gt;paused(), m_videoElement-&gt;playbackRate());
-
-    if (all
-        || eventName == eventNames().timeupdateEvent) {
-        m_videoFullscreenInterface-&gt;setCurrentTime(m_videoElement-&gt;currentTime(), [[NSProcessInfo processInfo] systemUptime]);
-        m_videoFullscreenInterface-&gt;setBufferedTime(m_videoElement-&gt;maxBufferedTime());
-        // FIXME: 130788 - find a better event to update seekable ranges from.
-        m_videoFullscreenInterface-&gt;setSeekableRanges(*m_videoElement-&gt;seekable());
-    }
-
-    if (all
-        || eventName == eventNames().addtrackEvent
-        || eventName == eventNames().removetrackEvent)
-        updateLegibleOptions();
-    
-    if (all
</del><span class="cx">         || eventName == eventNames().resizeEvent)
</span><span class="cx">         m_videoFullscreenInterface-&gt;setVideoDimensions(true, m_videoElement-&gt;videoWidth(), m_videoElement-&gt;videoHeight());
</span><del>-
-    if (all
-        || eventName == eventNames().webkitcurrentplaybacktargetiswirelesschangedEvent) {
-        bool enabled = m_videoElement-&gt;webkitCurrentPlaybackTargetIsWireless();
-        WebVideoFullscreenInterface::ExternalPlaybackTargetType targetType = WebVideoFullscreenInterface::TargetTypeNone;
-        String localizedDeviceName;
-
-        if (m_videoElement-&gt;mediaControlsHost()) {
-            static NeverDestroyed&lt;String&gt; airplay(ASCIILiteral(&quot;airplay&quot;));
-            static NeverDestroyed&lt;String&gt; tvout(ASCIILiteral(&quot;tvout&quot;));
-            
-            String type = m_videoElement-&gt;mediaControlsHost()-&gt;externalDeviceType();
-            if (type == airplay)
-                targetType = WebVideoFullscreenInterface::TargetTypeAirPlay;
-            else if (type == tvout)
-                targetType = WebVideoFullscreenInterface::TargetTypeTVOut;
-            localizedDeviceName = m_videoElement-&gt;mediaControlsHost()-&gt;externalDeviceDisplayName();
-        }
-        m_videoFullscreenInterface-&gt;setExternalPlayback(enabled, targetType, localizedDeviceName);
-        m_videoFullscreenInterface-&gt;setWirelessVideoPlaybackDisabled(m_videoElement-&gt;mediaSession().wirelessVideoPlaybackDisabled(*m_videoElement));
-    }
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::setVideoFullscreenLayer(PlatformLayer* videoLayer)
</span><span class="lines">@@ -193,62 +139,52 @@
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::play()
</span><span class="cx"> {
</span><del>-    if (m_videoElement)
-        m_videoElement-&gt;play();
</del><ins>+    m_playbackSessionModel-&gt;play();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::pause()
</span><span class="cx"> {
</span><del>-    if (m_videoElement)
-        m_videoElement-&gt;pause();
</del><ins>+    m_playbackSessionModel-&gt;pause();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::togglePlayState()
</span><span class="cx"> {
</span><del>-    if (m_videoElement)
-        m_videoElement-&gt;togglePlayState();
</del><ins>+    m_playbackSessionModel-&gt;togglePlayState();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::beginScrubbing()
</span><span class="cx"> {
</span><del>-    if (m_videoElement)
-        m_videoElement-&gt;beginScrubbing();
</del><ins>+    m_playbackSessionModel-&gt;beginScrubbing();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::endScrubbing()
</span><span class="cx"> {
</span><del>-    if (m_videoElement)
-        m_videoElement-&gt;endScrubbing();
</del><ins>+    m_playbackSessionModel-&gt;endScrubbing();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::seekToTime(double time)
</span><span class="cx"> {
</span><del>-    if (m_videoElement)
-        m_videoElement-&gt;setCurrentTime(time);
</del><ins>+    m_playbackSessionModel-&gt;seekToTime(time);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::fastSeek(double time)
</span><span class="cx"> {
</span><del>-    if (m_videoElement)
-        m_videoElement-&gt;fastSeek(time);
</del><ins>+    m_playbackSessionModel-&gt;fastSeek(time);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::beginScanningForward()
</span><span class="cx"> {
</span><del>-    if (m_videoElement)
-        m_videoElement-&gt;beginScanning(MediaControllerInterface::Forward);
</del><ins>+    m_playbackSessionModel-&gt;beginScanningForward();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::beginScanningBackward()
</span><span class="cx"> {
</span><del>-    if (m_videoElement)
-        m_videoElement-&gt;beginScanning(MediaControllerInterface::Backward);
</del><ins>+    m_playbackSessionModel-&gt;beginScanningBackward();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::endScanning()
</span><span class="cx"> {
</span><del>-    if (m_videoElement)
-        m_videoElement-&gt;endScanning();
</del><ins>+    m_playbackSessionModel-&gt;endScanning();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenMode mode)
</span><span class="lines">@@ -282,105 +218,20 @@
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::selectAudioMediaOption(uint64_t selectedAudioIndex)
</span><span class="cx"> {
</span><del>-    AudioTrack* selectedAudioTrack = nullptr;
-
-    for (size_t index = 0; index &lt; m_audioTracksForMenu.size(); ++index) {
-        auto&amp; audioTrack = m_audioTracksForMenu[index];
-        audioTrack-&gt;setEnabled(index == static_cast&lt;size_t&gt;(selectedAudioIndex));
-        if (audioTrack-&gt;enabled())
-            selectedAudioTrack = audioTrack.get();
-    }
-
-    m_videoElement-&gt;audioTrackEnabledChanged(selectedAudioTrack);
</del><ins>+    m_playbackSessionModel-&gt;selectAudioMediaOption(selectedAudioIndex);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelVideoElement::selectLegibleMediaOption(uint64_t index)
</span><span class="cx"> {
</span><del>-    TextTrack* textTrack = nullptr;
-    
-    if (index &lt; m_legibleTracksForMenu.size())
-        textTrack = m_legibleTracksForMenu[static_cast&lt;size_t&gt;(index)].get();
-    else
-        textTrack = TextTrack::captionMenuOffItem();
-    
-    m_videoElement-&gt;setSelectedTextTrack(textTrack);
</del><ins>+    m_playbackSessionModel-&gt;selectLegibleMediaOption(index);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenModelVideoElement::updateLegibleOptions()
-{
-    AudioTrackList* audioTrackList = m_videoElement-&gt;audioTracks();
-    TextTrackList* trackList = m_videoElement-&gt;textTracks();
-
-    if ((!trackList &amp;&amp; !audioTrackList) || !m_videoElement-&gt;document().page() || !m_videoElement-&gt;mediaControlsHost())
-        return;
-    
-    WTF::AtomicString displayMode = m_videoElement-&gt;mediaControlsHost()-&gt;captionDisplayMode();
-    TextTrack* offItem = m_videoElement-&gt;mediaControlsHost()-&gt;captionMenuOffItem();
-    TextTrack* automaticItem = m_videoElement-&gt;mediaControlsHost()-&gt;captionMenuAutomaticItem();
-
-    auto&amp; captionPreferences = m_videoElement-&gt;document().page()-&gt;group().captionPreferences();
-    m_legibleTracksForMenu = captionPreferences.sortedTrackListForMenu(trackList);
-    m_audioTracksForMenu = captionPreferences.sortedTrackListForMenu(audioTrackList);
-
-    Vector&lt;String&gt; audioTrackDisplayNames;
-    uint64_t selectedAudioIndex = 0;
-    
-    for (size_t index = 0; index &lt; m_audioTracksForMenu.size(); ++index) {
-        auto&amp; track = m_audioTracksForMenu[index];
-        audioTrackDisplayNames.append(captionPreferences.displayNameForTrack(track.get()));
-        
-        if (track-&gt;enabled())
-            selectedAudioIndex = index;
-    }
-    
-    m_videoFullscreenInterface-&gt;setAudioMediaSelectionOptions(audioTrackDisplayNames, selectedAudioIndex);
-
-    Vector&lt;String&gt; trackDisplayNames;
-    uint64_t selectedIndex = 0;
-    uint64_t offIndex = 0;
-    bool trackMenuItemSelected = false;
-    
-    for (size_t index = 0; index &lt; m_legibleTracksForMenu.size(); index++) {
-        auto&amp; track = m_legibleTracksForMenu[index];
-        trackDisplayNames.append(captionPreferences.displayNameForTrack(track.get()));
-        
-        if (track == offItem)
-            offIndex = index;
-        
-        if (track == automaticItem &amp;&amp; displayMode == MediaControlsHost::automaticKeyword()) {
-            selectedIndex = index;
-            trackMenuItemSelected = true;
-        }
-        
-        if (displayMode != MediaControlsHost::automaticKeyword() &amp;&amp; track-&gt;mode() == TextTrack::showingKeyword()) {
-            selectedIndex = index;
-            trackMenuItemSelected = true;
-        }
-    }
-    
-    if (offIndex &amp;&amp; !trackMenuItemSelected &amp;&amp; displayMode == MediaControlsHost::forcedOnlyKeyword()) {
-        selectedIndex = offIndex;
-        trackMenuItemSelected = true;
-    }
-    
-    m_videoFullscreenInterface-&gt;setLegibleMediaSelectionOptions(trackDisplayNames, selectedIndex);
-}
-
</del><span class="cx"> const Vector&lt;AtomicString&gt;&amp; WebVideoFullscreenModelVideoElement::observedEventNames()
</span><span class="cx"> {
</span><span class="cx">     static NeverDestroyed&lt;Vector&lt;AtomicString&gt;&gt; sEventNames;
</span><span class="cx"> 
</span><del>-    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);
</del><ins>+    if (!sEventNames.get().size())
</ins><span class="cx">         sEventNames.get().append(eventNames().resizeEvent);
</span><del>-        sEventNames.get().append(eventNames().webkitcurrentplaybacktargetiswirelesschangedEvent);
-    }
</del><span class="cx">     return sEventNames.get();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebAVPlayerControllerh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/ios/WebAVPlayerController.h (0 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebAVPlayerController.h                                (rev 0)
+++ trunk/Source/WebCore/platform/ios/WebAVPlayerController.h        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -0,0 +1,93 @@
</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. ``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
+ * 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.
+ */
+
+#if PLATFORM(IOS)
+
+#import &quot;AVKitSPI.h&quot;
+
+namespace WebCore {
+class WebPlaybackSessionModel;
+class WebPlaybackSessionInterfaceAVKit;
+}
+
+@interface WebAVMediaSelectionOption : NSObject
+@property (retain) NSString *localizedDisplayName;
+@end
+
+@interface WebAVPlayerController : NSObject {
+    WebAVMediaSelectionOption *_currentAudioMediaSelectionOption;
+    WebAVMediaSelectionOption *_currentLegibleMediaSelectionOption;
+    BOOL _pictureInPictureInterrupted;
+}
+
+- (void)resetState;
+
+@property (retain) AVPlayerController* playerControllerProxy;
+@property (assign) WebCore::WebPlaybackSessionModel* delegate;
+@property (assign) WebCore::WebPlaybackSessionInterfaceAVKit* playbackSessionInterface;
+
+@property (readonly) BOOL canScanForward;
+@property BOOL canScanBackward;
+@property (readonly) BOOL canSeekToBeginning;
+@property (readonly) BOOL canSeekToEnd;
+
+@property BOOL canPlay;
+@property (getter=isPlaying) BOOL playing;
+@property BOOL canPause;
+@property BOOL canTogglePlayback;
+@property double rate;
+@property BOOL canSeek;
+@property NSTimeInterval contentDuration;
+@property CGSize contentDimensions;
+@property BOOL hasEnabledAudio;
+@property BOOL hasEnabledVideo;
+@property NSTimeInterval minTime;
+@property NSTimeInterval maxTime;
+@property NSTimeInterval contentDurationWithinEndTimes;
+@property (retain) NSArray *loadedTimeRanges;
+@property AVPlayerControllerStatus status;
+@property (retain) AVValueTiming *timing;
+@property (retain) NSArray *seekableTimeRanges;
+
+@property (readonly) BOOL hasMediaSelectionOptions;
+@property (readonly) BOOL hasAudioMediaSelectionOptions;
+@property (retain) NSArray *audioMediaSelectionOptions;
+@property (retain) WebAVMediaSelectionOption *currentAudioMediaSelectionOption;
+@property (readonly) BOOL hasLegibleMediaSelectionOptions;
+@property (retain) NSArray *legibleMediaSelectionOptions;
+@property (retain) WebAVMediaSelectionOption *currentLegibleMediaSelectionOption;
+
+@property (readonly, getter=isPlayingOnExternalScreen) BOOL playingOnExternalScreen;
+@property (readonly, getter=isPlayingOnSecondScreen) BOOL playingOnSecondScreen;
+@property (getter=isExternalPlaybackActive) BOOL externalPlaybackActive;
+@property AVPlayerControllerExternalPlaybackType externalPlaybackType;
+@property (retain) NSString *externalPlaybackAirPlayDeviceLocalizedName;
+@property BOOL allowsExternalPlayback;
+@property (getter=isPictureInPicturePossible) BOOL pictureInPicturePossible;
+@property (getter=isPictureInPictureInterrupted) BOOL pictureInPictureInterrupted;
+@end
+
+#endif
+
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebAVPlayerControllermm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/ios/WebAVPlayerController.mm (0 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebAVPlayerController.mm                                (rev 0)
+++ trunk/Source/WebCore/platform/ios/WebAVPlayerController.mm        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -0,0 +1,456 @@
</span><ins>+/*
+ * Copyright (C) 2014, 2015 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. ``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
+ * 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.
+ */
+
+
+#import &quot;config.h&quot;
+#import &quot;WebAVPlayerController.h&quot;
+
+#if PLATFORM(IOS)
+
+#import &quot;AVKitSPI.h&quot;
+#import &quot;Logging.h&quot;
+#import &quot;TimeRanges.h&quot;
+#import &quot;WebPlaybackSessionInterfaceAVKit.h&quot;
+#import &quot;WebPlaybackSessionModel.h&quot;
+#import &lt;AVFoundation/AVTime.h&gt;
+#import &lt;wtf/RetainPtr.h&gt;
+#import &lt;wtf/text/CString.h&gt;
+#import &lt;wtf/text/WTFString.h&gt;
+
+#import &quot;CoreMediaSoftLink.h&quot;
+
+SOFT_LINK_FRAMEWORK(AVKit)
+SOFT_LINK_CLASS(AVKit, AVPlayerController)
+
+using namespace WebCore;
+
+@implementation WebAVPlayerController
+
+- (instancetype)init
+{
+    if (!(self = [super init]))
+        return self;
+
+    initAVPlayerController();
+    self.playerControllerProxy = [[allocAVPlayerControllerInstance() init] autorelease];
+    return self;
+}
+
+- (void)dealloc
+{
+    [_playerControllerProxy release];
+    [_loadedTimeRanges release];
+    [_seekableTimeRanges release];
+    [_timing release];
+    [_audioMediaSelectionOptions release];
+    [_legibleMediaSelectionOptions release];
+    [_currentAudioMediaSelectionOption release];
+    [_currentLegibleMediaSelectionOption release];
+    [super dealloc];
+}
+
+- (void)resetState
+{
+    self.contentDuration = 0;
+    self.maxTime = 0;
+    self.contentDurationWithinEndTimes = 0;
+    self.loadedTimeRanges = @[];
+
+    self.canPlay = NO;
+    self.canPause = NO;
+    self.canTogglePlayback = NO;
+    self.hasEnabledAudio = NO;
+    self.canSeek = NO;
+    self.minTime = 0;
+    self.status = AVPlayerControllerStatusUnknown;
+
+    self.timing = nil;
+    self.rate = 0;
+
+    self.hasEnabledVideo = NO;
+    self.contentDimensions = CGSizeMake(0, 0);
+
+    self.seekableTimeRanges = [NSMutableArray array];
+
+    self.canScanBackward = NO;
+
+    self.audioMediaSelectionOptions = nil;
+    self.currentAudioMediaSelectionOption = nil;
+
+    self.legibleMediaSelectionOptions = nil;
+    self.currentLegibleMediaSelectionOption = nil;
+}
+
+- (AVPlayer *)player
+{
+    return nil;
+}
+
+- (id)forwardingTargetForSelector:(SEL)selector
+{
+    UNUSED_PARAM(selector);
+    return self.playerControllerProxy;
+}
+
+- (void)play:(id)sender
+{
+    UNUSED_PARAM(sender);
+    if (!self.delegate)
+        return;
+    self.delegate-&gt;play();
+}
+
+- (void)pause:(id)sender
+{
+    UNUSED_PARAM(sender);
+    if (!self.delegate)
+        return;
+    self.delegate-&gt;pause();
+}
+
+- (void)togglePlayback:(id)sender
+{
+    UNUSED_PARAM(sender);
+    if (!self.delegate)
+        return;
+    self.delegate-&gt;togglePlayState();
+}
+
+- (void)togglePlaybackEvenWhenInBackground:(id)sender
+{
+    [self togglePlayback:sender];
+}
+
+- (BOOL)isPlaying
+{
+    return [self rate];
+}
+
+- (void)setPlaying:(BOOL)playing
+{
+    if (!self.delegate)
+        return;
+    if (playing)
+        self.delegate-&gt;play();
+    else
+        self.delegate-&gt;pause();
+}
+
++ (NSSet *)keyPathsForValuesAffectingPlaying
+{
+    return [NSSet setWithObject:@&quot;rate&quot;];
+}
+
+- (void)beginScrubbing:(id)sender
+{
+    UNUSED_PARAM(sender);
+    if (!self.delegate)
+        return;
+    self.delegate-&gt;beginScrubbing();
+}
+
+- (void)endScrubbing:(id)sender
+{
+    UNUSED_PARAM(sender);
+    if (!self.delegate)
+        return;
+    self.delegate-&gt;endScrubbing();
+}
+
+- (void)seekToTime:(NSTimeInterval)time
+{
+    if (!self.delegate)
+        return;
+    self.delegate-&gt;fastSeek(time);
+}
+
+- (NSTimeInterval)currentTimeWithinEndTimes
+{
+    return self.timing.currentValue;
+}
+
+- (void)setCurrentTimeWithinEndTimes:(NSTimeInterval)currentTimeWithinEndTimes
+{
+    [self seekToTime:currentTimeWithinEndTimes];
+}
+
++ (NSSet *)keyPathsForValuesAffectingCurrentTimeWithinEndTimes
+{
+    return [NSSet setWithObject:@&quot;timing&quot;];
+}
+
+- (BOOL)hasLiveStreamingContent
+{
+    if ([self status] == AVPlayerControllerStatusReadyToPlay)
+        return [self contentDuration] == std::numeric_limits&lt;float&gt;::infinity();
+    return NO;
+}
+
++ (NSSet *)keyPathsForValuesAffectingHasLiveStreamingContent
+{
+    return [NSSet setWithObjects:@&quot;contentDuration&quot;, @&quot;status&quot;, nil];
+}
+
+- (void)skipBackwardThirtySeconds:(id)sender
+{
+    UNUSED_PARAM(sender);
+    BOOL isTimeWithinSeekableTimeRanges = NO;
+    CMTime currentTime = CMTimeMakeWithSeconds([[self timing] currentValue], 1000);
+    CMTime thirtySecondsBeforeCurrentTime = CMTimeSubtract(currentTime, CMTimeMake(30, 1));
+
+    for (NSValue *seekableTimeRangeValue in [self seekableTimeRanges]) {
+        if (CMTimeRangeContainsTime([seekableTimeRangeValue CMTimeRangeValue], thirtySecondsBeforeCurrentTime)) {
+            isTimeWithinSeekableTimeRanges = YES;
+            break;
+        }
+    }
+
+    if (isTimeWithinSeekableTimeRanges)
+        [self seekToTime:CMTimeGetSeconds(thirtySecondsBeforeCurrentTime)];
+}
+
+- (void)gotoEndOfSeekableRanges:(id)sender
+{
+    UNUSED_PARAM(sender);
+    NSTimeInterval timeAtEndOfSeekableTimeRanges = NAN;
+
+    for (NSValue *seekableTimeRangeValue in [self seekableTimeRanges]) {
+        CMTimeRange seekableTimeRange = [seekableTimeRangeValue CMTimeRangeValue];
+        NSTimeInterval endOfSeekableTimeRange = CMTimeGetSeconds(CMTimeRangeGetEnd(seekableTimeRange));
+        if (isnan(timeAtEndOfSeekableTimeRanges) || endOfSeekableTimeRange &gt; timeAtEndOfSeekableTimeRanges)
+            timeAtEndOfSeekableTimeRanges = endOfSeekableTimeRange;
+    }
+
+    if (!isnan(timeAtEndOfSeekableTimeRanges))
+        [self seekToTime:timeAtEndOfSeekableTimeRanges];
+}
+
+- (BOOL)canScanForward
+{
+    return [self canPlay];
+}
+
++ (NSSet *)keyPathsForValuesAffectingCanScanForward
+{
+    return [NSSet setWithObject:@&quot;canPlay&quot;];
+}
+
+- (void)beginScanningForward:(id)sender
+{
+    UNUSED_PARAM(sender);
+    if (!self.delegate)
+        return;
+    self.delegate-&gt;beginScanningForward();
+}
+
+- (void)endScanningForward:(id)sender
+{
+    UNUSED_PARAM(sender);
+    if (!self.delegate)
+        return;
+    self.delegate-&gt;endScanning();
+}
+
+- (void)beginScanningBackward:(id)sender
+{
+    UNUSED_PARAM(sender);
+    if (!self.delegate)
+        return;
+    self.delegate-&gt;beginScanningBackward();
+}
+
+- (void)endScanningBackward:(id)sender
+{
+    UNUSED_PARAM(sender);
+    if (!self.delegate)
+        return;
+    self.delegate-&gt;endScanning();
+}
+
+- (BOOL)canSeekToBeginning
+{
+    CMTime minimumTime = kCMTimeIndefinite;
+
+    for (NSValue *value in [self seekableTimeRanges])
+        minimumTime = CMTimeMinimum([value CMTimeRangeValue].start, minimumTime);
+
+    return CMTIME_IS_NUMERIC(minimumTime);
+}
+
++ (NSSet *)keyPathsForValuesAffectingCanSeekToBeginning
+{
+    return [NSSet setWithObject:@&quot;seekableTimeRanges&quot;];
+}
+
+- (void)seekToBeginning:(id)sender
+{
+    UNUSED_PARAM(sender);
+    if (!self.delegate)
+        return;
+    self.delegate-&gt;seekToTime(-INFINITY);
+}
+
+- (void)seekChapterBackward:(id)sender
+{
+    [self seekToBeginning:sender];
+}
+
+- (BOOL)canSeekToEnd
+{
+    CMTime maximumTime = kCMTimeIndefinite;
+
+    for (NSValue *value in [self seekableTimeRanges])
+        maximumTime = CMTimeMaximum(CMTimeRangeGetEnd([value CMTimeRangeValue]), maximumTime);
+
+    return CMTIME_IS_NUMERIC(maximumTime);
+}
+
++ (NSSet *)keyPathsForValuesAffectingCanSeekToEnd
+{
+    return [NSSet setWithObject:@&quot;seekableTimeRanges&quot;];
+}
+
+- (void)seekToEnd:(id)sender
+{
+    UNUSED_PARAM(sender);
+    if (!self.delegate)
+        return;
+    self.delegate-&gt;seekToTime(INFINITY);
+}
+
+- (void)seekChapterForward:(id)sender
+{
+    [self seekToEnd:sender];
+}
+
+- (BOOL)hasMediaSelectionOptions
+{
+    return [self hasAudioMediaSelectionOptions] || [self hasLegibleMediaSelectionOptions];
+}
+
++ (NSSet *)keyPathsForValuesAffectingHasMediaSelectionOptions
+{
+    return [NSSet setWithObjects:@&quot;hasAudioMediaSelectionOptions&quot;, @&quot;hasLegibleMediaSelectionOptions&quot;, nil];
+}
+
+- (BOOL)hasAudioMediaSelectionOptions
+{
+    return [[self audioMediaSelectionOptions] count] &gt; 1;
+}
+
++ (NSSet *)keyPathsForValuesAffectingHasAudioMediaSelectionOptions
+{
+    return [NSSet setWithObject:@&quot;audioMediaSelectionOptions&quot;];
+}
+
+- (BOOL)hasLegibleMediaSelectionOptions
+{
+    const NSUInteger numDefaultLegibleOptions = 2;
+    return [[self legibleMediaSelectionOptions] count] &gt; numDefaultLegibleOptions;
+}
+
++ (NSSet *)keyPathsForValuesAffectingHasLegibleMediaSelectionOptions
+{
+    return [NSSet setWithObject:@&quot;legibleMediaSelectionOptions&quot;];
+}
+
+- (WebAVMediaSelectionOption *)currentAudioMediaSelectionOption
+{
+    return _currentAudioMediaSelectionOption;
+}
+
+- (void)setCurrentAudioMediaSelectionOption:(WebAVMediaSelectionOption *)option
+{
+    if (option == _currentAudioMediaSelectionOption)
+        return;
+
+    [_currentAudioMediaSelectionOption release];
+    _currentAudioMediaSelectionOption = [option retain];
+
+    if (!self.delegate)
+        return;
+
+    NSInteger index = NSNotFound;
+
+    if (option &amp;&amp; self.audioMediaSelectionOptions)
+        index = [self.audioMediaSelectionOptions indexOfObject:option];
+
+    self.delegate-&gt;selectAudioMediaOption(index != NSNotFound ? index : UINT64_MAX);
+}
+
+- (WebAVMediaSelectionOption *)currentLegibleMediaSelectionOption
+{
+    return _currentLegibleMediaSelectionOption;
+}
+
+- (void)setCurrentLegibleMediaSelectionOption:(WebAVMediaSelectionOption *)option
+{
+    if (option == _currentLegibleMediaSelectionOption)
+        return;
+
+    [_currentLegibleMediaSelectionOption release];
+    _currentLegibleMediaSelectionOption = [option retain];
+
+    if (!self.delegate)
+        return;
+
+    NSInteger index = NSNotFound;
+
+    if (option &amp;&amp; self.legibleMediaSelectionOptions)
+        index = [self.legibleMediaSelectionOptions indexOfObject:option];
+
+    self.delegate-&gt;selectLegibleMediaOption(index != NSNotFound ? index : UINT64_MAX);
+}
+
+- (BOOL)isPlayingOnExternalScreen
+{
+    return [self isExternalPlaybackActive] || [self isPlayingOnSecondScreen];
+}
+
++ (NSSet *)keyPathsForValuesAffectingPlayingOnExternalScreen
+{
+    return [NSSet setWithObjects:@&quot;externalPlaybackActive&quot;, @&quot;playingOnSecondScreen&quot;, nil];
+}
+
+- (BOOL)isPictureInPictureInterrupted
+{
+    return _pictureInPictureInterrupted;
+}
+
+- (void)setPictureInPictureInterrupted:(BOOL)pictureInPictureInterrupted
+{
+    if (_pictureInPictureInterrupted != pictureInPictureInterrupted) {
+        _pictureInPictureInterrupted = pictureInPictureInterrupted;
+        if (pictureInPictureInterrupted)
+            [self setPlaying:NO];
+    }
+}
+@end
+
+@implementation WebAVMediaSelectionOption
+@end
+
+#endif // PLATFORM(IOS)
+
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebPlaybackSessionInterfaceAVKith"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/ios/WebPlaybackSessionInterfaceAVKit.h (0 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebPlaybackSessionInterfaceAVKit.h                                (rev 0)
+++ trunk/Source/WebCore/platform/ios/WebPlaybackSessionInterfaceAVKit.h        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -0,0 +1,108 @@
</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. ``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
+ * 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.
+ */
+
+
+#ifndef WebPlaybackSessionInterfaceAVKit_h
+#define WebPlaybackSessionInterfaceAVKit_h
+
+#if PLATFORM(IOS)
+
+#include &quot;EventListener.h&quot;
+#include &quot;HTMLMediaElementEnums.h&quot;
+#include &quot;Timer.h&quot;
+#include &quot;WebPlaybackSessionInterface.h&quot;
+#include &lt;functional&gt;
+#include &lt;objc/objc.h&gt;
+#include &lt;wtf/RefCounted.h&gt;
+#include &lt;wtf/RefPtr.h&gt;
+#include &lt;wtf/RetainPtr.h&gt;
+
+OBJC_CLASS WebAVPlayerController;
+OBJC_CLASS AVPlayerViewController;
+OBJC_CLASS UIViewController;
+OBJC_CLASS UIWindow;
+OBJC_CLASS UIView;
+
+namespace WTF {
+class String;
+}
+
+namespace WebCore {
+class IntRect;
+class WebPlaybackSessionModel;
+class WebPlaybackSessionChangeObserver;
+
+class WebPlaybackSessionInterfaceAVKitClient {
+public:
+    virtual ~WebPlaybackSessionInterfaceAVKitClient() { }
+
+    virtual void externalPlaybackEnabledChanged(bool) = 0;
+};
+
+class WEBCORE_EXPORT WebPlaybackSessionInterfaceAVKit
+    : public WebPlaybackSessionInterface
+    , public RefCounted&lt;WebPlaybackSessionInterfaceAVKit&gt; {
+
+public:
+    static Ref&lt;WebPlaybackSessionInterfaceAVKit&gt; create()
+    {
+        return adoptRef(*new WebPlaybackSessionInterfaceAVKit());
+    }
+    virtual ~WebPlaybackSessionInterfaceAVKit();
+    WEBCORE_EXPORT void setWebPlaybackSessionModel(WebPlaybackSessionModel*);
+    void setClient(WebPlaybackSessionInterfaceAVKitClient* client) { m_client = client; }
+
+    WEBCORE_EXPORT void resetMediaState() override;
+    WEBCORE_EXPORT void setDuration(double) override;
+    WEBCORE_EXPORT void setCurrentTime(double currentTime, double anchorTime) override;
+    WEBCORE_EXPORT void setBufferedTime(double) override;
+    WEBCORE_EXPORT void setRate(bool isPlaying, float playbackRate) override;
+    WEBCORE_EXPORT void setSeekableRanges(const TimeRanges&amp;) override;
+    WEBCORE_EXPORT void setCanPlayFastReverse(bool) override;
+    WEBCORE_EXPORT void setAudioMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex) override;
+    WEBCORE_EXPORT void setLegibleMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex) override;
+    WEBCORE_EXPORT void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, WTF::String localizedDeviceName) override;
+    WEBCORE_EXPORT void setWirelessVideoPlaybackDisabled(bool) override;
+    bool wirelessVideoPlaybackDisabled() const;
+
+    WEBCORE_EXPORT virtual void invalidate();
+
+    WebAVPlayerController *playerController() const { return m_playerController.get(); }
+
+protected:
+    WEBCORE_EXPORT WebPlaybackSessionInterfaceAVKit();
+
+    RetainPtr&lt;WebAVPlayerController&gt; m_playerController;
+    WebPlaybackSessionModel* m_playbackSessionModel { nullptr };
+    WebPlaybackSessionInterfaceAVKitClient* m_client { nullptr};
+
+    bool m_wirelessVideoPlaybackDisabled { true };
+};
+
+}
+
+#endif
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebPlaybackSessionInterfaceAVKitmm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/ios/WebPlaybackSessionInterfaceAVKit.mm (0 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebPlaybackSessionInterfaceAVKit.mm                                (rev 0)
+++ trunk/Source/WebCore/platform/ios/WebPlaybackSessionInterfaceAVKit.mm        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -0,0 +1,202 @@
</span><ins>+/*
+ * Copyright (C) 2014, 2015 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. ``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
+ * 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.
+ */
+
+
+#import &quot;config.h&quot;
+#import &quot;WebPlaybackSessionInterfaceAVKit.h&quot;
+
+#if PLATFORM(IOS)
+#if HAVE(AVKIT)
+
+#import &quot;AVKitSPI.h&quot;
+#import &quot;Logging.h&quot;
+#import &quot;TimeRanges.h&quot;
+#import &quot;WebAVPlayerController.h&quot;
+#import &quot;WebPlaybackSessionModel.h&quot;
+#import &lt;AVFoundation/AVTime.h&gt;
+#import &lt;wtf/RetainPtr.h&gt;
+#import &lt;wtf/text/CString.h&gt;
+#import &lt;wtf/text/WTFString.h&gt;
+
+#import &quot;CoreMediaSoftLink.h&quot;
+
+SOFT_LINK_FRAMEWORK(AVKit)
+SOFT_LINK_CLASS(AVKit, AVValueTiming)
+
+namespace WebCore {
+
+WebPlaybackSessionInterfaceAVKit::WebPlaybackSessionInterfaceAVKit()
+    : m_playerController(adoptNS([[WebAVPlayerController alloc] init]))
+{
+    [m_playerController setPlaybackSessionInterface:this];
+}
+
+WebPlaybackSessionInterfaceAVKit::~WebPlaybackSessionInterfaceAVKit()
+{
+    WebAVPlayerController* playerController = m_playerController.get();
+    if (playerController &amp;&amp; playerController.externalPlaybackActive)
+        setExternalPlayback(false, TargetTypeNone, &quot;&quot;);
+}
+
+void WebPlaybackSessionInterfaceAVKit::resetMediaState()
+{
+    [m_playerController resetState];
+}
+
+void WebPlaybackSessionInterfaceAVKit::setWebPlaybackSessionModel(WebPlaybackSessionModel* model)
+{
+    m_playbackSessionModel = model;
+    [m_playerController setDelegate:m_playbackSessionModel];
+}
+
+void WebPlaybackSessionInterfaceAVKit::setDuration(double duration)
+{
+    WebAVPlayerController* playerController = m_playerController.get();
+
+    // FIXME: https://bugs.webkit.org/show_bug.cgi?id=127017 use correct values instead of duration for all these
+    playerController.contentDuration = duration;
+    playerController.maxTime = duration;
+    playerController.contentDurationWithinEndTimes = duration;
+
+    // FIXME: we take this as an indication that playback is ready.
+    playerController.canPlay = YES;
+    playerController.canPause = YES;
+    playerController.canTogglePlayback = YES;
+    playerController.hasEnabledAudio = YES;
+    playerController.canSeek = YES;
+    playerController.minTime = 0;
+    playerController.status = AVPlayerControllerStatusReadyToPlay;
+}
+
+void WebPlaybackSessionInterfaceAVKit::setCurrentTime(double currentTime, double anchorTime)
+{
+    NSTimeInterval anchorTimeStamp = ![m_playerController rate] ? NAN : anchorTime;
+    AVValueTiming *timing = [getAVValueTimingClass() valueTimingWithAnchorValue:currentTime
+        anchorTimeStamp:anchorTimeStamp rate:0];
+
+    [m_playerController setTiming:timing];
+}
+
+void WebPlaybackSessionInterfaceAVKit::setBufferedTime(double bufferedTime)
+{
+    WebAVPlayerController* playerController = m_playerController.get();
+    double duration = playerController.contentDuration;
+    double normalizedBufferedTime;
+    if (!duration)
+        normalizedBufferedTime = 0;
+    else
+        normalizedBufferedTime = bufferedTime / duration;
+    playerController.loadedTimeRanges = @[@0, @(normalizedBufferedTime)];
+}
+
+void WebPlaybackSessionInterfaceAVKit::setRate(bool isPlaying, float playbackRate)
+{
+    [m_playerController setRate:isPlaying ? playbackRate : 0.];
+}
+
+void WebPlaybackSessionInterfaceAVKit::setSeekableRanges(const TimeRanges&amp; timeRanges)
+{
+    RetainPtr&lt;NSMutableArray&gt; seekableRanges = adoptNS([[NSMutableArray alloc] init]);
+    ExceptionCode exceptionCode;
+
+    for (unsigned i = 0; i &lt; timeRanges.length(); i++) {
+        double start = timeRanges.start(i, exceptionCode);
+        double end = timeRanges.end(i, exceptionCode);
+
+        CMTimeRange range = CMTimeRangeMake(CMTimeMakeWithSeconds(start, 1000), CMTimeMakeWithSeconds(end-start, 1000));
+        [seekableRanges addObject:[NSValue valueWithCMTimeRange:range]];
+    }
+
+    [m_playerController setSeekableTimeRanges:seekableRanges.get()];
+}
+
+void WebPlaybackSessionInterfaceAVKit::setCanPlayFastReverse(bool canPlayFastReverse)
+{
+    [m_playerController setCanScanBackward:canPlayFastReverse];
+}
+
+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) {
+        RetainPtr&lt;WebAVMediaSelectionOption&gt; webOption = adoptNS([[WebAVMediaSelectionOption alloc] init]);
+        [webOption setLocalizedDisplayName:name];
+        [webOptions addObject:webOption.get()];
+    }
+    return webOptions;
+}
+
+void WebPlaybackSessionInterfaceAVKit::setAudioMediaSelectionOptions(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex)
+{
+    RetainPtr&lt;NSMutableArray&gt; webOptions = mediaSelectionOptions(options);
+    [m_playerController setAudioMediaSelectionOptions:webOptions.get()];
+    if (selectedIndex &lt; [webOptions count])
+        [m_playerController setCurrentAudioMediaSelectionOption:[webOptions objectAtIndex:static_cast&lt;NSUInteger&gt;(selectedIndex)]];
+}
+
+void WebPlaybackSessionInterfaceAVKit::setLegibleMediaSelectionOptions(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex)
+{
+    RetainPtr&lt;NSMutableArray&gt; webOptions = mediaSelectionOptions(options);
+    [m_playerController setLegibleMediaSelectionOptions:webOptions.get()];
+    if (selectedIndex &lt; [webOptions count])
+        [m_playerController setCurrentLegibleMediaSelectionOption:[webOptions objectAtIndex:static_cast&lt;NSUInteger&gt;(selectedIndex)]];
+}
+
+void WebPlaybackSessionInterfaceAVKit::setExternalPlayback(bool enabled, ExternalPlaybackTargetType targetType, String localizedDeviceName)
+{
+    AVPlayerControllerExternalPlaybackType externalPlaybackType = AVPlayerControllerExternalPlaybackTypeNone;
+    if (targetType == TargetTypeAirPlay)
+        externalPlaybackType = AVPlayerControllerExternalPlaybackTypeAirPlay;
+    else if (targetType == TargetTypeTVOut)
+        externalPlaybackType = AVPlayerControllerExternalPlaybackTypeTVOut;
+
+    WebAVPlayerController* playerController = m_playerController.get();
+    playerController.externalPlaybackAirPlayDeviceLocalizedName = localizedDeviceName;
+    playerController.externalPlaybackType = externalPlaybackType;
+    playerController.externalPlaybackActive = enabled;
+
+    if (m_client)
+        m_client-&gt;externalPlaybackEnabledChanged(enabled);
+}
+
+void WebPlaybackSessionInterfaceAVKit::setWirelessVideoPlaybackDisabled(bool disabled)
+{
+    [m_playerController setAllowsExternalPlayback:!disabled];
+}
+
+bool WebPlaybackSessionInterfaceAVKit::wirelessVideoPlaybackDisabled() const
+{
+    return [m_playerController allowsExternalPlayback];
+}
+
+void WebPlaybackSessionInterfaceAVKit::invalidate()
+{
+    m_playbackSessionModel = nil;
+}
+
+}
+
+#endif // HAVE(AVKIT)
+#endif // PLATFORM(IOS)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenControllerAVKitmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm (199592 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm        2016-04-15 17:18:12 UTC (rev 199592)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -33,6 +33,8 @@
</span><span class="cx"> #import &quot;QuartzCoreSPI.h&quot;
</span><span class="cx"> #import &quot;SoftLinking.h&quot;
</span><span class="cx"> #import &quot;TimeRanges.h&quot;
</span><ins>+#import &quot;WebPlaybackSessionInterfaceAVKit.h&quot;
+#import &quot;WebPlaybackSessionModelMediaElement.h&quot;
</ins><span class="cx"> #import &quot;WebVideoFullscreenChangeObserver.h&quot;
</span><span class="cx"> #import &quot;WebVideoFullscreenInterfaceAVKit.h&quot;
</span><span class="cx"> #import &quot;WebVideoFullscreenModelVideoElement.h&quot;
</span><span class="lines">@@ -554,14 +556,14 @@
</span><span class="cx">     dispatch_async(dispatch_get_main_queue(), [strongThis, this, viewRef, mode] {
</span><span class="cx">         ASSERT(isUIThread());
</span><span class="cx"> 
</span><del>-        m_interface = WebVideoFullscreenInterfaceAVKit::create();
</del><ins>+        m_interface = WebVideoFullscreenInterfaceAVKit::create(WebPlaybackSessionInterfaceAVKit::create().get());
</ins><span class="cx">         m_interface-&gt;setWebVideoFullscreenChangeObserver(this);
</span><span class="cx">         m_interface-&gt;setWebVideoFullscreenModel(this);
</span><span class="cx">         m_videoFullscreenView = adoptNS([[getUIViewClass() alloc] init]);
</span><span class="cx">         
</span><span class="cx">         RefPtr&lt;WebVideoFullscreenControllerContext&gt; strongThis(this);
</span><span class="cx">         WebThreadRun([strongThis, this, viewRef, mode] {
</span><del>-            m_model = WebVideoFullscreenModelVideoElement::create();
</del><ins>+            m_model = WebVideoFullscreenModelVideoElement::create(WebPlaybackSessionModelMediaElement::create().get());
</ins><span class="cx">             m_model-&gt;setWebVideoFullscreenInterface(this);
</span><span class="cx">             m_model-&gt;setVideoElement(m_videoElement.get());
</span><span class="cx">             
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceAVKith"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h (199592 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h        2016-04-15 17:18:12 UTC (rev 199592)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #include &quot;HTMLMediaElementEnums.h&quot;
</span><span class="cx"> #include &quot;PlatformLayer.h&quot;
</span><span class="cx"> #include &quot;Timer.h&quot;
</span><ins>+#include &quot;WebPlaybackSessionInterfaceAVKit.h&quot;
</ins><span class="cx"> #include &quot;WebVideoFullscreenInterface.h&quot;
</span><span class="cx"> #include &lt;functional&gt;
</span><span class="cx"> #include &lt;objc/objc.h&gt;
</span><span class="lines">@@ -40,14 +41,15 @@
</span><span class="cx"> #include &lt;wtf/RefPtr.h&gt;
</span><span class="cx"> #include &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> 
</span><del>-OBJC_CLASS WebAVPlayerController;
</del><span class="cx"> OBJC_CLASS AVPlayerViewController;
</span><span class="cx"> OBJC_CLASS UIViewController;
</span><span class="cx"> OBJC_CLASS UIWindow;
</span><span class="cx"> OBJC_CLASS UIView;
</span><span class="cx"> OBJC_CLASS CALayer;
</span><ins>+OBJC_CLASS WebAVPlayerController;
</ins><span class="cx"> OBJC_CLASS WebAVPlayerLayerView;
</span><span class="cx"> OBJC_CLASS WebAVPlayerLayer;
</span><ins>+OBJC_CLASS WebAVPlayerViewControllerDelegate;
</ins><span class="cx"> 
</span><span class="cx"> namespace WTF {
</span><span class="cx"> class String;
</span><span class="lines">@@ -58,32 +60,29 @@
</span><span class="cx"> class WebVideoFullscreenModel;
</span><span class="cx"> class WebVideoFullscreenChangeObserver;
</span><span class="cx">     
</span><del>-class WEBCORE_EXPORT WebVideoFullscreenInterfaceAVKit
</del><ins>+class WEBCORE_EXPORT WebVideoFullscreenInterfaceAVKit final
</ins><span class="cx">     : public WebVideoFullscreenInterface
</span><ins>+    , public WebPlaybackSessionInterfaceAVKitClient
</ins><span class="cx">     , public RefCounted&lt;WebVideoFullscreenInterfaceAVKit&gt; {
</span><span class="cx"> 
</span><span class="cx"> public:
</span><del>-    static Ref&lt;WebVideoFullscreenInterfaceAVKit&gt; create()
-    {
-        return adoptRef(*new WebVideoFullscreenInterfaceAVKit());
-    }
</del><ins>+    static Ref&lt;WebVideoFullscreenInterfaceAVKit&gt; create(WebPlaybackSessionInterfaceAVKit&amp;);
</ins><span class="cx">     virtual ~WebVideoFullscreenInterfaceAVKit();
</span><span class="cx">     WEBCORE_EXPORT void setWebVideoFullscreenModel(WebVideoFullscreenModel*);
</span><span class="cx">     WEBCORE_EXPORT void setWebVideoFullscreenChangeObserver(WebVideoFullscreenChangeObserver*);
</span><span class="cx">     
</span><del>-    WEBCORE_EXPORT void resetMediaState() override;
-    WEBCORE_EXPORT void setDuration(double) override;
-    WEBCORE_EXPORT void setCurrentTime(double currentTime, double anchorTime) override;
-    WEBCORE_EXPORT void setBufferedTime(double bufferedTime) override;
-    WEBCORE_EXPORT void setRate(bool isPlaying, float playbackRate) override;
-    WEBCORE_EXPORT void setVideoDimensions(bool hasVideo, float width, float height) override;
-    WEBCORE_EXPORT void setSeekableRanges(const TimeRanges&amp;) override;
-    WEBCORE_EXPORT void setCanPlayFastReverse(bool) override;
-    WEBCORE_EXPORT void setAudioMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex) override;
-    WEBCORE_EXPORT void setLegibleMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex) override;
-    WEBCORE_EXPORT void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, WTF::String localizedDeviceName) override;
-    WEBCORE_EXPORT void setWirelessVideoPlaybackDisabled(bool) override;
-
</del><ins>+    WEBCORE_EXPORT void resetMediaState() final;
+    WEBCORE_EXPORT void setDuration(double) final;
+    WEBCORE_EXPORT void setCurrentTime(double currentTime, double anchorTime) final;
+    WEBCORE_EXPORT void setBufferedTime(double) final;
+    WEBCORE_EXPORT void setRate(bool isPlaying, float playbackRate) final;
+    WEBCORE_EXPORT void setVideoDimensions(bool hasVideo, float width, float height) final;
+    WEBCORE_EXPORT void setSeekableRanges(const TimeRanges&amp;) final;
+    WEBCORE_EXPORT void setCanPlayFastReverse(bool) final;
+    WEBCORE_EXPORT void setAudioMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex) final;
+    WEBCORE_EXPORT void setLegibleMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex) final;
+    WEBCORE_EXPORT void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, WTF::String localizedDeviceName) final;
+    WEBCORE_EXPORT void setWirelessVideoPlaybackDisabled(bool) final;
</ins><span class="cx">     WEBCORE_EXPORT virtual void setupFullscreen(UIView&amp;, const IntRect&amp; initialRect, UIView *, HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicturePlayback);
</span><span class="cx">     WEBCORE_EXPORT virtual void enterFullscreen();
</span><span class="cx">     WEBCORE_EXPORT virtual void exitFullscreen(const IntRect&amp; finalRect);
</span><span class="lines">@@ -100,6 +99,7 @@
</span><span class="cx">         PictureInPictureStarted
</span><span class="cx">     };
</span><span class="cx"> 
</span><ins>+    WebVideoFullscreenModel* model() const { return m_videoFullscreenModel; }
</ins><span class="cx">     bool shouldExitFullscreenWithReason(ExitFullScreenReason);
</span><span class="cx">     HTMLMediaElementEnums::VideoFullscreenMode mode() const { return m_mode; }
</span><span class="cx">     bool allowsPictureInPicturePlayback() const { return m_allowsPictureInPicturePlayback; }
</span><span class="lines">@@ -121,13 +121,16 @@
</span><span class="cx">     bool isMode(HTMLMediaElementEnums::VideoFullscreenMode mode) const { return m_mode == mode; }
</span><span class="cx"> 
</span><span class="cx"> protected:
</span><del>-    WEBCORE_EXPORT WebVideoFullscreenInterfaceAVKit();
</del><ins>+    WEBCORE_EXPORT WebVideoFullscreenInterfaceAVKit(WebPlaybackSessionInterfaceAVKit&amp;);
</ins><span class="cx">     void beginSession();
</span><span class="cx">     void enterPictureInPicture();
</span><span class="cx">     void enterFullscreenStandard();
</span><span class="cx">     void watchdogTimerFired();
</span><ins>+    void externalPlaybackEnabledChanged(bool) final;
+    WebAVPlayerController *playerController() const;
</ins><span class="cx"> 
</span><del>-    RetainPtr&lt;WebAVPlayerController&gt; m_playerController;
</del><ins>+    Ref&lt;WebPlaybackSessionInterfaceAVKit&gt; m_playbackSessionInterface;
+    RetainPtr&lt;WebAVPlayerViewControllerDelegate&gt; m_playerViewControllerDelegate;
</ins><span class="cx">     RetainPtr&lt;AVPlayerViewController&gt; m_playerViewController;
</span><span class="cx">     WebVideoFullscreenModel* m_videoFullscreenModel { nullptr };
</span><span class="cx">     WebVideoFullscreenChangeObserver* m_fullscreenChangeObserver { nullptr };
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceAVKitmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm (199592 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm        2016-04-15 17:18:12 UTC (rev 199592)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -37,7 +37,9 @@
</span><span class="cx"> #import &quot;Logging.h&quot;
</span><span class="cx"> #import &quot;RuntimeApplicationChecks.h&quot;
</span><span class="cx"> #import &quot;TimeRanges.h&quot;
</span><ins>+#import &quot;WebAVPlayerController.h&quot;
</ins><span class="cx"> #import &quot;WebCoreSystemInterface.h&quot;
</span><ins>+#import &quot;WebPlaybackSessionInterfaceAVKit.h&quot;
</ins><span class="cx"> #import &quot;WebVideoFullscreenChangeObserver.h&quot;
</span><span class="cx"> #import &quot;WebVideoFullscreenModel.h&quot;
</span><span class="cx"> #import &lt;AVFoundation/AVTime.h&gt;
</span><span class="lines">@@ -61,9 +63,7 @@
</span><span class="cx"> 
</span><span class="cx"> SOFT_LINK_FRAMEWORK(AVKit)
</span><span class="cx"> SOFT_LINK_CLASS(AVKit, AVPictureInPictureController)
</span><del>-SOFT_LINK_CLASS(AVKit, AVPlayerController)
</del><span class="cx"> SOFT_LINK_CLASS(AVKit, AVPlayerViewController)
</span><del>-SOFT_LINK_CLASS(AVKit, AVValueTiming)
</del><span class="cx"> SOFT_LINK_CLASS(AVKit, __AVPlayerLayerView)
</span><span class="cx"> 
</span><span class="cx"> SOFT_LINK_FRAMEWORK(UIKit)
</span><span class="lines">@@ -125,128 +125,24 @@
</span><span class="cx"> 
</span><span class="cx"> @class WebAVMediaSelectionOption;
</span><span class="cx"> 
</span><del>-@interface WebAVPlayerController : NSObject &lt;AVPlayerViewControllerDelegate_WebKitOnly&gt; {
-    WebAVMediaSelectionOption *_currentAudioMediaSelectionOption;
-    WebAVMediaSelectionOption *_currentLegibleMediaSelectionOption;
-    BOOL _pictureInPictureInterrupted;
</del><ins>+@interface WebAVPlayerViewControllerDelegate : NSObject &lt;AVPlayerViewControllerDelegate_WebKitOnly&gt; {
+    RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; _fullscreenInterface;
</ins><span class="cx"> }
</span><del>-
-- (void)resetState;
-
-@property (retain) AVPlayerController* playerControllerProxy;
-@property (assign) WebVideoFullscreenModel* delegate;
</del><span class="cx"> @property (assign) WebVideoFullscreenInterfaceAVKit* fullscreenInterface;
</span><del>-
-@property (readonly) BOOL canScanForward;
-@property BOOL canScanBackward;
-@property (readonly) BOOL canSeekToBeginning;
-@property (readonly) BOOL canSeekToEnd;
-
-@property BOOL canPlay;
-@property (getter=isPlaying) BOOL playing;
-@property BOOL canPause;
-@property BOOL canTogglePlayback;
-@property double rate;
-@property BOOL canSeek;
-@property NSTimeInterval contentDuration;
-@property NSSize contentDimensions;
-@property BOOL hasEnabledAudio;
-@property BOOL hasEnabledVideo;
-@property NSTimeInterval minTime;
-@property NSTimeInterval maxTime;
-@property NSTimeInterval contentDurationWithinEndTimes;
-@property (retain) NSArray *loadedTimeRanges;
-@property AVPlayerControllerStatus status;
-@property (retain) AVValueTiming *timing;
-@property (retain) NSArray *seekableTimeRanges;
-
-@property (readonly) BOOL hasMediaSelectionOptions;
-@property (readonly) BOOL hasAudioMediaSelectionOptions;
-@property (retain) NSArray *audioMediaSelectionOptions;
-@property (retain) WebAVMediaSelectionOption *currentAudioMediaSelectionOption;
-@property (readonly) BOOL hasLegibleMediaSelectionOptions;
-@property (retain) NSArray *legibleMediaSelectionOptions;
-@property (retain) WebAVMediaSelectionOption *currentLegibleMediaSelectionOption;
-
-@property (readonly, getter=isPlayingOnExternalScreen) BOOL playingOnExternalScreen;
-@property (readonly, getter=isPlayingOnSecondScreen) BOOL playingOnSecondScreen;
-@property (getter=isExternalPlaybackActive) BOOL externalPlaybackActive;
-@property AVPlayerControllerExternalPlaybackType externalPlaybackType;
-@property (retain) NSString *externalPlaybackAirPlayDeviceLocalizedName;
-@property BOOL allowsExternalPlayback;
-
</del><span class="cx"> - (BOOL)playerViewController:(AVPlayerViewController *)playerViewController shouldExitFullScreenWithReason:(AVPlayerViewControllerExitFullScreenReason)reason;
</span><span class="cx"> @end
</span><span class="cx"> 
</span><del>-@implementation WebAVPlayerController
-
-- (instancetype)init
</del><ins>+@implementation WebAVPlayerViewControllerDelegate
+- (WebVideoFullscreenInterfaceAVKit*)fullscreenInterface
</ins><span class="cx"> {
</span><del>-    if (!(self = [super init]))
-        return self;
-    
-    _pictureInPictureInterrupted = NO;
-    initAVPlayerController();
-    self.playerControllerProxy = [[allocAVPlayerControllerInstance() init] autorelease];
-    return self;
</del><ins>+    return _fullscreenInterface.get();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)dealloc
</del><ins>+- (void)setFullscreenInterface:(WebVideoFullscreenInterfaceAVKit*)fullscreenInterface
</ins><span class="cx"> {
</span><del>-    [_playerControllerProxy release];
-    [_loadedTimeRanges release];
-    [_seekableTimeRanges release];
-    [_timing release];
-    [_audioMediaSelectionOptions release];
-    [_legibleMediaSelectionOptions release];
-    [_currentAudioMediaSelectionOption release];
-    [_currentLegibleMediaSelectionOption release];
-    [super dealloc];
</del><ins>+    _fullscreenInterface = fullscreenInterface;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)resetState
-{
-    self.contentDuration = 0;
-    self.maxTime = 0;
-    self.contentDurationWithinEndTimes = 0;
-    self.loadedTimeRanges = @[];
-    
-    self.canPlay = NO;
-    self.canPause = NO;
-    self.canTogglePlayback = NO;
-    self.hasEnabledAudio = NO;
-    self.canSeek = NO;
-    self.minTime = 0;
-    self.status = AVPlayerControllerStatusUnknown;
-    
-    self.timing = nil;
-    self.rate = 0;
-    
-    self.hasEnabledVideo = NO;
-    self.contentDimensions = CGSizeMake(0, 0);
-    
-    self.seekableTimeRanges = [NSMutableArray array];
-    
-    self.canScanBackward = NO;
-    
-    self.audioMediaSelectionOptions = nil;
-    self.currentAudioMediaSelectionOption = nil;
-    
-    self.legibleMediaSelectionOptions = nil;
-    self.currentLegibleMediaSelectionOption = nil;
-}
-
-- (AVPlayer *) player
-{
-    return nil;
-}
-
-- (id)forwardingTargetForSelector:(SEL)selector
-{
-    UNUSED_PARAM(selector);
-    return self.playerControllerProxy;
-}
-
</del><span class="cx"> - (void)playerViewControllerWillStartPictureInPicture:(AVPlayerViewController *)playerViewController
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(playerViewController);
</span><span class="lines">@@ -305,358 +201,12 @@
</span><span class="cx">     UNUSED_PARAM(playerViewController);
</span><span class="cx">     self.fullscreenInterface-&gt;prepareForPictureInPictureStopWithCompletionHandler(completionHandler);
</span><span class="cx"> }
</span><del>-
-- (void)play:(id)sender
-{
-    UNUSED_PARAM(sender);
-    if (!self.delegate)
-        return;
-    self.delegate-&gt;play();
-}
-
-- (void)pause:(id)sender
-{
-    UNUSED_PARAM(sender);
-    if (!self.delegate)
-        return;
-    self.delegate-&gt;pause();
-}
-
-- (void)togglePlayback:(id)sender
-{
-    UNUSED_PARAM(sender);
-    if (!self.delegate)
-        return;
-    self.delegate-&gt;togglePlayState();
-}
-
-- (void)togglePlaybackEvenWhenInBackground:(id)sender
-{
-    [self togglePlayback:sender];
-}
-
-- (BOOL)isPlaying
-{
-    return [self rate] != 0;
-}
-
-- (void)setPlaying:(BOOL)playing
-{
-    if (!self.delegate)
-        return;
-    if (playing)
-        self.delegate-&gt;play();
-    else
-        self.delegate-&gt;pause();
-}
-
-+ (NSSet *)keyPathsForValuesAffectingPlaying
-{
-    return [NSSet setWithObject:@&quot;rate&quot;];
-}
-
-- (void)beginScrubbing:(id)sender
-{
-    UNUSED_PARAM(sender);
-    if (!self.delegate)
-        return;
-    self.delegate-&gt;beginScrubbing();
-}
-
-- (void)endScrubbing:(id)sender
-{
-    UNUSED_PARAM(sender);
-    if (!self.delegate)
-        return;
-    self.delegate-&gt;endScrubbing();
-}
-
-- (void)seekToTime:(NSTimeInterval)time
-{
-    if (!self.delegate)
-        return;
-    self.delegate-&gt;fastSeek(time);
-}
-
-- (NSTimeInterval)currentTimeWithinEndTimes
-{
-    return self.timing.currentValue;
-}
-
-- (void)setCurrentTimeWithinEndTimes:(NSTimeInterval)currentTimeWithinEndTimes
-{
-    [self seekToTime:currentTimeWithinEndTimes];
-}
-
-+ (NSSet *)keyPathsForValuesAffectingCurrentTimeWithinEndTimes
-{
-    return [NSSet setWithObject:@&quot;timing&quot;];
-}
-
-- (BOOL)hasLiveStreamingContent
-{
-    if ([self status] == AVPlayerControllerStatusReadyToPlay)
-        return [self contentDuration] == std::numeric_limits&lt;float&gt;::infinity();
-    return NO;
-}
-
-+ (NSSet *)keyPathsForValuesAffectingHasLiveStreamingContent
-{
-    return [NSSet setWithObjects:@&quot;contentDuration&quot;, @&quot;status&quot;, nil];
-}
-
-- (void)skipBackwardThirtySeconds:(id)sender
-{
-    UNUSED_PARAM(sender);
-    BOOL isTimeWithinSeekableTimeRanges = NO;
-    CMTime currentTime = CMTimeMakeWithSeconds([[self timing] currentValue], 1000);
-    CMTime thirtySecondsBeforeCurrentTime = CMTimeSubtract(currentTime, CMTimeMake(30, 1));
-    
-    for (NSValue *seekableTimeRangeValue in [self seekableTimeRanges]) {
-        if (CMTimeRangeContainsTime([seekableTimeRangeValue CMTimeRangeValue], thirtySecondsBeforeCurrentTime)) {
-            isTimeWithinSeekableTimeRanges = YES;
-            break;
-        }
-    }
-    
-    if (isTimeWithinSeekableTimeRanges)
-        [self seekToTime:CMTimeGetSeconds(thirtySecondsBeforeCurrentTime)];
-}
-
-- (void)gotoEndOfSeekableRanges:(id)sender
-{
-    UNUSED_PARAM(sender);
-    NSTimeInterval timeAtEndOfSeekableTimeRanges = NAN;
-    
-    for (NSValue *seekableTimeRangeValue in [self seekableTimeRanges]) {
-        CMTimeRange seekableTimeRange = [seekableTimeRangeValue CMTimeRangeValue];
-        NSTimeInterval endOfSeekableTimeRange = CMTimeGetSeconds(CMTimeRangeGetEnd(seekableTimeRange));
-        if (isnan(timeAtEndOfSeekableTimeRanges) || endOfSeekableTimeRange &gt; timeAtEndOfSeekableTimeRanges)
-            timeAtEndOfSeekableTimeRanges = endOfSeekableTimeRange;
-    }
-    
-    if (!isnan(timeAtEndOfSeekableTimeRanges))
-        [self seekToTime:timeAtEndOfSeekableTimeRanges];
-}
-
-- (BOOL)canScanForward
-{
-    return [self canPlay];
-}
-
-+ (NSSet *)keyPathsForValuesAffectingCanScanForward
-{
-    return [NSSet setWithObject:@&quot;canPlay&quot;];
-}
-
-- (void)beginScanningForward:(id)sender
-{
-    UNUSED_PARAM(sender);
-    if (!self.delegate)
-        return;
-    self.delegate-&gt;beginScanningForward();
-}
-
-- (void)endScanningForward:(id)sender
-{
-    UNUSED_PARAM(sender);
-    if (!self.delegate)
-        return;
-    self.delegate-&gt;endScanning();
-}
-
-- (void)beginScanningBackward:(id)sender
-{
-    UNUSED_PARAM(sender);
-    if (!self.delegate)
-        return;
-    self.delegate-&gt;beginScanningBackward();
-}
-
-- (void)endScanningBackward:(id)sender
-{
-    UNUSED_PARAM(sender);
-    if (!self.delegate)
-        return;
-    self.delegate-&gt;endScanning();
-}
-
-- (BOOL)canSeekToBeginning
-{
-    CMTime minimumTime = kCMTimeIndefinite;
-
-    for (NSValue *value in [self seekableTimeRanges])
-        minimumTime = CMTimeMinimum([value CMTimeRangeValue].start, minimumTime);
-
-    return CMTIME_IS_NUMERIC(minimumTime);
-}
-
-+ (NSSet *)keyPathsForValuesAffectingCanSeekToBeginning
-{
-    return [NSSet setWithObject:@&quot;seekableTimeRanges&quot;];
-}
-
-- (void)seekToBeginning:(id)sender
-{
-    UNUSED_PARAM(sender);
-    if (!self.delegate)
-        return;
-    self.delegate-&gt;seekToTime(-INFINITY);
-}
-
-- (void)seekChapterBackward:(id)sender
-{
-    [self seekToBeginning:sender];
-}
-
-- (BOOL)canSeekToEnd
-{
-    CMTime maximumTime = kCMTimeIndefinite;
-
-    for (NSValue *value in [self seekableTimeRanges])
-        maximumTime = CMTimeMaximum(CMTimeRangeGetEnd([value CMTimeRangeValue]), maximumTime);
-
-    return CMTIME_IS_NUMERIC(maximumTime);
-}
-
-+ (NSSet *)keyPathsForValuesAffectingCanSeekToEnd
-{
-    return [NSSet setWithObject:@&quot;seekableTimeRanges&quot;];
-}
-
-- (void)seekToEnd:(id)sender
-{
-    UNUSED_PARAM(sender);
-    if (!self.delegate)
-        return;
-    self.delegate-&gt;seekToTime(INFINITY);
-}
-
-- (void)seekChapterForward:(id)sender
-{
-    [self seekToEnd:sender];
-}
-
-- (BOOL)hasMediaSelectionOptions
-{
-    return [self hasAudioMediaSelectionOptions] || [self hasLegibleMediaSelectionOptions];
-}
-
-+ (NSSet *)keyPathsForValuesAffectingHasMediaSelectionOptions
-{
-    return [NSSet setWithObjects:@&quot;hasAudioMediaSelectionOptions&quot;, @&quot;hasLegibleMediaSelectionOptions&quot;, nil];
-}
-
-- (BOOL)hasAudioMediaSelectionOptions
-{
-    return [[self audioMediaSelectionOptions] count] &gt; 1;
-}
-
-+ (NSSet *)keyPathsForValuesAffectingHasAudioMediaSelectionOptions
-{
-    return [NSSet setWithObject:@&quot;audioMediaSelectionOptions&quot;];
-}
-
-- (BOOL)hasLegibleMediaSelectionOptions
-{
-    const NSUInteger numDefaultLegibleOptions = 2;
-    return [[self legibleMediaSelectionOptions] count] &gt; numDefaultLegibleOptions;
-}
-
-+ (NSSet *)keyPathsForValuesAffectingHasLegibleMediaSelectionOptions
-{
-    return [NSSet setWithObject:@&quot;legibleMediaSelectionOptions&quot;];
-}
-
-- (WebAVMediaSelectionOption *)currentAudioMediaSelectionOption
-{
-    return _currentAudioMediaSelectionOption;
-}
-
-- (void)setCurrentAudioMediaSelectionOption:(WebAVMediaSelectionOption *)option
-{
-    if (option == _currentAudioMediaSelectionOption)
-        return;
-    
-    [_currentAudioMediaSelectionOption release];
-    _currentAudioMediaSelectionOption = [option retain];
-    
-    if (!self.delegate)
-        return;
-    
-    NSInteger index = NSNotFound;
-    
-    if (option &amp;&amp; self.audioMediaSelectionOptions)
-        index = [self.audioMediaSelectionOptions indexOfObject:option];
-    
-    self.delegate-&gt;selectAudioMediaOption(index != NSNotFound ? index : UINT64_MAX);
-}
-
-- (WebAVMediaSelectionOption *)currentLegibleMediaSelectionOption
-{
-    return _currentLegibleMediaSelectionOption;
-}
-
-- (void)setCurrentLegibleMediaSelectionOption:(WebAVMediaSelectionOption *)option
-{
-    if (option == _currentLegibleMediaSelectionOption)
-        return;
-    
-    [_currentLegibleMediaSelectionOption release];
-    _currentLegibleMediaSelectionOption = [option retain];
-    
-    if (!self.delegate)
-        return;
-    
-    NSInteger index = NSNotFound;
-    
-    if (option &amp;&amp; self.legibleMediaSelectionOptions)
-        index = [self.legibleMediaSelectionOptions indexOfObject:option];
-    
-    self.delegate-&gt;selectLegibleMediaOption(index != NSNotFound ? index : UINT64_MAX);
-}
-
-- (BOOL)isPlayingOnExternalScreen
-{
-    return [self isExternalPlaybackActive] || [self isPlayingOnSecondScreen];
-}
-
-+ (NSSet *)keyPathsForValuesAffectingPlayingOnExternalScreen
-{
-    return [NSSet setWithObjects:@&quot;externalPlaybackActive&quot;, @&quot;playingOnSecondScreen&quot;, nil];
-}
-
-- (BOOL)isPictureInPicturePossible
-{
-    return self.fullscreenInterface-&gt;allowsPictureInPicturePlayback();
-}
-
-- (BOOL)isPictureInPictureInterrupted
-{
-    return _pictureInPictureInterrupted;
-}
-
-- (void)setPictureInPictureInterrupted:(BOOL)pictureInPictureInterrupted
-{
-    if (_pictureInPictureInterrupted != pictureInPictureInterrupted) {
-        _pictureInPictureInterrupted = pictureInPictureInterrupted;
-        if (pictureInPictureInterrupted)
-            [self setPlaying:NO];
-    }
-}
-
</del><span class="cx"> @end
</span><span class="cx"> 
</span><del>-@interface WebAVMediaSelectionOption : NSObject
-@property (retain) NSString *localizedDisplayName;
-@end
-
-@implementation WebAVMediaSelectionOption
-@end
-
</del><span class="cx"> @interface WebAVPlayerLayer : CALayer
</span><span class="cx"> @property (nonatomic, retain) NSString *videoGravity;
</span><span class="cx"> @property (nonatomic, getter=isReadyForDisplay) BOOL readyForDisplay;
</span><ins>+@property (nonatomic, assign) WebVideoFullscreenInterfaceAVKit* fullscreenInterface;
</ins><span class="cx"> @property (nonatomic, retain) AVPlayerController *playerController;
</span><span class="cx"> @property (nonatomic, retain) CALayer *videoSublayer;
</span><span class="cx"> @property (nonatomic, copy, nullable) NSDictionary *pixelBufferAttributes;
</span><span class="lines">@@ -665,6 +215,7 @@
</span><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> @implementation WebAVPlayerLayer {
</span><ins>+    RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; _fullscreenInterface;
</ins><span class="cx">     RetainPtr&lt;WebAVPlayerController&gt; _avPlayerController;
</span><span class="cx">     RetainPtr&lt;CALayer&gt; _videoSublayer;
</span><span class="cx">     RetainPtr&lt;NSString&gt; _videoGravity;
</span><span class="lines">@@ -686,6 +237,16 @@
</span><span class="cx">     [super dealloc];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (WebVideoFullscreenInterfaceAVKit*)fullscreenInterface
+{
+    return _fullscreenInterface.get();
+}
+
+- (void)setFullscreenInterface:(WebVideoFullscreenInterfaceAVKit*)fullscreenInterface
+{
+    _fullscreenInterface = fullscreenInterface;
+}
+
</ins><span class="cx"> - (AVPlayerController *)playerController
</span><span class="cx"> {
</span><span class="cx">     return (AVPlayerController *)_avPlayerController.get();
</span><span class="lines">@@ -733,7 +294,8 @@
</span><span class="cx">     } else if ([getAVLayerVideoGravityResizeAspectFill() isEqualToString:self.videoGravity]) {
</span><span class="cx">         sourceVideoFrame = smallestRectWithAspectRatioAroundRect(videoAspectRatio, self.modelVideoLayerFrame);
</span><span class="cx">         self.modelVideoLayerFrame = CGRectMake(0, 0, sourceVideoFrame.width(), sourceVideoFrame.height());
</span><del>-        [_avPlayerController delegate]-&gt;setVideoLayerFrame(self.modelVideoLayerFrame);
</del><ins>+        ASSERT(fullscreenInterface-&gt;model());
+        _fullscreenInterface-&gt;model()-&gt;setVideoLayerFrame(self.modelVideoLayerFrame);
</ins><span class="cx">         targetVideoFrame = smallestRectWithAspectRatioAroundRect(videoAspectRatio, self.bounds);
</span><span class="cx">     } else
</span><span class="cx">         ASSERT_NOT_REACHED();
</span><span class="lines">@@ -765,7 +327,8 @@
</span><span class="cx">     [CATransaction setDisableActions:YES];
</span><span class="cx">     
</span><span class="cx">     self.modelVideoLayerFrame = [self bounds];
</span><del>-    [_avPlayerController delegate]-&gt;setVideoLayerFrame(self.modelVideoLayerFrame);
</del><ins>+    ASSERT(fullscreenInterface-&gt;model());
+    _fullscreenInterface-&gt;model()-&gt;setVideoLayerFrame(self.modelVideoLayerFrame);
</ins><span class="cx">     [(UIView *)[_videoSublayer delegate] setTransform:CGAffineTransformIdentity];
</span><span class="cx">     
</span><span class="cx">     [CATransaction commit];
</span><span class="lines">@@ -788,7 +351,8 @@
</span><span class="cx">     else
</span><span class="cx">         ASSERT_NOT_REACHED();
</span><span class="cx">     
</span><del>-    [_avPlayerController delegate]-&gt;setVideoLayerGravity(gravity);
</del><ins>+    ASSERT(fullscreenInterface-&gt;model());
+    _fullscreenInterface-&gt;model()-&gt;setVideoLayerGravity(gravity);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (NSString *)videoGravity
</span><span class="lines">@@ -954,35 +518,40 @@
</span><span class="cx">     return theClass;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-WebVideoFullscreenInterfaceAVKit::WebVideoFullscreenInterfaceAVKit()
-    : m_playerController(adoptNS([[WebAVPlayerController alloc] init]))
</del><ins>+Ref&lt;WebVideoFullscreenInterfaceAVKit&gt; WebVideoFullscreenInterfaceAVKit::create(WebPlaybackSessionInterfaceAVKit&amp; playbackSessionInterface)
+{
+    Ref&lt;WebVideoFullscreenInterfaceAVKit&gt; interface = adoptRef(*new WebVideoFullscreenInterfaceAVKit(playbackSessionInterface));
+    [interface-&gt;m_playerViewControllerDelegate setFullscreenInterface:interface.ptr()];
+    return interface;
+}
+
+WebVideoFullscreenInterfaceAVKit::WebVideoFullscreenInterfaceAVKit(WebPlaybackSessionInterfaceAVKit&amp; playbackSessionInterface)
+    : m_playbackSessionInterface(playbackSessionInterface)
+    , m_playerViewControllerDelegate(adoptNS([[WebAVPlayerViewControllerDelegate alloc] init]))
</ins><span class="cx">     , m_watchdogTimer(*this, &amp;WebVideoFullscreenInterfaceAVKit::watchdogTimerFired)
</span><span class="cx"> {
</span><del>-    [m_playerController setFullscreenInterface:this];
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> WebVideoFullscreenInterfaceAVKit::~WebVideoFullscreenInterfaceAVKit()
</span><span class="cx"> {
</span><del>-    WebAVPlayerController* playerController = m_playerController.get();
</del><ins>+    WebAVPlayerController* playerController = this-&gt;playerController();
</ins><span class="cx">     if (playerController &amp;&amp; playerController.externalPlaybackActive)
</span><span class="cx">         setExternalPlayback(false, TargetTypeNone, &quot;&quot;);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+WebAVPlayerController *WebVideoFullscreenInterfaceAVKit::playerController() const
+{
+    return m_playbackSessionInterface-&gt;playerController();
+}
+
</ins><span class="cx"> void WebVideoFullscreenInterfaceAVKit::resetMediaState()
</span><span class="cx"> {
</span><del>-    if (!m_playerController) {
-        m_playerController = adoptNS([[WebAVPlayerController alloc] init]);
-        [m_playerController setDelegate:m_videoFullscreenModel];
-        [m_playerController setFullscreenInterface:this];
-        
-    } else
-        [m_playerController resetState];
</del><ins>+    m_playbackSessionInterface-&gt;resetMediaState();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::setWebVideoFullscreenModel(WebVideoFullscreenModel* model)
</span><span class="cx"> {
</span><span class="cx">     m_videoFullscreenModel = model;
</span><del>-    [m_playerController setDelegate:m_videoFullscreenModel];
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::setWebVideoFullscreenChangeObserver(WebVideoFullscreenChangeObserver* observer)
</span><span class="lines">@@ -992,47 +561,22 @@
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::setDuration(double duration)
</span><span class="cx"> {
</span><del>-    WebAVPlayerController* playerController = m_playerController.get();
-
-    // FIXME: https://bugs.webkit.org/show_bug.cgi?id=127017 use correct values instead of duration for all these
-    playerController.contentDuration = duration;
-    playerController.maxTime = duration;
-    playerController.contentDurationWithinEndTimes = duration;
-
-    // FIXME: we take this as an indication that playback is ready.
-    playerController.canPlay = YES;
-    playerController.canPause = YES;
-    playerController.canTogglePlayback = YES;
-    playerController.hasEnabledAudio = YES;
-    playerController.canSeek = YES;
-    playerController.minTime = 0;
-    playerController.status = AVPlayerControllerStatusReadyToPlay;
</del><ins>+    m_playbackSessionInterface-&gt;setDuration(duration);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::setCurrentTime(double currentTime, double anchorTime)
</span><span class="cx"> {
</span><del>-    NSTimeInterval anchorTimeStamp = ![m_playerController rate] ? NAN : anchorTime;
-    AVValueTiming *timing = [getAVValueTimingClass() valueTimingWithAnchorValue:currentTime
-        anchorTimeStamp:anchorTimeStamp rate:0];
-    
-    [m_playerController setTiming:timing];
</del><ins>+    m_playbackSessionInterface-&gt;setCurrentTime(currentTime, anchorTime);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::setBufferedTime(double bufferedTime)
</span><span class="cx"> {
</span><del>-    WebAVPlayerController* playerController = m_playerController.get();
-    double duration = playerController.contentDuration;
-    double normalizedBufferedTime;
-    if (!duration)
-        normalizedBufferedTime = 0;
-    else
-        normalizedBufferedTime = bufferedTime / duration;
-    playerController.loadedTimeRanges = @[@0, @(normalizedBufferedTime)];
</del><ins>+    m_playbackSessionInterface-&gt;setBufferedTime(bufferedTime);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::setRate(bool isPlaying, float playbackRate)
</span><span class="cx"> {
</span><del>-    [m_playerController setRate:isPlaying ? playbackRate : 0.];
</del><ins>+    m_playbackSessionInterface-&gt;setRate(isPlaying, playbackRate);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::setVideoDimensions(bool hasVideo, float width, float height)
</span><span class="lines">@@ -1040,8 +584,8 @@
</span><span class="cx">     WebAVPlayerLayer *playerLayer = (WebAVPlayerLayer *)[m_playerLayerView playerLayer];
</span><span class="cx"> 
</span><span class="cx">     [playerLayer setVideoDimensions:CGSizeMake(width, height)];
</span><del>-    [m_playerController setHasEnabledVideo:hasVideo];
-    [m_playerController setContentDimensions:CGSizeMake(width, height)];
</del><ins>+    [playerController() setHasEnabledVideo:hasVideo];
+    [playerController() setContentDimensions:CGSizeMake(width, height)];
</ins><span class="cx">     [m_playerLayerView setNeedsLayout];
</span><span class="cx"> 
</span><span class="cx">     WebAVPictureInPicturePlayerLayerView *pipView = (WebAVPictureInPicturePlayerLayerView *)[m_playerLayerView pictureInPicturePlayerLayerView];
</span><span class="lines">@@ -1052,75 +596,42 @@
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::setSeekableRanges(const TimeRanges&amp; timeRanges)
</span><span class="cx"> {
</span><del>-    RetainPtr&lt;NSMutableArray&gt; seekableRanges = adoptNS([[NSMutableArray alloc] init]);
-    ExceptionCode exceptionCode;
-
-    for (unsigned i = 0; i &lt; timeRanges.length(); i++) {
-        double start = timeRanges.start(i, exceptionCode);
-        double end = timeRanges.end(i, exceptionCode);
-        
-        CMTimeRange range = CMTimeRangeMake(CMTimeMakeWithSeconds(start, 1000), CMTimeMakeWithSeconds(end-start, 1000));
-        [seekableRanges addObject:[NSValue valueWithCMTimeRange:range]];
-    }
-    
-    [m_playerController setSeekableTimeRanges:seekableRanges.get()];
</del><ins>+    m_playbackSessionInterface-&gt;setSeekableRanges(timeRanges);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::setCanPlayFastReverse(bool canPlayFastReverse)
</span><span class="cx"> {
</span><del>-    [m_playerController setCanScanBackward:canPlayFastReverse];
</del><ins>+    m_playbackSessionInterface-&gt;setCanPlayFastReverse(canPlayFastReverse);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-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) {
-        RetainPtr&lt;WebAVMediaSelectionOption&gt; webOption = adoptNS([[WebAVMediaSelectionOption alloc] init]);
-        [webOption setLocalizedDisplayName:name];
-        [webOptions addObject:webOption.get()];
-    }
-    return webOptions;
-}
-
</del><span class="cx"> void WebVideoFullscreenInterfaceAVKit::setAudioMediaSelectionOptions(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex)
</span><span class="cx"> {
</span><del>-    RetainPtr&lt;NSMutableArray&gt; webOptions = mediaSelectionOptions(options);
-    [m_playerController setAudioMediaSelectionOptions:webOptions.get()];
-    if (selectedIndex &lt; [webOptions count])
-        [m_playerController setCurrentAudioMediaSelectionOption:[webOptions objectAtIndex:static_cast&lt;NSUInteger&gt;(selectedIndex)]];
</del><ins>+    m_playbackSessionInterface-&gt;setAudioMediaSelectionOptions(options, selectedIndex);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::setLegibleMediaSelectionOptions(const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex)
</span><span class="cx"> {
</span><del>-    RetainPtr&lt;NSMutableArray&gt; webOptions = mediaSelectionOptions(options);
-    [m_playerController setLegibleMediaSelectionOptions:webOptions.get()];
-    if (selectedIndex &lt; [webOptions count])
-        [m_playerController setCurrentLegibleMediaSelectionOption:[webOptions objectAtIndex:static_cast&lt;NSUInteger&gt;(selectedIndex)]];
</del><ins>+    m_playbackSessionInterface-&gt;setLegibleMediaSelectionOptions(options, selectedIndex);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::setExternalPlayback(bool enabled, ExternalPlaybackTargetType targetType, String localizedDeviceName)
</span><span class="cx"> {
</span><del>-    AVPlayerControllerExternalPlaybackType externalPlaybackType = AVPlayerControllerExternalPlaybackTypeNone;
-    if (targetType == TargetTypeAirPlay)
-        externalPlaybackType = AVPlayerControllerExternalPlaybackTypeAirPlay;
-    else if (targetType == TargetTypeTVOut)
-        externalPlaybackType = AVPlayerControllerExternalPlaybackTypeTVOut;
</del><ins>+    m_playbackSessionInterface-&gt;setExternalPlayback(enabled, targetType, localizedDeviceName);
+}
</ins><span class="cx"> 
</span><del>-    WebAVPlayerController* playerController = m_playerController.get();
-    playerController.externalPlaybackAirPlayDeviceLocalizedName = localizedDeviceName;
-    playerController.externalPlaybackType = externalPlaybackType;
-    playerController.externalPlaybackActive = enabled;
</del><ins>+void WebVideoFullscreenInterfaceAVKit::externalPlaybackEnabledChanged(bool enabled)
+{
</ins><span class="cx">     [m_playerLayerView setHidden:enabled];
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::setWirelessVideoPlaybackDisabled(bool disabled)
</span><span class="cx"> {
</span><del>-    [m_playerController setAllowsExternalPlayback:!disabled];
</del><ins>+    m_playbackSessionInterface-&gt;setWirelessVideoPlaybackDisabled(disabled);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool WebVideoFullscreenInterfaceAVKit::wirelessVideoPlaybackDisabled() const
</span><span class="cx"> {
</span><del>-    return [m_playerController allowsExternalPlayback];
</del><ins>+    return m_playbackSessionInterface-&gt;wirelessVideoPlaybackDisabled();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::applicationDidBecomeActive()
</span><span class="lines">@@ -1178,7 +689,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (!m_playerLayerView)
</span><span class="cx">         m_playerLayerView = adoptNS([[getWebAVPlayerLayerViewClass() alloc] init]);
</span><del>-    [m_playerLayerView setHidden:[m_playerController isExternalPlaybackActive]];
</del><ins>+    [m_playerLayerView setHidden:[playerController() isExternalPlaybackActive]];
</ins><span class="cx">     [m_playerLayerView setBackgroundColor:[getUIColorClass() clearColor]];
</span><span class="cx"> 
</span><span class="cx">     if (!isInPictureInPictureMode) {
</span><span class="lines">@@ -1189,16 +700,19 @@
</span><span class="cx">     WebAVPlayerLayer *playerLayer = (WebAVPlayerLayer *)[m_playerLayerView playerLayer];
</span><span class="cx"> 
</span><span class="cx">     [playerLayer setModelVideoLayerFrame:CGRectMake(0, 0, initialRect.width(), initialRect.height())];
</span><del>-    [playerLayer setVideoDimensions:[m_playerController contentDimensions]];
</del><ins>+    [playerLayer setVideoDimensions:[playerController() contentDimensions]];
+    playerLayer.fullscreenInterface = this;
</ins><span class="cx"> 
</span><span class="cx">     if (!m_playerViewController)
</span><span class="cx">         m_playerViewController = adoptNS([allocAVPlayerViewControllerInstance() initWithPlayerLayerView:m_playerLayerView.get()]);
</span><span class="cx"> 
</span><span class="cx">     [m_playerViewController setShowsPlaybackControls:NO];
</span><del>-    [m_playerViewController setPlayerController:(AVPlayerController *)m_playerController.get()];
-    [m_playerViewController setDelegate:m_playerController.get()];
</del><ins>+    [m_playerViewController setPlayerController:(AVPlayerController *)playerController()];
+    [m_playerViewController setDelegate:m_playerViewControllerDelegate.get()];
</ins><span class="cx">     [m_playerViewController setAllowsPictureInPicturePlayback:m_allowsPictureInPicturePlayback];
</span><span class="cx"> 
</span><ins>+    [playerController() setPictureInPicturePossible:m_allowsPictureInPicturePlayback];
+
</ins><span class="cx">     if (m_viewController) {
</span><span class="cx">         [m_viewController addChildViewController:m_playerViewController.get()];
</span><span class="cx">         [[m_viewController view] addSubview:[m_playerViewController view]];
</span><span class="lines">@@ -1339,8 +853,7 @@
</span><span class="cx">             [[getUIApplicationClass() sharedApplication] _setStatusBarOrientation:[m_parentWindow interfaceOrientation]];
</span><span class="cx">     }
</span><span class="cx">     
</span><del>-    [m_playerController setDelegate:nil];
-    [m_playerController setFullscreenInterface:nil];
</del><ins>+    [playerController() setDelegate:nil];
</ins><span class="cx">     
</span><span class="cx">     [m_playerViewController setDelegate:nil];
</span><span class="cx">     [m_playerViewController setPlayerController:nil];
</span><span class="lines">@@ -1359,8 +872,6 @@
</span><span class="cx"> 
</span><span class="cx">     m_playerLayerView = nil;
</span><span class="cx">     m_playerViewController = nil;
</span><del>-    m_playerController = nil;
-    m_viewController = nil;
</del><span class="cx">     m_window = nil;
</span><span class="cx">     m_parentView = nil;
</span><span class="cx">     m_parentWindow = nil;
</span><span class="lines">@@ -1412,7 +923,7 @@
</span><span class="cx"> 
</span><span class="cx"> bool WebVideoFullscreenInterfaceAVKit::mayAutomaticallyShowVideoPictureInPicture() const
</span><span class="cx"> {
</span><del>-    return [m_playerController isPlaying] &amp;&amp; m_mode == HTMLMediaElementEnums::VideoFullscreenModeStandard &amp;&amp; supportsPictureInPicture();
</del><ins>+    return [playerController() isPlaying] &amp;&amp; m_mode == HTMLMediaElementEnums::VideoFullscreenModeStandard &amp;&amp; supportsPictureInPicture();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceAVKit::fullscreenMayReturnToInline(std::function&lt;void(bool)&gt; callback)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacWebPlaybackSessionInterfaceMach"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.h (0 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.h                                (rev 0)
+++ trunk/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.h        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -0,0 +1,79 @@
</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.
+ */
+
+#ifndef WebPlaybackSessionInterfaceMac_h
+#define WebPlaybackSessionInterfaceMac_h
+
+#if PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE)
+
+#include &quot;HTMLMediaElementEnums.h&quot;
+#include &quot;WebPlaybackSessionInterface.h&quot;
+#include &lt;wtf/RefCounted.h&gt;
+#include &lt;wtf/RetainPtr.h&gt;
+#include &lt;wtf/text/WTFString.h&gt;
+
+OBJC_CLASS WebPlaybackControlsManager;
+
+namespace WebCore {
+class IntRect;
+class WebPlaybackSessionModel;
+
+class WEBCORE_EXPORT WebPlaybackSessionInterfaceMac final
+    : public WebPlaybackSessionInterface
+    , public RefCounted&lt;WebPlaybackSessionInterfaceMac&gt; {
+public:
+    static Ref&lt;WebPlaybackSessionInterfaceMac&gt; create()
+    {
+        return adoptRef(*new WebPlaybackSessionInterfaceMac());
+    }
+    virtual ~WebPlaybackSessionInterfaceMac();
+    WebPlaybackSessionModel* webPlaybackSessionModel() const { return m_playbackSessionModel; }
+    WEBCORE_EXPORT void setWebPlaybackSessionModel(WebPlaybackSessionModel*);
+
+    WEBCORE_EXPORT void resetMediaState() final { }
+    WEBCORE_EXPORT void setDuration(double) final;
+    WEBCORE_EXPORT void setCurrentTime(double /*currentTime*/, double /*anchorTime*/) final;
+    WEBCORE_EXPORT void setBufferedTime(double) final { }
+    WEBCORE_EXPORT void setRate(bool /*isPlaying*/, float /*playbackRate*/) final;
+    WEBCORE_EXPORT void setSeekableRanges(const TimeRanges&amp;) final;
+    WEBCORE_EXPORT void setCanPlayFastReverse(bool) final { }
+    WEBCORE_EXPORT void setAudioMediaSelectionOptions(const Vector&lt;String&gt;&amp; /*options*/, uint64_t /*selectedIndex*/) final;
+    WEBCORE_EXPORT void setLegibleMediaSelectionOptions(const Vector&lt;String&gt;&amp; /*options*/, uint64_t /*selectedIndex*/) final;
+    WEBCORE_EXPORT void setExternalPlayback(bool, ExternalPlaybackTargetType, String) final { }
+    WEBCORE_EXPORT void setWirelessVideoPlaybackDisabled(bool) final { }
+    WEBCORE_EXPORT void invalidate();
+    WEBCORE_EXPORT void ensureControlsManager();
+    WEBCORE_EXPORT WebPlaybackControlsManager *playBackControlsManager();
+
+private:
+    WebPlaybackSessionModel* m_playbackSessionModel { nullptr };
+    RetainPtr&lt;WebPlaybackControlsManager&gt; m_playbackControlsManager;
+};
+
+}
+
+#endif // PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE)
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformmacWebPlaybackSessionInterfaceMacmmfromrev199592trunkSourceWebCoreplatformmacWebVideoFullscreenInterfaceMacmm"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.mm (from rev 199592, trunk/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.mm) (0 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.mm                                (rev 0)
+++ trunk/Source/WebCore/platform/mac/WebPlaybackSessionInterfaceMac.mm        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -0,0 +1,332 @@
</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 &quot;config.h&quot;
+#include &quot;WebPlaybackSessionInterfaceMac.h&quot;
+
+#if PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE)
+
+#import &quot;AVKitSPI.h&quot;
+#import &quot;IntRect.h&quot;
+#import &quot;MediaTimeAVFoundation.h&quot;
+#import &quot;TimeRanges.h&quot;
+#import &quot;WebPlaybackSessionModel.h&quot;
+#import &lt;AVFoundation/AVFoundation.h&gt;
+
+#import &quot;CoreMediaSoftLink.h&quot;
+
+SOFT_LINK_FRAMEWORK(AVKit)
+SOFT_LINK_CLASS(AVKit, AVValueTiming)
+
+using namespace WebCore;
+
+@interface WebAVMediaSelectionOptionMac : NSObject {
+    RetainPtr&lt;NSString&gt; _localizedDisplayName;
+}
+@property (retain) NSString *localizedDisplayName;
+@end
+
+@implementation WebAVMediaSelectionOptionMac
+
+- (NSString *)localizedDisplayName
+{
+    return _localizedDisplayName.get();
+}
+
+- (void)setLocalizedDisplayName:(NSString *)name
+{
+    _localizedDisplayName = name;
+}
+
+@end
+
+@interface WebPlaybackControlsManager : NSObject {
+    NSTimeInterval _contentDuration;
+    RetainPtr&lt;AVValueTiming&gt; _timing;
+    NSTimeInterval _seekToTime;
+    RetainPtr&lt;NSArray&gt; _seekableTimeRanges;
+    BOOL _hasEnabledAudio;
+    BOOL _hasEnabledVideo;
+    RetainPtr&lt;NSArray&lt;AVMediaSelectionOption *&gt;&gt; _audioMediaSelectionOptions;
+    RetainPtr&lt;AVMediaSelectionOption&gt; _currentAudioMediaSelectionOption;
+    RetainPtr&lt;NSArray&lt;AVMediaSelectionOption *&gt;&gt; _legibleMediaSelectionOptions;
+    RetainPtr&lt;AVMediaSelectionOption&gt; _currentLegibleMediaSelectionOption;
+
+    float _rate;
+
+@private
+    WebCore::WebPlaybackSessionInterfaceMac* _webPlaybackSessionInterfaceMac;
+}
+
+@property (readwrite) NSTimeInterval contentDuration;
+@property (nonatomic, retain, readwrite) AVValueTiming *timing;
+@property NSTimeInterval seekToTime;
+@property (nonatomic, retain, readwrite) NSArray *seekableTimeRanges;
+@property (readwrite) BOOL hasEnabledAudio;
+@property (readwrite) BOOL hasEnabledVideo;
+@property (nonatomic, retain, readwrite) NSArray&lt;AVMediaSelectionOption *&gt; *audioMediaSelectionOptions;
+@property (nonatomic, retain, readwrite) AVMediaSelectionOption *currentAudioMediaSelectionOption;
+@property (nonatomic, retain, readwrite) NSArray&lt;AVMediaSelectionOption *&gt; *legibleMediaSelectionOptions;
+@property (nonatomic, retain, readwrite) AVMediaSelectionOption *currentLegibleMediaSelectionOption;
+
+@property (nonatomic) float rate;
+
+- (instancetype)initWithWebPlaybackSessionInterfaceMac:(WebCore::WebPlaybackSessionInterfaceMac*)webPlaybackSessionInterfaceMac;
+
+@end
+
+#if USE(APPLE_INTERNAL_SDK)
+#import &lt;WebKitAdditions/WebPlaybackControlsControllerAdditions.mm&gt;
+#endif
+
+@implementation WebPlaybackControlsManager
+
+@synthesize contentDuration=_contentDuration;
+@synthesize seekToTime=_seekToTime;
+@synthesize hasEnabledAudio=_hasEnabledAudio;
+@synthesize hasEnabledVideo=_hasEnabledVideo;
+@synthesize rate=_rate;
+
+- (instancetype)initWithWebPlaybackSessionInterfaceMac:(WebCore::WebPlaybackSessionInterfaceMac*)webPlaybackSessionInterfaceMac
+{
+    if (!(self = [super init]))
+        return nil;
+
+    _webPlaybackSessionInterfaceMac = webPlaybackSessionInterfaceMac;
+
+    return self;
+}
+
+- (AVValueTiming *)timing
+{
+    return _timing.get();
+}
+
+- (void)setTiming:(AVValueTiming *)timing
+{
+    _timing = timing;
+}
+
+- (NSArray *)seekableTimeRanges
+{
+    return _seekableTimeRanges.get();
+}
+
+- (void)setSeekableTimeRanges:(NSArray *)timeRanges
+{
+    _seekableTimeRanges = timeRanges;
+}
+
+- (BOOL)isSeeking
+{
+    return NO;
+}
+
+- (void)seekToTime:(NSTimeInterval)time toleranceBefore:(NSTimeInterval)toleranceBefore toleranceAfter:(NSTimeInterval)toleranceAfter
+{
+    UNUSED_PARAM(toleranceBefore);
+    UNUSED_PARAM(toleranceAfter);
+    _webPlaybackSessionInterfaceMac-&gt;webPlaybackSessionModel()-&gt;seekToTime(time);
+}
+
+- (NSArray&lt;AVMediaSelectionOption *&gt; *)audioMediaSelectionOptions
+{
+    return _audioMediaSelectionOptions.get();
+}
+
+- (void)setAudioMediaSelectionOptions:(NSArray&lt;AVMediaSelectionOption *&gt; *)audioOptions
+{
+    _audioMediaSelectionOptions = audioOptions;
+}
+
+- (AVMediaSelectionOption *)currentAudioMediaSelectionOption
+{
+    return _currentAudioMediaSelectionOption.get();
+}
+
+- (void)setCurrentAudioMediaSelectionOption:(AVMediaSelectionOption *)audioMediaSelectionOption
+{
+    if (audioMediaSelectionOption == _currentAudioMediaSelectionOption)
+        return;
+
+    _currentAudioMediaSelectionOption = audioMediaSelectionOption;
+
+    NSInteger index = NSNotFound;
+
+    if (audioMediaSelectionOption &amp;&amp; self.audioMediaSelectionOptions)
+        index = [self.audioMediaSelectionOptions indexOfObject:audioMediaSelectionOption];
+
+    _webPlaybackSessionInterfaceMac-&gt;webPlaybackSessionModel()-&gt;selectAudioMediaOption(index != NSNotFound ? index : UINT64_MAX);
+}
+
+- (NSArray&lt;AVMediaSelectionOption *&gt; *)legibleMediaSelectionOptions
+{
+    return _legibleMediaSelectionOptions.get();
+}
+
+- (void)setLegibleMediaSelectionOptions:(NSArray&lt;AVMediaSelectionOption *&gt; *)legibleOptions
+{
+    _legibleMediaSelectionOptions = legibleOptions;
+}
+
+- (AVMediaSelectionOption *)currentLegibleMediaSelectionOption
+{
+    return _currentLegibleMediaSelectionOption.get();
+}
+
+- (void)setCurrentLegibleMediaSelectionOption:(AVMediaSelectionOption *)legibleMediaSelectionOption
+{
+    if (legibleMediaSelectionOption == _currentLegibleMediaSelectionOption)
+        return;
+
+    _currentLegibleMediaSelectionOption = legibleMediaSelectionOption;
+
+    NSInteger index = NSNotFound;
+
+    if (legibleMediaSelectionOption &amp;&amp; self.legibleMediaSelectionOptions)
+        index = [self.legibleMediaSelectionOptions indexOfObject:legibleMediaSelectionOption];
+
+    _webPlaybackSessionInterfaceMac-&gt;webPlaybackSessionModel()-&gt;selectLegibleMediaOption(index != NSNotFound ? index : UINT64_MAX);
+}
+
+- (void)cancelThumbnailAndAudioAmplitudeSampleGeneration
+{
+}
+
+#if USE(APPLE_INTERNAL_SDK)
+#import &lt;WebKitAdditions/WebPlaybackControlsControllerThumbnailAdditions.mm&gt;
+#endif
+
+@end
+
+namespace WebCore {
+
+WebPlaybackSessionInterfaceMac::~WebPlaybackSessionInterfaceMac()
+{
+}
+
+void WebPlaybackSessionInterfaceMac::setWebPlaybackSessionModel(WebPlaybackSessionModel* model)
+{
+    m_playbackSessionModel = model;
+}
+
+void WebPlaybackSessionInterfaceMac::setDuration(double duration)
+{
+    WebPlaybackControlsManager* controlsManager = playBackControlsManager();
+
+    controlsManager.contentDuration = duration;
+
+    // FIXME: We take this as an indication that playback is ready, but that is not necessarily true.
+    controlsManager.hasEnabledAudio = YES;
+    controlsManager.hasEnabledVideo = YES;
+}
+
+void WebPlaybackSessionInterfaceMac::setCurrentTime(double currentTime, double anchorTime)
+{
+    WebPlaybackControlsManager* controlsManager = playBackControlsManager();
+
+    NSTimeInterval anchorTimeStamp = ![controlsManager rate] ? NAN : anchorTime;
+    AVValueTiming *timing = [getAVValueTimingClass() valueTimingWithAnchorValue:currentTime
+        anchorTimeStamp:anchorTimeStamp rate:0];
+
+    [controlsManager setTiming:timing];
+}
+
+void WebPlaybackSessionInterfaceMac::setRate(bool isPlaying, float playbackRate)
+{
+    WebPlaybackControlsManager* controlsManager = playBackControlsManager();
+
+    [controlsManager setRate:isPlaying ? playbackRate : 0.];
+}
+
+void WebPlaybackSessionInterfaceMac::setSeekableRanges(const TimeRanges&amp; timeRanges)
+{
+    WebPlaybackControlsManager* controlsManager = playBackControlsManager();
+
+    RetainPtr&lt;NSMutableArray&gt; seekableRanges = adoptNS([[NSMutableArray alloc] init]);
+
+    for (unsigned i = 0; i &lt; timeRanges.length(); i++) {
+        const PlatformTimeRanges&amp; ranges = timeRanges.ranges();
+        CMTimeRange range = CMTimeRangeMake(toCMTime(ranges.start(i)), toCMTime(ranges.end(i)));
+        [seekableRanges addObject:[NSValue valueWithCMTimeRange:range]];
+    }
+
+    [controlsManager setSeekableTimeRanges:seekableRanges.get()];
+}
+
+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) {
+        RetainPtr&lt;WebAVMediaSelectionOptionMac&gt; webOption = adoptNS([[WebAVMediaSelectionOptionMac alloc] init]);
+        [webOption setLocalizedDisplayName:name];
+        [webOptions addObject:webOption.get()];
+    }
+    return webOptions;
+}
+
+void WebPlaybackSessionInterfaceMac::setAudioMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex)
+{
+    WebPlaybackControlsManager* controlsManager = playBackControlsManager();
+
+    RetainPtr&lt;NSMutableArray&gt; webOptions = mediaSelectionOptions(options);
+    [controlsManager setAudioMediaSelectionOptions:webOptions.get()];
+    if (selectedIndex &lt; [webOptions count])
+        [controlsManager setCurrentAudioMediaSelectionOption:[webOptions objectAtIndex:static_cast&lt;NSUInteger&gt;(selectedIndex)]];
+}
+
+void WebPlaybackSessionInterfaceMac::setLegibleMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex)
+{
+    WebPlaybackControlsManager* controlsManager = playBackControlsManager();
+
+    RetainPtr&lt;NSMutableArray&gt; webOptions = mediaSelectionOptions(options);
+    [controlsManager setLegibleMediaSelectionOptions:webOptions.get()];
+    if (selectedIndex &lt; [webOptions count])
+        [controlsManager setCurrentLegibleMediaSelectionOption:[webOptions objectAtIndex:static_cast&lt;NSUInteger&gt;(selectedIndex)]];
+}
+
+void WebPlaybackSessionInterfaceMac::invalidate()
+{
+}
+
+void WebPlaybackSessionInterfaceMac::ensureControlsManager()
+{
+    playBackControlsManager();
+}
+
+WebPlaybackControlsManager *WebPlaybackSessionInterfaceMac::playBackControlsManager()
+{
+#if __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200
+    if (!m_playbackControlsManager)
+        m_playbackControlsManager = adoptNS([[WebPlaybackControlsManager alloc] initWithWebPlaybackSessionInterfaceMac:this]);
+    return m_playbackControlsManager.get();
+#else
+    return nil;
+#endif
+}
+    
+}
+
+#endif // PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformmacWebVideoFullscreenInterfaceMach"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.h (199592 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.h        2016-04-15 17:18:12 UTC (rev 199592)
+++ trunk/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.h        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -35,7 +35,6 @@
</span><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="cx"> 
</span><span class="cx"> OBJC_CLASS NSWindow;
</span><del>-OBJC_CLASS WebPlaybackControlsManager;
</del><span class="cx"> 
</span><span class="cx"> #if USE(APPLE_INTERNAL_SDK)
</span><span class="cx"> OBJC_CLASS WebVideoFullscreenInterfaceMacObjC;
</span><span class="lines">@@ -43,6 +42,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> class IntRect;
</span><ins>+class WebPlaybackSessionInterfaceMac;
</ins><span class="cx"> class WebVideoFullscreenChangeObserver;
</span><span class="cx"> class WebVideoFullscreenModel;
</span><span class="cx"> 
</span><span class="lines">@@ -51,9 +51,9 @@
</span><span class="cx">     , public RefCounted&lt;WebVideoFullscreenInterfaceMac&gt; {
</span><span class="cx"> 
</span><span class="cx"> public:
</span><del>-    static Ref&lt;WebVideoFullscreenInterfaceMac&gt; create()
</del><ins>+    static Ref&lt;WebVideoFullscreenInterfaceMac&gt; create(WebPlaybackSessionInterfaceMac&amp; playbackSessionInterface)
</ins><span class="cx">     {
</span><del>-        return adoptRef(*new WebVideoFullscreenInterfaceMac());
</del><ins>+        return adoptRef(*new WebVideoFullscreenInterfaceMac(playbackSessionInterface));
</ins><span class="cx">     }
</span><span class="cx">     virtual ~WebVideoFullscreenInterfaceMac();
</span><span class="cx">     WebVideoFullscreenModel* webVideoFullscreenModel() const { return m_videoFullscreenModel; }
</span><span class="lines">@@ -93,12 +93,13 @@
</span><span class="cx">     WEBCORE_EXPORT bool mayAutomaticallyShowVideoPictureInPicture() const { return false; }
</span><span class="cx">     void applicationDidBecomeActive() { }
</span><span class="cx"> 
</span><del>-    WEBCORE_EXPORT WebPlaybackControlsManager *playBackControlsManager();
</del><span class="cx"> #if USE(APPLE_INTERNAL_SDK)
</span><span class="cx">     WEBCORE_EXPORT WebVideoFullscreenInterfaceMacObjC *videoFullscreenInterfaceObjC();
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> private:
</span><ins>+    WebVideoFullscreenInterfaceMac(WebPlaybackSessionInterfaceMac&amp;);
+    Ref&lt;WebPlaybackSessionInterfaceMac&gt; m_playbackSessionInterface;
</ins><span class="cx">     WebVideoFullscreenModel* m_videoFullscreenModel { nullptr };
</span><span class="cx">     WebVideoFullscreenChangeObserver* m_fullscreenChangeObserver { nullptr };
</span><span class="cx">     HTMLMediaElementEnums::VideoFullscreenMode m_mode { HTMLMediaElementEnums::VideoFullscreenModeNone };
</span><span class="lines">@@ -106,7 +107,6 @@
</span><span class="cx"> #if USE(APPLE_INTERNAL_SDK)
</span><span class="cx">     RetainPtr&lt;WebVideoFullscreenInterfaceMacObjC&gt; m_webVideoFullscreenInterfaceObjC;
</span><span class="cx"> #endif
</span><del>-    RetainPtr&lt;WebPlaybackControlsManager&gt; m_playbackControlsManager;
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacWebVideoFullscreenInterfaceMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.mm (199592 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.mm        2016-04-15 17:18:12 UTC (rev 199592)
+++ trunk/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.mm        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -29,15 +29,15 @@
</span><span class="cx"> #if PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE)
</span><span class="cx"> 
</span><span class="cx"> #import &quot;AVKitSPI.h&quot;
</span><del>-#import &quot;CoreMediaSoftLink.h&quot;
</del><span class="cx"> #import &quot;IntRect.h&quot;
</span><span class="cx"> #import &quot;MediaTimeAVFoundation.h&quot;
</span><span class="cx"> #import &quot;TimeRanges.h&quot;
</span><ins>+#import &quot;WebPlaybackSessionInterfaceMac.h&quot;
</ins><span class="cx"> #import &quot;WebVideoFullscreenChangeObserver.h&quot;
</span><span class="cx"> #import &quot;WebVideoFullscreenModel.h&quot;
</span><span class="cx"> #import &lt;AVFoundation/AVTime.h&gt;
</span><span class="cx"> 
</span><del>-#import &quot;SoftLinking.h&quot;
</del><ins>+#import &quot;CoreMediaSoftLink.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> SOFT_LINK_FRAMEWORK(AVKit)
</span><span class="cx"> SOFT_LINK_CLASS(AVKit, AVValueTiming)
</span><span class="lines">@@ -46,189 +46,13 @@
</span><span class="cx"> #include &lt;WebKitAdditions/WebVideoFullscreenInterfaceMacAdditions.mm&gt;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-using namespace WebCore;
</del><ins>+namespace WebCore {
</ins><span class="cx"> 
</span><del>-@interface WebAVMediaSelectionOptionMac : NSObject {
-    RetainPtr&lt;NSString&gt; _localizedDisplayName;
-}
-@property (retain) NSString *localizedDisplayName;
-@end
-
-@implementation WebAVMediaSelectionOptionMac
-
-- (NSString *)localizedDisplayName
</del><ins>+WebVideoFullscreenInterfaceMac::WebVideoFullscreenInterfaceMac(WebPlaybackSessionInterfaceMac&amp; playbackSessionInterface)
+    : m_playbackSessionInterface(playbackSessionInterface)
</ins><span class="cx"> {
</span><del>-    return _localizedDisplayName.get();
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)setLocalizedDisplayName:(NSString *)name
-{
-    _localizedDisplayName = name;
-}
-
-@end
-
-@interface WebPlaybackControlsManager : NSObject {
-    NSTimeInterval _contentDuration;
-    RetainPtr&lt;AVValueTiming&gt; _timing;
-    NSTimeInterval _seekToTime;
-    RetainPtr&lt;NSArray&gt; _seekableTimeRanges;
-    BOOL _hasEnabledAudio;
-    BOOL _hasEnabledVideo;
-    RetainPtr&lt;NSArray&lt;AVMediaSelectionOption *&gt;&gt; _audioMediaSelectionOptions;
-    RetainPtr&lt;AVMediaSelectionOption&gt; _currentAudioMediaSelectionOption;
-    RetainPtr&lt;NSArray&lt;AVMediaSelectionOption *&gt;&gt; _legibleMediaSelectionOptions;
-    RetainPtr&lt;AVMediaSelectionOption&gt; _currentLegibleMediaSelectionOption;
-    
-    float _rate;
-
-@private
-    WebCore::WebVideoFullscreenInterfaceMac* _webVideoFullscreenInterfaceMac;
-}
-
-@property (readwrite) NSTimeInterval contentDuration;
-@property (nonatomic, retain, readwrite) AVValueTiming *timing;
-@property NSTimeInterval seekToTime;
-@property (nonatomic, retain, readwrite) NSArray *seekableTimeRanges;
-@property (readwrite) BOOL hasEnabledAudio;
-@property (readwrite) BOOL hasEnabledVideo;
-@property (nonatomic, retain, readwrite) NSArray&lt;AVMediaSelectionOption *&gt; *audioMediaSelectionOptions;
-@property (nonatomic, retain, readwrite) AVMediaSelectionOption *currentAudioMediaSelectionOption;
-@property (nonatomic, retain, readwrite) NSArray&lt;AVMediaSelectionOption *&gt; *legibleMediaSelectionOptions;
-@property (nonatomic, retain, readwrite) AVMediaSelectionOption *currentLegibleMediaSelectionOption;
-
-@property (nonatomic) float rate;
-
-- (instancetype)initWithWebVideoFullscreenInterfaceMac:(WebCore::WebVideoFullscreenInterfaceMac*)webVideoFullscreenInterfaceMac;
-
-@end
-
-#if USE(APPLE_INTERNAL_SDK)
-#import &lt;WebKitAdditions/WebPlaybackControlsControllerAdditions.mm&gt;
-#endif
-
-@implementation WebPlaybackControlsManager
-
-@synthesize contentDuration=_contentDuration;
-@synthesize seekToTime=_seekToTime;
-@synthesize hasEnabledAudio=_hasEnabledAudio;
-@synthesize hasEnabledVideo=_hasEnabledVideo;
-@synthesize rate=_rate;
-
-- (instancetype)initWithWebVideoFullscreenInterfaceMac:(WebCore::WebVideoFullscreenInterfaceMac*)webVideoFullscreenInterfaceMac
-{
-    if (!(self = [super init]))
-        return nil;
-
-    _webVideoFullscreenInterfaceMac = webVideoFullscreenInterfaceMac;
-
-    return self;
-}
-
-- (AVValueTiming *)timing
-{
-    return _timing.get();
-}
-
-- (void)setTiming:(AVValueTiming *)timing
-{
-    _timing = timing;
-}
-
-- (NSArray *)seekableTimeRanges
-{
-    return _seekableTimeRanges.get();
-}
-
-- (void)setSeekableTimeRanges:(NSArray *)timeRanges
-{
-    _seekableTimeRanges = timeRanges;
-}
-
-- (BOOL)isSeeking
-{
-    return NO;
-}
-
-- (void)seekToTime:(NSTimeInterval)time toleranceBefore:(NSTimeInterval)toleranceBefore toleranceAfter:(NSTimeInterval)toleranceAfter
-{
-    UNUSED_PARAM(toleranceBefore);
-    UNUSED_PARAM(toleranceAfter);
-    _webVideoFullscreenInterfaceMac-&gt;webVideoFullscreenModel()-&gt;seekToTime(time);
-}
-
-- (NSArray&lt;AVMediaSelectionOption *&gt; *)audioMediaSelectionOptions
-{
-    return _audioMediaSelectionOptions.get();
-}
-
-- (void)setAudioMediaSelectionOptions:(NSArray&lt;AVMediaSelectionOption *&gt; *)audioOptions
-{
-    _audioMediaSelectionOptions = audioOptions;
-}
-
-- (AVMediaSelectionOption *)currentAudioMediaSelectionOption
-{
-    return _currentAudioMediaSelectionOption.get();
-}
-
-- (void)setCurrentAudioMediaSelectionOption:(AVMediaSelectionOption *)audioMediaSelectionOption
-{
-    if (audioMediaSelectionOption == _currentAudioMediaSelectionOption)
-        return;
-    
-    _currentAudioMediaSelectionOption = audioMediaSelectionOption;
-    
-    NSInteger index = NSNotFound;
-    
-    if (audioMediaSelectionOption &amp;&amp; self.audioMediaSelectionOptions)
-        index = [self.audioMediaSelectionOptions indexOfObject:audioMediaSelectionOption];
-    
-    _webVideoFullscreenInterfaceMac-&gt;webVideoFullscreenModel()-&gt;selectAudioMediaOption(index != NSNotFound ? index : UINT64_MAX);
-}
-
-- (NSArray&lt;AVMediaSelectionOption *&gt; *)legibleMediaSelectionOptions
-{
-    return _legibleMediaSelectionOptions.get();
-}
-
-- (void)setLegibleMediaSelectionOptions:(NSArray&lt;AVMediaSelectionOption *&gt; *)legibleOptions
-{
-    _legibleMediaSelectionOptions = legibleOptions;
-}
-
-- (AVMediaSelectionOption *)currentLegibleMediaSelectionOption
-{
-    return _currentLegibleMediaSelectionOption.get();
-}
-
-- (void)setCurrentLegibleMediaSelectionOption:(AVMediaSelectionOption *)legibleMediaSelectionOption
-{
-    if (legibleMediaSelectionOption == _currentLegibleMediaSelectionOption)
-        return;
-    
-    _currentLegibleMediaSelectionOption = legibleMediaSelectionOption;
-    
-    NSInteger index = NSNotFound;
-    
-    if (legibleMediaSelectionOption &amp;&amp; self.legibleMediaSelectionOptions)
-        index = [self.legibleMediaSelectionOptions indexOfObject:legibleMediaSelectionOption];
-    
-    _webVideoFullscreenInterfaceMac-&gt;webVideoFullscreenModel()-&gt;selectLegibleMediaOption(index != NSNotFound ? index : UINT64_MAX);
-}
-
-- (void)cancelThumbnailAndAudioAmplitudeSampleGeneration
-{
-}
-
-#if USE(APPLE_INTERNAL_SDK)
-#import &lt;WebKitAdditions/WebPlaybackControlsControllerThumbnailAdditions.mm&gt;
-#endif
-
-@end
-
-namespace WebCore {
-
</del><span class="cx"> WebVideoFullscreenInterfaceMac::~WebVideoFullscreenInterfaceMac()
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="lines">@@ -236,6 +60,7 @@
</span><span class="cx"> void WebVideoFullscreenInterfaceMac::setWebVideoFullscreenModel(WebVideoFullscreenModel* model)
</span><span class="cx"> {
</span><span class="cx">     m_videoFullscreenModel = model;
</span><ins>+    m_playbackSessionInterface-&gt;setWebPlaybackSessionModel(model);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceMac::setWebVideoFullscreenChangeObserver(WebVideoFullscreenChangeObserver* observer)
</span><span class="lines">@@ -267,32 +92,18 @@
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceMac::setDuration(double duration)
</span><span class="cx"> {
</span><del>-    WebPlaybackControlsManager* controlsManager = playBackControlsManager();
-
-    controlsManager.contentDuration = duration;
-
-    // FIXME: We take this as an indication that playback is ready, but that is not necessarily true.
-    controlsManager.hasEnabledAudio = YES;
-    controlsManager.hasEnabledVideo = YES;
</del><ins>+    m_playbackSessionInterface-&gt;setDuration(duration);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceMac::setCurrentTime(double currentTime, double anchorTime)
</span><span class="cx"> {
</span><del>-    WebPlaybackControlsManager* controlsManager = playBackControlsManager();
-
-    NSTimeInterval anchorTimeStamp = ![controlsManager rate] ? NAN : anchorTime;
-    AVValueTiming *timing = [getAVValueTimingClass() valueTimingWithAnchorValue:currentTime
-        anchorTimeStamp:anchorTimeStamp rate:0];
-    
-    [controlsManager setTiming:timing];
</del><ins>+    m_playbackSessionInterface-&gt;setCurrentTime(currentTime, anchorTime);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceMac::setRate(bool isPlaying, float playbackRate)
</span><span class="cx"> {
</span><del>-    WebPlaybackControlsManager* controlsManager = playBackControlsManager();
</del><ins>+    m_playbackSessionInterface-&gt;setRate(isPlaying, playbackRate);
</ins><span class="cx"> 
</span><del>-    [controlsManager setRate:isPlaying ? playbackRate : 0.];
-
</del><span class="cx"> #if USE(APPLE_INTERNAL_SDK)
</span><span class="cx">     [videoFullscreenInterfaceObjC() setRate:isPlaying ? playbackRate : 0.];
</span><span class="cx"> #endif
</span><span class="lines">@@ -300,66 +111,24 @@
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceMac::setSeekableRanges(const TimeRanges&amp; timeRanges)
</span><span class="cx"> {
</span><del>-    WebPlaybackControlsManager* controlsManager = playBackControlsManager();
-
-    RetainPtr&lt;NSMutableArray&gt; seekableRanges = adoptNS([[NSMutableArray alloc] init]);
-
-    for (unsigned i = 0; i &lt; timeRanges.length(); i++) {
-        const PlatformTimeRanges&amp; ranges = timeRanges.ranges();
-        CMTimeRange range = CMTimeRangeMake(toCMTime(ranges.start(i)), toCMTime(ranges.end(i)));
-        [seekableRanges addObject:[NSValue valueWithCMTimeRange:range]];
-    }
-    
-    [controlsManager setSeekableTimeRanges:seekableRanges.get()];
</del><ins>+    m_playbackSessionInterface-&gt;setSeekableRanges(timeRanges);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-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) {
-        RetainPtr&lt;WebAVMediaSelectionOptionMac&gt; webOption = adoptNS([[WebAVMediaSelectionOptionMac alloc] init]);
-        [webOption setLocalizedDisplayName:name];
-        [webOptions addObject:webOption.get()];
-    }
-    return webOptions;
-}
-
</del><span class="cx"> void WebVideoFullscreenInterfaceMac::setAudioMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex)
</span><span class="cx"> {
</span><del>-    WebPlaybackControlsManager* controlsManager = playBackControlsManager();
-
-    RetainPtr&lt;NSMutableArray&gt; webOptions = mediaSelectionOptions(options);
-    [controlsManager setAudioMediaSelectionOptions:webOptions.get()];
-    if (selectedIndex &lt; [webOptions count])
-        [controlsManager setCurrentAudioMediaSelectionOption:[webOptions objectAtIndex:static_cast&lt;NSUInteger&gt;(selectedIndex)]];
</del><ins>+    m_playbackSessionInterface-&gt;setAudioMediaSelectionOptions(options, selectedIndex);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceMac::setLegibleMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex)
</span><span class="cx"> {
</span><del>-    WebPlaybackControlsManager* controlsManager = playBackControlsManager();
-
-    RetainPtr&lt;NSMutableArray&gt; webOptions = mediaSelectionOptions(options);
-    [controlsManager setLegibleMediaSelectionOptions:webOptions.get()];
-    if (selectedIndex &lt; [webOptions count])
-        [controlsManager setCurrentLegibleMediaSelectionOption:[webOptions objectAtIndex:static_cast&lt;NSUInteger&gt;(selectedIndex)]];
</del><ins>+    m_playbackSessionInterface-&gt;setLegibleMediaSelectionOptions(options, selectedIndex);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceMac::ensureControlsManager()
</span><span class="cx"> {
</span><del>-    playBackControlsManager();
</del><ins>+    m_playbackSessionInterface-&gt;ensureControlsManager();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-WebPlaybackControlsManager *WebVideoFullscreenInterfaceMac::playBackControlsManager()
-{
-#if __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200
-    if (!m_playbackControlsManager)
-        m_playbackControlsManager = adoptNS([[WebPlaybackControlsManager alloc] initWithWebVideoFullscreenInterfaceMac:this]);
-    return m_playbackControlsManager.get();
-#else
-    return nil;
-#endif
-}
-
</del><span class="cx"> #if !USE(APPLE_INTERNAL_SDK)
</span><span class="cx"> void WebVideoFullscreenInterfaceMac::setupFullscreen(NSView&amp;, const IntRect&amp;, NSWindow *, HTMLMediaElementEnums::VideoFullscreenMode, bool)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (199592 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-04-15 17:18:12 UTC (rev 199592)
+++ trunk/Source/WebKit2/ChangeLog        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -1,3 +1,217 @@
</span><ins>+2016-04-14  Jer Noble  &lt;jer.noble@apple.com&gt;
+
+        Allow WebVideoFullscreenManager and Proxy to be used by audio elements.
+        https://bugs.webkit.org/show_bug.cgi?id=156564
+
+        Reviewed by Beth Dakin.
+
+        Tease apart WebVideoFullscreenManager and …Proxy into WebPlaybackSessionManager and …Proxy
+        classes dealing exclusively with playback state and commands, leaving fullscreen state and
+        commands in the WebVideoFullscreenManager… classes.
+
+        WebVideoFullscreenManager and …Proxy will now require an associated
+        WebPlaybackSessionManager and …Proxy class. The WebPlaybackSessionManager classes can be
+        used separately and without the WebVideoFullscreenManager classes.
+
+        * DerivedSources.make:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _mayAutomaticallyShowVideoPictureInPicture]):
+        * UIProcess/Cocoa/WebPlaybackSessionManagerProxy.h: Copied from Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.h.
+        * UIProcess/Cocoa/WebPlaybackSessionManagerProxy.messages.in: Copied from Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.messages.in.
+        * UIProcess/Cocoa/WebPlaybackSessionManagerProxy.mm: Added.
+        (WebKit::WebPlaybackSessionModelContext::play):
+        (WebKit::WebPlaybackSessionModelContext::pause):
+        (WebKit::WebPlaybackSessionModelContext::togglePlayState):
+        (WebKit::WebPlaybackSessionModelContext::beginScrubbing):
+        (WebKit::WebPlaybackSessionModelContext::endScrubbing):
+        (WebKit::WebPlaybackSessionModelContext::seekToTime):
+        (WebKit::WebPlaybackSessionModelContext::fastSeek):
+        (WebKit::WebPlaybackSessionModelContext::beginScanningForward):
+        (WebKit::WebPlaybackSessionModelContext::beginScanningBackward):
+        (WebKit::WebPlaybackSessionModelContext::endScanning):
+        (WebKit::WebPlaybackSessionModelContext::selectAudioMediaOption):
+        (WebKit::WebPlaybackSessionModelContext::selectLegibleMediaOption):
+        (WebKit::WebPlaybackSessionManagerProxy::create):
+        (WebKit::WebPlaybackSessionManagerProxy::WebPlaybackSessionManagerProxy):
+        (WebKit::WebPlaybackSessionManagerProxy::~WebPlaybackSessionManagerProxy):
+        (WebKit::WebPlaybackSessionManagerProxy::invalidate):
+        (WebKit::WebPlaybackSessionManagerProxy::createModelAndInterface):
+        (WebKit::WebPlaybackSessionManagerProxy::ensureModelAndInterface):
+        (WebKit::WebPlaybackSessionManagerProxy::ensureModel):
+        (WebKit::WebPlaybackSessionManagerProxy::ensureInterface):
+        (WebKit::WebPlaybackSessionManagerProxy::addClientForContext):
+        (WebKit::WebPlaybackSessionManagerProxy::removeClientForContext):
+        (WebKit::WebPlaybackSessionManagerProxy::setUpPlaybackControlsManagerWithID):
+        (WebKit::WebPlaybackSessionManagerProxy::clearPlaybackControlsManager):
+        (WebKit::WebPlaybackSessionManagerProxy::resetMediaState):
+        (WebKit::WebPlaybackSessionManagerProxy::setCurrentTime):
+        (WebKit::WebPlaybackSessionManagerProxy::setBufferedTime):
+        (WebKit::WebPlaybackSessionManagerProxy::setSeekableRangesVector):
+        (WebKit::WebPlaybackSessionManagerProxy::setCanPlayFastReverse):
+        (WebKit::WebPlaybackSessionManagerProxy::setAudioMediaSelectionOptions):
+        (WebKit::WebPlaybackSessionManagerProxy::setLegibleMediaSelectionOptions):
+        (WebKit::WebPlaybackSessionManagerProxy::setExternalPlaybackProperties):
+        (WebKit::WebPlaybackSessionManagerProxy::setWirelessVideoPlaybackDisabled):
+        (WebKit::WebPlaybackSessionManagerProxy::setDuration):
+        (WebKit::WebPlaybackSessionManagerProxy::setRate):
+        (WebKit::WebPlaybackSessionManagerProxy::play):
+        (WebKit::WebPlaybackSessionManagerProxy::pause):
+        (WebKit::WebPlaybackSessionManagerProxy::togglePlayState):
+        (WebKit::WebPlaybackSessionManagerProxy::beginScrubbing):
+        (WebKit::WebPlaybackSessionManagerProxy::endScrubbing):
+        (WebKit::WebPlaybackSessionManagerProxy::seekToTime):
+        (WebKit::WebPlaybackSessionManagerProxy::fastSeek):
+        (WebKit::WebPlaybackSessionManagerProxy::beginScanningForward):
+        (WebKit::WebPlaybackSessionManagerProxy::beginScanningBackward):
+        (WebKit::WebPlaybackSessionManagerProxy::endScanning):
+        (WebKit::WebPlaybackSessionManagerProxy::selectAudioMediaOption):
+        (WebKit::WebPlaybackSessionManagerProxy::selectLegibleMediaOption):
+        (WebKit::WebPlaybackSessionManagerProxy::controlsManagerInterface):
+        * UIProcess/Cocoa/WebVideoFullscreenManagerProxy.h:
+        * UIProcess/Cocoa/WebVideoFullscreenManagerProxy.messages.in:
+        * UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm:
+        (WebKit::WebVideoFullscreenModelContext::WebVideoFullscreenModelContext):
+        (WebKit::WebVideoFullscreenModelContext::~WebVideoFullscreenModelContext):
+        (WebKit::WebVideoFullscreenModelContext::play):
+        (WebKit::WebVideoFullscreenModelContext::pause):
+        (WebKit::WebVideoFullscreenModelContext::togglePlayState):
+        (WebKit::WebVideoFullscreenModelContext::beginScrubbing):
+        (WebKit::WebVideoFullscreenModelContext::endScrubbing):
+        (WebKit::WebVideoFullscreenModelContext::seekToTime):
+        (WebKit::WebVideoFullscreenModelContext::fastSeek):
+        (WebKit::WebVideoFullscreenModelContext::beginScanningForward):
+        (WebKit::WebVideoFullscreenModelContext::beginScanningBackward):
+        (WebKit::WebVideoFullscreenModelContext::endScanning):
+        (WebKit::WebVideoFullscreenModelContext::selectAudioMediaOption):
+        (WebKit::WebVideoFullscreenModelContext::selectLegibleMediaOption):
+        (WebKit::WebVideoFullscreenManagerProxy::create):
+        (WebKit::WebVideoFullscreenManagerProxy::WebVideoFullscreenManagerProxy):
+        (WebKit::WebVideoFullscreenManagerProxy::createModelAndInterface):
+        (WebKit::WebVideoFullscreenManagerProxy::setupFullscreenWithID): Deleted.
+        (WebKit::WebVideoFullscreenManagerProxy::setVideoDimensions): Deleted.
+        (WebKit::WebVideoFullscreenManagerProxy::enterFullscreen): Deleted.
+        (WebKit::WebVideoFullscreenManagerProxy::exitFullscreen): Deleted.
+        (WebKit::WebVideoFullscreenManagerProxy::exitFullscreenWithoutAnimationToMode): Deleted.
+        (WebKit::WebVideoFullscreenManagerProxy::cleanupFullscreen): Deleted.
+        (WebKit::WebVideoFullscreenManagerProxy::preparedToReturnToInline): Deleted.
+        (WebKit::WebVideoFullscreenManagerProxy::requestFullscreenMode): Deleted.
+        (WebKit::WebVideoFullscreenManagerProxy::didSetupFullscreen): Deleted.
+        (WebKit::WebVideoFullscreenManagerProxy::didExitFullscreen): Deleted.
+        (WebKit::WebVideoFullscreenManagerProxy::didEnterFullscreen): Deleted.
+        (WebKit::WebVideoFullscreenManagerProxy::didCleanupFullscreen): Deleted.
+        (WebKit::WebVideoFullscreenManagerProxy::setVideoLayerFrame): Deleted.
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::WebPageProxy):
+        (WebKit::WebPageProxy::reattachToWebProcess):
+        (WebKit::WebPageProxy::playbackSessionManager):
+        (WebKit::WebPageProxy::videoFullscreenManager):
+        (WebKit::WebPageProxy::resetState):
+        (WebKit::WebPageProxy::hasActiveVideoForControlsManager):
+        (WebKit::WebPageProxy::isPlayingMediaDidChange): Deleted.
+        * UIProcess/WebPageProxy.h:
+        * WebKit2.xcodeproj/project.pbxproj:
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::supportsVideoFullscreen):
+        (WebKit::WebChromeClient::setUpPlaybackControlsManager):
+        (WebKit::WebChromeClient::clearPlaybackControlsManager):
+        (WebKit::WebChromeClient::enterVideoFullscreenForVideoElement):
+        (WebKit::WebChromeClient::exitVideoFullscreenForVideoElement):
+        (WebKit::WebChromeClient::exitVideoFullscreenToModeWithoutAnimation):
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::playbackSessionManager):
+        (WebKit::WebPage::videoFullscreenManager):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/cocoa/WebPlaybackSessionManager.h: Copied from Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.h.
+        (WebKit::WebPlaybackSessionInterfaceContext::create):
+        (WebKit::WebPlaybackSessionInterfaceContext::invalidate):
+        * WebProcess/cocoa/WebPlaybackSessionManager.messages.in: Added.
+        * WebProcess/cocoa/WebPlaybackSessionManager.mm: Added.
+        (WebKit::nextContextId):
+        (WebKit::WebPlaybackSessionInterfaceContext::WebPlaybackSessionInterfaceContext):
+        (WebKit::WebPlaybackSessionInterfaceContext::~WebPlaybackSessionInterfaceContext):
+        (WebKit::WebPlaybackSessionInterfaceContext::resetMediaState):
+        (WebKit::WebPlaybackSessionInterfaceContext::setDuration):
+        (WebKit::WebPlaybackSessionInterfaceContext::setCurrentTime):
+        (WebKit::WebPlaybackSessionInterfaceContext::setBufferedTime):
+        (WebKit::WebPlaybackSessionInterfaceContext::setRate):
+        (WebKit::WebPlaybackSessionInterfaceContext::setSeekableRanges):
+        (WebKit::WebPlaybackSessionInterfaceContext::setCanPlayFastReverse):
+        (WebKit::WebPlaybackSessionInterfaceContext::setAudioMediaSelectionOptions):
+        (WebKit::WebPlaybackSessionInterfaceContext::setLegibleMediaSelectionOptions):
+        (WebKit::WebPlaybackSessionInterfaceContext::setExternalPlayback):
+        (WebKit::WebPlaybackSessionInterfaceContext::setWirelessVideoPlaybackDisabled):
+        (WebKit::WebPlaybackSessionManager::create):
+        (WebKit::WebPlaybackSessionManager::WebPlaybackSessionManager):
+        (WebKit::WebPlaybackSessionManager::~WebPlaybackSessionManager):
+        (WebKit::WebPlaybackSessionManager::createModelAndInterface):
+        (WebKit::WebPlaybackSessionManager::ensureModelAndInterface):
+        (WebKit::WebPlaybackSessionManager::ensureModel):
+        (WebKit::WebPlaybackSessionManager::ensureInterface):
+        (WebKit::WebPlaybackSessionManager::removeContext):
+        (WebKit::WebPlaybackSessionManager::addClientForContext):
+        (WebKit::WebPlaybackSessionManager::removeClientForContext):
+        (WebKit::WebPlaybackSessionManager::setUpPlaybackControlsManager):
+        (WebKit::WebPlaybackSessionManager::clearPlaybackControlsManager):
+        (WebKit::WebPlaybackSessionManager::contextIdForMediaElement):
+        (WebKit::WebPlaybackSessionManager::resetMediaState):
+        (WebKit::WebPlaybackSessionManager::setDuration):
+        (WebKit::WebPlaybackSessionManager::setCurrentTime):
+        (WebKit::WebPlaybackSessionManager::setBufferedTime):
+        (WebKit::WebPlaybackSessionManager::setRate):
+        (WebKit::WebPlaybackSessionManager::setSeekableRanges):
+        (WebKit::WebPlaybackSessionManager::setCanPlayFastReverse):
+        (WebKit::WebPlaybackSessionManager::setAudioMediaSelectionOptions):
+        (WebKit::WebPlaybackSessionManager::setLegibleMediaSelectionOptions):
+        (WebKit::WebPlaybackSessionManager::setExternalPlayback):
+        (WebKit::WebPlaybackSessionManager::setWirelessVideoPlaybackDisabled):
+        (WebKit::WebPlaybackSessionManager::play):
+        (WebKit::WebPlaybackSessionManager::pause):
+        (WebKit::WebPlaybackSessionManager::togglePlayState):
+        (WebKit::WebPlaybackSessionManager::beginScrubbing):
+        (WebKit::WebPlaybackSessionManager::endScrubbing):
+        (WebKit::WebPlaybackSessionManager::seekToTime):
+        (WebKit::WebPlaybackSessionManager::fastSeek):
+        (WebKit::WebPlaybackSessionManager::beginScanningForward):
+        (WebKit::WebPlaybackSessionManager::beginScanningBackward):
+        (WebKit::WebPlaybackSessionManager::endScanning):
+        (WebKit::WebPlaybackSessionManager::selectAudioMediaOption):
+        (WebKit::WebPlaybackSessionManager::selectLegibleMediaOption):
+        * WebProcess/cocoa/WebVideoFullscreenManager.h:
+        (WebKit::WebVideoFullscreenInterfaceContext::create):
+        * WebProcess/cocoa/WebVideoFullscreenManager.messages.in:
+        * WebProcess/cocoa/WebVideoFullscreenManager.mm:
+        (WebKit::WebVideoFullscreenInterfaceContext::WebVideoFullscreenInterfaceContext):
+        (WebKit::WebVideoFullscreenInterfaceContext::resetMediaState):
+        (WebKit::WebVideoFullscreenInterfaceContext::setDuration):
+        (WebKit::WebVideoFullscreenInterfaceContext::setCurrentTime):
+        (WebKit::WebVideoFullscreenInterfaceContext::setBufferedTime):
+        (WebKit::WebVideoFullscreenInterfaceContext::setRate):
+        (WebKit::WebVideoFullscreenInterfaceContext::setSeekableRanges):
+        (WebKit::WebVideoFullscreenInterfaceContext::setCanPlayFastReverse):
+        (WebKit::WebVideoFullscreenInterfaceContext::setAudioMediaSelectionOptions):
+        (WebKit::WebVideoFullscreenInterfaceContext::setLegibleMediaSelectionOptions):
+        (WebKit::WebVideoFullscreenInterfaceContext::setExternalPlayback):
+        (WebKit::WebVideoFullscreenInterfaceContext::setWirelessVideoPlaybackDisabled):
+        (WebKit::WebVideoFullscreenManager::create):
+        (WebKit::WebVideoFullscreenManager::WebVideoFullscreenManager):
+        (WebKit::WebVideoFullscreenManager::createModelAndInterface):
+        (WebKit::WebVideoFullscreenManager::enterVideoFullscreenForVideoElement):
+        (WebKit::WebVideoFullscreenInterfaceContext::setVideoDimensions): Deleted.
+        (WebKit::WebVideoFullscreenManager::~WebVideoFullscreenManager): Deleted.
+        (WebKit::WebVideoFullscreenManager::ensureModelAndInterface): Deleted.
+        (WebKit::WebVideoFullscreenManager::exitVideoFullscreenToModeWithoutAnimation): Deleted.
+        (WebKit::WebVideoFullscreenManager::setVideoDimensions): Deleted.
+        (WebKit::WebVideoFullscreenManager::requestFullscreenMode): Deleted.
+        (WebKit::WebVideoFullscreenManager::fullscreenModeChanged): Deleted.
+        (WebKit::WebVideoFullscreenManager::didSetupFullscreen): Deleted.
+        (WebKit::WebVideoFullscreenManager::didEnterFullscreen): Deleted.
+        (WebKit::WebVideoFullscreenManager::didExitFullscreen): Deleted.
+        (WebKit::WebVideoFullscreenManager::didCleanupFullscreen): Deleted.
+        (WebKit::WebVideoFullscreenManager::setVideoLayerGravityEnum): Deleted.
+        (WebKit::WebVideoFullscreenManager::fullscreenMayReturnToInline): Deleted.
+        (WebKit::WebVideoFullscreenManager::setVideoLayerFrameFenced): Deleted.
+
</ins><span class="cx"> 2016-04-15  John Wilander  &lt;wilander@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Refactor WebSockets handshake to use StringView instead of String for header validation.
</span></span></pre></div>
<a id="trunkSourceWebKit2DerivedSourcesmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/DerivedSources.make (199592 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/DerivedSources.make        2016-04-15 17:18:12 UTC (rev 199592)
+++ trunk/Source/WebKit2/DerivedSources.make        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -138,6 +138,8 @@
</span><span class="cx">     WebPage \
</span><span class="cx">     WebPageProxy \
</span><span class="cx">     WebPasteboardProxy \
</span><ins>+    WebPlaybackSessionManager \
+    WebPlaybackSessionManagerProxy \
</ins><span class="cx">     WebProcess \
</span><span class="cx">     WebProcessConnection \
</span><span class="cx">     WebProcessPool \
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (199592 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2016-04-15 17:18:12 UTC (rev 199592)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -303,7 +303,7 @@
</span><span class="cx"> #if !HAVE(AVKIT)
</span><span class="cx">     return false;
</span><span class="cx"> #else
</span><del>-    if (!_page || !_page-&gt;videoFullscreenManager())
</del><ins>+    if (!_page)
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     return _page-&gt;videoFullscreenManager()-&gt;mayAutomaticallyShowVideoPictureInPicture();
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebPlaybackSessionManagerProxyh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.h (0 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.h                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.h        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -0,0 +1,156 @@
</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.
+ */
+
+#ifndef WebPlaybackSessionManagerProxy_h
+#define WebPlaybackSessionManagerProxy_h
+#if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
+
+#include &quot;MessageReceiver.h&quot;
+#include &lt;WebCore/GraphicsLayer.h&gt;
+#include &lt;WebCore/PlatformView.h&gt;
+#include &lt;WebCore/WebPlaybackSessionModel.h&gt;
+#include &lt;wtf/HashMap.h&gt;
+#include &lt;wtf/PassRefPtr.h&gt;
+#include &lt;wtf/RefCounted.h&gt;
+#include &lt;wtf/RefPtr.h&gt;
+
+#if PLATFORM(IOS)
+#include &lt;WebCore/WebPlaybackSessionInterfaceAVKit.h&gt;
+#else
+#include &lt;WebCore/WebPlaybackSessionInterfaceMac.h&gt;
+#endif
+
+#if PLATFORM(IOS)
+typedef WebCore::WebPlaybackSessionInterfaceAVKit PlatformWebPlaybackSessionInterface;
+#else
+typedef WebCore::WebPlaybackSessionInterfaceMac PlatformWebPlaybackSessionInterface;
+#endif
+
+namespace WebKit {
+
+class WebPageProxy;
+class WebPlaybackSessionManagerProxy;
+
+class WebPlaybackSessionModelContext final: public RefCounted&lt;WebPlaybackSessionModelContext&gt;, public WebCore::WebPlaybackSessionModel  {
+public:
+    static Ref&lt;WebPlaybackSessionModelContext&gt; create(WebPlaybackSessionManagerProxy&amp; manager, uint64_t contextId)
+    {
+        return adoptRef(*new WebPlaybackSessionModelContext(manager, contextId));
+    }
+    virtual ~WebPlaybackSessionModelContext() { }
+
+    void invalidate() { m_manager = nullptr; }
+
+private:
+    friend class WebVideoFullscreenModelContext;
+
+    WebPlaybackSessionModelContext(WebPlaybackSessionManagerProxy&amp; manager, uint64_t contextId)
+        : m_manager(&amp;manager)
+        , m_contextId(contextId)
+    {
+    }
+
+    // WebPlaybackSessionModel
+    void play() final;
+    void pause() final;
+    void togglePlayState() final;
+    void beginScrubbing() final;
+    void endScrubbing() final;
+    void seekToTime(double) final;
+    void fastSeek(double time) final;
+    void beginScanningForward() final;
+    void beginScanningBackward() final;
+    void endScanning() final;
+    void selectAudioMediaOption(uint64_t) final;
+    void selectLegibleMediaOption(uint64_t) final;
+
+    WebPlaybackSessionManagerProxy* m_manager;
+    uint64_t m_contextId;
+};
+
+class WebPlaybackSessionManagerProxy : public RefCounted&lt;WebPlaybackSessionManagerProxy&gt;, private IPC::MessageReceiver {
+public:
+    static RefPtr&lt;WebPlaybackSessionManagerProxy&gt; create(WebPageProxy&amp;);
+    virtual ~WebPlaybackSessionManagerProxy();
+
+    void invalidate();
+
+    PlatformWebPlaybackSessionInterface* controlsManagerInterface();
+
+private:
+    friend class WebPlaybackSessionModelContext;
+    friend class WebVideoFullscreenManagerProxy;
+
+    explicit WebPlaybackSessionManagerProxy(WebPageProxy&amp;);
+    void didReceiveMessage(IPC::Connection&amp;, IPC::MessageDecoder&amp;) final;
+
+    typedef std::tuple&lt;RefPtr&lt;WebPlaybackSessionModelContext&gt;, RefPtr&lt;PlatformWebPlaybackSessionInterface&gt;&gt; ModelInterfaceTuple;
+    ModelInterfaceTuple createModelAndInterface(uint64_t contextId);
+    ModelInterfaceTuple&amp; ensureModelAndInterface(uint64_t contextId);
+    WebPlaybackSessionModelContext&amp; ensureModel(uint64_t contextId);
+    PlatformWebPlaybackSessionInterface&amp; ensureInterface(uint64_t contextId);
+    void addClientForContext(uint64_t contextId);
+    void removeClientForContext(uint64_t contextId);
+
+    // Messages from WebPlaybackSessionManager
+    void setUpPlaybackControlsManagerWithID(uint64_t contextId);
+    void clearPlaybackControlsManager();
+    void resetMediaState(uint64_t contextId);
+    void setCurrentTime(uint64_t contextId, double currentTime, double hostTime);
+    void setBufferedTime(uint64_t contextId, double bufferedTime);
+    void setSeekableRangesVector(uint64_t contextId, Vector&lt;std::pair&lt;double, double&gt;&gt; ranges);
+    void setCanPlayFastReverse(uint64_t contextId, bool value);
+    void setAudioMediaSelectionOptions(uint64_t contextId, Vector&lt;String&gt; options, uint64_t selectedIndex);
+    void setLegibleMediaSelectionOptions(uint64_t contextId, Vector&lt;String&gt; options, uint64_t selectedIndex);
+    void setExternalPlaybackProperties(uint64_t contextId, bool enabled, uint32_t targetType, String localizedDeviceName);
+    void setWirelessVideoPlaybackDisabled(uint64_t contextId, bool);
+    void setDuration(uint64_t contextId, double duration);
+    void setRate(uint64_t contextId, bool isPlaying, double rate);
+
+    // Messages to WebPlaybackSessionManager
+    void play(uint64_t contextId);
+    void pause(uint64_t contextId);
+    void togglePlayState(uint64_t contextId);
+    void beginScrubbing(uint64_t contextId);
+    void endScrubbing(uint64_t contextId);
+    void seekToTime(uint64_t contextId, double time);
+    void fastSeek(uint64_t contextId, double time);
+    void beginScanningForward(uint64_t contextId);
+    void beginScanningBackward(uint64_t contextId);
+    void endScanning(uint64_t contextId);
+    void selectAudioMediaOption(uint64_t contextId, uint64_t index);
+    void selectLegibleMediaOption(uint64_t contextId, uint64_t index);
+
+    WebPageProxy* m_page;
+    HashMap&lt;uint64_t, ModelInterfaceTuple&gt; m_contextMap;
+    uint64_t m_controlsManagerContextId { 0 };
+    HashMap&lt;uint64_t, int&gt; m_clientCounts;
+};
+
+} // namespace WebKit
+
+#endif // PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
+
+#endif // WebPlaybackSessionManagerProxy_h
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebPlaybackSessionManagerProxymessagesinfromrev199592trunkSourceWebKit2UIProcessCocoaWebVideoFullscreenManagerProxymessagesin"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.messages.in (from rev 199592, trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.messages.in) (0 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.messages.in                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.messages.in        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -0,0 +1,39 @@
</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.
+
+#if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
+messages -&gt; WebPlaybackSessionManagerProxy {
+    ResetMediaState(uint64_t contextId)
+    SetCurrentTime(uint64_t contextId, double currentTime, double hostTime)
+    SetBufferedTime(uint64_t contextId, double bufferedTime)
+    SetSeekableRangesVector(uint64_t contextId, Vector&lt;std::pair&lt;double, double&gt;&gt; ranges)
+    SetCanPlayFastReverse(uint64_t contextId, bool value)
+    SetAudioMediaSelectionOptions(uint64_t contextId, Vector&lt;String&gt; options, uint64_t selectedIndex)
+    SetLegibleMediaSelectionOptions(uint64_t contextId, Vector&lt;String&gt; options, uint64_t selectedIndex)
+    SetExternalPlaybackProperties(uint64_t contextId, bool enabled, uint32_t targetType, String localizedDeviceName)
+    SetWirelessVideoPlaybackDisabled(uint64_t contextId, bool disabled)
+    SetDuration(uint64_t contextId, double duration)
+    SetRate(uint64_t contextId, bool isPlaying, double rate)
+    SetUpPlaybackControlsManagerWithID(uint64_t contextId)
+    ClearPlaybackControlsManager()
+}
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebPlaybackSessionManagerProxymm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.mm (0 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.mm                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.mm        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -0,0 +1,377 @@
</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.
+ */
+
+#import &quot;config.h&quot;
+#import &quot;WebPlaybackSessionManagerProxy.h&quot;
+
+#if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
+
+#import &quot;WebPageProxy.h&quot;
+#import &quot;WebPlaybackSessionManagerMessages.h&quot;
+#import &quot;WebPlaybackSessionManagerProxyMessages.h&quot;
+#import &quot;WebProcessProxy.h&quot;
+#import &lt;WebCore/TimeRanges.h&gt;
+#import &lt;WebKitSystemInterface.h&gt;
+
+using namespace WebCore;
+
+namespace WebKit {
+
+#pragma mark - WebPlaybackSessionModelContext
+
+void WebPlaybackSessionModelContext::play()
+{
+    if (m_manager)
+        m_manager-&gt;play(m_contextId);
+}
+
+void WebPlaybackSessionModelContext::pause()
+{
+    if (m_manager)
+        m_manager-&gt;pause(m_contextId);
+}
+
+void WebPlaybackSessionModelContext::togglePlayState()
+{
+    if (m_manager)
+        m_manager-&gt;togglePlayState(m_contextId);
+}
+
+void WebPlaybackSessionModelContext::beginScrubbing()
+{
+    if (m_manager)
+        m_manager-&gt;beginScrubbing(m_contextId);
+}
+
+void WebPlaybackSessionModelContext::endScrubbing()
+{
+    if (m_manager)
+        m_manager-&gt;endScrubbing(m_contextId);
+}
+
+void WebPlaybackSessionModelContext::seekToTime(double time)
+{
+    if (m_manager)
+        m_manager-&gt;seekToTime(m_contextId, time);
+}
+
+void WebPlaybackSessionModelContext::fastSeek(double time)
+{
+    if (m_manager)
+        m_manager-&gt;fastSeek(m_contextId, time);
+}
+
+void WebPlaybackSessionModelContext::beginScanningForward()
+{
+    if (m_manager)
+        m_manager-&gt;beginScanningForward(m_contextId);
+}
+
+void WebPlaybackSessionModelContext::beginScanningBackward()
+{
+    if (m_manager)
+        m_manager-&gt;beginScanningBackward(m_contextId);
+}
+
+void WebPlaybackSessionModelContext::endScanning()
+{
+    if (m_manager)
+        m_manager-&gt;endScanning(m_contextId);
+}
+
+void WebPlaybackSessionModelContext::selectAudioMediaOption(uint64_t optionId)
+{
+    if (m_manager)
+        m_manager-&gt;selectAudioMediaOption(m_contextId, optionId);
+}
+
+void WebPlaybackSessionModelContext::selectLegibleMediaOption(uint64_t optionId)
+{
+    if (m_manager)
+        m_manager-&gt;selectLegibleMediaOption(m_contextId, optionId);
+}
+
+#pragma mark - WebPlaybackSessionManagerProxy
+
+RefPtr&lt;WebPlaybackSessionManagerProxy&gt; WebPlaybackSessionManagerProxy::create(WebPageProxy&amp; page)
+{
+    return adoptRef(new WebPlaybackSessionManagerProxy(page));
+}
+
+WebPlaybackSessionManagerProxy::WebPlaybackSessionManagerProxy(WebPageProxy&amp; page)
+    : m_page(&amp;page)
+{
+    m_page-&gt;process().addMessageReceiver(Messages::WebPlaybackSessionManagerProxy::messageReceiverName(), m_page-&gt;pageID(), *this);
+}
+
+WebPlaybackSessionManagerProxy::~WebPlaybackSessionManagerProxy()
+{
+    if (!m_page)
+        return;
+    invalidate();
+}
+
+void WebPlaybackSessionManagerProxy::invalidate()
+{
+    m_page-&gt;process().removeMessageReceiver(Messages::WebPlaybackSessionManagerProxy::messageReceiverName(), m_page-&gt;pageID());
+    m_page = nullptr;
+
+    for (auto&amp; tuple : m_contextMap.values()) {
+        RefPtr&lt;WebPlaybackSessionModelContext&gt; model;
+        RefPtr&lt;PlatformWebPlaybackSessionInterface&gt; interface;
+        std::tie(model, interface) = tuple;
+
+        interface-&gt;invalidate();
+    }
+
+    m_contextMap.clear();
+    m_clientCounts.clear();
+}
+
+WebPlaybackSessionManagerProxy::ModelInterfaceTuple WebPlaybackSessionManagerProxy::createModelAndInterface(uint64_t contextId)
+{
+    Ref&lt;WebPlaybackSessionModelContext&gt; model = WebPlaybackSessionModelContext::create(*this, contextId);
+    Ref&lt;PlatformWebPlaybackSessionInterface&gt; interface = PlatformWebPlaybackSessionInterface::create();
+
+    interface-&gt;setWebPlaybackSessionModel(&amp;model.get());
+
+    return std::make_tuple(WTFMove(model), WTFMove(interface));
+}
+
+WebPlaybackSessionManagerProxy::ModelInterfaceTuple&amp; WebPlaybackSessionManagerProxy::ensureModelAndInterface(uint64_t contextId)
+{
+    auto addResult = m_contextMap.add(contextId, ModelInterfaceTuple());
+    if (addResult.isNewEntry)
+        addResult.iterator-&gt;value = createModelAndInterface(contextId);
+    return addResult.iterator-&gt;value;
+}
+
+WebPlaybackSessionModelContext&amp; WebPlaybackSessionManagerProxy::ensureModel(uint64_t contextId)
+{
+    return *std::get&lt;0&gt;(ensureModelAndInterface(contextId));
+}
+
+PlatformWebPlaybackSessionInterface&amp; WebPlaybackSessionManagerProxy::ensureInterface(uint64_t contextId)
+{
+    return *std::get&lt;1&gt;(ensureModelAndInterface(contextId));
+}
+
+void WebPlaybackSessionManagerProxy::addClientForContext(uint64_t contextId)
+{
+    auto addResult = m_clientCounts.add(contextId, 1);
+    if (!addResult.isNewEntry)
+        addResult.iterator-&gt;value++;
+}
+
+void WebPlaybackSessionManagerProxy::removeClientForContext(uint64_t contextId)
+{
+    ASSERT(m_clientCounts.contains(contextId));
+
+    int clientCount = m_clientCounts.get(contextId);
+    ASSERT(clientCount &gt; 0);
+    clientCount--;
+
+    if (clientCount &lt;= 0) {
+        m_clientCounts.remove(contextId);
+        m_contextMap.remove(contextId);
+        return;
+    }
+
+    m_clientCounts.set(contextId, clientCount);
+}
+
+#pragma mark Messages from WebPlaybackSessionManager
+
+void WebPlaybackSessionManagerProxy::setUpPlaybackControlsManagerWithID(uint64_t contextId)
+{
+#if PLATFORM(MAC)
+    if (m_controlsManagerContextId == contextId)
+        return;
+
+    if (m_controlsManagerContextId)
+        removeClientForContext(m_controlsManagerContextId);
+
+    m_controlsManagerContextId = contextId;
+    ensureInterface(m_controlsManagerContextId).ensureControlsManager();
+    addClientForContext(m_controlsManagerContextId);
+
+    m_page-&gt;videoControlsManagerDidChange();
+#else
+    UNUSED_PARAM(contextId);
+#endif
+}
+
+void WebPlaybackSessionManagerProxy::clearPlaybackControlsManager()
+{
+#if PLATFORM(MAC)
+    if (!m_controlsManagerContextId)
+        return;
+
+    removeClientForContext(m_controlsManagerContextId);
+    m_controlsManagerContextId = 0;
+    m_page-&gt;videoControlsManagerDidChange();
+#endif
+}
+
+void WebPlaybackSessionManagerProxy::resetMediaState(uint64_t contextId)
+{
+    ensureInterface(contextId).resetMediaState();
+}
+
+void WebPlaybackSessionManagerProxy::setCurrentTime(uint64_t contextId, double currentTime, double hostTime)
+{
+    ensureInterface(contextId).setCurrentTime(currentTime, hostTime);
+}
+
+void WebPlaybackSessionManagerProxy::setBufferedTime(uint64_t contextId, double bufferedTime)
+{
+    ensureInterface(contextId).setBufferedTime(bufferedTime);
+}
+
+void WebPlaybackSessionManagerProxy::setSeekableRangesVector(uint64_t contextId, Vector&lt;std::pair&lt;double, double&gt;&gt; ranges)
+{
+    RefPtr&lt;TimeRanges&gt; timeRanges = TimeRanges::create();
+    for (const auto&amp; range : ranges) {
+        ASSERT(isfinite(range.first));
+        ASSERT(isfinite(range.second));
+        ASSERT(range.second &gt;= range.first);
+        timeRanges-&gt;add(range.first, range.second);
+    }
+
+    ensureInterface(contextId).setSeekableRanges(*timeRanges);
+}
+
+void WebPlaybackSessionManagerProxy::setCanPlayFastReverse(uint64_t contextId, bool value)
+{
+    ensureInterface(contextId).setCanPlayFastReverse(value);
+}
+
+void WebPlaybackSessionManagerProxy::setAudioMediaSelectionOptions(uint64_t contextId, Vector&lt;String&gt; options, uint64_t selectedIndex)
+{
+    ensureInterface(contextId).setAudioMediaSelectionOptions(options, selectedIndex);
+}
+
+void WebPlaybackSessionManagerProxy::setLegibleMediaSelectionOptions(uint64_t contextId, Vector&lt;String&gt; options, uint64_t selectedIndex)
+{
+    ensureInterface(contextId).setLegibleMediaSelectionOptions(options, selectedIndex);
+}
+
+void WebPlaybackSessionManagerProxy::setExternalPlaybackProperties(uint64_t contextId, bool enabled, uint32_t targetType, String localizedDeviceName)
+{
+    WebPlaybackSessionInterface::ExternalPlaybackTargetType type = static_cast&lt;WebPlaybackSessionInterface::ExternalPlaybackTargetType&gt;(targetType);
+    ASSERT(type == WebPlaybackSessionInterface::TargetTypeAirPlay || type == WebPlaybackSessionInterface::TargetTypeTVOut || type == WebPlaybackSessionInterface::TargetTypeNone);
+
+    ensureInterface(contextId).setExternalPlayback(enabled, type, localizedDeviceName);
+}
+
+void WebPlaybackSessionManagerProxy::setWirelessVideoPlaybackDisabled(uint64_t contextId, bool disabled)
+{
+    ensureInterface(contextId).setWirelessVideoPlaybackDisabled(disabled);
+}
+
+void WebPlaybackSessionManagerProxy::setDuration(uint64_t contextId, double duration)
+{
+    ensureInterface(contextId).setDuration(duration);
+}
+
+void WebPlaybackSessionManagerProxy::setRate(uint64_t contextId, bool isPlaying, double rate)
+{
+    ensureInterface(contextId).setRate(isPlaying, rate);
+}
+
+#pragma mark Messages to WebPlaybackSessionManager
+
+void WebPlaybackSessionManagerProxy::play(uint64_t contextId)
+{
+    m_page-&gt;send(Messages::WebPlaybackSessionManager::Play(contextId), m_page-&gt;pageID());
+}
+
+void WebPlaybackSessionManagerProxy::pause(uint64_t contextId)
+{
+    m_page-&gt;send(Messages::WebPlaybackSessionManager::Pause(contextId), m_page-&gt;pageID());
+}
+
+void WebPlaybackSessionManagerProxy::togglePlayState(uint64_t contextId)
+{
+    m_page-&gt;send(Messages::WebPlaybackSessionManager::TogglePlayState(contextId), m_page-&gt;pageID());
+}
+
+void WebPlaybackSessionManagerProxy::beginScrubbing(uint64_t contextId)
+{
+    m_page-&gt;send(Messages::WebPlaybackSessionManager::BeginScrubbing(contextId), m_page-&gt;pageID());
+}
+
+void WebPlaybackSessionManagerProxy::endScrubbing(uint64_t contextId)
+{
+    m_page-&gt;send(Messages::WebPlaybackSessionManager::EndScrubbing(contextId), m_page-&gt;pageID());
+}
+
+void WebPlaybackSessionManagerProxy::seekToTime(uint64_t contextId, double time)
+{
+    m_page-&gt;send(Messages::WebPlaybackSessionManager::SeekToTime(contextId, time), m_page-&gt;pageID());
+}
+
+void WebPlaybackSessionManagerProxy::fastSeek(uint64_t contextId, double time)
+{
+    m_page-&gt;send(Messages::WebPlaybackSessionManager::FastSeek(contextId, time), m_page-&gt;pageID());
+}
+
+void WebPlaybackSessionManagerProxy::beginScanningForward(uint64_t contextId)
+{
+    m_page-&gt;send(Messages::WebPlaybackSessionManager::BeginScanningForward(contextId), m_page-&gt;pageID());
+}
+
+void WebPlaybackSessionManagerProxy::beginScanningBackward(uint64_t contextId)
+{
+    m_page-&gt;send(Messages::WebPlaybackSessionManager::BeginScanningBackward(contextId), m_page-&gt;pageID());
+}
+
+void WebPlaybackSessionManagerProxy::endScanning(uint64_t contextId)
+{
+    m_page-&gt;send(Messages::WebPlaybackSessionManager::EndScanning(contextId), m_page-&gt;pageID());
+}
+
+void WebPlaybackSessionManagerProxy::selectAudioMediaOption(uint64_t contextId, uint64_t index)
+{
+    m_page-&gt;send(Messages::WebPlaybackSessionManager::SelectAudioMediaOption(contextId, index), m_page-&gt;pageID());
+}
+
+void WebPlaybackSessionManagerProxy::selectLegibleMediaOption(uint64_t contextId, uint64_t index)
+{
+    m_page-&gt;send(Messages::WebPlaybackSessionManager::SelectLegibleMediaOption(contextId, index), m_page-&gt;pageID());
+}
+
+PlatformWebPlaybackSessionInterface* WebPlaybackSessionManagerProxy::controlsManagerInterface()
+{
+    if (!m_controlsManagerContextId)
+        return nullptr;
+    
+    auto&amp; interface = ensureInterface(m_controlsManagerContextId);
+    return &amp;interface;
+}
+
+} // namespace WebKit
+
+#endif // PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebVideoFullscreenManagerProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.h (199592 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.h        2016-04-15 17:18:12 UTC (rev 199592)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.h        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -53,15 +53,17 @@
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> class WebPageProxy;
</span><ins>+class WebPlaybackSessionManagerProxy;
+class WebPlaybackSessionModelContext;
</ins><span class="cx"> class WebVideoFullscreenManagerProxy;
</span><span class="cx"> 
</span><span class="cx"> class WebVideoFullscreenModelContext final: public RefCounted&lt;WebVideoFullscreenModelContext&gt;, public WebCore::WebVideoFullscreenModel, public WebCore::WebVideoFullscreenChangeObserver  {
</span><span class="cx"> public:
</span><del>-    static Ref&lt;WebVideoFullscreenModelContext&gt; create(WebVideoFullscreenManagerProxy&amp; manager, uint64_t contextId)
</del><ins>+    static Ref&lt;WebVideoFullscreenModelContext&gt; create(WebVideoFullscreenManagerProxy&amp; manager, WebPlaybackSessionModelContext&amp; playbackSessionModel, uint64_t contextId)
</ins><span class="cx">     {
</span><del>-        return adoptRef(*new WebVideoFullscreenModelContext(manager, contextId));
</del><ins>+        return adoptRef(*new WebVideoFullscreenModelContext(manager, playbackSessionModel, contextId));
</ins><span class="cx">     }
</span><del>-    virtual ~WebVideoFullscreenModelContext() { }
</del><ins>+    virtual ~WebVideoFullscreenModelContext();
</ins><span class="cx"> 
</span><span class="cx">     void invalidate() { m_manager = nullptr; }
</span><span class="cx"> 
</span><span class="lines">@@ -69,11 +71,7 @@
</span><span class="cx">     void setLayerHostView(RetainPtr&lt;PlatformView&gt;&amp;&amp; layerHostView) { m_layerHostView = WTFMove(layerHostView); }
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    WebVideoFullscreenModelContext(WebVideoFullscreenManagerProxy&amp; manager, uint64_t contextId)
-        : m_manager(&amp;manager)
-        , m_contextId(contextId)
-    {
-    }
</del><ins>+    WebVideoFullscreenModelContext(WebVideoFullscreenManagerProxy&amp;, WebPlaybackSessionModelContext&amp;, uint64_t);
</ins><span class="cx"> 
</span><span class="cx">     // WebVideoFullscreenModel
</span><span class="cx">     void play() override;
</span><span class="lines">@@ -102,13 +100,14 @@
</span><span class="cx">     void fullscreenMayReturnToInline() override;
</span><span class="cx"> 
</span><span class="cx">     WebVideoFullscreenManagerProxy* m_manager;
</span><ins>+    Ref&lt;WebPlaybackSessionModelContext&gt; m_playbackSessionModel;
</ins><span class="cx">     uint64_t m_contextId;
</span><span class="cx">     RetainPtr&lt;PlatformView *&gt; m_layerHostView;
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> class WebVideoFullscreenManagerProxy : public RefCounted&lt;WebVideoFullscreenManagerProxy&gt;, private IPC::MessageReceiver {
</span><span class="cx"> public:
</span><del>-    static RefPtr&lt;WebVideoFullscreenManagerProxy&gt; create(WebPageProxy&amp;);
</del><ins>+    static RefPtr&lt;WebVideoFullscreenManagerProxy&gt; create(WebPageProxy&amp;, WebPlaybackSessionManagerProxy&amp;);
</ins><span class="cx">     virtual ~WebVideoFullscreenManagerProxy();
</span><span class="cx"> 
</span><span class="cx">     void invalidate();
</span><span class="lines">@@ -119,12 +118,10 @@
</span><span class="cx">     void applicationDidBecomeActive();
</span><span class="cx">     bool isVisible() const;
</span><span class="cx"> 
</span><del>-    PlatformWebVideoFullscreenInterface* controlsManagerInterface();
-
</del><span class="cx"> private:
</span><span class="cx">     friend class WebVideoFullscreenModelContext;
</span><span class="cx"> 
</span><del>-    explicit WebVideoFullscreenManagerProxy(WebPageProxy&amp;);
</del><ins>+    explicit WebVideoFullscreenManagerProxy(WebPageProxy&amp;, WebPlaybackSessionManagerProxy&amp;);
</ins><span class="cx">     void didReceiveMessage(IPC::Connection&amp;, IPC::MessageDecoder&amp;) override;
</span><span class="cx"> 
</span><span class="cx">     typedef std::tuple&lt;RefPtr&lt;WebVideoFullscreenModelContext&gt;, RefPtr&lt;PlatformWebVideoFullscreenInterface&gt;&gt; ModelInterfaceTuple;
</span><span class="lines">@@ -137,20 +134,7 @@
</span><span class="cx"> 
</span><span class="cx">     // Messages from WebVideoFullscreenManager
</span><span class="cx">     void setupFullscreenWithID(uint64_t contextId, uint32_t videoLayerID, const WebCore::IntRect&amp; initialRect, float hostingScaleFactor, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicture);
</span><del>-    void setUpVideoControlsManagerWithID(uint64_t contextId);
-    void clearVideoControlsManager();
-    void resetMediaState(uint64_t contextId);
-    void setCurrentTime(uint64_t contextId, double currentTime, double hostTime);
-    void setBufferedTime(uint64_t contextId, double bufferedTime);
</del><span class="cx">     void setVideoDimensions(uint64_t contextId, bool hasVideo, unsigned width, unsigned height);
</span><del>-    void setSeekableRangesVector(uint64_t contextId, Vector&lt;std::pair&lt;double, double&gt;&gt; ranges);
-    void setCanPlayFastReverse(uint64_t contextId, bool value);
-    void setAudioMediaSelectionOptions(uint64_t contextId, Vector&lt;String&gt; options, uint64_t selectedIndex);
-    void setLegibleMediaSelectionOptions(uint64_t contextId, Vector&lt;String&gt; options, uint64_t selectedIndex);
-    void setExternalPlaybackProperties(uint64_t contextId, bool enabled, uint32_t targetType, String localizedDeviceName);
-    void setWirelessVideoPlaybackDisabled(uint64_t contextId, bool);
-    void setDuration(uint64_t contextId, double duration);
-    void setRate(uint64_t contextId, bool isPlaying, double rate);
</del><span class="cx">     void enterFullscreen(uint64_t contextId);
</span><span class="cx">     void exitFullscreen(uint64_t contextId, WebCore::IntRect finalRect);
</span><span class="cx">     void cleanupFullscreen(uint64_t contextId);
</span><span class="lines">@@ -160,16 +144,6 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     // Messages to WebVideoFullscreenManager
</span><del>-    void play(uint64_t contextId);
-    void pause(uint64_t contextId);
-    void togglePlayState(uint64_t contextId);
-    void beginScrubbing(uint64_t contextId);
-    void endScrubbing(uint64_t contextId);
-    void seekToTime(uint64_t contextId, double time);
-    void fastSeek(uint64_t contextId, double time);
-    void beginScanningForward(uint64_t contextId);
-    void beginScanningBackward(uint64_t contextId);
-    void endScanning(uint64_t contextId);
</del><span class="cx">     void requestFullscreenMode(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode);
</span><span class="cx">     void didSetupFullscreen(uint64_t contextId);
</span><span class="cx">     void didExitFullscreen(uint64_t contextId);
</span><span class="lines">@@ -177,12 +151,11 @@
</span><span class="cx">     void didCleanupFullscreen(uint64_t contextId);
</span><span class="cx">     void setVideoLayerFrame(uint64_t contextId, WebCore::FloatRect);
</span><span class="cx">     void setVideoLayerGravity(uint64_t contextId, WebCore::WebVideoFullscreenModel::VideoGravity);
</span><del>-    void selectAudioMediaOption(uint64_t contextId, uint64_t index);
-    void selectLegibleMediaOption(uint64_t contextId, uint64_t index);
</del><span class="cx">     void fullscreenModeChanged(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode);
</span><span class="cx">     void fullscreenMayReturnToInline(uint64_t contextId);
</span><span class="cx"> 
</span><span class="cx">     WebPageProxy* m_page;
</span><ins>+    Ref&lt;WebPlaybackSessionManagerProxy&gt; m_playbackSessionManagerProxy;
</ins><span class="cx">     HashMap&lt;uint64_t, ModelInterfaceTuple&gt; m_contextMap;
</span><span class="cx">     uint64_t m_controlsManagerContextId { 0 };
</span><span class="cx">     HashMap&lt;uint64_t, int&gt; m_clientCounts;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebVideoFullscreenManagerProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.messages.in (199592 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.messages.in        2016-04-15 17:18:12 UTC (rev 199592)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.messages.in        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -22,25 +22,12 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
</span><span class="cx"> messages -&gt; WebVideoFullscreenManagerProxy {
</span><del>-    ResetMediaState(uint64_t contextId)
-    SetCurrentTime(uint64_t contextId, double currentTime, double hostTime)
-    SetBufferedTime(uint64_t contextId, double bufferedTime)
</del><span class="cx">     SetVideoDimensions(uint64_t contextId, bool hasVideo, unsigned width, unsigned height)
</span><del>-    SetSeekableRangesVector(uint64_t contextId, Vector&lt;std::pair&lt;double, double&gt;&gt; ranges)
-    SetCanPlayFastReverse(uint64_t contextId, bool value)
-    SetAudioMediaSelectionOptions(uint64_t contextId, Vector&lt;String&gt; options, uint64_t selectedIndex)
-    SetLegibleMediaSelectionOptions(uint64_t contextId, Vector&lt;String&gt; options, uint64_t selectedIndex)
-    SetExternalPlaybackProperties(uint64_t contextId, bool enabled, uint32_t targetType, String localizedDeviceName)
-    SetWirelessVideoPlaybackDisabled(uint64_t contextId, bool disabled)
-    SetDuration(uint64_t contextId, double duration)
-    SetRate(uint64_t contextId, bool isPlaying, double rate)
</del><span class="cx">     SetupFullscreenWithID(uint64_t contextId, uint32_t videoLayerID, WebCore::IntRect initialRect, float hostingScaleFactor, WebCore::HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode, bool allowsPictureInPicture)
</span><span class="cx">     EnterFullscreen(uint64_t contextId)
</span><span class="cx">     ExitFullscreen(uint64_t contextId, WebCore::IntRect finalRect)
</span><span class="cx">     CleanupFullscreen(uint64_t contextId)
</span><span class="cx">     PreparedToReturnToInline(uint64_t contextId, bool visible, WebCore::IntRect inlineRect)
</span><del>-    SetUpVideoControlsManagerWithID(uint64_t contextId)
-    ClearVideoControlsManager()
</del><span class="cx"> #if PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE)
</span><span class="cx">     ExitFullscreenWithoutAnimationToMode(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode)
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebVideoFullscreenManagerProxymm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm (199592 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm        2016-04-15 17:18:12 UTC (rev 199592)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
</span><span class="cx"> 
</span><span class="cx"> #import &quot;WebPageProxy.h&quot;
</span><ins>+#import &quot;WebPlaybackSessionManagerProxy.h&quot;
</ins><span class="cx"> #import &quot;WebProcessProxy.h&quot;
</span><span class="cx"> #import &quot;WebVideoFullscreenManagerMessages.h&quot;
</span><span class="cx"> #import &quot;WebVideoFullscreenManagerProxyMessages.h&quot;
</span><span class="lines">@@ -111,64 +112,65 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma mark - WebVideoFullscreenModelContext
</span><span class="cx"> 
</span><ins>+WebVideoFullscreenModelContext::WebVideoFullscreenModelContext(WebVideoFullscreenManagerProxy&amp; manager, WebPlaybackSessionModelContext&amp; playbackSessionModel, uint64_t contextId)
+    : m_manager(&amp;manager)
+    , m_playbackSessionModel(playbackSessionModel)
+    , m_contextId(contextId)
+{
+}
+
+WebVideoFullscreenModelContext::~WebVideoFullscreenModelContext()
+{
+}
+
</ins><span class="cx"> void WebVideoFullscreenModelContext::play()
</span><span class="cx"> {
</span><del>-    if (m_manager)
-        m_manager-&gt;play(m_contextId);
</del><ins>+    m_playbackSessionModel-&gt;play();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelContext::pause()
</span><span class="cx"> {
</span><del>-    if (m_manager)
-        m_manager-&gt;pause(m_contextId);
</del><ins>+    m_playbackSessionModel-&gt;pause();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelContext::togglePlayState()
</span><span class="cx"> {
</span><del>-    if (m_manager)
-        m_manager-&gt;togglePlayState(m_contextId);
</del><ins>+    m_playbackSessionModel-&gt;togglePlayState();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelContext::beginScrubbing()
</span><span class="cx"> {
</span><del>-    if (m_manager)
-        m_manager-&gt;beginScrubbing(m_contextId);
</del><ins>+    m_playbackSessionModel-&gt;beginScrubbing();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelContext::endScrubbing()
</span><span class="cx"> {
</span><del>-    if (m_manager)
-        m_manager-&gt;endScrubbing(m_contextId);
</del><ins>+    m_playbackSessionModel-&gt;endScrubbing();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelContext::seekToTime(double time)
</span><span class="cx"> {
</span><del>-    if (m_manager)
-        m_manager-&gt;seekToTime(m_contextId, time);
</del><ins>+    m_playbackSessionModel-&gt;seekToTime(time);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelContext::fastSeek(double time)
</span><span class="cx"> {
</span><del>-    if (m_manager)
-        m_manager-&gt;fastSeek(m_contextId, time);
</del><ins>+    m_playbackSessionModel-&gt;fastSeek(time);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelContext::beginScanningForward()
</span><span class="cx"> {
</span><del>-    if (m_manager)
-        m_manager-&gt;beginScanningForward(m_contextId);
</del><ins>+    m_playbackSessionModel-&gt;beginScanningForward();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelContext::beginScanningBackward()
</span><span class="cx"> {
</span><del>-    if (m_manager)
-        m_manager-&gt;beginScanningBackward(m_contextId);
</del><ins>+    m_playbackSessionModel-&gt;beginScanningBackward();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelContext::endScanning()
</span><span class="cx"> {
</span><del>-    if (m_manager)
-        m_manager-&gt;endScanning(m_contextId);
</del><ins>+    m_playbackSessionModel-&gt;endScanning();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelContext::requestFullscreenMode(HTMLMediaElementEnums::VideoFullscreenMode mode)
</span><span class="lines">@@ -191,14 +193,12 @@
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelContext::selectAudioMediaOption(uint64_t optionId)
</span><span class="cx"> {
</span><del>-    if (m_manager)
-        m_manager-&gt;selectAudioMediaOption(m_contextId, optionId);
</del><ins>+    m_playbackSessionModel-&gt;selectAudioMediaOption(optionId);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelContext::selectLegibleMediaOption(uint64_t optionId)
</span><span class="cx"> {
</span><del>-    if (m_manager)
-        m_manager-&gt;selectLegibleMediaOption(m_contextId, optionId);
</del><ins>+    m_playbackSessionModel-&gt;selectLegibleMediaOption(optionId);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelContext::fullscreenModeChanged(WebCore::HTMLMediaElementEnums::VideoFullscreenMode mode)
</span><span class="lines">@@ -244,13 +244,14 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma mark - WebVideoFullscreenManagerProxy
</span><span class="cx"> 
</span><del>-RefPtr&lt;WebVideoFullscreenManagerProxy&gt; WebVideoFullscreenManagerProxy::create(WebPageProxy&amp; page)
</del><ins>+RefPtr&lt;WebVideoFullscreenManagerProxy&gt; WebVideoFullscreenManagerProxy::create(WebPageProxy&amp; page, WebPlaybackSessionManagerProxy&amp; playbackSessionManagerProxy)
</ins><span class="cx"> {
</span><del>-    return adoptRef(new WebVideoFullscreenManagerProxy(page));
</del><ins>+    return adoptRef(new WebVideoFullscreenManagerProxy(page, playbackSessionManagerProxy));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-WebVideoFullscreenManagerProxy::WebVideoFullscreenManagerProxy(WebPageProxy&amp; page)
</del><ins>+WebVideoFullscreenManagerProxy::WebVideoFullscreenManagerProxy(WebPageProxy&amp; page, WebPlaybackSessionManagerProxy&amp; playbackSessionManagerProxy)
</ins><span class="cx">     : m_page(&amp;page)
</span><ins>+    , m_playbackSessionManagerProxy(playbackSessionManagerProxy)
</ins><span class="cx"> {
</span><span class="cx">     m_page-&gt;process().addMessageReceiver(Messages::WebVideoFullscreenManagerProxy::messageReceiverName(), m_page-&gt;pageID(), *this);
</span><span class="cx"> }
</span><span class="lines">@@ -313,8 +314,10 @@
</span><span class="cx"> 
</span><span class="cx"> WebVideoFullscreenManagerProxy::ModelInterfaceTuple WebVideoFullscreenManagerProxy::createModelAndInterface(uint64_t contextId)
</span><span class="cx"> {
</span><del>-    Ref&lt;WebVideoFullscreenModelContext&gt; model = WebVideoFullscreenModelContext::create(*this, contextId);
-    Ref&lt;PlatformWebVideoFullscreenInterface&gt; interface = PlatformWebVideoFullscreenInterface::create();
</del><ins>+    auto&amp; playbackSessionModel = m_playbackSessionManagerProxy-&gt;ensureModel(contextId);
+    Ref&lt;WebVideoFullscreenModelContext&gt; model = WebVideoFullscreenModelContext::create(*this, playbackSessionModel, contextId);
+    auto&amp; playbackSessionInterface = m_playbackSessionManagerProxy-&gt;ensureInterface(contextId);
+    Ref&lt;PlatformWebVideoFullscreenInterface&gt; interface = PlatformWebVideoFullscreenInterface::create(playbackSessionInterface);
</ins><span class="cx"> 
</span><span class="cx">     interface-&gt;setWebVideoFullscreenModel(&amp;model.get());
</span><span class="cx">     interface-&gt;setWebVideoFullscreenChangeObserver(&amp;model.get());
</span><span class="lines">@@ -400,108 +403,11 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenManagerProxy::setUpVideoControlsManagerWithID(uint64_t contextId)
-{
-#if PLATFORM(MAC)
-    if (m_controlsManagerContextId == contextId)
-        return;
-
-    if (m_controlsManagerContextId)
-        removeClientForContext(m_controlsManagerContextId);
-
-    m_controlsManagerContextId = contextId;
-    ensureInterface(m_controlsManagerContextId).ensureControlsManager();
-    addClientForContext(m_controlsManagerContextId);
-
-    m_page-&gt;videoControlsManagerDidChange();
-#else
-    UNUSED_PARAM(contextId);
-#endif
-}
-
-void WebVideoFullscreenManagerProxy::clearVideoControlsManager()
-{
-#if PLATFORM(MAC)
-    if (!m_controlsManagerContextId)
-        return;
-
-    removeClientForContext(m_controlsManagerContextId);
-    m_controlsManagerContextId = 0;
-    m_page-&gt;videoControlsManagerDidChange();
-#endif
-}
-
-void WebVideoFullscreenManagerProxy::resetMediaState(uint64_t contextId)
-{
-    ensureInterface(contextId).resetMediaState();
-}
-
-void WebVideoFullscreenManagerProxy::setCurrentTime(uint64_t contextId, double currentTime, double hostTime)
-{
-    ensureInterface(contextId).setCurrentTime(currentTime, hostTime);
-}
-
-void WebVideoFullscreenManagerProxy::setBufferedTime(uint64_t contextId, double bufferedTime)
-{
-    ensureInterface(contextId).setBufferedTime(bufferedTime);
-}
-
</del><span class="cx"> void WebVideoFullscreenManagerProxy::setVideoDimensions(uint64_t contextId, bool hasVideo, unsigned width, unsigned height)
</span><span class="cx"> {
</span><span class="cx">     ensureInterface(contextId).setVideoDimensions(hasVideo, width, height);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenManagerProxy::setSeekableRangesVector(uint64_t contextId, Vector&lt;std::pair&lt;double, double&gt;&gt; ranges)
-{
-    RefPtr&lt;TimeRanges&gt; timeRanges = TimeRanges::create();
-    for (const auto&amp; range : ranges) {
-        ASSERT(isfinite(range.first));
-        ASSERT(isfinite(range.second));
-        ASSERT(range.second &gt;= range.first);
-        timeRanges-&gt;add(range.first, range.second);
-    }
-
-    ensureInterface(contextId).setSeekableRanges(*timeRanges);
-}
-
-void WebVideoFullscreenManagerProxy::setCanPlayFastReverse(uint64_t contextId, bool value)
-{
-    ensureInterface(contextId).setCanPlayFastReverse(value);
-}
-
-void WebVideoFullscreenManagerProxy::setAudioMediaSelectionOptions(uint64_t contextId, Vector&lt;String&gt; options, uint64_t selectedIndex)
-{
-    ensureInterface(contextId).setAudioMediaSelectionOptions(options, selectedIndex);
-}
-
-void WebVideoFullscreenManagerProxy::setLegibleMediaSelectionOptions(uint64_t contextId, Vector&lt;String&gt; options, uint64_t selectedIndex)
-{
-    ensureInterface(contextId).setLegibleMediaSelectionOptions(options, selectedIndex);
-}
-
-void WebVideoFullscreenManagerProxy::setExternalPlaybackProperties(uint64_t contextId, 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);
-    
-    ensureInterface(contextId).setExternalPlayback(enabled, type, localizedDeviceName);
-}
-
-void WebVideoFullscreenManagerProxy::setWirelessVideoPlaybackDisabled(uint64_t contextId, bool disabled)
-{
-    ensureInterface(contextId).setWirelessVideoPlaybackDisabled(disabled);
-}
-
-void WebVideoFullscreenManagerProxy::setDuration(uint64_t contextId, double duration)
-{
-    ensureInterface(contextId).setDuration(duration);
-}
-
-void WebVideoFullscreenManagerProxy::setRate(uint64_t contextId, bool isPlaying, double rate)
-{
-    ensureInterface(contextId).setRate(isPlaying, rate);
-}
-
</del><span class="cx"> void WebVideoFullscreenManagerProxy::enterFullscreen(uint64_t contextId)
</span><span class="cx"> {
</span><span class="cx">     auto&amp; interface = ensureInterface(contextId);
</span><span class="lines">@@ -557,56 +463,6 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma mark Messages to WebVideoFullscreenManager
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenManagerProxy::play(uint64_t contextId)
-{
-    m_page-&gt;send(Messages::WebVideoFullscreenManager::Play(contextId), m_page-&gt;pageID());
-}
-
-void WebVideoFullscreenManagerProxy::pause(uint64_t contextId)
-{
-    m_page-&gt;send(Messages::WebVideoFullscreenManager::Pause(contextId), m_page-&gt;pageID());
-}
-
-void WebVideoFullscreenManagerProxy::togglePlayState(uint64_t contextId)
-{
-    m_page-&gt;send(Messages::WebVideoFullscreenManager::TogglePlayState(contextId), m_page-&gt;pageID());
-}
-
-void WebVideoFullscreenManagerProxy::beginScrubbing(uint64_t contextId)
-{
-    m_page-&gt;send(Messages::WebVideoFullscreenManager::BeginScrubbing(contextId), m_page-&gt;pageID());
-}
-
-void WebVideoFullscreenManagerProxy::endScrubbing(uint64_t contextId)
-{
-    m_page-&gt;send(Messages::WebVideoFullscreenManager::EndScrubbing(contextId), m_page-&gt;pageID());
-}
-
-void WebVideoFullscreenManagerProxy::seekToTime(uint64_t contextId, double time)
-{
-    m_page-&gt;send(Messages::WebVideoFullscreenManager::SeekToTime(contextId, time), m_page-&gt;pageID());
-}
-
-void WebVideoFullscreenManagerProxy::fastSeek(uint64_t contextId, double time)
-{
-    m_page-&gt;send(Messages::WebVideoFullscreenManager::FastSeek(contextId, time), m_page-&gt;pageID());
-}
-
-void WebVideoFullscreenManagerProxy::beginScanningForward(uint64_t contextId)
-{
-    m_page-&gt;send(Messages::WebVideoFullscreenManager::BeginScanningForward(contextId), m_page-&gt;pageID());
-}
-
-void WebVideoFullscreenManagerProxy::beginScanningBackward(uint64_t contextId)
-{
-    m_page-&gt;send(Messages::WebVideoFullscreenManager::BeginScanningBackward(contextId), m_page-&gt;pageID());
-}
-
-void WebVideoFullscreenManagerProxy::endScanning(uint64_t contextId)
-{
-    m_page-&gt;send(Messages::WebVideoFullscreenManager::EndScanning(contextId), m_page-&gt;pageID());
-}
-
</del><span class="cx"> void WebVideoFullscreenManagerProxy::requestFullscreenMode(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode mode)
</span><span class="cx"> {
</span><span class="cx">     m_page-&gt;send(Messages::WebVideoFullscreenManager::RequestFullscreenMode(contextId, mode), m_page-&gt;pageID());
</span><span class="lines">@@ -663,16 +519,6 @@
</span><span class="cx">     m_page-&gt;send(Messages::WebVideoFullscreenManager::SetVideoLayerGravityEnum(contextId, (unsigned)gravity), m_page-&gt;pageID());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenManagerProxy::selectAudioMediaOption(uint64_t contextId, uint64_t index)
-{
-    m_page-&gt;send(Messages::WebVideoFullscreenManager::SelectAudioMediaOption(contextId, index), m_page-&gt;pageID());
-}
-
-void WebVideoFullscreenManagerProxy::selectLegibleMediaOption(uint64_t contextId, uint64_t index)
-{
-    m_page-&gt;send(Messages::WebVideoFullscreenManager::SelectLegibleMediaOption(contextId, index), m_page-&gt;pageID());
-}
-
</del><span class="cx"> void WebVideoFullscreenManagerProxy::fullscreenModeChanged(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode mode)
</span><span class="cx"> {
</span><span class="cx">     m_page-&gt;send(Messages::WebVideoFullscreenManager::FullscreenModeChanged(contextId, mode), m_page-&gt;pageID());
</span><span class="lines">@@ -683,15 +529,6 @@
</span><span class="cx">     return m_page-&gt;isViewVisible() &amp;&amp; m_page-&gt;isInWindow();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-PlatformWebVideoFullscreenInterface* WebVideoFullscreenManagerProxy::controlsManagerInterface()
-{
-    if (!m_controlsManagerContextId)
-        return nullptr;
-
-    auto&amp; interface = ensureInterface(m_controlsManagerContextId);
-    return &amp;interface;
-}
-
</del><span class="cx"> void WebVideoFullscreenManagerProxy::fullscreenMayReturnToInline(uint64_t contextId)
</span><span class="cx"> {
</span><span class="cx">     bool isViewVisible = m_page-&gt;isViewVisible();
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (199592 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2016-04-15 17:18:12 UTC (rev 199592)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -170,6 +170,10 @@
</span><span class="cx"> #include &lt;WebKitAdditions/WebPageProxyIncludes.h&gt;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
+#include &quot;WebPlaybackSessionManagerProxy.h&quot;
+#endif
+
</ins><span class="cx"> // This controls what strategy we use for mouse wheel coalescing.
</span><span class="cx"> #define MERGE_WHEEL_EVENTS 1
</span><span class="cx"> 
</span><span class="lines">@@ -471,7 +475,8 @@
</span><span class="cx">     m_fullScreenManager = WebFullScreenManagerProxy::create(*this, m_pageClient.fullScreenManagerProxyClient());
</span><span class="cx"> #endif
</span><span class="cx"> #if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
</span><del>-    m_videoFullscreenManager = WebVideoFullscreenManagerProxy::create(*this);
</del><ins>+    m_playbackSessionManager = WebPlaybackSessionManagerProxy::create(*this);
+    m_videoFullscreenManager = WebVideoFullscreenManagerProxy::create(*this, *m_playbackSessionManager);
</ins><span class="cx"> #endif
</span><span class="cx"> #if ENABLE(VIBRATION)
</span><span class="cx">     m_vibration = WebVibrationProxy::create(this);
</span><span class="lines">@@ -708,7 +713,8 @@
</span><span class="cx">     m_fullScreenManager = WebFullScreenManagerProxy::create(*this, m_pageClient.fullScreenManagerProxyClient());
</span><span class="cx"> #endif
</span><span class="cx"> #if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
</span><del>-    m_videoFullscreenManager = WebVideoFullscreenManagerProxy::create(*this);
</del><ins>+    m_playbackSessionManager = WebPlaybackSessionManagerProxy::create(*this);
+    m_videoFullscreenManager = WebVideoFullscreenManagerProxy::create(*this, *m_playbackSessionManager);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if USE(APPLE_INTERNAL_SDK)
</span><span class="lines">@@ -4029,10 +4035,15 @@
</span><span class="cx"> #endif
</span><span class="cx">     
</span><span class="cx"> #if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
</span><del>-RefPtr&lt;WebVideoFullscreenManagerProxy&gt; WebPageProxy::videoFullscreenManager()
</del><ins>+WebPlaybackSessionManagerProxy* WebPageProxy::playbackSessionManager()
</ins><span class="cx"> {
</span><del>-    return m_videoFullscreenManager;
</del><ins>+    return m_playbackSessionManager.get();
</ins><span class="cx"> }
</span><ins>+
+WebVideoFullscreenManagerProxy* WebPageProxy::videoFullscreenManager()
+{
+    return m_videoFullscreenManager.get();
+}
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="lines">@@ -5064,6 +5075,10 @@
</span><span class="cx">     m_visibleScrollerThumbRect = IntRect();
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
</span><ins>+    if (m_playbackSessionManager) {
+        m_playbackSessionManager-&gt;invalidate();
+        m_playbackSessionManager = nullptr;
+    }
</ins><span class="cx">     if (m_videoFullscreenManager) {
</span><span class="cx">         m_videoFullscreenManager-&gt;invalidate();
</span><span class="cx">         m_videoFullscreenManager = nullptr;
</span><span class="lines">@@ -6040,7 +6055,7 @@
</span><span class="cx"> bool WebPageProxy::hasActiveVideoForControlsManager() const
</span><span class="cx"> {
</span><span class="cx"> #if ENABLE(VIDEO_PRESENTATION_MODE)
</span><del>-    return m_videoFullscreenManager &amp;&amp; m_videoFullscreenManager-&gt;controlsManagerInterface() &amp;&amp; m_mediaState &amp; MediaProducer::HasAudioOrVideo;
</del><ins>+    return m_playbackSessionManager &amp;&amp; m_playbackSessionManager-&gt;controlsManagerInterface() &amp;&amp; m_mediaState &amp; MediaProducer::HasAudioOrVideo;
</ins><span class="cx"> #else
</span><span class="cx">     return false;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (199592 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2016-04-15 17:18:12 UTC (rev 199592)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -192,6 +192,7 @@
</span><span class="cx"> class WebContextMenuProxy;
</span><span class="cx"> class WebEditCommandProxy;
</span><span class="cx"> class WebFullScreenManagerProxy;
</span><ins>+class WebPlaybackSessionManagerProxy;
</ins><span class="cx"> class WebNavigationState;
</span><span class="cx"> class WebVideoFullscreenManagerProxy;
</span><span class="cx"> class WebKeyboardEvent;
</span><span class="lines">@@ -328,7 +329,8 @@
</span><span class="cx">     WebFullScreenManagerProxy* fullScreenManager();
</span><span class="cx"> #endif
</span><span class="cx"> #if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
</span><del>-    RefPtr&lt;WebVideoFullscreenManagerProxy&gt; videoFullscreenManager();
</del><ins>+    WebPlaybackSessionManagerProxy* playbackSessionManager();
+    WebVideoFullscreenManagerProxy* videoFullscreenManager();
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="lines">@@ -1547,6 +1549,7 @@
</span><span class="cx">     RefPtr&lt;WebFullScreenManagerProxy&gt; m_fullScreenManager;
</span><span class="cx"> #endif
</span><span class="cx"> #if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
</span><ins>+    RefPtr&lt;WebPlaybackSessionManagerProxy&gt; m_playbackSessionManager;
</ins><span class="cx">     RefPtr&lt;WebVideoFullscreenManagerProxy&gt; m_videoFullscreenManager;
</span><span class="cx"> #endif
</span><span class="cx"> #if PLATFORM(IOS)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (199592 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2016-04-15 17:18:12 UTC (rev 199592)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -1708,6 +1708,14 @@
</span><span class="cx">                 CD73BA4E131ACDB700EEDED2 /* WebFullScreenManagerMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD73BA48131ACD8E00EEDED2 /* WebFullScreenManagerMessageReceiver.cpp */; };
</span><span class="cx">                 CD73BA53131B645B00EEDED2 /* WebFullScreenManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD73BA37131A29FE00EEDED2 /* WebFullScreenManager.cpp */; };
</span><span class="cx">                 CDA041F41ACE2105004A13EC /* BackBoardServicesSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA041F31ACE2105004A13EC /* BackBoardServicesSPI.h */; };
</span><ins>+                CDA29A1A1CBDBF4100901CCF /* WebPlaybackSessionManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDA29A181CBDBF4100901CCF /* WebPlaybackSessionManager.mm */; };
+                CDA29A1B1CBDBF4100901CCF /* WebPlaybackSessionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA29A191CBDBF4100901CCF /* WebPlaybackSessionManager.h */; };
+                CDA29A201CBEB5FB00901CCF /* WebPlaybackSessionManagerProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA29A1E1CBEB5FB00901CCF /* WebPlaybackSessionManagerProxy.h */; };
+                CDA29A211CBEB5FB00901CCF /* WebPlaybackSessionManagerProxy.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDA29A1F1CBEB5FB00901CCF /* WebPlaybackSessionManagerProxy.mm */; };
+                CDA29A281CBEB67A00901CCF /* WebPlaybackSessionManagerMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDA29A241CBEB67A00901CCF /* WebPlaybackSessionManagerMessageReceiver.cpp */; };
+                CDA29A291CBEB67A00901CCF /* WebPlaybackSessionManagerMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA29A251CBEB67A00901CCF /* WebPlaybackSessionManagerMessages.h */; };
+                CDA29A2A1CBEB67A00901CCF /* WebPlaybackSessionManagerProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDA29A261CBEB67A00901CCF /* WebPlaybackSessionManagerProxyMessageReceiver.cpp */; };
+                CDA29A2B1CBEB67A00901CCF /* WebPlaybackSessionManagerProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA29A271CBEB67A00901CCF /* WebPlaybackSessionManagerProxyMessages.h */; };
</ins><span class="cx">                 CDC382FE17211799008A2FC3 /* SecItemShimLibrary.mm in Sources */ = {isa = PBXBuildFile; fileRef = 511F8A78138B460900A95F44 /* SecItemShimLibrary.mm */; };
</span><span class="cx">                 CDC38307172117DD008A2FC3 /* CookieStorageShimLibrary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDC382F9172116D3008A2FC3 /* CookieStorageShimLibrary.cpp */; };
</span><span class="cx">                 CDC3830C17212282008A2FC3 /* CookieStorageShimLibrary.h in Headers */ = {isa = PBXBuildFile; fileRef = CDC3830B172121CE008A2FC3 /* CookieStorageShimLibrary.h */; };
</span><span class="lines">@@ -3784,6 +3792,16 @@
</span><span class="cx">                 CD73BA49131ACD8E00EEDED2 /* WebFullScreenManagerMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebFullScreenManagerMessages.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CD73BA4A131ACD8F00EEDED2 /* WebFullScreenManagerProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebFullScreenManagerProxyMessages.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CDA041F31ACE2105004A13EC /* BackBoardServicesSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BackBoardServicesSPI.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                CDA29A181CBDBF4100901CCF /* WebPlaybackSessionManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPlaybackSessionManager.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CDA29A191CBDBF4100901CCF /* WebPlaybackSessionManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPlaybackSessionManager.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CDA29A1C1CBDBF5B00901CCF /* WebPlaybackSessionManager.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebPlaybackSessionManager.messages.in; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CDA29A1E1CBEB5FB00901CCF /* WebPlaybackSessionManagerProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPlaybackSessionManagerProxy.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CDA29A1F1CBEB5FB00901CCF /* WebPlaybackSessionManagerProxy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPlaybackSessionManagerProxy.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CDA29A221CBEB61A00901CCF /* WebPlaybackSessionManagerProxy.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebPlaybackSessionManagerProxy.messages.in; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CDA29A241CBEB67A00901CCF /* WebPlaybackSessionManagerMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebPlaybackSessionManagerMessageReceiver.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CDA29A251CBEB67A00901CCF /* WebPlaybackSessionManagerMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPlaybackSessionManagerMessages.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CDA29A261CBEB67A00901CCF /* WebPlaybackSessionManagerProxyMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebPlaybackSessionManagerProxyMessageReceiver.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CDA29A271CBEB67A00901CCF /* WebPlaybackSessionManagerProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPlaybackSessionManagerProxyMessages.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 CDC382F717211506008A2FC3 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = /System/Library/Frameworks/CFNetwork.framework; sourceTree = &quot;&lt;absolute&gt;&quot;; };
</span><span class="cx">                 CDC382F9172116D3008A2FC3 /* CookieStorageShimLibrary.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CookieStorageShimLibrary.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CDC3830617211799008A2FC3 /* WebProcessShim.dylib */ = {isa = PBXFileReference; explicitFileType = &quot;compiled.mach-o.dylib&quot;; includeInIndex = 0; path = WebProcessShim.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
</span><span class="lines">@@ -4644,6 +4662,9 @@
</span><span class="cx">                                 9986BDD61CA9A222004800AA /* WebAutomationSessionCocoa.mm */,
</span><span class="cx">                                 1AC0273E196622D600C12B75 /* WebPageProxyCocoa.mm */,
</span><span class="cx">                                 7C4694CB1A4B510A00AD5845 /* WebPasteboardProxyCocoa.mm */,
</span><ins>+                                CDA29A1E1CBEB5FB00901CCF /* WebPlaybackSessionManagerProxy.h */,
+                                CDA29A221CBEB61A00901CCF /* WebPlaybackSessionManagerProxy.messages.in */,
+                                CDA29A1F1CBEB5FB00901CCF /* WebPlaybackSessionManagerProxy.mm */,
</ins><span class="cx">                                 7CE4D2151A49148400C7F152 /* WebProcessPoolCocoa.mm */,
</span><span class="cx">                                 1A04F6171A4A3A7A00A21B6E /* WebProcessProxyCocoa.mm */,
</span><span class="cx">                                 52D5A1AA1C57494E00DE34A3 /* WebVideoFullscreenManagerProxy.h */,
</span><span class="lines">@@ -5588,6 +5609,9 @@
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><span class="cx">                                 7C6E70F918B2D4A000F24E2E /* WebProcessCocoa.mm */,
</span><ins>+                                CDA29A191CBDBF4100901CCF /* WebPlaybackSessionManager.h */,
+                                CDA29A1C1CBDBF5B00901CCF /* WebPlaybackSessionManager.messages.in */,
+                                CDA29A181CBDBF4100901CCF /* WebPlaybackSessionManager.mm */,
</ins><span class="cx">                                 52D5A1B21C5749F200DE34A3 /* WebVideoFullscreenManager.h */,
</span><span class="cx">                                 52D5A1B31C5749F200DE34A3 /* WebVideoFullscreenManager.messages.in */,
</span><span class="cx">                                 52D5A1B41C5749F200DE34A3 /* WebVideoFullscreenManager.mm */,
</span><span class="lines">@@ -6964,6 +6988,10 @@
</span><span class="cx">                                 BCBD3913125BB1A800D2C29F /* WebPageProxyMessages.h */,
</span><span class="cx">                                 7C4694C71A4B4EA000AD5845 /* WebPasteboardProxyMessageReceiver.cpp */,
</span><span class="cx">                                 7C4694C81A4B4EA100AD5845 /* WebPasteboardProxyMessages.h */,
</span><ins>+                                CDA29A241CBEB67A00901CCF /* WebPlaybackSessionManagerMessageReceiver.cpp */,
+                                CDA29A251CBEB67A00901CCF /* WebPlaybackSessionManagerMessages.h */,
+                                CDA29A261CBEB67A00901CCF /* WebPlaybackSessionManagerProxyMessageReceiver.cpp */,
+                                CDA29A271CBEB67A00901CCF /* WebPlaybackSessionManagerProxyMessages.h */,
</ins><span class="cx">                                 1A043F6712514D8B00FFBFB5 /* WebProcessConnectionMessageReceiver.cpp */,
</span><span class="cx">                                 1A043F6812514D8B00FFBFB5 /* WebProcessConnectionMessages.h */,
</span><span class="cx">                                 BC3066BC125A442100E71278 /* WebProcessMessageReceiver.cpp */,
</span><span class="lines">@@ -7575,6 +7603,7 @@
</span><span class="cx">                                 514D9F5719119D35000063A7 /* ServicesController.h in Headers */,
</span><span class="cx">                                 1AFDE65A1954A42B00C48FFA /* SessionState.h in Headers */,
</span><span class="cx">                                 1A002D49196B345D00B9AD44 /* SessionStateCoding.h in Headers */,
</span><ins>+                                CDA29A201CBEB5FB00901CCF /* WebPlaybackSessionManagerProxy.h in Headers */,
</ins><span class="cx">                                 753E3E0E1887398900188496 /* SessionTracker.h in Headers */,
</span><span class="cx">                                 99C81D5A1C20E7E2005C4C82 /* AutomationClient.h in Headers */,
</span><span class="cx">                                 9955A6EC1C7980C200EB6A93 /* WebAutomationSession.h in Headers */,
</span><span class="lines">@@ -8000,6 +8029,7 @@
</span><span class="cx">                                 A5EFD38C16B0E88C00B2F0E8 /* WKPageVisibilityTypes.h in Headers */,
</span><span class="cx">                                 2D6AB541192B1C4A003A9FD1 /* WKPDFPageNumberIndicator.h in Headers */,
</span><span class="cx">                                 2DA1E4FE18C02B6A00DBC929 /* WKPDFView.h in Headers */,
</span><ins>+                                CDA29A291CBEB67A00901CCF /* WebPlaybackSessionManagerMessages.h in Headers */,
</ins><span class="cx">                                 7C135AA9173B0BCA00586AE2 /* WKPluginInformation.h in Headers */,
</span><span class="cx">                                 2DABA7741A817EE600EF0F1A /* WKPluginLoadPolicy.h in Headers */,
</span><span class="cx">                                 1AFDD3171891C94700153970 /* WKPreferences.h in Headers */,
</span><span class="lines">@@ -8060,6 +8090,7 @@
</span><span class="cx">                                 377EAD4817E2C77B002D193D /* WKUserContentInjectedFrames.h in Headers */,
</span><span class="cx">                                 F6113E29126CE19B0057D0A7 /* WKUserContentURLPattern.h in Headers */,
</span><span class="cx">                                 4A3CC18F19B07B8A00D14AEF /* WKUserMediaPermissionRequest.h in Headers */,
</span><ins>+                                CDA29A1B1CBDBF4100901CCF /* WebPlaybackSessionManager.h in Headers */,
</ins><span class="cx">                                 1AAF089B19267EE500B6390C /* WKUserScript.h in Headers */,
</span><span class="cx">                                 377EAD4917E2C77B002D193D /* WKUserScriptInjectionTime.h in Headers */,
</span><span class="cx">                                 1AAF089D19267FC800B6390C /* WKUserScriptInternal.h in Headers */,
</span><span class="lines">@@ -8101,6 +8132,7 @@
</span><span class="cx">                                 1A57109F1ABA0027002FABBE /* WKWebsiteDataStoreRef.h in Headers */,
</span><span class="cx">                                 93A253F31C92411200F9F68D /* WKPreviewActionItemIdentifiers.h in Headers */,
</span><span class="cx">                                 1A3CC16718906ACF001E6ED8 /* WKWebView.h in Headers */,
</span><ins>+                                CDA29A2B1CBEB67A00901CCF /* WebPlaybackSessionManagerProxyMessages.h in Headers */,
</ins><span class="cx">                                 1ADF591B1890528E0043C145 /* WKWebViewConfiguration.h in Headers */,
</span><span class="cx">                                 2D7AAFD618C956AF00A7ACD4 /* WKWebViewConfigurationInternal.h in Headers */,
</span><span class="cx">                                 1AC1415118AC47EE006C602C /* WKWebViewConfigurationPrivate.h in Headers */,
</span><span class="lines">@@ -8728,6 +8760,7 @@
</span><span class="cx">                                 7C1BA33D1A4A0E600043E249 /* APIDictionary.cpp in Sources */,
</span><span class="cx">                                 1AB40EE51BF677E300BA81BE /* WKMenuItemIdentifiers.mm in Sources */,
</span><span class="cx">                                 BC575613126E0138006F0F12 /* APIError.cpp in Sources */,
</span><ins>+                                CDA29A2A1CBEB67A00901CCF /* WebPlaybackSessionManagerProxyMessageReceiver.cpp in Sources */,
</ins><span class="cx">                                 1AC1337118566C7C00F3EC05 /* APIFrameHandle.cpp in Sources */,
</span><span class="cx">                                 2DF9EEE51A781FB400B6CFBE /* APIFrameInfo.cpp in Sources */,
</span><span class="cx">                                 1AC133741857C21E00F3EC05 /* APIGeometry.cpp in Sources */,
</span><span class="lines">@@ -8872,6 +8905,7 @@
</span><span class="cx">                                 2D5AB6301A69D6FB0014A9CB /* MessageRecorderProbes.d in Sources */,
</span><span class="cx">                                 1AAB0379185A7C6A00EDF501 /* MessageSender.cpp in Sources */,
</span><span class="cx">                                 C0E3AA7B1209E83500A49D01 /* Module.cpp in Sources */,
</span><ins>+                                CDA29A281CBEB67A00901CCF /* WebPlaybackSessionManagerMessageReceiver.cpp in Sources */,
</ins><span class="cx">                                 C0E3AA7A1209E83000A49D01 /* ModuleCF.cpp in Sources */,
</span><span class="cx">                                 2D50365E1BCC793F00E20BB3 /* NativeWebGestureEventMac.mm in Sources */,
</span><span class="cx">                                 2DA9449E1884E4F000ED86DB /* NativeWebKeyboardEventIOS.mm in Sources */,
</span><span class="lines">@@ -8974,6 +9008,7 @@
</span><span class="cx">                                 7C135AAC173B0CFF00586AE2 /* PluginInformationMac.mm in Sources */,
</span><span class="cx">                                 1AEFCC1311D01F96008219D3 /* PluginInfoStore.cpp in Sources */,
</span><span class="cx">                                 1AEFCCBD11D02C5E008219D3 /* PluginInfoStoreMac.mm in Sources */,
</span><ins>+                                CDA29A1A1CBDBF4100901CCF /* WebPlaybackSessionManager.mm in Sources */,
</ins><span class="cx">                                 1A043977124D034800FFBFB5 /* PluginProcess.cpp in Sources */,
</span><span class="cx">                                 1A0EC907124C0AB8007EF4A5 /* PluginProcessConnection.cpp in Sources */,
</span><span class="cx">                                 1A0EC910124C0AF5007EF4A5 /* PluginProcessConnectionManager.cpp in Sources */,
</span><span class="lines">@@ -9027,6 +9062,7 @@
</span><span class="cx">                                 0F59479A187B3B6000437857 /* RemoteScrollingCoordinatorProxy.cpp in Sources */,
</span><span class="cx">                                 0F0C365C18C05CA100F607D7 /* RemoteScrollingCoordinatorProxyIOS.mm in Sources */,
</span><span class="cx">                                 0F5947A3187B3B7D00437857 /* RemoteScrollingCoordinatorTransaction.cpp in Sources */,
</span><ins>+                                CDA29A211CBEB5FB00901CCF /* WebPlaybackSessionManagerProxy.mm in Sources */,
</ins><span class="cx">                                 0F59479C187B3B6000437857 /* RemoteScrollingTree.cpp in Sources */,
</span><span class="cx">                                 BC111B09112F5E3C00337BAB /* ResponsivenessTimer.cpp in Sources */,
</span><span class="cx">                                 1AAB4AAA1296F1540023952F /* SandboxExtensionMac.mm in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebChromeClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp (199592 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp        2016-04-15 17:18:12 UTC (rev 199592)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -75,6 +75,7 @@
</span><span class="cx"> #include &lt;WebCore/Settings.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
</span><ins>+#include &quot;WebPlaybackSessionManager.h&quot;
</ins><span class="cx"> #include &quot;WebVideoFullscreenManager.h&quot;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -852,34 +853,34 @@
</span><span class="cx"> #if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
</span><span class="cx"> bool WebChromeClient::supportsVideoFullscreen(WebCore::HTMLMediaElementEnums::VideoFullscreenMode mode)
</span><span class="cx"> {
</span><del>-    return m_page-&gt;videoFullscreenManager()-&gt;supportsVideoFullscreen(mode);
</del><ins>+    return m_page-&gt;videoFullscreenManager().supportsVideoFullscreen(mode);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebChromeClient::setUpVideoControlsManager(WebCore::HTMLVideoElement&amp; videoElement)
</del><ins>+void WebChromeClient::setUpPlaybackControlsManager(WebCore::HTMLMediaElement&amp; mediaElement)
</ins><span class="cx"> {
</span><del>-    m_page-&gt;videoFullscreenManager()-&gt;setUpVideoControlsManager(videoElement);
</del><ins>+    m_page-&gt;playbackSessionManager().setUpPlaybackControlsManager(mediaElement);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebChromeClient::clearVideoControlsManager()
</del><ins>+void WebChromeClient::clearPlaybackControlsManager(WebCore::HTMLMediaElement&amp; mediaElement)
</ins><span class="cx"> {
</span><del>-    m_page-&gt;videoFullscreenManager()-&gt;clearVideoControlsManager();
</del><ins>+    m_page-&gt;playbackSessionManager().clearPlaybackControlsManager(mediaElement);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebChromeClient::enterVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&amp; videoElement, WebCore::HTMLMediaElementEnums::VideoFullscreenMode mode)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(mode != HTMLMediaElementEnums::VideoFullscreenModeNone);
</span><del>-    m_page-&gt;videoFullscreenManager()-&gt;enterVideoFullscreenForVideoElement(videoElement, mode);
</del><ins>+    m_page-&gt;videoFullscreenManager().enterVideoFullscreenForVideoElement(videoElement, mode);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebChromeClient::exitVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&amp; videoElement)
</span><span class="cx"> {
</span><del>-    m_page-&gt;videoFullscreenManager()-&gt;exitVideoFullscreenForVideoElement(videoElement);
</del><ins>+    m_page-&gt;videoFullscreenManager().exitVideoFullscreenForVideoElement(videoElement);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE)
</span><span class="cx"> void WebChromeClient::exitVideoFullscreenToModeWithoutAnimation(WebCore::HTMLVideoElement&amp; videoElement, HTMLMediaElementEnums::VideoFullscreenMode targetMode)
</span><span class="cx"> {
</span><del>-    m_page-&gt;videoFullscreenManager()-&gt;exitVideoFullscreenToModeWithoutAnimation(videoElement, targetMode);
</del><ins>+    m_page-&gt;videoFullscreenManager().exitVideoFullscreenToModeWithoutAnimation(videoElement, targetMode);
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebChromeClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h (199592 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h        2016-04-15 17:18:12 UTC (rev 199592)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -244,8 +244,8 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
</span><span class="cx">     bool supportsVideoFullscreen(WebCore::HTMLMediaElementEnums::VideoFullscreenMode) override;
</span><del>-    void setUpVideoControlsManager(WebCore::HTMLVideoElement&amp;) override;
-    void clearVideoControlsManager() override;
</del><ins>+    void setUpPlaybackControlsManager(WebCore::HTMLMediaElement&amp;) override;
+    void clearPlaybackControlsManager(WebCore::HTMLMediaElement&amp;) override;
</ins><span class="cx">     void enterVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&amp;, WebCore::HTMLMediaElementEnums::VideoFullscreenMode) override;
</span><span class="cx">     void exitVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&amp;) override;
</span><span class="cx"> #if PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (199592 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2016-04-15 17:18:12 UTC (rev 199592)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -1,3 +1,4 @@
</span><ins>+
</ins><span class="cx"> /*
</span><span class="cx">  * Copyright (C) 2010-2016 Apple Inc. All rights reserved.
</span><span class="cx">  * Copyright (C) 2012 Intel Corporation. All rights reserved.
</span><span class="lines">@@ -196,6 +197,7 @@
</span><span class="cx"> #include &quot;PDFPlugin.h&quot;
</span><span class="cx"> #include &quot;RemoteLayerTreeTransaction.h&quot;
</span><span class="cx"> #include &quot;WKStringCF.h&quot;
</span><ins>+#include &quot;WebPlaybackSessionManager.h&quot;
</ins><span class="cx"> #include &quot;WebVideoFullscreenManager.h&quot;
</span><span class="cx"> #include &lt;WebCore/LegacyWebArchive.h&gt;
</span><span class="cx"> #endif
</span><span class="lines">@@ -3192,11 +3194,18 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
</span><del>-WebVideoFullscreenManager* WebPage::videoFullscreenManager()
</del><ins>+WebPlaybackSessionManager&amp; WebPage::playbackSessionManager()
</ins><span class="cx"> {
</span><ins>+    if (!m_playbackSessionManager)
+        m_playbackSessionManager = WebPlaybackSessionManager::create(*this);
+    return *m_playbackSessionManager;
+}
+
+WebVideoFullscreenManager&amp; WebPage::videoFullscreenManager()
+{
</ins><span class="cx">     if (!m_videoFullscreenManager)
</span><del>-        m_videoFullscreenManager = WebVideoFullscreenManager::create(this);
-    return m_videoFullscreenManager.get();
</del><ins>+        m_videoFullscreenManager = WebVideoFullscreenManager::create(*this, playbackSessionManager());
+    return *m_videoFullscreenManager;
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (199592 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2016-04-15 17:18:12 UTC (rev 199592)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -180,6 +180,7 @@
</span><span class="cx"> class WebOpenPanelResultListener;
</span><span class="cx"> class WebPageGroupProxy;
</span><span class="cx"> class WebPageOverlay;
</span><ins>+class WebPlaybackSessionManager;
</ins><span class="cx"> class WebPopupMenu;
</span><span class="cx"> class WebUndoStep;
</span><span class="cx"> class WebUserContentController;
</span><span class="lines">@@ -251,7 +252,8 @@
</span><span class="cx">     bool isInspectorPage() { return !!m_inspectorUI; }
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
</span><del>-    WebVideoFullscreenManager* videoFullscreenManager();
</del><ins>+    WebPlaybackSessionManager&amp; playbackSessionManager();
+    WebVideoFullscreenManager&amp; videoFullscreenManager();
</ins><span class="cx"> #endif
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     void setAllowsMediaDocumentInlinePlayback(bool);
</span><span class="lines">@@ -1308,6 +1310,7 @@
</span><span class="cx">     RefPtr&lt;WebInspector&gt; m_inspector;
</span><span class="cx">     RefPtr&lt;WebInspectorUI&gt; m_inspectorUI;
</span><span class="cx"> #if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
</span><ins>+    RefPtr&lt;WebPlaybackSessionManager&gt; m_playbackSessionManager;
</ins><span class="cx">     RefPtr&lt;WebVideoFullscreenManager&gt; m_videoFullscreenManager;
</span><span class="cx"> #endif
</span><span class="cx"> #if PLATFORM(IOS)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcesscocoaWebPlaybackSessionManagerh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.h (0 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.h                                (rev 0)
+++ trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.h        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -0,0 +1,153 @@
</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.
+ */
+
+#ifndef WebPlaybackSessionManager_h
+#define WebPlaybackSessionManager_h
+
+#if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
+
+#include &quot;MessageReceiver.h&quot;
+#include &lt;WebCore/EventListener.h&gt;
+#include &lt;WebCore/HTMLMediaElementEnums.h&gt;
+#include &lt;WebCore/PlatformCALayer.h&gt;
+#include &lt;WebCore/WebPlaybackSessionInterface.h&gt;
+#include &lt;WebCore/WebPlaybackSessionModelMediaElement.h&gt;
+#include &lt;wtf/HashMap.h&gt;
+#include &lt;wtf/RefCounted.h&gt;
+#include &lt;wtf/RefPtr.h&gt;
+
+namespace IPC {
+class Attachment;
+class Connection;
+class MessageDecoder;
+class MessageReceiver;
+}
+
+namespace WebCore {
+class Node;
+}
+
+namespace WebKit {
+
+class WebPage;
+class WebPlaybackSessionManager;
+
+class WebPlaybackSessionInterfaceContext final : public RefCounted&lt;WebPlaybackSessionInterfaceContext&gt;, public WebCore::WebPlaybackSessionInterface {
+public:
+    static Ref&lt;WebPlaybackSessionInterfaceContext&gt; create(WebPlaybackSessionManager&amp; manager, uint64_t contextId)
+    {
+        return adoptRef(*new WebPlaybackSessionInterfaceContext(manager, contextId));
+    }
+    virtual ~WebPlaybackSessionInterfaceContext();
+
+    void invalidate() { m_manager = nullptr; }
+
+private:
+    friend class WebVideoFullscreenInterfaceContext;
+
+    // WebPlaybackSessionInterface
+    void resetMediaState() final;
+    void setDuration(double) final;
+    void setCurrentTime(double currentTime, double anchorTime) final;
+    void setBufferedTime(double) final;
+    void setRate(bool isPlaying, float playbackRate) final;
+    void setSeekableRanges(const WebCore::TimeRanges&amp;) final;
+    void setCanPlayFastReverse(bool value) final;
+    void setAudioMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex) final;
+    void setLegibleMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex) final;
+    void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, WTF::String localizedDeviceName) final;
+    void setWirelessVideoPlaybackDisabled(bool) final;
+
+    WebPlaybackSessionInterfaceContext(WebPlaybackSessionManager&amp;, uint64_t contextId);
+
+    WebPlaybackSessionManager* m_manager;
+    uint64_t m_contextId;
+};
+
+class WebPlaybackSessionManager : public RefCounted&lt;WebPlaybackSessionManager&gt;, private IPC::MessageReceiver {
+public:
+    static Ref&lt;WebPlaybackSessionManager&gt; create(WebPage&amp;);
+    virtual ~WebPlaybackSessionManager();
+
+    void didReceiveMessage(IPC::Connection&amp;, IPC::MessageDecoder&amp;) final;
+
+    void setUpPlaybackControlsManager(WebCore::HTMLMediaElement&amp;);
+    void clearPlaybackControlsManager(WebCore::HTMLMediaElement&amp;);
+    uint64_t contextIdForMediaElement(WebCore::HTMLMediaElement&amp;);
+
+protected:
+    friend class WebPlaybackSessionInterfaceContext;
+    friend class WebVideoFullscreenManager;
+
+    explicit WebPlaybackSessionManager(WebPage&amp;);
+
+    typedef std::tuple&lt;RefPtr&lt;WebCore::WebPlaybackSessionModelMediaElement&gt;, RefPtr&lt;WebPlaybackSessionInterfaceContext&gt;&gt; ModelInterfaceTuple;
+    ModelInterfaceTuple createModelAndInterface(uint64_t contextId);
+    ModelInterfaceTuple&amp; ensureModelAndInterface(uint64_t contextId);
+    WebCore::WebPlaybackSessionModelMediaElement&amp; ensureModel(uint64_t contextId);
+    WebPlaybackSessionInterfaceContext&amp; ensureInterface(uint64_t contextId);
+    void removeContext(uint64_t contextId);
+    void addClientForContext(uint64_t contextId);
+    void removeClientForContext(uint64_t contextId);
+
+    // Interface to WebPlaybackSessionInterfaceContext
+    void resetMediaState(uint64_t contextId);
+    void setDuration(uint64_t contextId, double);
+    void setCurrentTime(uint64_t contextId, double currentTime, double anchorTime);
+    void setBufferedTime(uint64_t contextId, double bufferedTime);
+    void setRate(uint64_t contextId, bool isPlaying, float playbackRate);
+    void setSeekableRanges(uint64_t contextId, const WebCore::TimeRanges&amp;);
+    void setCanPlayFastReverse(uint64_t contextId, bool value);
+    void setAudioMediaSelectionOptions(uint64_t contextId, const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex);
+    void setLegibleMediaSelectionOptions(uint64_t contextId, const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex);
+    void setExternalPlayback(uint64_t contextId, bool enabled, WebCore::WebPlaybackSessionInterface::ExternalPlaybackTargetType, String localizedDeviceName);
+    void setWirelessVideoPlaybackDisabled(uint64_t contextId, bool);
+
+    // Messages from WebPlaybackSessionManagerProxy
+    void play(uint64_t contextId);
+    void pause(uint64_t contextId);
+    void togglePlayState(uint64_t contextId);
+    void beginScrubbing(uint64_t contextId);
+    void endScrubbing(uint64_t contextId);
+    void seekToTime(uint64_t contextId, double time);
+    void fastSeek(uint64_t contextId, double time);
+    void beginScanningForward(uint64_t contextId);
+    void beginScanningBackward(uint64_t contextId);
+    void endScanning(uint64_t contextId);
+    void selectAudioMediaOption(uint64_t contextId, uint64_t index);
+    void selectLegibleMediaOption(uint64_t contextId, uint64_t index);
+
+    WebPage* m_page;
+    HashMap&lt;WebCore::HTMLMediaElement*, uint64_t&gt; m_mediaElements;
+    HashMap&lt;uint64_t, ModelInterfaceTuple&gt; m_contextMap;
+    uint64_t m_controlsManagerContextId { 0 };
+    HashMap&lt;uint64_t, int&gt; m_clientCounts;
+};
+
+} // namespace WebKit
+
+#endif // PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
+
+#endif // WebPlaybackSessionManager_h
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcesscocoaWebPlaybackSessionManagermessagesin"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.messages.in (0 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.messages.in                                (rev 0)
+++ trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.messages.in        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -0,0 +1,39 @@
</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.
+
+#if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
+messages -&gt; WebPlaybackSessionManager {
+    Play(uint64_t contextId)
+    Pause(uint64_t contextId)
+    TogglePlayState(uint64_t contextId)
+    BeginScrubbing(uint64_t contextId)
+    EndScrubbing(uint64_t contextId)
+    SeekToTime(uint64_t contextId, double time)
+    FastSeek(uint64_t contextId, double time)
+    BeginScanningForward(uint64_t contextId)
+    BeginScanningBackward(uint64_t contextId)
+    EndScanning(uint64_t contextId)
+    SelectAudioMediaOption(uint64_t contextId, uint64_t index)
+    SelectLegibleMediaOption(uint64_t contextId, uint64_t index)
+}
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcesscocoaWebPlaybackSessionManagermm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.mm (0 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.mm                                (rev 0)
+++ trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.mm        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -0,0 +1,408 @@
</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 &quot;config.h&quot;
+#include &quot;WebPlaybackSessionManager.h&quot;
+
+
+#if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
+
+#import &quot;Attachment.h&quot;
+#import &quot;WebCoreArgumentCoders.h&quot;
+#import &quot;WebPage.h&quot;
+#import &quot;WebPlaybackSessionManagerMessages.h&quot;
+#import &quot;WebPlaybackSessionManagerProxyMessages.h&quot;
+#import &quot;WebProcess.h&quot;
+#import &lt;WebCore/Color.h&gt;
+#import &lt;WebCore/Event.h&gt;
+#import &lt;WebCore/EventNames.h&gt;
+#import &lt;WebCore/HTMLMediaElement.h&gt;
+#import &lt;WebCore/Settings.h&gt;
+#import &lt;WebCore/TimeRanges.h&gt;
+#import &lt;mach/mach_port.h&gt;
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static uint64_t nextContextId()
+{
+    static uint64_t contextId = 0;
+    return ++contextId;
+}
+
+#pragma mark - WebPlaybackSessionInterfaceContext
+
+WebPlaybackSessionInterfaceContext::WebPlaybackSessionInterfaceContext(WebPlaybackSessionManager&amp; manager, uint64_t contextId)
+    : m_manager(&amp;manager)
+    , m_contextId(contextId)
+{
+}
+
+WebPlaybackSessionInterfaceContext::~WebPlaybackSessionInterfaceContext()
+{
+}
+
+void WebPlaybackSessionInterfaceContext::resetMediaState()
+{
+    if (m_manager)
+        m_manager-&gt;resetMediaState(m_contextId);
+}
+
+void WebPlaybackSessionInterfaceContext::setDuration(double duration)
+{
+    if (m_manager)
+        m_manager-&gt;setDuration(m_contextId, duration);
+}
+
+void WebPlaybackSessionInterfaceContext::setCurrentTime(double currentTime, double anchorTime)
+{
+    if (m_manager)
+        m_manager-&gt;setCurrentTime(m_contextId, currentTime, anchorTime);
+}
+
+void WebPlaybackSessionInterfaceContext::setBufferedTime(double bufferedTime)
+{
+    if (m_manager)
+        m_manager-&gt;setBufferedTime(m_contextId, bufferedTime);
+}
+
+void WebPlaybackSessionInterfaceContext::setRate(bool isPlaying, float playbackRate)
+{
+    if (m_manager)
+        m_manager-&gt;setRate(m_contextId, isPlaying, playbackRate);
+}
+
+void WebPlaybackSessionInterfaceContext::setSeekableRanges(const WebCore::TimeRanges&amp; ranges)
+{
+    if (m_manager)
+        m_manager-&gt;setSeekableRanges(m_contextId, ranges);
+}
+
+void WebPlaybackSessionInterfaceContext::setCanPlayFastReverse(bool value)
+{
+    if (m_manager)
+        m_manager-&gt;setCanPlayFastReverse(m_contextId, value);
+}
+
+void WebPlaybackSessionInterfaceContext::setAudioMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex)
+{
+    if (m_manager)
+        m_manager-&gt;setAudioMediaSelectionOptions(m_contextId, options, selectedIndex);
+}
+
+void WebPlaybackSessionInterfaceContext::setLegibleMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex)
+{
+    if (m_manager)
+        m_manager-&gt;setLegibleMediaSelectionOptions(m_contextId, options, selectedIndex);
+}
+
+void WebPlaybackSessionInterfaceContext::setExternalPlayback(bool enabled, ExternalPlaybackTargetType type, WTF::String localizedDeviceName)
+{
+    if (m_manager)
+        m_manager-&gt;setExternalPlayback(m_contextId, enabled, type, localizedDeviceName);
+}
+
+void WebPlaybackSessionInterfaceContext::setWirelessVideoPlaybackDisabled(bool disabled)
+{
+    if (m_manager)
+        m_manager-&gt;setWirelessVideoPlaybackDisabled(m_contextId, disabled);
+}
+
+#pragma mark - WebPlaybackSessionManager
+
+Ref&lt;WebPlaybackSessionManager&gt; WebPlaybackSessionManager::create(WebPage&amp; page)
+{
+    return adoptRef(*new WebPlaybackSessionManager(page));
+}
+
+WebPlaybackSessionManager::WebPlaybackSessionManager(WebPage&amp; page)
+    : m_page(&amp;page)
+{
+    WebProcess::singleton().addMessageReceiver(Messages::WebPlaybackSessionManager::messageReceiverName(), page.pageID(), *this);
+}
+
+WebPlaybackSessionManager::~WebPlaybackSessionManager()
+{
+    for (auto&amp; tuple : m_contextMap.values()) {
+        RefPtr&lt;WebPlaybackSessionModelMediaElement&gt; model;
+        RefPtr&lt;WebPlaybackSessionInterfaceContext&gt; interface;
+        std::tie(model, interface) = tuple;
+
+        model-&gt;setWebPlaybackSessionInterface(nullptr);
+        model-&gt;setMediaElement(nullptr);
+
+        interface-&gt;invalidate();
+    }
+
+    m_contextMap.clear();
+    m_mediaElements.clear();
+    m_clientCounts.clear();
+
+    WebProcess::singleton().removeMessageReceiver(Messages::WebPlaybackSessionManager::messageReceiverName(), m_page-&gt;pageID());
+}
+
+WebPlaybackSessionManager::ModelInterfaceTuple WebPlaybackSessionManager::createModelAndInterface(uint64_t contextId)
+{
+    RefPtr&lt;WebPlaybackSessionModelMediaElement&gt; model = WebPlaybackSessionModelMediaElement::create();
+    RefPtr&lt;WebPlaybackSessionInterfaceContext&gt; interface = WebPlaybackSessionInterfaceContext::create(*this, contextId);
+
+    model-&gt;setWebPlaybackSessionInterface(interface.get());
+
+    return std::make_tuple(WTFMove(model), WTFMove(interface));
+}
+
+WebPlaybackSessionManager::ModelInterfaceTuple&amp; WebPlaybackSessionManager::ensureModelAndInterface(uint64_t contextId)
+{
+    auto addResult = m_contextMap.add(contextId, ModelInterfaceTuple());
+    if (addResult.isNewEntry)
+        addResult.iterator-&gt;value = createModelAndInterface(contextId);
+    return addResult.iterator-&gt;value;
+}
+
+WebCore::WebPlaybackSessionModelMediaElement&amp; WebPlaybackSessionManager::ensureModel(uint64_t contextId)
+{
+    return *std::get&lt;0&gt;(ensureModelAndInterface(contextId));
+}
+
+WebPlaybackSessionInterfaceContext&amp; WebPlaybackSessionManager::ensureInterface(uint64_t contextId)
+{
+    return *std::get&lt;1&gt;(ensureModelAndInterface(contextId));
+}
+
+void WebPlaybackSessionManager::removeContext(uint64_t contextId)
+{
+    RefPtr&lt;WebPlaybackSessionModelMediaElement&gt; model;
+    RefPtr&lt;WebPlaybackSessionInterfaceContext&gt; interface;
+    std::tie(model, interface) = ensureModelAndInterface(contextId);
+
+    RefPtr&lt;HTMLMediaElement&gt; mediaElement = model-&gt;mediaElement();
+    model-&gt;setMediaElement(nullptr);
+    model-&gt;setWebPlaybackSessionInterface(nullptr);
+    interface-&gt;invalidate();
+    m_mediaElements.remove(mediaElement.get());
+    m_contextMap.remove(contextId);
+}
+
+void WebPlaybackSessionManager::addClientForContext(uint64_t contextId)
+{
+    auto addResult = m_clientCounts.add(contextId, 1);
+    if (!addResult.isNewEntry)
+        addResult.iterator-&gt;value++;
+}
+
+void WebPlaybackSessionManager::removeClientForContext(uint64_t contextId)
+{
+    ASSERT(m_clientCounts.contains(contextId));
+
+    int clientCount = m_clientCounts.get(contextId);
+    ASSERT(clientCount &gt; 0);
+    clientCount--;
+
+    if (clientCount &lt;= 0) {
+        m_clientCounts.remove(contextId);
+        removeContext(contextId);
+        return;
+    }
+
+    m_clientCounts.set(contextId, clientCount);
+}
+
+void WebPlaybackSessionManager::setUpPlaybackControlsManager(WebCore::HTMLMediaElement&amp; mediaElement)
+{
+#if PLATFORM(MAC)
+    if (m_mediaElements.contains(&amp;mediaElement)) {
+        uint64_t contextId = m_mediaElements.get(&amp;mediaElement);
+        if (m_controlsManagerContextId == contextId)
+            return;
+
+        if (m_controlsManagerContextId)
+            removeClientForContext(m_controlsManagerContextId);
+        m_controlsManagerContextId = contextId;
+    } else {
+        auto addResult = m_mediaElements.ensure(&amp;mediaElement, [&amp;] { return nextContextId(); });
+        auto contextId = addResult.iterator-&gt;value;
+        m_controlsManagerContextId = contextId;
+        ensureModel(contextId).setMediaElement(&amp;mediaElement);
+    }
+
+    addClientForContext(m_controlsManagerContextId);
+    m_page-&gt;send(Messages::WebPlaybackSessionManagerProxy::SetUpPlaybackControlsManagerWithID(m_controlsManagerContextId), m_page-&gt;pageID());
+#endif
+}
+
+void WebPlaybackSessionManager::clearPlaybackControlsManager(WebCore::HTMLMediaElement&amp; mediaElement)
+{
+#if PLATFORM(MAC)
+    if (m_mediaElements.contains(&amp;mediaElement))
+        return;
+
+    uint64_t contextId = m_mediaElements.get(&amp;mediaElement);
+    if (m_controlsManagerContextId != contextId)
+        return;
+
+    removeClientForContext(m_controlsManagerContextId);
+    m_controlsManagerContextId = 0;
+    m_page-&gt;send(Messages::WebPlaybackSessionManagerProxy::ClearPlaybackControlsManager(), m_page-&gt;pageID());
+#endif
+}
+
+uint64_t WebPlaybackSessionManager::contextIdForMediaElement(WebCore::HTMLMediaElement&amp; mediaElement)
+{
+    auto addResult = m_mediaElements.ensure(&amp;mediaElement, [&amp;] { return nextContextId(); });
+    return addResult.iterator-&gt;value;
+}
+
+#pragma mark Interface to WebPlaybackSessionInterfaceContext:
+
+void WebPlaybackSessionManager::resetMediaState(uint64_t contextId)
+{
+    m_page-&gt;send(Messages::WebPlaybackSessionManagerProxy::ResetMediaState(contextId), m_page-&gt;pageID());
+}
+
+void WebPlaybackSessionManager::setDuration(uint64_t contextId, double duration)
+{
+    m_page-&gt;send(Messages::WebPlaybackSessionManagerProxy::SetDuration(contextId, duration), m_page-&gt;pageID());
+}
+
+void WebPlaybackSessionManager::setCurrentTime(uint64_t contextId, double currentTime, double anchorTime)
+{
+    m_page-&gt;send(Messages::WebPlaybackSessionManagerProxy::SetCurrentTime(contextId, currentTime, anchorTime), m_page-&gt;pageID());
+}
+
+void WebPlaybackSessionManager::setBufferedTime(uint64_t contextId, double bufferedTime)
+{
+    m_page-&gt;send(Messages::WebPlaybackSessionManagerProxy::SetBufferedTime(contextId, bufferedTime), m_page-&gt;pageID());
+}
+
+void WebPlaybackSessionManager::setRate(uint64_t contextId, bool isPlaying, float playbackRate)
+{
+    m_page-&gt;send(Messages::WebPlaybackSessionManagerProxy::SetRate(contextId, isPlaying, playbackRate), m_page-&gt;pageID());
+}
+
+void WebPlaybackSessionManager::setSeekableRanges(uint64_t contextId, const WebCore::TimeRanges&amp; timeRanges)
+{
+    Vector&lt;std::pair&lt;double, double&gt;&gt; rangesVector;
+
+    for (unsigned i = 0; i &lt; timeRanges.length(); i++) {
+        ExceptionCode exceptionCode;
+        double start = timeRanges.start(i, exceptionCode);
+        double end = timeRanges.end(i, exceptionCode);
+        rangesVector.append(std::pair&lt;double, double&gt;(start, end));
+    }
+
+    m_page-&gt;send(Messages::WebPlaybackSessionManagerProxy::SetSeekableRangesVector(contextId, WTFMove(rangesVector)), m_page-&gt;pageID());
+}
+
+void WebPlaybackSessionManager::setCanPlayFastReverse(uint64_t contextId, bool value)
+{
+    m_page-&gt;send(Messages::WebPlaybackSessionManagerProxy::SetCanPlayFastReverse(contextId, value), m_page-&gt;pageID());
+}
+
+void WebPlaybackSessionManager::setAudioMediaSelectionOptions(uint64_t contextId, const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex)
+{
+    m_page-&gt;send(Messages::WebPlaybackSessionManagerProxy::SetAudioMediaSelectionOptions(contextId, options, selectedIndex), m_page-&gt;pageID());
+}
+
+void WebPlaybackSessionManager::setLegibleMediaSelectionOptions(uint64_t contextId, const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex)
+{
+    m_page-&gt;send(Messages::WebPlaybackSessionManagerProxy::SetLegibleMediaSelectionOptions(contextId, options, selectedIndex), m_page-&gt;pageID());
+}
+
+void WebPlaybackSessionManager::setExternalPlayback(uint64_t contextId, bool enabled, WebPlaybackSessionInterface::ExternalPlaybackTargetType targetType, String localizedDeviceName)
+{
+    m_page-&gt;send(Messages::WebPlaybackSessionManagerProxy::SetExternalPlaybackProperties(contextId, enabled, static_cast&lt;uint32_t&gt;(targetType), localizedDeviceName), m_page-&gt;pageID());
+}
+
+void WebPlaybackSessionManager::setWirelessVideoPlaybackDisabled(uint64_t contextId, bool disabled)
+{
+    m_page-&gt;send(Messages::WebPlaybackSessionManagerProxy::SetWirelessVideoPlaybackDisabled(contextId, disabled));
+}
+
+#pragma mark Messages from WebPlaybackSessionManagerProxy:
+
+void WebPlaybackSessionManager::play(uint64_t contextId)
+{
+    ensureModel(contextId).play();
+}
+
+void WebPlaybackSessionManager::pause(uint64_t contextId)
+{
+    ensureModel(contextId).pause();
+}
+
+void WebPlaybackSessionManager::togglePlayState(uint64_t contextId)
+{
+    ensureModel(contextId).togglePlayState();
+}
+
+void WebPlaybackSessionManager::beginScrubbing(uint64_t contextId)
+{
+    ensureModel(contextId).beginScrubbing();
+}
+
+void WebPlaybackSessionManager::endScrubbing(uint64_t contextId)
+{
+    ensureModel(contextId).endScrubbing();
+}
+
+void WebPlaybackSessionManager::seekToTime(uint64_t contextId, double time)
+{
+    ensureModel(contextId).seekToTime(time);
+}
+
+void WebPlaybackSessionManager::fastSeek(uint64_t contextId, double time)
+{
+    ensureModel(contextId).fastSeek(time);
+}
+
+void WebPlaybackSessionManager::beginScanningForward(uint64_t contextId)
+{
+    ensureModel(contextId).beginScanningForward();
+}
+
+void WebPlaybackSessionManager::beginScanningBackward(uint64_t contextId)
+{
+    ensureModel(contextId).beginScanningBackward();
+}
+
+void WebPlaybackSessionManager::endScanning(uint64_t contextId)
+{
+    ensureModel(contextId).endScanning();
+}
+
+void WebPlaybackSessionManager::selectAudioMediaOption(uint64_t contextId, uint64_t index)
+{
+    ensureModel(contextId).selectAudioMediaOption(index);
+}
+
+void WebPlaybackSessionManager::selectLegibleMediaOption(uint64_t contextId, uint64_t index)
+{
+    ensureModel(contextId).selectLegibleMediaOption(index);
+}
+
+} // namespace WebKit
+
+#endif // PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcesscocoaWebVideoFullscreenManagerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.h (199592 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.h        2016-04-15 17:18:12 UTC (rev 199592)
+++ trunk/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.h        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -52,13 +52,15 @@
</span><span class="cx"> 
</span><span class="cx"> class LayerHostingContext;
</span><span class="cx"> class WebPage;
</span><ins>+class WebPlaybackSessionInterfaceContext;
+class WebPlaybackSessionManager;
</ins><span class="cx"> class WebVideoFullscreenManager;
</span><span class="cx"> 
</span><span class="cx"> class WebVideoFullscreenInterfaceContext : public RefCounted&lt;WebVideoFullscreenInterfaceContext&gt;, public WebCore::WebVideoFullscreenInterface {
</span><span class="cx"> public:
</span><del>-    static Ref&lt;WebVideoFullscreenInterfaceContext&gt; create(WebVideoFullscreenManager&amp; manager, uint64_t contextId)
</del><ins>+    static Ref&lt;WebVideoFullscreenInterfaceContext&gt; create(WebVideoFullscreenManager&amp; manager, WebPlaybackSessionInterfaceContext&amp; playbackSessionInterface, uint64_t contextId)
</ins><span class="cx">     {
</span><del>-        return adoptRef(*new WebVideoFullscreenInterfaceContext(manager, contextId));
</del><ins>+        return adoptRef(*new WebVideoFullscreenInterfaceContext(manager, playbackSessionInterface, contextId));
</ins><span class="cx">     }
</span><span class="cx">     virtual ~WebVideoFullscreenInterfaceContext();
</span><span class="cx"> 
</span><span class="lines">@@ -80,13 +82,12 @@
</span><span class="cx">     void setIsFullscreen(bool flag) { m_isFullscreen = flag; }
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    // WebVideoFullscreenInterface
</del><ins>+    // WebPlaybackSessionInterface
</ins><span class="cx">     void resetMediaState() override;
</span><span class="cx">     void setDuration(double) override;
</span><span class="cx">     void setCurrentTime(double currentTime, double anchorTime) override;
</span><span class="cx">     void setBufferedTime(double) override;
</span><span class="cx">     void setRate(bool isPlaying, float playbackRate) override;
</span><del>-    void setVideoDimensions(bool hasVideo, float width, float height) override;
</del><span class="cx">     void setSeekableRanges(const WebCore::TimeRanges&amp;) override;
</span><span class="cx">     void setCanPlayFastReverse(bool value) override;
</span><span class="cx">     void setAudioMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex) override;
</span><span class="lines">@@ -94,9 +95,13 @@
</span><span class="cx">     void setExternalPlayback(bool enabled, ExternalPlaybackTargetType, WTF::String localizedDeviceName) override;
</span><span class="cx">     void setWirelessVideoPlaybackDisabled(bool) override;
</span><span class="cx"> 
</span><del>-    WebVideoFullscreenInterfaceContext(WebVideoFullscreenManager&amp;, uint64_t contextId);
</del><ins>+    // WebVideoFullscreenInterface
+    void setVideoDimensions(bool hasVideo, float width, float height) override;
</ins><span class="cx"> 
</span><ins>+    WebVideoFullscreenInterfaceContext(WebVideoFullscreenManager&amp;, WebPlaybackSessionInterfaceContext&amp;, uint64_t contextId);
+
</ins><span class="cx">     WebVideoFullscreenManager* m_manager;
</span><ins>+    Ref&lt;WebPlaybackSessionInterfaceContext&gt; m_playbackSessionInterface;
</ins><span class="cx">     uint64_t m_contextId;
</span><span class="cx">     std::unique_ptr&lt;LayerHostingContext&gt; m_layerHostingContext;
</span><span class="cx">     bool m_isAnimating { false };
</span><span class="lines">@@ -107,7 +112,7 @@
</span><span class="cx"> 
</span><span class="cx"> class WebVideoFullscreenManager : public RefCounted&lt;WebVideoFullscreenManager&gt;, private IPC::MessageReceiver {
</span><span class="cx"> public:
</span><del>-    static Ref&lt;WebVideoFullscreenManager&gt; create(PassRefPtr&lt;WebPage&gt;);
</del><ins>+    static Ref&lt;WebVideoFullscreenManager&gt; create(WebPage&amp;, WebPlaybackSessionManager&amp;);
</ins><span class="cx">     virtual ~WebVideoFullscreenManager();
</span><span class="cx">     
</span><span class="cx">     void didReceiveMessage(IPC::Connection&amp;, IPC::MessageDecoder&amp;) override;
</span><span class="lines">@@ -117,13 +122,11 @@
</span><span class="cx">     void enterVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&amp;, WebCore::HTMLMediaElementEnums::VideoFullscreenMode);
</span><span class="cx">     void exitVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&amp;);
</span><span class="cx">     void exitVideoFullscreenToModeWithoutAnimation(WebCore::HTMLVideoElement&amp;, WebCore::HTMLMediaElementEnums::VideoFullscreenMode);
</span><del>-    void setUpVideoControlsManager(WebCore::HTMLVideoElement&amp;);
-    void clearVideoControlsManager();
-    
</del><ins>+
</ins><span class="cx"> protected:
</span><span class="cx">     friend class WebVideoFullscreenInterfaceContext;
</span><span class="cx"> 
</span><del>-    explicit WebVideoFullscreenManager(PassRefPtr&lt;WebPage&gt;);
</del><ins>+    explicit WebVideoFullscreenManager(WebPage&amp;, WebPlaybackSessionManager&amp;);
</ins><span class="cx"> 
</span><span class="cx">     typedef std::tuple&lt;RefPtr&lt;WebCore::WebVideoFullscreenModelVideoElement&gt;, RefPtr&lt;WebVideoFullscreenInterfaceContext&gt;&gt; ModelInterfaceTuple;
</span><span class="cx">     ModelInterfaceTuple createModelAndInterface(uint64_t contextId);
</span><span class="lines">@@ -135,30 +138,9 @@
</span><span class="cx">     void removeClientForContext(uint64_t contextId);
</span><span class="cx"> 
</span><span class="cx">     // Interface to WebVideoFullscreenInterfaceContext
</span><del>-    void resetMediaState(uint64_t contextId);
-    void setDuration(uint64_t contextId, double);
-    void setCurrentTime(uint64_t contextId, double currentTime, double anchorTime);
-    void setBufferedTime(uint64_t contextId, double bufferedTime);
-    void setRate(uint64_t contextId, bool isPlaying, float playbackRate);
</del><span class="cx">     void setVideoDimensions(uint64_t contextId, bool hasVideo, float width, float height);
</span><del>-    void setSeekableRanges(uint64_t contextId, const WebCore::TimeRanges&amp;);
-    void setCanPlayFastReverse(uint64_t contextId, bool value);
-    void setAudioMediaSelectionOptions(uint64_t contextId, const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex);
-    void setLegibleMediaSelectionOptions(uint64_t contextId, const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex);
-    void setExternalPlayback(uint64_t contextId, bool enabled, WebCore::WebVideoFullscreenInterface::ExternalPlaybackTargetType, String localizedDeviceName);
-    void setWirelessVideoPlaybackDisabled(uint64_t contextId, bool);
</del><span class="cx"> 
</span><span class="cx">     // Messages from WebVideoFullscreenManagerProxy
</span><del>-    void play(uint64_t contextId);
-    void pause(uint64_t contextId);
-    void togglePlayState(uint64_t contextId);
-    void beginScrubbing(uint64_t contextId);
-    void endScrubbing(uint64_t contextId);
-    void seekToTime(uint64_t contextId, double time);
-    void fastSeek(uint64_t contextId, double time);
-    void beginScanningForward(uint64_t contextId);
-    void beginScanningBackward(uint64_t contextId);
-    void endScanning(uint64_t contextId);
</del><span class="cx">     void requestFullscreenMode(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode);
</span><span class="cx">     void didSetupFullscreen(uint64_t contextId);
</span><span class="cx">     void didExitFullscreen(uint64_t contextId);
</span><span class="lines">@@ -166,12 +148,11 @@
</span><span class="cx">     void didCleanupFullscreen(uint64_t contextId);
</span><span class="cx">     void setVideoLayerFrameFenced(uint64_t contextId, WebCore::FloatRect bounds, IPC::Attachment fencePort);
</span><span class="cx">     void setVideoLayerGravityEnum(uint64_t contextId, unsigned gravity);
</span><del>-    void selectAudioMediaOption(uint64_t contextId, uint64_t index);
-    void selectLegibleMediaOption(uint64_t contextId, uint64_t index);
</del><span class="cx">     void fullscreenModeChanged(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode);
</span><span class="cx">     void fullscreenMayReturnToInline(uint64_t contextId, bool isPageVisible);
</span><span class="cx">     
</span><span class="cx">     WebPage* m_page;
</span><ins>+    Ref&lt;WebPlaybackSessionManager&gt; m_playbackSessionManager;
</ins><span class="cx">     HashMap&lt;WebCore::HTMLVideoElement*, uint64_t&gt; m_videoElements;
</span><span class="cx">     HashMap&lt;uint64_t, ModelInterfaceTuple&gt; m_contextMap;
</span><span class="cx">     uint64_t m_controlsManagerContextId { 0 };
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcesscocoaWebVideoFullscreenManagermessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.messages.in (199592 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.messages.in        2016-04-15 17:18:12 UTC (rev 199592)
+++ trunk/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.messages.in        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -22,16 +22,6 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS) || (PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE))
</span><span class="cx"> messages -&gt; WebVideoFullscreenManager {
</span><del>-    Play(uint64_t contextId)
-    Pause(uint64_t contextId)
-    TogglePlayState(uint64_t contextId)
-    BeginScrubbing(uint64_t contextId)
-    EndScrubbing(uint64_t contextId)
-    SeekToTime(uint64_t contextId, double time)
-    FastSeek(uint64_t contextId, double time)
-    BeginScanningForward(uint64_t contextId)
-    BeginScanningBackward(uint64_t contextId)
-    EndScanning(uint64_t contextId)
</del><span class="cx">     RequestFullscreenMode(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode)
</span><span class="cx">     DidSetupFullscreen(uint64_t contextId)
</span><span class="cx">     DidExitFullscreen(uint64_t contextId)
</span><span class="lines">@@ -39,8 +29,6 @@
</span><span class="cx">     DidCleanupFullscreen(uint64_t contextId)
</span><span class="cx">     SetVideoLayerFrameFenced(uint64_t contextId, WebCore::FloatRect bounds, IPC::Attachment fencePort)
</span><span class="cx">     SetVideoLayerGravityEnum(uint64_t contextId, unsigned gravity)
</span><del>-    SelectAudioMediaOption(uint64_t contextId, uint64_t index)
-    SelectLegibleMediaOption(uint64_t contextId, uint64_t index)
</del><span class="cx">     FullscreenModeChanged(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode)
</span><span class="cx">     FullscreenMayReturnToInline(uint64_t contextId, bool isPageVisible)
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcesscocoaWebVideoFullscreenManagermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.mm (199592 => 199593)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.mm        2016-04-15 17:18:12 UTC (rev 199592)
+++ trunk/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.mm        2016-04-15 17:50:26 UTC (rev 199593)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> #import &quot;Attachment.h&quot;
</span><span class="cx"> #import &quot;WebCoreArgumentCoders.h&quot;
</span><span class="cx"> #import &quot;WebPage.h&quot;
</span><ins>+#import &quot;WebPlaybackSessionManager.h&quot;
</ins><span class="cx"> #import &quot;WebProcess.h&quot;
</span><span class="cx"> #import &quot;WebVideoFullscreenManagerMessages.h&quot;
</span><span class="cx"> #import &quot;WebVideoFullscreenManagerProxyMessages.h&quot;
</span><span class="lines">@@ -59,16 +60,11 @@
</span><span class="cx">     return element-&gt;clientRect();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static uint64_t nextContextId()
-{
-    static uint64_t contextId = 0;
-    return ++contextId;
-}
-
</del><span class="cx"> #pragma mark - WebVideoFullscreenInterfaceContext
</span><span class="cx"> 
</span><del>-WebVideoFullscreenInterfaceContext::WebVideoFullscreenInterfaceContext(WebVideoFullscreenManager&amp; manager, uint64_t contextId)
</del><ins>+WebVideoFullscreenInterfaceContext::WebVideoFullscreenInterfaceContext(WebVideoFullscreenManager&amp; manager, WebPlaybackSessionInterfaceContext&amp; playbackSessionInterface, uint64_t contextId)
</ins><span class="cx">     : m_manager(&amp;manager)
</span><ins>+    , m_playbackSessionInterface(playbackSessionInterface)
</ins><span class="cx">     , m_contextId(contextId)
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="lines">@@ -84,32 +80,27 @@
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceContext::resetMediaState()
</span><span class="cx"> {
</span><del>-    if (m_manager)
-        m_manager-&gt;resetMediaState(m_contextId);
</del><ins>+    m_playbackSessionInterface-&gt;resetMediaState();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceContext::setDuration(double duration)
</span><span class="cx"> {
</span><del>-    if (m_manager)
-        m_manager-&gt;setDuration(m_contextId, duration);
</del><ins>+    m_playbackSessionInterface-&gt;setDuration(duration);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceContext::setCurrentTime(double currentTime, double anchorTime)
</span><span class="cx"> {
</span><del>-    if (m_manager)
-        m_manager-&gt;setCurrentTime(m_contextId, currentTime, anchorTime);
</del><ins>+    m_playbackSessionInterface-&gt;setCurrentTime(currentTime, anchorTime);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceContext::setBufferedTime(double bufferedTime)
</span><span class="cx"> {
</span><del>-    if (m_manager)
-        m_manager-&gt;setBufferedTime(m_contextId, bufferedTime);
</del><ins>+    m_playbackSessionInterface-&gt;setBufferedTime(bufferedTime);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceContext::setRate(bool isPlaying, float playbackRate)
</span><span class="cx"> {
</span><del>-    if (m_manager)
-        m_manager-&gt;setRate(m_contextId, isPlaying, playbackRate);
</del><ins>+    m_playbackSessionInterface-&gt;setRate(isPlaying, playbackRate);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceContext::setVideoDimensions(bool hasVideo, float width, float height)
</span><span class="lines">@@ -120,51 +111,46 @@
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceContext::setSeekableRanges(const WebCore::TimeRanges&amp; ranges)
</span><span class="cx"> {
</span><del>-    if (m_manager)
-        m_manager-&gt;setSeekableRanges(m_contextId, ranges);
</del><ins>+    m_playbackSessionInterface-&gt;setSeekableRanges(ranges);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceContext::setCanPlayFastReverse(bool value)
</span><span class="cx"> {
</span><del>-    if (m_manager)
-        m_manager-&gt;setCanPlayFastReverse(m_contextId, value);
</del><ins>+    m_playbackSessionInterface-&gt;setCanPlayFastReverse(value);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceContext::setAudioMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex)
</span><span class="cx"> {
</span><del>-    if (m_manager)
-        m_manager-&gt;setAudioMediaSelectionOptions(m_contextId, options, selectedIndex);
</del><ins>+    m_playbackSessionInterface-&gt;setAudioMediaSelectionOptions(options, selectedIndex);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceContext::setLegibleMediaSelectionOptions(const Vector&lt;WTF::String&gt;&amp; options, uint64_t selectedIndex)
</span><span class="cx"> {
</span><del>-    if (m_manager)
-        m_manager-&gt;setLegibleMediaSelectionOptions(m_contextId, options, selectedIndex);
</del><ins>+    m_playbackSessionInterface-&gt;setLegibleMediaSelectionOptions(options, selectedIndex);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceContext::setExternalPlayback(bool enabled, ExternalPlaybackTargetType type, WTF::String localizedDeviceName)
</span><span class="cx"> {
</span><del>-    if (m_manager)
-        m_manager-&gt;setExternalPlayback(m_contextId, enabled, type, localizedDeviceName);
</del><ins>+    m_playbackSessionInterface-&gt;setExternalPlayback(enabled, type, localizedDeviceName);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenInterfaceContext::setWirelessVideoPlaybackDisabled(bool disabled)
</span><span class="cx"> {
</span><del>-    if (m_manager)
-        m_manager-&gt;setWirelessVideoPlaybackDisabled(m_contextId, disabled);
</del><ins>+    m_playbackSessionInterface-&gt;setWirelessVideoPlaybackDisabled(disabled);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #pragma mark - WebVideoFullscreenManager
</span><span class="cx"> 
</span><del>-Ref&lt;WebVideoFullscreenManager&gt; WebVideoFullscreenManager::create(PassRefPtr&lt;WebPage&gt; page)
</del><ins>+Ref&lt;WebVideoFullscreenManager&gt; WebVideoFullscreenManager::create(WebPage&amp; page, WebPlaybackSessionManager&amp; playbackSessionManager)
</ins><span class="cx"> {
</span><del>-    return adoptRef(*new WebVideoFullscreenManager(page));
</del><ins>+    return adoptRef(*new WebVideoFullscreenManager(page, playbackSessionManager));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-WebVideoFullscreenManager::WebVideoFullscreenManager(PassRefPtr&lt;WebPage&gt; page)
-    : m_page(page.get())
</del><ins>+WebVideoFullscreenManager::WebVideoFullscreenManager(WebPage&amp; page, WebPlaybackSessionManager&amp; playbackSessionManager)
+    : m_page(&amp;page)
+    , m_playbackSessionManager(playbackSessionManager)
</ins><span class="cx"> {
</span><del>-    WebProcess::singleton().addMessageReceiver(Messages::WebVideoFullscreenManager::messageReceiverName(), page-&gt;pageID(), *this);
</del><ins>+    WebProcess::singleton().addMessageReceiver(Messages::WebVideoFullscreenManager::messageReceiverName(), page.pageID(), *this);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> WebVideoFullscreenManager::~WebVideoFullscreenManager()
</span><span class="lines">@@ -189,8 +175,10 @@
</span><span class="cx"> 
</span><span class="cx"> WebVideoFullscreenManager::ModelInterfaceTuple WebVideoFullscreenManager::createModelAndInterface(uint64_t contextId)
</span><span class="cx"> {
</span><del>-    RefPtr&lt;WebVideoFullscreenModelVideoElement&gt; model = WebVideoFullscreenModelVideoElement::create();
-    RefPtr&lt;WebVideoFullscreenInterfaceContext&gt; interface = WebVideoFullscreenInterfaceContext::create(*this, contextId);
</del><ins>+    auto&amp; playbackSessionModel = m_playbackSessionManager-&gt;ensureModel(contextId);
+    RefPtr&lt;WebVideoFullscreenModelVideoElement&gt; model = WebVideoFullscreenModelVideoElement::create(playbackSessionModel);
+    auto&amp; playbackSessionInterface = m_playbackSessionManager-&gt;ensureInterface(contextId);
+    RefPtr&lt;WebVideoFullscreenInterfaceContext&gt; interface = WebVideoFullscreenInterfaceContext::create(*this, playbackSessionInterface, contextId);
</ins><span class="cx"> 
</span><span class="cx">     interface-&gt;setLayerHostingContext(LayerHostingContext::createForExternalHostingProcess());
</span><span class="cx">     model-&gt;setWebVideoFullscreenInterface(interface.get());
</span><span class="lines">@@ -272,13 +260,11 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(mode != HTMLMediaElementEnums::VideoFullscreenModeNone);
</span><span class="cx"> 
</span><del>-    uint64_t contextId;
</del><ins>+    uint64_t contextId = m_playbackSessionManager-&gt;contextIdForMediaElement(videoElement);
+    auto addResult = m_videoElements.add(&amp;videoElement, contextId);
+    UNUSED_PARAM(addResult);
+    ASSERT(addResult.iterator-&gt;value == contextId);
</ins><span class="cx"> 
</span><del>-    auto addResult = m_videoElements.add(&amp;videoElement, 0);
-    if (addResult.isNewEntry)
-        addResult.iterator-&gt;value = nextContextId();
-    contextId = addResult.iterator-&gt;value;
-
</del><span class="cx">     RefPtr&lt;WebVideoFullscreenModelVideoElement&gt; model;
</span><span class="cx">     RefPtr&lt;WebVideoFullscreenInterfaceContext&gt; interface;
</span><span class="cx">     std::tie(model, interface) = ensureModelAndInterface(contextId);
</span><span class="lines">@@ -321,41 +307,6 @@
</span><span class="cx">     m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::ExitFullscreen(contextId, clientRectForElement(&amp;videoElement)), m_page-&gt;pageID());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenManager::setUpVideoControlsManager(WebCore::HTMLVideoElement&amp; videoElement)
-{
-#if PLATFORM(MAC)
-    if (m_videoElements.contains(&amp;videoElement)) {
-        uint64_t contextId = m_videoElements.get(&amp;videoElement);
-        if (m_controlsManagerContextId == contextId)
-            return;
-
-        if (m_controlsManagerContextId)
-            removeClientForContext(m_controlsManagerContextId);
-        m_controlsManagerContextId = contextId;
-    } else {
-        auto addResult = m_videoElements.ensure(&amp;videoElement, [&amp;] { return nextContextId(); });
-        auto contextId = addResult.iterator-&gt;value;
-        m_controlsManagerContextId = contextId;
-        ensureModel(contextId).setVideoElement(&amp;videoElement);
-    }
-
-    addClientForContext(m_controlsManagerContextId);
-    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::SetUpVideoControlsManagerWithID(m_controlsManagerContextId), m_page-&gt;pageID());
-#endif
-}
-
-void WebVideoFullscreenManager::clearVideoControlsManager()
-{
-#if PLATFORM(MAC)
-    if (!m_controlsManagerContextId)
-        return;
-
-    removeClientForContext(m_controlsManagerContextId);
-    m_controlsManagerContextId = 0;
-    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::ClearVideoControlsManager(), m_page-&gt;pageID());
-#endif
-}
-
</del><span class="cx"> void WebVideoFullscreenManager::exitVideoFullscreenToModeWithoutAnimation(WebCore::HTMLVideoElement&amp; videoElement, WebCore::HTMLMediaElementEnums::VideoFullscreenMode targetMode)
</span><span class="cx"> {
</span><span class="cx"> #if PLATFORM(MAC) &amp;&amp; ENABLE(VIDEO_PRESENTATION_MODE)
</span><span class="lines">@@ -375,149 +326,23 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma mark Interface to WebVideoFullscreenInterfaceContext:
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenManager::resetMediaState(uint64_t contextId)
-{
-    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::ResetMediaState(contextId), m_page-&gt;pageID());
-}
-    
-void WebVideoFullscreenManager::setDuration(uint64_t contextId, double duration)
-{
-    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::SetDuration(contextId, duration), m_page-&gt;pageID());
-}
-
-void WebVideoFullscreenManager::setCurrentTime(uint64_t contextId, double currentTime, double anchorTime)
-{
-    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::SetCurrentTime(contextId, currentTime, anchorTime), m_page-&gt;pageID());
-}
-
-void WebVideoFullscreenManager::setBufferedTime(uint64_t contextId, double bufferedTime)
-{
-    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::SetBufferedTime(contextId, bufferedTime), m_page-&gt;pageID());
-}
-
-void WebVideoFullscreenManager::setRate(uint64_t contextId, bool isPlaying, float playbackRate)
-{
-    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::SetRate(contextId, isPlaying, playbackRate), m_page-&gt;pageID());
-}
-
</del><span class="cx"> void WebVideoFullscreenManager::setVideoDimensions(uint64_t contextId, bool hasVideo, float width, float height)
</span><span class="cx"> {
</span><span class="cx">     m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::SetVideoDimensions(contextId, hasVideo, width, height), m_page-&gt;pageID());
</span><span class="cx"> }
</span><del>-    
-void WebVideoFullscreenManager::setSeekableRanges(uint64_t contextId, const WebCore::TimeRanges&amp; timeRanges)
-{
-    Vector&lt;std::pair&lt;double, double&gt;&gt; rangesVector;
-    
-    for (unsigned i = 0; i &lt; timeRanges.length(); i++) {
-        ExceptionCode exceptionCode;
-        double start = timeRanges.start(i, exceptionCode);
-        double end = timeRanges.end(i, exceptionCode);
-        rangesVector.append(std::pair&lt;double, double&gt;(start, end));
-    }
</del><span class="cx"> 
</span><del>-    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::SetSeekableRangesVector(contextId, WTFMove(rangesVector)), m_page-&gt;pageID());
-}
-
-void WebVideoFullscreenManager::setCanPlayFastReverse(uint64_t contextId, bool value)
-{
-    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::SetCanPlayFastReverse(contextId, value), m_page-&gt;pageID());
-}
-
-void WebVideoFullscreenManager::setAudioMediaSelectionOptions(uint64_t contextId, const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex)
-{
-    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::SetAudioMediaSelectionOptions(contextId, options, selectedIndex), m_page-&gt;pageID());
-}
-
-void WebVideoFullscreenManager::setLegibleMediaSelectionOptions(uint64_t contextId, const Vector&lt;String&gt;&amp; options, uint64_t selectedIndex)
-{
-    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::SetLegibleMediaSelectionOptions(contextId, options, selectedIndex), m_page-&gt;pageID());
-}
-
-void WebVideoFullscreenManager::setExternalPlayback(uint64_t contextId, bool enabled, WebVideoFullscreenInterface::ExternalPlaybackTargetType targetType, String localizedDeviceName)
-{
-    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::SetExternalPlaybackProperties(contextId, enabled, static_cast&lt;uint32_t&gt;(targetType), localizedDeviceName), m_page-&gt;pageID());
-}
-
-void WebVideoFullscreenManager::setWirelessVideoPlaybackDisabled(uint64_t contextId, bool disabled)
-{
-    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::SetWirelessVideoPlaybackDisabled(contextId, disabled));
-}
-
</del><span class="cx"> #pragma mark Messages from WebVideoFullscreenManagerProxy:
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenManager::play(uint64_t contextId)
-{
-    ensureModel(contextId).play();
-}
-
-void WebVideoFullscreenManager::pause(uint64_t contextId)
-{
-    ensureModel(contextId).pause();
-}
-
-void WebVideoFullscreenManager::togglePlayState(uint64_t contextId)
-{
-    ensureModel(contextId).togglePlayState();
-}
-
-void WebVideoFullscreenManager::beginScrubbing(uint64_t contextId)
-{
-    ensureModel(contextId).beginScrubbing();
-}
-
-void WebVideoFullscreenManager::endScrubbing(uint64_t contextId)
-{
-    ensureModel(contextId).endScrubbing();
-}
-
-void WebVideoFullscreenManager::seekToTime(uint64_t contextId, double time)
-{
-    ensureModel(contextId).seekToTime(time);
-}
-
-void WebVideoFullscreenManager::fastSeek(uint64_t contextId, double time)
-{
-    ensureModel(contextId).fastSeek(time);
-}
-
-void WebVideoFullscreenManager::beginScanningForward(uint64_t contextId)
-{
-    ensureModel(contextId).beginScanningForward();
-}
-
-void WebVideoFullscreenManager::beginScanningBackward(uint64_t contextId)
-{
-    ensureModel(contextId).beginScanningBackward();
-}
-
-void WebVideoFullscreenManager::endScanning(uint64_t contextId)
-{
-    ensureModel(contextId).endScanning();
-}
-
</del><span class="cx"> void WebVideoFullscreenManager::requestFullscreenMode(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode mode)
</span><span class="cx"> {
</span><span class="cx">     ensureModel(contextId).requestFullscreenMode(mode);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebVideoFullscreenManager::selectAudioMediaOption(uint64_t contextId, uint64_t index)
-{
-    ensureModel(contextId).selectAudioMediaOption(index);
-}
-
-void WebVideoFullscreenManager::selectLegibleMediaOption(uint64_t contextId, uint64_t index)
-{
-    ensureModel(contextId).selectLegibleMediaOption(index);
-}
-
</del><span class="cx"> void WebVideoFullscreenManager::fullscreenModeChanged(uint64_t contextId, WebCore::HTMLMediaElementEnums::VideoFullscreenMode videoFullscreenMode)
</span><span class="cx"> {
</span><span class="cx">     ensureModel(contextId).fullscreenModeChanged(videoFullscreenMode);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#pragma mark Messages from WebVideoFullscreenManager:
-
</del><span class="cx"> void WebVideoFullscreenManager::didSetupFullscreen(uint64_t contextId)
</span><span class="cx"> {
</span><span class="cx">     PlatformLayer* videoLayer = [CALayer layer];
</span></span></pre>
</div>
</div>

</body>
</html>