Chromium Code Reviews| Index: content/browser/renderer_host/media/media_devices_dispatcher_host.h |
| diff --git a/content/browser/renderer_host/media/media_devices_dispatcher_host.h b/content/browser/renderer_host/media/media_devices_dispatcher_host.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5ee7cbd3ac07ec685fd116066f53ed1c772e4016 |
| --- /dev/null |
| +++ b/content/browser/renderer_host/media/media_devices_dispatcher_host.h |
| @@ -0,0 +1,101 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_DEVICES_DISPATCHER_HOST_H_ |
| +#define CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_DEVICES_DISPATCHER_HOST_H_ |
| + |
| +#include <memory> |
| +#include <string> |
| + |
| +#include "base/macros.h" |
| +#include "content/browser/renderer_host/media/media_devices_manager.h" |
| +#include "content/common/content_export.h" |
| +#include "content/common/media/media_devices.mojom.h" |
| + |
| +using ::mojom::MediaDeviceType; |
| + |
| +namespace url { |
| +class Origin; |
| +} |
| + |
| +namespace content { |
| + |
| +class MediaStreamManager; |
| +class MediaStreamUIProxy; |
| + |
| +class CONTENT_EXPORT MediaDevicesDispatcherHost |
| + : public ::mojom::MediaDevicesDispatcherHost { |
| + public: |
| + MediaDevicesDispatcherHost(int render_process_id, |
| + int routing_id, |
| + const std::string& device_id_salt, |
| + MediaStreamManager* media_stream_manager, |
| + bool use_fake_ui); |
| + ~MediaDevicesDispatcherHost() override; |
| + |
| + static void Create(int render_process_id, |
| + int routing_id, |
| + const std::string& device_id_salt, |
| + MediaStreamManager* media_stream_manager, |
| + bool use_fake_ui, |
| + ::mojom::MediaDevicesDispatcherHostRequest request); |
| + |
| + // ::mojom::MediaDevicesDispatcherHost implementation. |
| + void EnumerateDevices( |
| + bool request_audio_input, |
| + bool request_video_input, |
| + bool request_audio_output, |
| + const url::Origin& security_origin, |
| + const EnumerateDevicesCallback& client_callback) override; |
| + |
| + private: |
| + // Friend the unit test to allow it to manually set the UI proxy. |
| + friend class MediaDevicesDispatcherHostTest; |
|
hta - Chromium
2016/09/30 08:38:12
If this is the only reason to friend the unit test
Guido Urdaneta
2016/10/07 17:07:13
Done.
|
| + |
| + // Internal type that represents a callback that receives a |
| + // MediaDevicesManager::BoolDeviceTypes containing the permissions for each |
| + // device type. |
| + using AccessCheckedCallback = |
| + base::Callback<void(const MediaDevicesManager::BoolDeviceTypes&)>; |
| + |
| + void AudioAccessChecked(std::unique_ptr<MediaStreamUIProxy> ui_proxy, |
| + bool check_video_permission, |
| + const url::Origin& security_origin, |
| + AccessCheckedCallback callback, |
| + bool has_audio_permission); |
| + void VideoAccessChecked(std::unique_ptr<MediaStreamUIProxy> ui_proxy, |
| + bool has_audio_permission, |
| + AccessCheckedCallback callback, |
| + bool has_video_permission); |
| + void DoEnumerateDevices( |
| + const MediaDevicesManager::BoolDeviceTypes& requested_types, |
| + const url::Origin& security_origin, |
| + const EnumerateDevicesCallback& client_callback, |
| + const MediaDevicesManager::BoolDeviceTypes& permissions); |
| + void DevicesEnumerated( |
| + const MediaDevicesManager::BoolDeviceTypes& requested_types, |
| + const url::Origin& security_origin, |
| + const EnumerateDevicesCallback& client_callback, |
| + const MediaDevicesManager::BoolDeviceTypes& has_permissions, |
| + const MediaDeviceEnumeration& enumeration); |
| + |
| + std::unique_ptr<MediaStreamUIProxy> GetUIProxy(); |
| + void SetFakeUIProxy(std::unique_ptr<MediaStreamUIProxy> fake_ui_proxy); |
| + |
| + int render_process_id_; |
| + int routing_id_; |
| + std::string device_id_salt_; |
| + std::string group_id_salt_; |
| + MediaStreamManager* media_stream_manager_; |
| + bool use_fake_ui_; |
| + std::unique_ptr<MediaStreamUIProxy> fake_ui_proxy_; |
| + |
| + base::WeakPtrFactory<MediaDevicesDispatcherHost> weak_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(MediaDevicesDispatcherHost); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_DEVICES_DISPATCHER_HOST_H_ |