dc36171b7b41f62eae4be3dfd3ee3cdf9e3c06d0
[WebKit-https.git] / Source / WebKit / UIProcess / Cocoa / PlaybackSessionManagerProxy.mm
1 /*
2  * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #import "config.h"
27 #import "PlaybackSessionManagerProxy.h"
28
29 #if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
30
31 #import "PlaybackSessionManagerMessages.h"
32 #import "PlaybackSessionManagerProxyMessages.h"
33 #import "WebPageProxy.h"
34 #import "WebProcessProxy.h"
35
36 namespace WebKit {
37 using namespace WebCore;
38
39 #pragma mark - PlaybackSessionModelContext
40
41 void PlaybackSessionModelContext::addClient(PlaybackSessionModelClient& client)
42 {
43     ASSERT(!m_clients.contains(&client));
44     m_clients.add(&client);
45 }
46
47 void PlaybackSessionModelContext::removeClient(PlaybackSessionModelClient& client)
48 {
49     ASSERT(m_clients.contains(&client));
50     m_clients.remove(&client);
51 }
52
53 void PlaybackSessionModelContext::play()
54 {
55     if (m_manager)
56         m_manager->play(m_contextId);
57 }
58
59 void PlaybackSessionModelContext::pause()
60 {
61     if (m_manager)
62         m_manager->pause(m_contextId);
63 }
64
65 void PlaybackSessionModelContext::togglePlayState()
66 {
67     if (m_manager)
68         m_manager->togglePlayState(m_contextId);
69 }
70
71 void PlaybackSessionModelContext::beginScrubbing()
72 {
73     if (m_manager)
74         m_manager->beginScrubbing(m_contextId);
75
76     m_isScrubbing = true;
77 }
78
79 void PlaybackSessionModelContext::endScrubbing()
80 {
81     if (m_manager)
82         m_manager->endScrubbing(m_contextId);
83
84     m_isScrubbing = false;
85     m_playbackStartedTimeNeedsUpdate = isPlaying();
86 }
87
88 void PlaybackSessionModelContext::seekToTime(double time, double toleranceBefore, double toleranceAfter)
89 {
90     if (m_manager)
91         m_manager->seekToTime(m_contextId, time, toleranceBefore, toleranceAfter);
92 }
93
94 void PlaybackSessionModelContext::fastSeek(double time)
95 {
96     if (m_manager)
97         m_manager->fastSeek(m_contextId, time);
98 }
99
100 void PlaybackSessionModelContext::beginScanningForward()
101 {
102     if (m_manager)
103         m_manager->beginScanningForward(m_contextId);
104 }
105
106 void PlaybackSessionModelContext::beginScanningBackward()
107 {
108     if (m_manager)
109         m_manager->beginScanningBackward(m_contextId);
110 }
111
112 void PlaybackSessionModelContext::endScanning()
113 {
114     if (m_manager)
115         m_manager->endScanning(m_contextId);
116 }
117
118 void PlaybackSessionModelContext::selectAudioMediaOption(uint64_t optionId)
119 {
120     if (m_manager)
121         m_manager->selectAudioMediaOption(m_contextId, optionId);
122 }
123
124 void PlaybackSessionModelContext::selectLegibleMediaOption(uint64_t optionId)
125 {
126     if (m_manager)
127         m_manager->selectLegibleMediaOption(m_contextId, optionId);
128 }
129
130 void PlaybackSessionModelContext::togglePictureInPicture()
131 {
132     if (m_manager)
133         m_manager->togglePictureInPicture(m_contextId);
134 }
135
136 void PlaybackSessionModelContext::toggleMuted()
137 {
138     if (m_manager)
139         m_manager->toggleMuted(m_contextId);
140 }
141
142 void PlaybackSessionModelContext::setMuted(bool muted)
143 {
144     if (m_manager)
145         m_manager->setMuted(m_contextId, muted);
146 }
147
148 void PlaybackSessionModelContext::setVolume(double volume)
149 {
150     if (m_manager)
151         m_manager->setVolume(m_contextId, volume);
152 }
153
154 void PlaybackSessionModelContext::setPlayingOnSecondScreen(bool value)
155 {
156     if (m_manager)
157         m_manager->setPlayingOnSecondScreen(m_contextId, value);
158 }
159
160 void PlaybackSessionModelContext::playbackStartedTimeChanged(double playbackStartedTime)
161 {
162     m_playbackStartedTime = playbackStartedTime;
163     m_playbackStartedTimeNeedsUpdate = false;
164 }
165
166 void PlaybackSessionModelContext::durationChanged(double duration)
167 {
168     m_duration = duration;
169     for (auto* client : m_clients)
170         client->durationChanged(duration);
171 }
172
173 void PlaybackSessionModelContext::currentTimeChanged(double currentTime)
174 {
175     m_currentTime = currentTime;
176     auto anchorTime = [[NSProcessInfo processInfo] systemUptime];
177     if (m_playbackStartedTimeNeedsUpdate)
178         playbackStartedTimeChanged(currentTime);
179
180     for (auto* client : m_clients)
181         client->currentTimeChanged(currentTime, anchorTime);
182 }
183
184 void PlaybackSessionModelContext::bufferedTimeChanged(double bufferedTime)
185 {
186     m_bufferedTime = bufferedTime;
187     for (auto* client : m_clients)
188         client->bufferedTimeChanged(bufferedTime);
189 }
190
191 void PlaybackSessionModelContext::rateChanged(bool isPlaying, float playbackRate)
192 {
193     m_isPlaying = isPlaying;
194     m_playbackRate = playbackRate;
195     for (auto* client : m_clients)
196         client->rateChanged(isPlaying, playbackRate);
197 }
198
199 void PlaybackSessionModelContext::seekableRangesChanged(WebCore::TimeRanges& seekableRanges, double lastModifiedTime, double liveUpdateInterval)
200 {
201     m_seekableRanges = seekableRanges;
202     m_seekableTimeRangesLastModifiedTime = lastModifiedTime;
203     m_liveUpdateInterval = liveUpdateInterval;
204     for (auto* client : m_clients)
205         client->seekableRangesChanged(seekableRanges, lastModifiedTime, liveUpdateInterval);
206 }
207
208 void PlaybackSessionModelContext::canPlayFastReverseChanged(bool canPlayFastReverse)
209 {
210     m_canPlayFastReverse = canPlayFastReverse;
211     for (auto* client : m_clients)
212         client->canPlayFastReverseChanged(canPlayFastReverse);
213 }
214
215 void PlaybackSessionModelContext::audioMediaSelectionOptionsChanged(const Vector<MediaSelectionOption>& audioMediaSelectionOptions, uint64_t audioMediaSelectedIndex)
216 {
217     m_audioMediaSelectionOptions = audioMediaSelectionOptions;
218     m_audioMediaSelectedIndex = audioMediaSelectedIndex;
219     for (auto* client : m_clients)
220         client->audioMediaSelectionOptionsChanged(audioMediaSelectionOptions, audioMediaSelectedIndex);
221 }
222
223 void PlaybackSessionModelContext::legibleMediaSelectionOptionsChanged(const Vector<MediaSelectionOption>& legibleMediaSelectionOptions, uint64_t legibleMediaSelectedIndex)
224 {
225     m_legibleMediaSelectionOptions = legibleMediaSelectionOptions;
226     m_legibleMediaSelectedIndex = legibleMediaSelectedIndex;
227
228     for (auto* client : m_clients)
229         client->legibleMediaSelectionOptionsChanged(legibleMediaSelectionOptions, legibleMediaSelectedIndex);
230 }
231
232 void PlaybackSessionModelContext::audioMediaSelectionIndexChanged(uint64_t selectedIndex)
233 {
234     m_audioMediaSelectedIndex = selectedIndex;
235
236     for (auto* client : m_clients)
237         client->audioMediaSelectionIndexChanged(selectedIndex);
238 }
239
240 void PlaybackSessionModelContext::legibleMediaSelectionIndexChanged(uint64_t selectedIndex)
241 {
242     m_legibleMediaSelectedIndex = selectedIndex;
243
244     for (auto* client : m_clients)
245         client->legibleMediaSelectionIndexChanged(selectedIndex);
246 }
247
248 void PlaybackSessionModelContext::externalPlaybackChanged(bool enabled, PlaybackSessionModel::ExternalPlaybackTargetType type, const String& localizedName)
249 {
250     m_externalPlaybackEnabled = enabled;
251     m_externalPlaybackTargetType = type;
252     m_externalPlaybackLocalizedDeviceName = localizedName;
253
254     for (auto* client : m_clients)
255         client->externalPlaybackChanged(enabled, type, localizedName);
256 }
257
258 void PlaybackSessionModelContext::wirelessVideoPlaybackDisabledChanged(bool wirelessVideoPlaybackDisabled)
259 {
260     m_wirelessVideoPlaybackDisabled = wirelessVideoPlaybackDisabled;
261     for (auto* client : m_clients)
262         client->wirelessVideoPlaybackDisabledChanged(wirelessVideoPlaybackDisabled);
263 }
264
265 void PlaybackSessionModelContext::mutedChanged(bool muted)
266 {
267     m_muted = muted;
268     for (auto* client : m_clients)
269         client->mutedChanged(muted);
270 }
271
272 void PlaybackSessionModelContext::volumeChanged(double volume)
273 {
274     m_volume = volume;
275     for (auto* client : m_clients)
276         client->volumeChanged(volume);
277 }
278
279 void PlaybackSessionModelContext::pictureInPictureSupportedChanged(bool supported)
280 {
281     m_pictureInPictureSupported = supported;
282     for (auto* client : m_clients)
283         client->isPictureInPictureSupportedChanged(supported);
284 }
285
286 void PlaybackSessionModelContext::pictureInPictureActiveChanged(bool active)
287 {
288     m_pictureInPictureActive = active;
289     for (auto* client : m_clients)
290         client->pictureInPictureActiveChanged(active);
291 }
292
293 #pragma mark - PlaybackSessionManagerProxy
294
295 RefPtr<PlaybackSessionManagerProxy> PlaybackSessionManagerProxy::create(WebPageProxy& page)
296 {
297     return adoptRef(new PlaybackSessionManagerProxy(page));
298 }
299
300 PlaybackSessionManagerProxy::PlaybackSessionManagerProxy(WebPageProxy& page)
301     : m_page(&page)
302 {
303     m_page->process().addMessageReceiver(Messages::PlaybackSessionManagerProxy::messageReceiverName(), m_page->pageID(), *this);
304 }
305
306 PlaybackSessionManagerProxy::~PlaybackSessionManagerProxy()
307 {
308     if (!m_page)
309         return;
310     invalidate();
311 }
312
313 void PlaybackSessionManagerProxy::invalidate()
314 {
315     m_page->process().removeMessageReceiver(Messages::PlaybackSessionManagerProxy::messageReceiverName(), m_page->pageID());
316     m_page = nullptr;
317
318     auto contextMap = WTFMove(m_contextMap);
319     m_clientCounts.clear();
320
321     for (auto& tuple : contextMap.values()) {
322         RefPtr<PlaybackSessionModelContext> model;
323         RefPtr<PlatformPlaybackSessionInterface> interface;
324         std::tie(model, interface) = tuple;
325
326         interface->invalidate();
327     }
328 }
329
330 PlaybackSessionManagerProxy::ModelInterfaceTuple PlaybackSessionManagerProxy::createModelAndInterface(uint64_t contextId)
331 {
332     Ref<PlaybackSessionModelContext> model = PlaybackSessionModelContext::create(*this, contextId);
333     Ref<PlatformPlaybackSessionInterface> interface = PlatformPlaybackSessionInterface::create(model);
334
335     return std::make_tuple(WTFMove(model), WTFMove(interface));
336 }
337
338 PlaybackSessionManagerProxy::ModelInterfaceTuple& PlaybackSessionManagerProxy::ensureModelAndInterface(uint64_t contextId)
339 {
340     auto addResult = m_contextMap.add(contextId, ModelInterfaceTuple());
341     if (addResult.isNewEntry)
342         addResult.iterator->value = createModelAndInterface(contextId);
343     return addResult.iterator->value;
344 }
345
346 PlaybackSessionModelContext& PlaybackSessionManagerProxy::ensureModel(uint64_t contextId)
347 {
348     return *std::get<0>(ensureModelAndInterface(contextId));
349 }
350
351 PlatformPlaybackSessionInterface& PlaybackSessionManagerProxy::ensureInterface(uint64_t contextId)
352 {
353     return *std::get<1>(ensureModelAndInterface(contextId));
354 }
355
356 void PlaybackSessionManagerProxy::addClientForContext(uint64_t contextId)
357 {
358     m_clientCounts.add(contextId);
359 }
360
361 void PlaybackSessionManagerProxy::removeClientForContext(uint64_t contextId)
362 {
363     if (!m_clientCounts.remove(contextId))
364         return;
365
366     ensureInterface(contextId).invalidate();
367     m_contextMap.remove(contextId);
368 }
369
370 #pragma mark Messages from PlaybackSessionManager
371
372 void PlaybackSessionManagerProxy::setUpPlaybackControlsManagerWithID(uint64_t contextId)
373 {
374     if (m_controlsManagerContextId == contextId)
375         return;
376
377     if (m_controlsManagerContextId)
378         removeClientForContext(m_controlsManagerContextId);
379
380     m_controlsManagerContextId = contextId;
381     ensureInterface(m_controlsManagerContextId).ensureControlsManager();
382     addClientForContext(m_controlsManagerContextId);
383
384     m_page->videoControlsManagerDidChange();
385 }
386
387 void PlaybackSessionManagerProxy::clearPlaybackControlsManager()
388 {
389     if (!m_controlsManagerContextId)
390         return;
391
392     removeClientForContext(m_controlsManagerContextId);
393     m_controlsManagerContextId = 0;
394     m_page->videoControlsManagerDidChange();
395 }
396
397 void PlaybackSessionManagerProxy::resetMediaState(uint64_t contextId)
398 {
399     ensureInterface(contextId).resetMediaState();
400 }
401
402 void PlaybackSessionManagerProxy::currentTimeChanged(uint64_t contextId, double currentTime, double hostTime)
403 {
404     ensureModel(contextId).currentTimeChanged(currentTime);
405 }
406
407 void PlaybackSessionManagerProxy::bufferedTimeChanged(uint64_t contextId, double bufferedTime)
408 {
409     ensureModel(contextId).bufferedTimeChanged(bufferedTime);
410 }
411
412 void PlaybackSessionManagerProxy::seekableRangesVectorChanged(uint64_t contextId, Vector<std::pair<double, double>> ranges, double lastModifiedTime, double liveUpdateInterval)
413 {
414     Ref<TimeRanges> timeRanges = TimeRanges::create();
415     for (const auto& range : ranges) {
416         ASSERT(isfinite(range.first));
417         ASSERT(isfinite(range.second));
418         ASSERT(range.second >= range.first);
419         timeRanges->add(range.first, range.second);
420     }
421
422     ensureModel(contextId).seekableRangesChanged(timeRanges, lastModifiedTime, liveUpdateInterval);
423 }
424
425 void PlaybackSessionManagerProxy::canPlayFastReverseChanged(uint64_t contextId, bool value)
426 {
427     ensureModel(contextId).canPlayFastReverseChanged(value);
428 }
429
430 void PlaybackSessionManagerProxy::audioMediaSelectionOptionsChanged(uint64_t contextId, Vector<MediaSelectionOption> options, uint64_t selectedIndex)
431 {
432     ensureModel(contextId).audioMediaSelectionOptionsChanged(options, selectedIndex);
433 }
434
435 void PlaybackSessionManagerProxy::legibleMediaSelectionOptionsChanged(uint64_t contextId, Vector<MediaSelectionOption> options, uint64_t selectedIndex)
436 {
437     ensureModel(contextId).legibleMediaSelectionOptionsChanged(options, selectedIndex);
438 }
439
440 void PlaybackSessionManagerProxy::audioMediaSelectionIndexChanged(uint64_t contextId, uint64_t selectedIndex)
441 {
442     ensureModel(contextId).audioMediaSelectionIndexChanged(selectedIndex);
443 }
444
445 void PlaybackSessionManagerProxy::legibleMediaSelectionIndexChanged(uint64_t contextId, uint64_t selectedIndex)
446 {
447     ensureModel(contextId).legibleMediaSelectionIndexChanged(selectedIndex);
448 }
449
450 void PlaybackSessionManagerProxy::externalPlaybackPropertiesChanged(uint64_t contextId, bool enabled, uint32_t targetType, String localizedDeviceName)
451 {
452     PlaybackSessionModel::ExternalPlaybackTargetType type = static_cast<PlaybackSessionModel::ExternalPlaybackTargetType>(targetType);
453     ASSERT(type == PlaybackSessionModel::TargetTypeAirPlay || type == PlaybackSessionModel::TargetTypeTVOut || type == PlaybackSessionModel::TargetTypeNone);
454
455     ensureModel(contextId).externalPlaybackChanged(enabled, type, localizedDeviceName);
456 }
457
458 void PlaybackSessionManagerProxy::wirelessVideoPlaybackDisabledChanged(uint64_t contextId, bool disabled)
459 {
460     ensureModel(contextId).wirelessVideoPlaybackDisabledChanged(disabled);
461 }
462
463 void PlaybackSessionManagerProxy::mutedChanged(uint64_t contextId, bool muted)
464 {
465     ensureModel(contextId).mutedChanged(muted);
466 }
467
468 void PlaybackSessionManagerProxy::volumeChanged(uint64_t contextId, double volume)
469 {
470     ensureModel(contextId).volumeChanged(volume);
471 }
472
473 void PlaybackSessionManagerProxy::durationChanged(uint64_t contextId, double duration)
474 {
475     ensureModel(contextId).durationChanged(duration);
476 }
477
478 void PlaybackSessionManagerProxy::playbackStartedTimeChanged(uint64_t contextId, double playbackStartedTime)
479 {
480     ensureModel(contextId).playbackStartedTimeChanged(playbackStartedTime);
481 }
482
483 void PlaybackSessionManagerProxy::rateChanged(uint64_t contextId, bool isPlaying, double rate)
484 {
485     ensureModel(contextId).rateChanged(isPlaying, rate);
486 }
487
488 void PlaybackSessionManagerProxy::pictureInPictureSupportedChanged(uint64_t contextId, bool supported)
489 {
490     ensureModel(contextId).pictureInPictureSupportedChanged(supported);
491 }
492
493 void PlaybackSessionManagerProxy::pictureInPictureActiveChanged(uint64_t contextId, bool active)
494 {
495     ensureModel(contextId).pictureInPictureActiveChanged(active);
496 }
497
498 void PlaybackSessionManagerProxy::handleControlledElementIDResponse(uint64_t contextId, String identifier) const
499 {
500 #if PLATFORM(MAC)
501     if (contextId == m_controlsManagerContextId)
502         m_page->handleControlledElementIDResponse(identifier);
503 #else
504     UNUSED_PARAM(contextId);
505     UNUSED_PARAM(identifier);
506 #endif
507 }
508
509
510 #pragma mark Messages to PlaybackSessionManager
511
512 void PlaybackSessionManagerProxy::play(uint64_t contextId)
513 {
514     m_page->send(Messages::PlaybackSessionManager::Play(contextId), m_page->pageID());
515 }
516
517 void PlaybackSessionManagerProxy::pause(uint64_t contextId)
518 {
519     m_page->send(Messages::PlaybackSessionManager::Pause(contextId), m_page->pageID());
520 }
521
522 void PlaybackSessionManagerProxy::togglePlayState(uint64_t contextId)
523 {
524     m_page->send(Messages::PlaybackSessionManager::TogglePlayState(contextId), m_page->pageID());
525 }
526
527 void PlaybackSessionManagerProxy::beginScrubbing(uint64_t contextId)
528 {
529     m_page->send(Messages::PlaybackSessionManager::BeginScrubbing(contextId), m_page->pageID());
530 }
531
532 void PlaybackSessionManagerProxy::endScrubbing(uint64_t contextId)
533 {
534     m_page->send(Messages::PlaybackSessionManager::EndScrubbing(contextId), m_page->pageID());
535 }
536
537 void PlaybackSessionManagerProxy::seekToTime(uint64_t contextId, double time, double toleranceBefore, double toleranceAfter)
538 {
539     m_page->send(Messages::PlaybackSessionManager::SeekToTime(contextId, time, toleranceBefore, toleranceAfter), m_page->pageID());
540 }
541
542 void PlaybackSessionManagerProxy::fastSeek(uint64_t contextId, double time)
543 {
544     m_page->send(Messages::PlaybackSessionManager::FastSeek(contextId, time), m_page->pageID());
545 }
546
547 void PlaybackSessionManagerProxy::beginScanningForward(uint64_t contextId)
548 {
549     m_page->send(Messages::PlaybackSessionManager::BeginScanningForward(contextId), m_page->pageID());
550 }
551
552 void PlaybackSessionManagerProxy::beginScanningBackward(uint64_t contextId)
553 {
554     m_page->send(Messages::PlaybackSessionManager::BeginScanningBackward(contextId), m_page->pageID());
555 }
556
557 void PlaybackSessionManagerProxy::endScanning(uint64_t contextId)
558 {
559     m_page->send(Messages::PlaybackSessionManager::EndScanning(contextId), m_page->pageID());
560 }
561
562 void PlaybackSessionManagerProxy::selectAudioMediaOption(uint64_t contextId, uint64_t index)
563 {
564     m_page->send(Messages::PlaybackSessionManager::SelectAudioMediaOption(contextId, index), m_page->pageID());
565 }
566
567 void PlaybackSessionManagerProxy::selectLegibleMediaOption(uint64_t contextId, uint64_t index)
568 {
569     m_page->send(Messages::PlaybackSessionManager::SelectLegibleMediaOption(contextId, index), m_page->pageID());
570 }
571
572 void PlaybackSessionManagerProxy::togglePictureInPicture(uint64_t contextId)
573 {
574     m_page->send(Messages::PlaybackSessionManager::TogglePictureInPicture(contextId), m_page->pageID());
575 }
576
577 void PlaybackSessionManagerProxy::toggleMuted(uint64_t contextId)
578 {
579     m_page->send(Messages::PlaybackSessionManager::ToggleMuted(contextId), m_page->pageID());
580 }
581
582 void PlaybackSessionManagerProxy::setMuted(uint64_t contextId, bool muted)
583 {
584     m_page->send(Messages::PlaybackSessionManager::SetMuted(contextId, muted), m_page->pageID());
585 }
586
587 void PlaybackSessionManagerProxy::setVolume(uint64_t contextId, double volume)
588 {
589     m_page->send(Messages::PlaybackSessionManager::SetVolume(contextId, volume), m_page->pageID());
590 }
591
592 void PlaybackSessionManagerProxy::setPlayingOnSecondScreen(uint64_t contextId, bool value)
593 {
594     if (m_page)
595         m_page->send(Messages::PlaybackSessionManager::SetPlayingOnSecondScreen(contextId, value), m_page->pageID());
596 }
597
598 void PlaybackSessionManagerProxy::requestControlledElementID()
599 {
600     if (m_controlsManagerContextId)
601         m_page->send(Messages::PlaybackSessionManager::HandleControlledElementIDRequest(m_controlsManagerContextId), m_page->pageID());
602 }
603
604 PlatformPlaybackSessionInterface* PlaybackSessionManagerProxy::controlsManagerInterface()
605 {
606     if (!m_controlsManagerContextId)
607         return nullptr;
608
609     auto& interface = ensureInterface(m_controlsManagerContextId);
610     return &interface;
611 }
612
613 } // namespace WebKit
614
615 #endif // PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))