[iOS] When simultaneously exiting-and-entering fullscreen, WebVideoFullscreenManager...
[WebKit-https.git] / Source / WebKit2 / UIProcess / ios / WebVideoFullscreenManagerProxy.mm
index 0fee743..2f3ba2b 100644 (file)
@@ -53,8 +53,168 @@ PassRefPtr<WebVideoFullscreenManagerProxy> WebVideoFullscreenManagerProxy::creat
     return nullptr;
 }
 
+void WebVideoFullscreenManagerProxy::invalidate()
+{
+}
+
+bool WebVideoFullscreenManagerProxy::hasMode(HTMLMediaElement::VideoFullscreenMode) const
+{
+    return false;
+}
+
+bool WebVideoFullscreenManagerProxy::mayAutomaticallyShowVideoOptimized() const
+{
+    return false;
+}
+
+void WebVideoFullscreenManagerProxy::requestHideAndExitFullscreen()
+{
+
+}
 #else
 
+#pragma mark - WebVideoFullscreenModelContext
+
+void WebVideoFullscreenModelContext::play()
+{
+    if (m_manager)
+        m_manager->play(m_contextId);
+}
+
+void WebVideoFullscreenModelContext::pause()
+{
+    if (m_manager)
+        m_manager->pause(m_contextId);
+}
+
+void WebVideoFullscreenModelContext::togglePlayState()
+{
+    if (m_manager)
+        m_manager->togglePlayState(m_contextId);
+}
+
+void WebVideoFullscreenModelContext::beginScrubbing()
+{
+    if (m_manager)
+        m_manager->beginScrubbing(m_contextId);
+}
+
+void WebVideoFullscreenModelContext::endScrubbing()
+{
+    if (m_manager)
+        m_manager->endScrubbing(m_contextId);
+}
+
+void WebVideoFullscreenModelContext::seekToTime(double time)
+{
+    if (m_manager)
+        m_manager->seekToTime(m_contextId, time);
+}
+
+void WebVideoFullscreenModelContext::fastSeek(double time)
+{
+    if (m_manager)
+        m_manager->fastSeek(m_contextId, time);
+}
+
+void WebVideoFullscreenModelContext::beginScanningForward()
+{
+    if (m_manager)
+        m_manager->beginScanningForward(m_contextId);
+}
+
+void WebVideoFullscreenModelContext::beginScanningBackward()
+{
+    if (m_manager)
+        m_manager->beginScanningBackward(m_contextId);
+}
+
+void WebVideoFullscreenModelContext::endScanning()
+{
+    if (m_manager)
+        m_manager->endScanning(m_contextId);
+}
+
+void WebVideoFullscreenModelContext::requestExitFullscreen()
+{
+    if (m_manager)
+        m_manager->requestExitFullscreen(m_contextId);
+}
+
+void WebVideoFullscreenModelContext::setVideoLayerFrame(WebCore::FloatRect frame)
+{
+    m_videoLayerFrame = frame;
+    if (m_manager)
+        m_manager->setVideoLayerFrame(m_contextId, frame);
+}
+
+WebCore::FloatRect WebVideoFullscreenModelContext::videoLayerFrame() const
+{
+    return m_videoLayerFrame;
+}
+
+void WebVideoFullscreenModelContext::setVideoLayerGravity(WebCore::WebVideoFullscreenModel::VideoGravity gravity)
+{
+    m_videoLayerGravity = gravity;
+    if (m_manager)
+        m_manager->setVideoLayerGravity(m_contextId, gravity);
+}
+
+WebCore::WebVideoFullscreenModel::VideoGravity WebVideoFullscreenModelContext::videoLayerGravity() const
+{
+    return m_videoLayerGravity;
+}
+
+void WebVideoFullscreenModelContext::selectAudioMediaOption(uint64_t optionId)
+{
+    if (m_manager)
+        m_manager->selectAudioMediaOption(m_contextId, optionId);
+}
+
+void WebVideoFullscreenModelContext::selectLegibleMediaOption(uint64_t optionId)
+{
+    if (m_manager)
+        m_manager->selectLegibleMediaOption(m_contextId, optionId);
+}
+
+void WebVideoFullscreenModelContext::fullscreenModeChanged(WebCore::HTMLMediaElement::VideoFullscreenMode mode)
+{
+    if (m_manager)
+        m_manager->fullscreenModeChanged(m_contextId, mode);
+}
+
+void WebVideoFullscreenModelContext::didSetupFullscreen()
+{
+    if (m_manager)
+        m_manager->didSetupFullscreen(m_contextId);
+}
+
+void WebVideoFullscreenModelContext::didEnterFullscreen()
+{
+    if (m_manager)
+        m_manager->didEnterFullscreen(m_contextId);
+}
+
+void WebVideoFullscreenModelContext::didExitFullscreen()
+{
+    if (m_manager)
+        m_manager->didExitFullscreen(m_contextId);
+}
+
+void WebVideoFullscreenModelContext::didCleanupFullscreen()
+{
+    if (m_manager)
+        m_manager->didCleanupFullscreen(m_contextId);
+}
+
+void WebVideoFullscreenModelContext::fullscreenMayReturnToInline()
+{
+    if (m_manager)
+        m_manager->fullscreenMayReturnToInline(m_contextId);
+}
+
+#pragma mark - WebVideoFullscreenManagerProxy
+
 PassRefPtr<WebVideoFullscreenManagerProxy> WebVideoFullscreenManagerProxy::create(WebPageProxy& page)
 {
     return adoptRef(new WebVideoFullscreenManagerProxy(page));
@@ -64,8 +224,6 @@ WebVideoFullscreenManagerProxy::WebVideoFullscreenManagerProxy(WebPageProxy& pag
     : m_page(&page)
 {
     m_page->process().addMessageReceiver(Messages::WebVideoFullscreenManagerProxy::messageReceiverName(), m_page->pageID(), *this);
-    setWebVideoFullscreenModel(this);
-    setWebVideoFullscreenChangeObserver(this);
 }
 
 WebVideoFullscreenManagerProxy::~WebVideoFullscreenManagerProxy()
@@ -77,37 +235,118 @@ WebVideoFullscreenManagerProxy::~WebVideoFullscreenManagerProxy()
 
 void WebVideoFullscreenManagerProxy::invalidate()
 {
-    WebVideoFullscreenInterfaceAVKit::invalidate();
-
     m_page->process().removeMessageReceiver(Messages::WebVideoFullscreenManagerProxy::messageReceiverName(), m_page->pageID());
     m_page = nullptr;
 
-    [m_layerHost removeFromSuperlayer];
-    m_layerHost.clear();
+    for (auto& tuple : m_contextMap.values()) {
+        RefPtr<WebVideoFullscreenModelContext> model;
+        RefPtr<WebCore::WebVideoFullscreenInterfaceAVKit> interface;
+        std::tie(model, interface) = tuple;
+
+        interface->invalidate();
+        [model->layerHost() removeFromSuperlayer];
+        model->setLayerHost(nullptr);
+    }
+
+    m_contextMap.clear();
+}
+
+void WebVideoFullscreenManagerProxy::requestHideAndExitFullscreen()
+{
+    for (auto& tuple : m_contextMap.values())
+        std::get<1>(tuple)->requestHideAndExitFullscreen();
+}
+
+bool WebVideoFullscreenManagerProxy::hasMode(HTMLMediaElement::VideoFullscreenMode mode) const
+{
+    for (auto& tuple : m_contextMap.values()) {
+        if (std::get<1>(tuple)->hasMode(mode))
+            return true;
+    }
+    return false;
 }
 
-void WebVideoFullscreenManagerProxy::setupFullscreenWithID(uint32_t videoLayerID, const WebCore::IntRect& initialRect, float hostingDeviceScaleFactor, HTMLMediaElement::VideoFullscreenMode videoFullscreenMode, bool allowOptimizedFullscreen)
+bool WebVideoFullscreenManagerProxy::mayAutomaticallyShowVideoOptimized() const
+{
+    for (auto& tuple : m_contextMap.values()) {
+        if (std::get<1>(tuple)->mayAutomaticallyShowVideoOptimized())
+            return true;
+    }
+    return false;
+}
+
+WebVideoFullscreenManagerProxy::ModelInterfaceTuple WebVideoFullscreenManagerProxy::createModelAndInterface(uint64_t contextId)
+{
+    Ref<WebVideoFullscreenModelContext> model = WebVideoFullscreenModelContext::create(*this, contextId);
+    Ref<WebCore::WebVideoFullscreenInterfaceAVKit> interface = WebVideoFullscreenInterfaceAVKit::create();
+
+    interface->setWebVideoFullscreenModel(&model.get());
+    interface->setWebVideoFullscreenChangeObserver(&model.get());
+
+    return std::make_tuple(WTF::move(model), WTF::move(interface));
+}
+
+WebVideoFullscreenManagerProxy::ModelInterfaceTuple& WebVideoFullscreenManagerProxy::ensureModelAndInterface(uint64_t contextId)
+{
+    auto addResult = m_contextMap.add(contextId, ModelInterfaceTuple());
+    if (addResult.isNewEntry)
+        addResult.iterator->value = createModelAndInterface(contextId);
+    return addResult.iterator->value;
+}
+
+WebVideoFullscreenModelContext& WebVideoFullscreenManagerProxy::ensureModel(uint64_t contextId)
+{
+    return *std::get<0>(ensureModelAndInterface(contextId));
+}
+
+WebCore::WebVideoFullscreenInterfaceAVKit& WebVideoFullscreenManagerProxy::ensureInterface(uint64_t contextId)
+{
+    return *std::get<1>(ensureModelAndInterface(contextId));
+}
+
+#pragma mark Messages from WebVideoFullscreenManager
+
+void WebVideoFullscreenManagerProxy::setupFullscreenWithID(uint64_t contextId, uint32_t videoLayerID, const WebCore::IntRect& initialRect, float hostingDeviceScaleFactor, HTMLMediaElement::VideoFullscreenMode videoFullscreenMode, bool allowOptimizedFullscreen)
 {
     ASSERT(videoLayerID);
-    m_layerHost = WKMakeRenderLayer(videoLayerID);
+    RefPtr<WebVideoFullscreenModelContext> model;
+    RefPtr<WebCore::WebVideoFullscreenInterfaceAVKit> interface;
+
+    std::tie(model, interface) = ensureModelAndInterface(contextId);
+
+    model->setInitialVideoLayerFrame(initialRect);
+    model->setLayerHost(WKMakeRenderLayer(videoLayerID));
     if (hostingDeviceScaleFactor != 1) {
         // Invert the scale transform added in the WebProcess to fix <rdar://problem/18316542>.
         float inverseScale = 1 / hostingDeviceScaleFactor;
-        [m_layerHost setTransform:CATransform3DMakeScale(inverseScale, inverseScale, 1)];
+        [model->layerHost() setTransform:CATransform3DMakeScale(inverseScale, inverseScale, 1)];
     }
 
-    m_videoLayerFrame = initialRect;
-
     UIView *parentView = downcast<RemoteLayerTreeDrawingAreaProxy>(*m_page->drawingArea()).remoteLayerTreeHost().rootLayer();
-    setupFullscreen(*m_layerHost.get(), initialRect, parentView, videoFullscreenMode, allowOptimizedFullscreen);
+    interface->setupFullscreen(*model->layerHost(), initialRect, parentView, videoFullscreenMode, allowOptimizedFullscreen);
 }
-    
-void WebVideoFullscreenManagerProxy::fullscreenModeChanged(HTMLMediaElement::VideoFullscreenMode mode)
+
+void WebVideoFullscreenManagerProxy::resetMediaState(uint64_t contextId)
 {
-    m_page->send(Messages::WebVideoFullscreenManager::fullscreenModeChanged(mode), m_page->pageID());
+    ensureInterface(contextId).resetMediaState();
 }
-    
-void WebVideoFullscreenManagerProxy::setSeekableRangesVector(const Vector<std::pair<double, double>>& ranges)
+
+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);
+}
+
+void WebVideoFullscreenManagerProxy::setVideoDimensions(uint64_t contextId, bool hasVideo, unsigned width, unsigned height)
+{
+    ensureInterface(contextId).setVideoDimensions(hasVideo, width, height);
+}
+
+void WebVideoFullscreenManagerProxy::setSeekableRangesVector(uint64_t contextId, Vector<std::pair<double, double>> ranges)
 {
     RefPtr<TimeRanges> timeRanges = TimeRanges::create();
     for (const auto& range : ranges)
@@ -118,118 +357,164 @@ void WebVideoFullscreenManagerProxy::setSeekableRangesVector(const Vector<std::p
         timeRanges->add(range.first, range.second);
     }
 
-    setSeekableRanges(*timeRanges);
+    ensureInterface(contextId).setSeekableRanges(*timeRanges);
 }
 
-void WebVideoFullscreenManagerProxy::setExternalPlaybackProperties(bool enabled, uint32_t targetType, String localizedDeviceName)
+void WebVideoFullscreenManagerProxy::setCanPlayFastReverse(uint64_t contextId, bool value)
+{
+    ensureInterface(contextId).setCanPlayFastReverse(value);
+}
+
+void WebVideoFullscreenManagerProxy::setAudioMediaSelectionOptions(uint64_t contextId, Vector<String> options, uint64_t selectedIndex)
+{
+    ensureInterface(contextId).setAudioMediaSelectionOptions(options, selectedIndex);
+}
+
+void WebVideoFullscreenManagerProxy::setLegibleMediaSelectionOptions(uint64_t contextId, Vector<String> 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<WebVideoFullscreenInterface::ExternalPlaybackTargetType>(targetType);
-    
     ASSERT(type == WebVideoFullscreenInterface::TargetTypeAirPlay || type == WebVideoFullscreenInterface::TargetTypeTVOut || type == WebVideoFullscreenInterface::TargetTypeNone);
     
-    setExternalPlayback(enabled, type, localizedDeviceName);
+    ensureInterface(contextId).setExternalPlayback(enabled, type, localizedDeviceName);
 }
-    
-void WebVideoFullscreenManagerProxy::fullscreenMayReturnToInline()
+
+void WebVideoFullscreenManagerProxy::setDuration(uint64_t contextId, double duration)
 {
-    bool isViewVisible = m_page->isViewVisible();
-    m_page->send(Messages::WebVideoFullscreenManager::FullscreenMayReturnToInline(isViewVisible), m_page->pageID());
+    ensureInterface(contextId).setDuration(duration);
 }
-    
-void WebVideoFullscreenManagerProxy::preparedToReturnToInline(bool visible, const WebCore::IntRect& inlineRect)
+
+void WebVideoFullscreenManagerProxy::setRate(uint64_t contextId, bool isPlaying, double rate)
 {
-    m_page->fullscreenMayReturnToInline();
-    WebVideoFullscreenInterfaceAVKit::preparedToReturnToInline(visible, inlineRect);
+    ensureInterface(contextId).setRate(isPlaying, rate);
 }
 
-void WebVideoFullscreenManagerProxy::requestExitFullscreen()
+void WebVideoFullscreenManagerProxy::enterFullscreen(uint64_t contextId)
 {
-    m_page->send(Messages::WebVideoFullscreenManager::RequestExitFullscreen(), m_page->pageID());
+    auto& interface = ensureInterface(contextId);
+    interface.enterFullscreen();
+
+    // Only one context can be in a given full screen mode at a time:
+    for (auto& contextPair : m_contextMap) {
+        auto& otherContextId = contextPair.key;
+        if (contextId == otherContextId)
+            continue;
+
+        auto& otherInterface = std::get<1>(contextPair.value);
+        if (otherInterface->hasMode(interface.mode()))
+            otherInterface->requestHideAndExitFullscreen();
+    }
 }
 
-void WebVideoFullscreenManagerProxy::didExitFullscreen()
+void WebVideoFullscreenManagerProxy::exitFullscreen(uint64_t contextId, WebCore::IntRect finalRect)
 {
-    m_page->send(Messages::WebVideoFullscreenManager::DidExitFullscreen(), m_page->pageID());
-    m_page->didExitFullscreen();
+    ensureInterface(contextId).exitFullscreen(finalRect);
 }
-    
-void WebVideoFullscreenManagerProxy::didCleanupFullscreen()
+
+void WebVideoFullscreenManagerProxy::cleanupFullscreen(uint64_t contextId)
 {
-    [CATransaction flush];
-    [m_layerHost removeFromSuperlayer];
-    m_layerHost.clear();
-    m_page->send(Messages::WebVideoFullscreenManager::DidCleanupFullscreen(), m_page->pageID());
+    ensureInterface(contextId).cleanupFullscreen();
 }
 
-void WebVideoFullscreenManagerProxy::didSetupFullscreen()
+void WebVideoFullscreenManagerProxy::preparedToReturnToInline(uint64_t contextId, bool visible, WebCore::IntRect inlineRect)
 {
-    m_page->send(Messages::WebVideoFullscreenManager::DidSetupFullscreen(), m_page->pageID());
+    m_page->fullscreenMayReturnToInline();
+
+    ensureInterface(contextId).preparedToReturnToInline(visible, inlineRect);
 }
 
-void WebVideoFullscreenManagerProxy::didEnterFullscreen()
+#pragma mark Messages to WebVideoFullscreenManager
+
+void WebVideoFullscreenManagerProxy::play(uint64_t contextId)
 {
-    m_page->send(Messages::WebVideoFullscreenManager::DidEnterFullscreen(), m_page->pageID());
-    m_page->didEnterFullscreen();
+    m_page->send(Messages::WebVideoFullscreenManager::Play(contextId), m_page->pageID());
 }
 
-void WebVideoFullscreenManagerProxy::play()
+void WebVideoFullscreenManagerProxy::pause(uint64_t contextId)
 {
-    m_page->send(Messages::WebVideoFullscreenManager::Play(), m_page->pageID());
+    m_page->send(Messages::WebVideoFullscreenManager::Pause(contextId), m_page->pageID());
 }
-    
-void WebVideoFullscreenManagerProxy::pause()
+
+void WebVideoFullscreenManagerProxy::togglePlayState(uint64_t contextId)
 {
-    m_page->send(Messages::WebVideoFullscreenManager::Pause(), m_page->pageID());
+    m_page->send(Messages::WebVideoFullscreenManager::TogglePlayState(contextId), m_page->pageID());
 }
-    
-void WebVideoFullscreenManagerProxy::togglePlayState()
+
+void WebVideoFullscreenManagerProxy::beginScrubbing(uint64_t contextId)
 {
-    m_page->send(Messages::WebVideoFullscreenManager::TogglePlayState(), m_page->pageID());
+    m_page->send(Messages::WebVideoFullscreenManager::BeginScrubbing(contextId), m_page->pageID());
 }
-    
-void WebVideoFullscreenManagerProxy::beginScrubbing()
+
+void WebVideoFullscreenManagerProxy::endScrubbing(uint64_t contextId)
 {
-    m_page->send(Messages::WebVideoFullscreenManager::BeginScrubbing(), m_page->pageID());
+    m_page->send(Messages::WebVideoFullscreenManager::EndScrubbing(contextId), m_page->pageID());
 }
 
-void WebVideoFullscreenManagerProxy::endScrubbing()
+void WebVideoFullscreenManagerProxy::seekToTime(uint64_t contextId, double time)
 {
-    m_page->send(Messages::WebVideoFullscreenManager::EndScrubbing(), m_page->pageID());
+    m_page->send(Messages::WebVideoFullscreenManager::SeekToTime(contextId, time), m_page->pageID());
 }
 
-void WebVideoFullscreenManagerProxy::seekToTime(double time)
+void WebVideoFullscreenManagerProxy::fastSeek(uint64_t contextId, double time)
 {
-    m_page->send(Messages::WebVideoFullscreenManager::SeekToTime(time), m_page->pageID());
+    m_page->send(Messages::WebVideoFullscreenManager::FastSeek(contextId, time), m_page->pageID());
 }
 
-void WebVideoFullscreenManagerProxy::fastSeek(double time)
+void WebVideoFullscreenManagerProxy::beginScanningForward(uint64_t contextId)
 {
-    m_page->send(Messages::WebVideoFullscreenManager::FastSeek(time), m_page->pageID());
+    m_page->send(Messages::WebVideoFullscreenManager::BeginScanningForward(contextId), m_page->pageID());
 }
 
-void WebVideoFullscreenManagerProxy::beginScanningForward()
+void WebVideoFullscreenManagerProxy::beginScanningBackward(uint64_t contextId)
 {
-    m_page->send(Messages::WebVideoFullscreenManager::BeginScanningForward(), m_page->pageID());
+    m_page->send(Messages::WebVideoFullscreenManager::BeginScanningBackward(contextId), m_page->pageID());
 }
 
-void WebVideoFullscreenManagerProxy::beginScanningBackward()
+void WebVideoFullscreenManagerProxy::endScanning(uint64_t contextId)
 {
-    m_page->send(Messages::WebVideoFullscreenManager::BeginScanningBackward(), m_page->pageID());
+    m_page->send(Messages::WebVideoFullscreenManager::EndScanning(contextId), m_page->pageID());
 }
 
-void WebVideoFullscreenManagerProxy::endScanning()
+void WebVideoFullscreenManagerProxy::requestExitFullscreen(uint64_t contextId)
 {
-    m_page->send(Messages::WebVideoFullscreenManager::EndScanning(), m_page->pageID());
+    m_page->send(Messages::WebVideoFullscreenManager::RequestExitFullscreen(contextId), m_page->pageID());
 }
 
-FloatRect WebVideoFullscreenManagerProxy::videoLayerFrame() const
+void WebVideoFullscreenManagerProxy::didSetupFullscreen(uint64_t contextId)
 {
-    return m_videoLayerFrame;
+    m_page->send(Messages::WebVideoFullscreenManager::DidSetupFullscreen(contextId), m_page->pageID());
 }
 
-void WebVideoFullscreenManagerProxy::setVideoLayerFrame(WebCore::FloatRect frame)
+void WebVideoFullscreenManagerProxy::didExitFullscreen(uint64_t contextId)
+{
+    m_page->send(Messages::WebVideoFullscreenManager::DidExitFullscreen(contextId), m_page->pageID());
+    m_page->didExitFullscreen();
+}
+
+void WebVideoFullscreenManagerProxy::didEnterFullscreen(uint64_t contextId)
+{
+    m_page->send(Messages::WebVideoFullscreenManager::DidEnterFullscreen(contextId), m_page->pageID());
+    m_page->didEnterFullscreen();
+}
+
+void WebVideoFullscreenManagerProxy::didCleanupFullscreen(uint64_t contextId)
+{
+    auto& model = ensureModel(contextId);
+
+    [CATransaction flush];
+    [model.layerHost() removeFromSuperlayer];
+    model.setLayerHost(nullptr);
+    m_page->send(Messages::WebVideoFullscreenManager::DidCleanupFullscreen(contextId), m_page->pageID());
+
+    m_contextMap.remove(contextId);
+}
+
+void WebVideoFullscreenManagerProxy::setVideoLayerFrame(uint64_t contextId, WebCore::FloatRect frame)
 {
-    m_videoLayerFrame = frame;
     @autoreleasepool {
 #if __IPHONE_OS_VERSION_MIN_REQUIRED > 90000
         BKSAnimationFenceHandle* synchronizationFence = [UIWindow _synchronizedDrawingFence];
@@ -238,30 +523,36 @@ void WebVideoFullscreenManagerProxy::setVideoLayerFrame(WebCore::FloatRect frame
         mach_port_name_t fencePort = [UIWindow _synchronizeDrawingAcrossProcesses];
 #endif
 
-        m_page->send(Messages::WebVideoFullscreenManager::SetVideoLayerFrameFenced(frame, IPC::Attachment(fencePort, MACH_MSG_TYPE_MOVE_SEND)), m_page->pageID());
+        m_page->send(Messages::WebVideoFullscreenManager::SetVideoLayerFrameFenced(contextId, frame, IPC::Attachment(fencePort, MACH_MSG_TYPE_MOVE_SEND)), m_page->pageID());
     }
 }
 
-WebCore::WebVideoFullscreenModel::VideoGravity WebVideoFullscreenManagerProxy::videoLayerGravity() const
+void WebVideoFullscreenManagerProxy::setVideoLayerGravity(uint64_t contextId, WebCore::WebVideoFullscreenModel::VideoGravity gravity)
 {
-    return m_videoLayerGravity;
+    m_page->send(Messages::WebVideoFullscreenManager::SetVideoLayerGravityEnum(contextId, (unsigned)gravity), m_page->pageID());
 }
 
-void WebVideoFullscreenManagerProxy::setVideoLayerGravity(WebCore::WebVideoFullscreenModel::VideoGravity gravity)
+void WebVideoFullscreenManagerProxy::selectAudioMediaOption(uint64_t contextId, uint64_t index)
 {
-    m_videoLayerGravity = gravity;
-    m_page->send(Messages::WebVideoFullscreenManager::SetVideoLayerGravityEnum((unsigned)gravity), m_page->pageID());
+    m_page->send(Messages::WebVideoFullscreenManager::SelectAudioMediaOption(contextId, index), m_page->pageID());
 }
-    
-void WebVideoFullscreenManagerProxy::selectAudioMediaOption(uint64_t index)
+
+void WebVideoFullscreenManagerProxy::selectLegibleMediaOption(uint64_t contextId, uint64_t index)
 {
-    m_page->send(Messages::WebVideoFullscreenManager::SelectAudioMediaOption(index), m_page->pageID());
+    m_page->send(Messages::WebVideoFullscreenManager::SelectLegibleMediaOption(contextId, index), m_page->pageID());
 }
-    
-void WebVideoFullscreenManagerProxy::selectLegibleMediaOption(uint64_t index)
+
+void WebVideoFullscreenManagerProxy::fullscreenModeChanged(uint64_t contextId, WebCore::HTMLMediaElement::VideoFullscreenMode mode)
+{
+    m_page->send(Messages::WebVideoFullscreenManager::FullscreenModeChanged(contextId, mode), m_page->pageID());
+}
+
+void WebVideoFullscreenManagerProxy::fullscreenMayReturnToInline(uint64_t contextId)
 {
-    m_page->send(Messages::WebVideoFullscreenManager::SelectLegibleMediaOption(index), m_page->pageID());
+    bool isViewVisible = m_page->isViewVisible();
+    m_page->send(Messages::WebVideoFullscreenManager::FullscreenMayReturnToInline(contextId, isViewVisible), m_page->pageID());
 }
+
 #endif
 
 } // namespace WebKit