#include "content/browser/media/captured_surface_controller.h"
#include <cmath>
#include "base/feature_list.h"
#include "base/task/bind_post_task.h"
#include "content/browser/media/captured_surface_control_permission_manager.h"
#include "content/browser/media/media_stream_web_contents_observer.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/common/features.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/global_routing_id.h"
#include "content/public/browser/host_zoom_map.h"
#include "content/public/browser/web_contents_media_capture_id.h"
#include "third_party/blink/public/common/input/synthetic_web_input_event_builders.h"
#include "third_party/blink/public/common/page/page_zoom.h"
#include "third_party/blink/public/mojom/mediastream/media_stream.mojom.h"
#include "ui/events/types/scroll_types.h"
#include "ui/gfx/geometry/size.h"
namespace content {
namespace {
CapturedSurfaceControlResult;
PermissionManager;
PermissionResult;
GetZoomLevelReplyCallback;
CapturedSurfaceInfo;
void OnZoomLevelChangeOnUI(
base::RepeatingCallback<void(int)> on_zoom_level_change_callback,
base::WeakPtr<WebContents> captured_wc,
const HostZoomMap::ZoomLevelChange& change) { … }
std::optional<CapturedSurfaceInfo> ResolveCapturedSurfaceOnUI(
WebContentsMediaCaptureId wc_id,
int subscription_version,
base::RepeatingCallback<void(int)> on_zoom_level_change_callback) { … }
CapturedSurfaceControlResult DoSendWheel(
GlobalRenderFrameHostId capturer_rfh_id,
base::WeakPtr<WebContents> captured_wc,
blink::mojom::CapturedWheelActionPtr action) { … }
CapturedSurfaceControlResult DoSetZoomLevel(
GlobalRenderFrameHostId capturer_rfh_id,
base::WeakPtr<WebContents> captured_wc,
int zoom_level) { … }
CapturedSurfaceControlResult FinalizeRequestPermission(
GlobalRenderFrameHostId capturer_rfh_id,
base::WeakPtr<WebContents> captured_wc) { … }
void OnPermissionCheckResult(
base::OnceCallback<CapturedSurfaceControlResult()> action_callback,
base::OnceCallback<void(CapturedSurfaceControlResult)> reply_callback,
PermissionResult permission_check_result) { … }
base::OnceCallback<void(PermissionResult)> ComposeCallbacks(
base::OnceCallback<CapturedSurfaceControlResult(void)> action_callback,
base::OnceCallback<void(CapturedSurfaceControlResult)> reply_callback) { … }
}
CapturedSurfaceInfo::CapturedSurfaceInfo(
base::WeakPtr<WebContents> captured_wc,
std::unique_ptr<base::CallbackListSubscription,
BrowserThread::DeleteOnUIThread> subscription,
int subscription_version,
int initial_zoom_level)
: … { … }
CapturedSurfaceInfo::CapturedSurfaceInfo(CapturedSurfaceInfo&& other) = default;
CapturedSurfaceInfo& CapturedSurfaceInfo::operator=(
CapturedSurfaceInfo&& other) = default;
CapturedSurfaceInfo::~CapturedSurfaceInfo() = default;
std::unique_ptr<CapturedSurfaceController>
CapturedSurfaceController::CreateForTesting(
GlobalRenderFrameHostId capturer_rfh_id,
WebContentsMediaCaptureId captured_wc_id,
std::unique_ptr<PermissionManager> permission_manager,
base::RepeatingCallback<void(int)> on_zoom_level_change_callback,
base::RepeatingCallback<void(base::WeakPtr<WebContents>)>
wc_resolution_callback) { … }
CapturedSurfaceController::CapturedSurfaceController(
GlobalRenderFrameHostId capturer_rfh_id,
WebContentsMediaCaptureId captured_wc_id,
base::RepeatingCallback<void(int)> on_zoom_level_change_callback)
: … { … }
CapturedSurfaceController::CapturedSurfaceController(
GlobalRenderFrameHostId capturer_rfh_id,
WebContentsMediaCaptureId captured_wc_id,
std::unique_ptr<PermissionManager> permission_manager,
base::RepeatingCallback<void(int)> on_zoom_level_change_callback,
base::RepeatingCallback<void(base::WeakPtr<WebContents>)>
wc_resolution_callback)
: … { … }
CapturedSurfaceController::~CapturedSurfaceController() = default;
void CapturedSurfaceController::UpdateCaptureTarget(
WebContentsMediaCaptureId captured_wc_id) { … }
void CapturedSurfaceController::SendWheel(
blink::mojom::CapturedWheelActionPtr action,
base::OnceCallback<void(CapturedSurfaceControlResult)> reply_callback) { … }
void CapturedSurfaceController::SetZoomLevel(
int zoom_level,
base::OnceCallback<void(CapturedSurfaceControlResult)> reply_callback) { … }
void CapturedSurfaceController::RequestPermission(
base::OnceCallback<void(CapturedSurfaceControlResult)> reply_callback) { … }
void CapturedSurfaceController::ResolveCapturedSurface(
WebContentsMediaCaptureId captured_wc_id) { … }
void CapturedSurfaceController::OnCapturedSurfaceResolved(
std::optional<CapturedSurfaceInfo> captured_surface_info) { … }
void CapturedSurfaceController::OnZoomLevelChange(
int zoom_level_subscription_version,
int zoom_level) { … }
}