#include "content/browser/renderer_host/media/media_stream_ui_proxy.h"
#include <utility>
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "build/build_config.h"
#include "content/browser/renderer_host/render_frame_host_delegate.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/desktop_media_id.h"
#include "content/public/browser/media_stream_request.h"
#include "content/public/common/content_switches.h"
#include "media/capture/video/fake_video_capture_device.h"
#include "third_party/blink/public/common/mediastream/media_stream_request.h"
#include "third_party/blink/public/mojom/mediastream/media_stream.mojom.h"
#include "third_party/blink/public/mojom/permissions_policy/permissions_policy.mojom.h"
#include "url/gurl.h"
#include "url/origin.h"
namespace content {
bool IsFeatureEnabled(RenderFrameHost* rfh,
bool tests_use_fake_render_frame_hosts,
blink::mojom::PermissionsPolicyFeature feature) { … }
class MediaStreamUIProxy::Core { … };
MediaStreamUIProxy::Core::Core(const base::WeakPtr<MediaStreamUIProxy>& proxy,
RenderFrameHostDelegate* test_render_delegate)
: … { … }
MediaStreamUIProxy::Core::~Core() { … }
void MediaStreamUIProxy::Core::RequestAccess(
std::unique_ptr<MediaStreamRequest> request) { … }
void MediaStreamUIProxy::Core::OnStarted(
gfx::NativeViewId* window_id,
bool has_source_callback,
const std::string& label,
std::vector<DesktopMediaID> screen_share_ids) { … }
void MediaStreamUIProxy::Core::OnDeviceStopped(const std::string& label,
const DesktopMediaID& media_id) { … }
void MediaStreamUIProxy::Core::OnDeviceStoppedForSourceChange(
const std::string& label,
const DesktopMediaID& old_media_id,
const DesktopMediaID& new_media_id,
bool captured_surface_control_active) { … }
void MediaStreamUIProxy::Core::OnRegionCaptureRectChanged(
const std::optional<gfx::Rect>& region_capture_rec) { … }
#if !BUILDFLAG(IS_ANDROID)
void MediaStreamUIProxy::Core::SetFocus(const DesktopMediaID& media_id,
bool focus,
bool is_from_microtask,
bool is_from_timer) { … }
#endif
void MediaStreamUIProxy::Core::ProcessAccessRequestResponseForPostTask(
int render_process_id,
int render_frame_id,
blink::mojom::StreamDevicesSetPtr stream_devices_set_ptr,
blink::mojom::MediaStreamRequestResult result,
std::unique_ptr<MediaStreamUI> stream_ui) { … }
void MediaStreamUIProxy::Core::ProcessAccessRequestResponse(
int render_process_id,
int render_frame_id,
const blink::mojom::StreamDevicesSet& stream_devices_set,
blink::mojom::MediaStreamRequestResult result,
std::unique_ptr<MediaStreamUI> stream_ui) { … }
void MediaStreamUIProxy::Core::ProcessStopRequestFromUI() { … }
void MediaStreamUIProxy::Core::ProcessChangeSourceRequestFromUI(
const DesktopMediaID& media_id,
bool captured_surface_control_active) { … }
void MediaStreamUIProxy::Core::ProcessStateChangeFromUI(
const DesktopMediaID& media_id,
blink::mojom::MediaStreamStateChange new_state) { … }
RenderFrameHostDelegate* MediaStreamUIProxy::Core::GetRenderFrameHostDelegate(
int render_process_id,
int render_frame_id) { … }
std::unique_ptr<MediaStreamUIProxy> MediaStreamUIProxy::Create() { … }
std::unique_ptr<MediaStreamUIProxy> MediaStreamUIProxy::CreateForTests(
RenderFrameHostDelegate* render_delegate) { … }
MediaStreamUIProxy::MediaStreamUIProxy(
RenderFrameHostDelegate* test_render_delegate) { … }
MediaStreamUIProxy::~MediaStreamUIProxy() { … }
void MediaStreamUIProxy::RequestAccess(
std::unique_ptr<MediaStreamRequest> request,
ResponseCallback response_callback) { … }
void MediaStreamUIProxy::OnStarted(
base::OnceClosure stop_callback,
MediaStreamUI::SourceCallback source_callback,
WindowIdCallback window_id_callback,
const std::string& label,
std::vector<DesktopMediaID> screen_share_ids,
MediaStreamUI::StateChangeCallback state_change_callback) { … }
void MediaStreamUIProxy::OnDeviceStopped(const std::string& label,
const DesktopMediaID& media_id) { … }
void MediaStreamUIProxy::OnDeviceStoppedForSourceChange(
const std::string& label,
const DesktopMediaID& old_media_id,
const DesktopMediaID& new_media_id,
bool captured_surface_control_active) { … }
void MediaStreamUIProxy::OnRegionCaptureRectChanged(
const std::optional<gfx::Rect>& region_capture_rec) { … }
#if !BUILDFLAG(IS_ANDROID)
void MediaStreamUIProxy::SetFocus(const DesktopMediaID& media_id,
bool focus,
bool is_from_microtask,
bool is_from_timer) { … }
#endif
void MediaStreamUIProxy::ProcessAccessRequestResponse(
blink::mojom::StreamDevicesSetPtr stream_devices_set,
blink::mojom::MediaStreamRequestResult result) { … }
void MediaStreamUIProxy::ProcessStopRequestFromUI() { … }
void MediaStreamUIProxy::ProcessChangeSourceRequestFromUI(
const DesktopMediaID& media_id,
bool captured_surface_control_active) { … }
void MediaStreamUIProxy::ProcessStateChangeFromUI(
const DesktopMediaID& media_id,
blink::mojom::MediaStreamStateChange new_state) { … }
void MediaStreamUIProxy::OnWindowId(WindowIdCallback window_id_callback,
gfx::NativeViewId* window_id) { … }
FakeMediaStreamUIProxy::FakeMediaStreamUIProxy(
bool tests_use_fake_render_frame_hosts)
: … { … }
FakeMediaStreamUIProxy::~FakeMediaStreamUIProxy() = default;
void FakeMediaStreamUIProxy::SetAvailableDevices(
const blink::MediaStreamDevices& devices) { … }
void FakeMediaStreamUIProxy::SetMicAccess(bool access) { … }
void FakeMediaStreamUIProxy::SetCameraAccess(bool access) { … }
void FakeMediaStreamUIProxy::SetAudioShare(bool audio_share) { … }
void FakeMediaStreamUIProxy::RequestAccess(
std::unique_ptr<MediaStreamRequest> request,
ResponseCallback response_callback) { … }
void FakeMediaStreamUIProxy::OnStarted(
base::OnceClosure stop_callback,
MediaStreamUI::SourceCallback source_callback,
WindowIdCallback window_id_callback,
const std::string& label,
std::vector<DesktopMediaID> screen_share_ids,
MediaStreamUI::StateChangeCallback state_change_callback) { … }
void FakeMediaStreamUIProxy::OnDeviceStopped(const std::string& label,
const DesktopMediaID& media_id) { … }
void FakeMediaStreamUIProxy::OnDeviceStoppedForSourceChange(
const std::string& label,
const DesktopMediaID& old_media_id,
const DesktopMediaID& new_media_id,
bool captured_surface_control_active) { … }
}