#ifndef REMOTING_CLIENT_CHROMOTING_SESSION_H_
#define REMOTING_CLIENT_CHROMOTING_SESSION_H_
#include <memory>
#include <string>
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "remoting/client/chromoting_client.h"
#include "remoting/client/client_context.h"
#include "remoting/client/client_telemetry_logger.h"
#include "remoting/client/client_user_interface.h"
#include "remoting/client/connect_to_host_info.h"
#include "remoting/client/feedback_data.h"
#include "remoting/client/input/client_input_injector.h"
#include "remoting/proto/control.pb.h"
#include "remoting/proto/event.pb.h"
#include "remoting/protocol/clipboard_stub.h"
#include "remoting/protocol/cursor_shape_stub.h"
#include "remoting/signaling/ftl_device_id_provider.h"
#include "remoting/signaling/signal_strategy.h"
namespace remoting {
namespace protocol {
class AudioStub;
class VideoRenderer;
}
class ChromotingClientRuntime;
class ChromotingSession : public ClientInputInjector {
public:
class Delegate {
public:
virtual ~Delegate() {}
virtual void OnConnectionState(protocol::ConnectionToHost::State state,
protocol::ErrorCode error) = 0;
virtual void CommitPairingCredentials(const std::string& host,
const std::string& id,
const std::string& secret) = 0;
virtual void FetchSecret(
bool pairing_supported,
const protocol::SecretFetchedCallback& secret_fetched_callback) = 0;
virtual void FetchThirdPartyToken(
const std::string& token_url,
const std::string& client_id,
const std::string& scopes,
const protocol::ThirdPartyTokenFetchedCallback&
token_fetched_callback) = 0;
virtual void SetCapabilities(const std::string& capabilities) = 0;
virtual void HandleExtensionMessage(const std::string& type,
const std::string& message) = 0;
};
using GetFeedbackDataCallback =
base::OnceCallback<void(std::unique_ptr<FeedbackData>)>;
ChromotingSession(base::WeakPtr<ChromotingSession::Delegate> delegate,
std::unique_ptr<protocol::CursorShapeStub> cursor_stub,
std::unique_ptr<protocol::VideoRenderer> video_renderer,
std::unique_ptr<protocol::AudioStub> audio_player,
const ConnectToHostInfo& info);
ChromotingSession(const ChromotingSession&) = delete;
ChromotingSession& operator=(const ChromotingSession&) = delete;
~ChromotingSession() override;
void GetFeedbackData(GetFeedbackDataCallback callback) const;
void RequestPairing(const std::string& device_name);
void SendMouseEvent(int x,
int y,
protocol::MouseEvent_MouseButton button,
bool button_down);
void SendMouseWheelEvent(int delta_x, int delta_y);
bool SendKeyEvent(int scan_code, int key_code, bool key_down) override;
void SendTextEvent(const std::string& text) override;
void SendTouchEvent(const protocol::TouchEvent& touch_event);
void SendClientResolution(int dips_width, int dips_height, float scale);
void EnableVideoChannel(bool enable);
void SendClientMessage(const std::string& type, const std::string& data);
private:
class Core;
template <typename Functor, typename... Args>
void RunCoreTaskOnNetworkThread(const base::Location& from_here,
Functor&& core_functor,
Args&&... args);
const raw_ptr<ChromotingClientRuntime> runtime_;
std::unique_ptr<Core> core_;
};
}
#endif