#include "remoting/host/desktop_session_proxy.h"
#include <stddef.h>
#include <memory>
#include <utility>
#include "base/compiler_specific.h"
#include "base/containers/map_util.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/notreached.h"
#include "base/process/process_handle.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
#include "ipc/ipc_channel_proxy.h"
#include "remoting/base/capabilities.h"
#include "remoting/host/client_session.h"
#include "remoting/host/client_session_control.h"
#include "remoting/host/crash_process.h"
#include "remoting/host/desktop_session_connector.h"
#include "remoting/host/ipc_action_executor.h"
#include "remoting/host/ipc_audio_capturer.h"
#include "remoting/host/ipc_input_injector.h"
#include "remoting/host/ipc_keyboard_layout_monitor.h"
#include "remoting/host/ipc_mouse_cursor_monitor.h"
#include "remoting/host/ipc_screen_controls.h"
#include "remoting/host/ipc_url_forwarder_configurator.h"
#include "remoting/host/ipc_video_frame_capturer.h"
#include "remoting/host/mojom/desktop_session.mojom.h"
#include "remoting/host/remote_open_url/remote_open_url_util.h"
#include "remoting/host/webauthn/remote_webauthn_delegated_state_change_notifier.h"
#include "remoting/proto/audio.pb.h"
#include "remoting/proto/control.pb.h"
#include "remoting/proto/event.pb.h"
#include "remoting/protocol/capability_names.h"
#include "third_party/webrtc/modules/desktop_capture/mouse_cursor.h"
namespace remoting {
using SetUpUrlForwarderResponse =
protocol::UrlForwarderControl::SetUpUrlForwarderResponse;
DesktopSessionProxy::DesktopSessionProxy(
scoped_refptr<base::SingleThreadTaskRunner> audio_capture_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
base::WeakPtr<ClientSessionControl> client_session_control,
base::WeakPtr<ClientSessionEvents> client_session_events,
base::WeakPtr<DesktopSessionConnector> desktop_session_connector,
const DesktopEnvironmentOptions& options)
: … { … }
std::unique_ptr<ActionExecutor> DesktopSessionProxy::CreateActionExecutor() { … }
std::unique_ptr<AudioCapturer> DesktopSessionProxy::CreateAudioCapturer() { … }
std::unique_ptr<InputInjector> DesktopSessionProxy::CreateInputInjector() { … }
std::unique_ptr<ScreenControls> DesktopSessionProxy::CreateScreenControls() { … }
std::unique_ptr<DesktopCapturer> DesktopSessionProxy::CreateVideoCapturer(
webrtc::ScreenId id) { … }
std::unique_ptr<webrtc::MouseCursorMonitor>
DesktopSessionProxy::CreateMouseCursorMonitor() { … }
std::unique_ptr<KeyboardLayoutMonitor>
DesktopSessionProxy::CreateKeyboardLayoutMonitor(
base::RepeatingCallback<void(const protocol::KeyboardLayout&)> callback) { … }
std::unique_ptr<FileOperations> DesktopSessionProxy::CreateFileOperations() { … }
std::unique_ptr<UrlForwarderConfigurator>
DesktopSessionProxy::CreateUrlForwarderConfigurator() { … }
std::unique_ptr<RemoteWebAuthnStateChangeNotifier>
DesktopSessionProxy::CreateRemoteWebAuthnStateChangeNotifier() { … }
std::string DesktopSessionProxy::GetCapabilities() const { … }
void DesktopSessionProxy::SetCapabilities(const std::string& capabilities) { … }
bool DesktopSessionProxy::OnMessageReceived(const IPC::Message& message) { … }
void DesktopSessionProxy::OnChannelConnected(int32_t peer_pid) { … }
void DesktopSessionProxy::OnChannelError() { … }
void DesktopSessionProxy::OnAssociatedInterfaceRequest(
const std::string& interface_name,
mojo::ScopedInterfaceEndpointHandle handle) { … }
bool DesktopSessionProxy::AttachToDesktop(
mojo::ScopedMessagePipeHandle desktop_pipe,
int session_id) { … }
void DesktopSessionProxy::DetachFromDesktop() { … }
void DesktopSessionProxy::OnDesktopSessionAgentStarted(
mojo::PendingAssociatedRemote<mojom::DesktopSessionControl>
pending_remote) { … }
void DesktopSessionProxy::SetAudioCapturer(
const base::WeakPtr<IpcAudioCapturer>& audio_capturer) { … }
void DesktopSessionProxy::SetMouseCursorMonitor(
const base::WeakPtr<IpcMouseCursorMonitor>& mouse_cursor_monitor) { … }
void DesktopSessionProxy::SetKeyboardLayoutMonitor(
const base::WeakPtr<IpcKeyboardLayoutMonitor>& keyboard_layout_monitor) { … }
void DesktopSessionProxy::RebindSingleVideoCapturer(
webrtc::ScreenId new_id,
base::WeakPtr<IpcVideoFrameCapturer> capturer_weakptr) { … }
const std::optional<protocol::KeyboardLayout>&
DesktopSessionProxy::GetKeyboardCurrentLayout() const { … }
void DesktopSessionProxy::DisconnectSession(protocol::ErrorCode error) { … }
void DesktopSessionProxy::InjectClipboardEvent(
const protocol::ClipboardEvent& event) { … }
void DesktopSessionProxy::InjectKeyEvent(const protocol::KeyEvent& event) { … }
void DesktopSessionProxy::InjectTextEvent(const protocol::TextEvent& event) { … }
void DesktopSessionProxy::InjectMouseEvent(const protocol::MouseEvent& event) { … }
void DesktopSessionProxy::InjectTouchEvent(const protocol::TouchEvent& event) { … }
void DesktopSessionProxy::StartInputInjector(
std::unique_ptr<protocol::ClipboardStub> client_clipboard) { … }
void DesktopSessionProxy::SetScreenResolution(
const ScreenResolution& resolution) { … }
void DesktopSessionProxy::ExecuteAction(
const protocol::ActionRequest& request) { … }
void DesktopSessionProxy::BeginFileRead(
IpcFileOperations::BeginFileReadCallback callback,
base::OnceClosure on_disconnect) { … }
void DesktopSessionProxy::BeginFileWrite(
const base::FilePath& file_path,
IpcFileOperations::BeginFileWriteCallback callback,
base::OnceClosure on_disconnect) { … }
void DesktopSessionProxy::IsUrlForwarderSetUp(
UrlForwarderConfigurator::IsUrlForwarderSetUpCallback callback) { … }
void DesktopSessionProxy::SetUpUrlForwarder(
const UrlForwarderConfigurator::SetUpUrlForwarderCallback& callback) { … }
void DesktopSessionProxy::OnUrlForwarderStateChange(
mojom::UrlForwarderState state) { … }
DesktopSessionProxy::~DesktopSessionProxy() { … }
void DesktopSessionProxy::OnAudioPacket(
std::unique_ptr<AudioPacket> audio_packet) { … }
void DesktopSessionProxy::OnDesktopDisplayChanged(
const protocol::VideoLayout& displays) { … }
void DesktopSessionProxy::OnBeginFileReadResult(
IpcFileOperations::BeginFileReadCallback callback,
base::CallbackListSubscription disconnect_handler_subscription,
mojom::BeginFileReadResultPtr result) { … }
void DesktopSessionProxy::OnBeginFileWriteResult(
IpcFileOperations::BeginFileWriteCallback callback,
base::CallbackListSubscription disconnect_handler_subscription,
mojom::BeginFileWriteResultPtr result) { … }
void DesktopSessionProxy::OnMouseCursorChanged(
const webrtc::MouseCursor& mouse_cursor) { … }
void DesktopSessionProxy::OnKeyboardLayoutChanged(
const protocol::KeyboardLayout& layout) { … }
void DesktopSessionProxy::OnClipboardEvent(
const protocol::ClipboardEvent& event) { … }
void DesktopSessionProxy::SignalWebAuthnExtension() { … }
void DesktopSessionProxy::RequestMojoVideoCapturer(
webrtc::ScreenId id,
base::WeakPtr<IpcVideoFrameCapturer> capturer) { … }
}