Revert of Remove OneClickSigninHelper since it is no longer used. (patchset #5 id...
[chromium-blink-merge.git] / remoting / host / ipc_desktop_environment.h
blobb1dd8611b5f19a3c8e76b1c938d1582c8329d344
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.
5 #ifndef REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_H_
6 #define REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_H_
8 #include <map>
9 #include <string>
11 #include "base/basictypes.h"
12 #include "base/callback_forward.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h"
16 #include "remoting/host/desktop_environment.h"
17 #include "remoting/host/desktop_session_connector.h"
19 namespace base {
20 class SingleThreadTaskRunner;
21 } // base
23 namespace IPC {
24 class Sender;
25 } // namespace IPC
27 namespace remoting {
29 class ClientSessionControl;
30 class DesktopSessionProxy;
31 class GnubbyAuthHandler;
32 class ScreenResolution;
34 // A variant of desktop environment integrating with the desktop by means of
35 // a helper process and talking to that process via IPC.
36 class IpcDesktopEnvironment : public DesktopEnvironment {
37 public:
38 // |desktop_session_connector| is used to bind DesktopSessionProxy to
39 // a desktop session, to be notified every time the desktop process is
40 // restarted.
41 IpcDesktopEnvironment(
42 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner,
43 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
44 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner,
45 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
46 base::WeakPtr<ClientSessionControl> client_session_control,
47 base::WeakPtr<DesktopSessionConnector> desktop_session_connector,
48 bool virtual_terminal);
49 ~IpcDesktopEnvironment() override;
51 // DesktopEnvironment implementation.
52 scoped_ptr<AudioCapturer> CreateAudioCapturer() override;
53 scoped_ptr<InputInjector> CreateInputInjector() override;
54 scoped_ptr<ScreenControls> CreateScreenControls() override;
55 scoped_ptr<webrtc::DesktopCapturer> CreateVideoCapturer() override;
56 scoped_ptr<webrtc::MouseCursorMonitor> CreateMouseCursorMonitor() override;
57 std::string GetCapabilities() const override;
58 void SetCapabilities(const std::string& capabilities) override;
59 scoped_ptr<GnubbyAuthHandler> CreateGnubbyAuthHandler(
60 protocol::ClientStub* client_stub) override;
62 private:
63 scoped_refptr<DesktopSessionProxy> desktop_session_proxy_;
65 DISALLOW_COPY_AND_ASSIGN(IpcDesktopEnvironment);
68 // Used to create IpcDesktopEnvironment objects integrating with the desktop via
69 // a helper process and talking to that process via IPC.
70 class IpcDesktopEnvironmentFactory
71 : public DesktopEnvironmentFactory,
72 public DesktopSessionConnector {
73 public:
74 // Passes a reference to the IPC channel connected to the daemon process and
75 // relevant task runners. |daemon_channel| must outlive this object.
76 IpcDesktopEnvironmentFactory(
77 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner,
78 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
79 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner,
80 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
81 IPC::Sender* daemon_channel);
82 ~IpcDesktopEnvironmentFactory() override;
84 // DesktopEnvironmentFactory implementation.
85 scoped_ptr<DesktopEnvironment> Create(
86 base::WeakPtr<ClientSessionControl> client_session_control) override;
87 void SetEnableCurtaining(bool enable) override;
88 bool SupportsAudioCapture() const override;
90 // DesktopSessionConnector implementation.
91 void ConnectTerminal(DesktopSessionProxy* desktop_session_proxy,
92 const ScreenResolution& resolution,
93 bool virtual_terminal) override;
94 void DisconnectTerminal(DesktopSessionProxy* desktop_session_proxy) override;
95 void SetScreenResolution(DesktopSessionProxy* desktop_session_proxy,
96 const ScreenResolution& resolution) override;
97 void OnDesktopSessionAgentAttached(
98 int terminal_id,
99 base::ProcessHandle desktop_process_handle,
100 IPC::PlatformFileForTransit desktop_pipe) override;
101 void OnTerminalDisconnected(int terminal_id) override;
103 private:
104 // Used to run the audio capturer.
105 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner_;
107 // Task runner on which methods of DesktopEnvironmentFactory interface should
108 // be called.
109 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_;
111 // Used to run the video capturer.
112 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_;
114 // Task runner used for running background I/O.
115 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
117 // True if curtain mode is enabled.
118 bool curtain_enabled_;
120 // IPC channel connected to the daemon process.
121 IPC::Sender* daemon_channel_;
123 // List of DesktopEnvironment instances we've told the daemon process about.
124 typedef std::map<int, DesktopSessionProxy*> ActiveConnectionsList;
125 ActiveConnectionsList active_connections_;
127 // Next desktop session ID. IDs are allocated sequentially starting from 0.
128 // This gives us more than 67 years of unique IDs assuming a new ID is
129 // allocated every second.
130 int next_id_;
132 // Factory for weak pointers to DesktopSessionConnector interface.
133 base::WeakPtrFactory<DesktopSessionConnector> connector_factory_;
135 DISALLOW_COPY_AND_ASSIGN(IpcDesktopEnvironmentFactory);
138 } // namespace remoting
140 #endif // REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_H_