#include "remoting/host/desktop_session_agent.h"
#include <memory>
#include <utility>
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/platform_shared_memory_region.h"
#include "base/memory/ptr_util.h"
#include "base/memory/read_only_shared_memory_region.h"
#include "base/memory/weak_ptr.h"
#include "base/notreached.h"
#include "base/process/process_handle.h"
#include "base/task/bind_post_task.h"
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
#include "ipc/ipc_channel_proxy.h"
#include "ipc/ipc_message.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "remoting/base/auto_thread_task_runner.h"
#include "remoting/base/constants.h"
#include "remoting/host/action_executor.h"
#include "remoting/host/audio_capturer.h"
#include "remoting/host/base/screen_controls.h"
#include "remoting/host/base/screen_resolution.h"
#include "remoting/host/crash_process.h"
#include "remoting/host/desktop_display_info_monitor.h"
#include "remoting/host/desktop_environment.h"
#include "remoting/host/input_injector.h"
#include "remoting/host/keyboard_layout_monitor.h"
#include "remoting/host/mojom/desktop_session.mojom-shared.h"
#include "remoting/host/remote_input_filter.h"
#include "remoting/host/remote_open_url/url_forwarder_configurator.h"
#include "remoting/host/video_memory_utils.h"
#include "remoting/host/webauthn/remote_webauthn_state_change_notifier.h"
#include "remoting/proto/action.pb.h"
#include "remoting/proto/audio.pb.h"
#include "remoting/proto/control.pb.h"
#include "remoting/proto/event.pb.h"
#include "remoting/protocol/clipboard_stub.h"
#include "remoting/protocol/desktop_capturer.h"
#include "remoting/protocol/errors.h"
#include "remoting/protocol/input_event_tracker.h"
#include "third_party/webrtc/modules/desktop_capture/mouse_cursor.h"
namespace remoting {
namespace {
using SetUpUrlForwarderResponse =
protocol::UrlForwarderControl::SetUpUrlForwarderResponse;
class DesktopSessionClipboardStub : public protocol::ClipboardStub { … };
DesktopSessionClipboardStub::DesktopSessionClipboardStub(
scoped_refptr<DesktopSessionAgent> desktop_session_agent)
: … { … }
DesktopSessionClipboardStub::~DesktopSessionClipboardStub() = default;
void DesktopSessionClipboardStub::InjectClipboardEvent(
const protocol::ClipboardEvent& event) { … }
}
DesktopSessionAgent::Delegate::~Delegate() = default;
DesktopSessionAgent::DesktopSessionAgent(
scoped_refptr<AutoThreadTaskRunner> audio_capture_task_runner,
scoped_refptr<AutoThreadTaskRunner> caller_task_runner,
scoped_refptr<AutoThreadTaskRunner> input_task_runner,
scoped_refptr<AutoThreadTaskRunner> io_task_runner)
: … { … }
bool DesktopSessionAgent::OnMessageReceived(const IPC::Message& message) { … }
void DesktopSessionAgent::OnChannelConnected(int32_t peer_pid) { … }
void DesktopSessionAgent::OnChannelError() { … }
void DesktopSessionAgent::OnAssociatedInterfaceRequest(
const std::string& interface_name,
mojo::ScopedInterfaceEndpointHandle handle) { … }
DesktopSessionAgent::~DesktopSessionAgent() { … }
const std::string& DesktopSessionAgent::client_jid() const { … }
void DesktopSessionAgent::DisconnectSession(protocol::ErrorCode error) { … }
void DesktopSessionAgent::OnLocalKeyPressed(uint32_t usb_keycode) { … }
void DesktopSessionAgent::OnLocalPointerMoved(
const webrtc::DesktopVector& new_pos,
ui::EventType type) { … }
void DesktopSessionAgent::SetDisableInputs(bool disable_inputs) { … }
void DesktopSessionAgent::OnDesktopDisplayChanged(
std::unique_ptr<protocol::VideoLayout> layout) { … }
void DesktopSessionAgent::Start(
const std::string& authenticated_jid,
const ScreenResolution& resolution,
const remoting::DesktopEnvironmentOptions& options,
StartCallback callback) { … }
void DesktopSessionAgent::OnMouseCursor(webrtc::MouseCursor* cursor) { … }
void DesktopSessionAgent::OnMouseCursorPosition(
const webrtc::DesktopVector& position) { … }
void DesktopSessionAgent::OnClipboardEvent(
const protocol::ClipboardEvent& event) { … }
void DesktopSessionAgent::ProcessAudioPacket(
std::unique_ptr<AudioPacket> packet) { … }
mojo::ScopedMessagePipeHandle DesktopSessionAgent::Initialize(
const base::WeakPtr<Delegate>& delegate) { … }
void DesktopSessionAgent::Stop() { … }
void DesktopSessionAgent::CreateVideoCapturer(
int64_t desktop_display_id,
CreateVideoCapturerCallback callback) { … }
void DesktopSessionAgent::InjectClipboardEvent(
const protocol::ClipboardEvent& event) { … }
void DesktopSessionAgent::InjectKeyEvent(const protocol::KeyEvent& event) { … }
void DesktopSessionAgent::InjectTextEvent(const protocol::TextEvent& event) { … }
void DesktopSessionAgent::InjectMouseEvent(const protocol::MouseEvent& event) { … }
void DesktopSessionAgent::InjectTouchEvent(const protocol::TouchEvent& event) { … }
void DesktopSessionAgent::InjectSendAttentionSequence() { … }
void DesktopSessionAgent::LockWorkstation() { … }
void DesktopSessionAgent::OnKeyboardLayoutChange(
const protocol::KeyboardLayout& layout) { … }
void DesktopSessionAgent::SetScreenResolution(
const ScreenResolution& resolution) { … }
void DesktopSessionAgent::StartAudioCapturer() { … }
void DesktopSessionAgent::StopAudioCapturer() { … }
void DesktopSessionAgent::SetUpUrlForwarder() { … }
void DesktopSessionAgent::SignalWebAuthnExtension() { … }
void DesktopSessionAgent::BeginFileRead(BeginFileReadCallback callback) { … }
void DesktopSessionAgent::BeginFileWrite(const base::FilePath& file_path,
BeginFileWriteCallback callback) { … }
void DesktopSessionAgent::OnCheckUrlForwarderSetUpResult(bool is_set_up) { … }
void DesktopSessionAgent::OnUrlForwarderSetUpStateChanged(
SetUpUrlForwarderResponse::State state) { … }
}