1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef REMOTING_PROTOCOL_CLIENT_CONTROL_DISPATCHER_H_ 6 #define REMOTING_PROTOCOL_CLIENT_CONTROL_DISPATCHER_H_ 7 8 #include "base/macros.h" 9 #include "base/memory/ref_counted.h" 10 #include "remoting/protocol/channel_dispatcher_base.h" 11 #include "remoting/protocol/clipboard_stub.h" 12 #include "remoting/protocol/cursor_shape_stub.h" 13 #include "remoting/protocol/host_stub.h" 14 15 namespace remoting { 16 namespace protocol { 17 18 class ClientStub; 19 20 // ClientControlDispatcher dispatches incoming messages on the control 21 // channel to ClientStub, ClipboardStub or CursorShapeStub. 22 // It also implements ClipboardStub and HostStub for outgoing messages. 23 class ClientControlDispatcher : public ChannelDispatcherBase, 24 public ClipboardStub, 25 public HostStub { 26 public: 27 ClientControlDispatcher(); 28 ~ClientControlDispatcher() override; 29 30 // ClipboardStub implementation. 31 void InjectClipboardEvent(const ClipboardEvent& event) override; 32 33 // HostStub implementation. 34 void NotifyClientResolution(const ClientResolution& resolution) override; 35 void ControlVideo(const VideoControl& video_control) override; 36 void ControlAudio(const AudioControl& audio_control) override; 37 void SetCapabilities(const Capabilities& capabilities) override; 38 void RequestPairing(const PairingRequest& pairing_request) override; 39 void DeliverClientMessage(const ExtensionMessage& message) override; 40 void SelectDesktopDisplay( 41 const SelectDesktopDisplayRequest& select_display) override; 42 void ControlPeerConnection( 43 const protocol::PeerConnectionParameters& parameters) override; 44 45 // Sets the ClientStub that will be called for each incoming control 46 // message. |client_stub| must outlive this object. set_client_stub(ClientStub * client_stub)47 void set_client_stub(ClientStub* client_stub) { client_stub_ = client_stub; } 48 49 // Sets the ClipboardStub that will be called for each incoming clipboard 50 // message. |clipboard_stub| must outlive this object. set_clipboard_stub(ClipboardStub * clipboard_stub)51 void set_clipboard_stub(ClipboardStub* clipboard_stub) { 52 clipboard_stub_ = clipboard_stub; 53 } 54 55 private: 56 void OnIncomingMessage(std::unique_ptr<CompoundBuffer> message) override; 57 58 ClientStub* client_stub_ = nullptr; 59 ClipboardStub* clipboard_stub_ = nullptr; 60 61 DISALLOW_COPY_AND_ASSIGN(ClientControlDispatcher); 62 }; 63 64 } // namespace protocol 65 } // namespace remoting 66 67 #endif // REMOTING_PROTOCOL_CLIENT_CONTROL_DISPATCHER_H_ 68