1/*
2 * Copyright (C) 2014 Igalia S.L.
3 * Copyright (C) 2016-2018 Apple Inc. All rights reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#include "config.h"
21#include "WebUserMediaClient.h"
22
23#if ENABLE(MEDIA_STREAM)
24
25#include "UserMediaPermissionRequestManager.h"
26#include "WebPage.h"
27#include <WebCore/UserMediaController.h>
28#include <WebCore/UserMediaRequest.h>
29
30namespace WebKit {
31using namespace WebCore;
32
33WebUserMediaClient::WebUserMediaClient(WebPage& page)
34 : m_page(page)
35{
36}
37
38void WebUserMediaClient::pageDestroyed()
39{
40 delete this;
41}
42
43void WebUserMediaClient::requestUserMediaAccess(UserMediaRequest& request)
44{
45 m_page.userMediaPermissionRequestManager().startUserMediaRequest(request);
46}
47
48void WebUserMediaClient::cancelUserMediaAccessRequest(UserMediaRequest& request)
49{
50 m_page.userMediaPermissionRequestManager().cancelUserMediaRequest(request);
51}
52
53void WebUserMediaClient::enumerateMediaDevices(MediaDevicesEnumerationRequest& request)
54{
55 m_page.userMediaPermissionRequestManager().enumerateMediaDevices(request);
56}
57
58void WebUserMediaClient::cancelMediaDevicesEnumerationRequest(MediaDevicesEnumerationRequest& request)
59{
60 m_page.userMediaPermissionRequestManager().cancelMediaDevicesEnumeration(request);
61}
62
63WebUserMediaClient::DeviceChangeObserverToken WebUserMediaClient::addDeviceChangeObserver(WTF::Function<void()>&& observer)
64{
65 return m_page.userMediaPermissionRequestManager().addDeviceChangeObserver(WTFMove(observer));
66}
67
68void WebUserMediaClient::removeDeviceChangeObserver(DeviceChangeObserverToken token)
69{
70 m_page.userMediaPermissionRequestManager().removeDeviceChangeObserver(token);
71}
72
73} // namespace WebKit;
74
75#endif // MEDIA_STREAM
76