Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / remoting / host / ipc_desktop_environment.h
blobfd8a6667844ba5b9e4a528f8b14cb09915722857
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 bool supports_touch_events);
50 ~IpcDesktopEnvironment() override;
52 // DesktopEnvironment implementation.
53 scoped_ptr<AudioCapturer> CreateAudioCapturer() override;
54 scoped_ptr<InputInjector> CreateInputInjector() override;
55 scoped_ptr<ScreenControls> CreateScreenControls() override;
56 scoped_ptr<webrtc::DesktopCapturer> CreateVideoCapturer() override;
57 scoped_ptr<webrtc::MouseCursorMonitor> CreateMouseCursorMonitor() override;
58 std::string GetCapabilities() const override;
59 void SetCapabilities(const std::string& capabilities) override;
60 scoped_ptr<GnubbyAuthHandler> CreateGnubbyAuthHandler(
61 protocol::ClientStub* client_stub) override;
63 private:
64 scoped_refptr<DesktopSessionProxy> desktop_session_proxy_;
66 DISALLOW_COPY_AND_ASSIGN(IpcDesktopEnvironment);
69 // Used to create IpcDesktopEnvironment objects integrating with the desktop via
70 // a helper process and talking to that process via IPC.
71 class IpcDesktopEnvironmentFactory
72 : public DesktopEnvironmentFactory,
73 public DesktopSessionConnector {
74 public:
75 // Passes a reference to the IPC channel connected to the daemon process and
76 // relevant task runners. |daemon_channel| must outlive this object.
77 IpcDesktopEnvironmentFactory(
78 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner,
79 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
80 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner,
81 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
82 IPC::Sender* daemon_channel);
83 ~IpcDesktopEnvironmentFactory() override;
85 // DesktopEnvironmentFactory implementation.
86 scoped_ptr<DesktopEnvironment> Create(
87 base::WeakPtr<ClientSessionControl> client_session_control) override;
88 void SetEnableCurtaining(bool enable) override;
89 bool SupportsAudioCapture() const override;
91 // DesktopSessionConnector implementation.
92 void ConnectTerminal(DesktopSessionProxy* desktop_session_proxy,
93 const ScreenResolution& resolution,
94 bool virtual_terminal) override;
95 void DisconnectTerminal(DesktopSessionProxy* desktop_session_proxy) override;
96 void SetScreenResolution(DesktopSessionProxy* desktop_session_proxy,
97 const ScreenResolution& resolution) override;
98 void OnDesktopSessionAgentAttached(
99 int terminal_id,
100 base::ProcessHandle desktop_process_handle,
101 IPC::PlatformFileForTransit desktop_pipe) override;
102 void OnTerminalDisconnected(int terminal_id) override;
104 // Enables or disables touch events capability.
105 void set_supports_touch_events(bool enable) {
106 supports_touch_events_ = enable;
109 private:
110 // Used to run the audio capturer.
111 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner_;
113 // Task runner on which methods of DesktopEnvironmentFactory interface should
114 // be called.
115 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_;
117 // Used to run the video capturer.
118 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_;
120 // Task runner used for running background I/O.
121 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
123 // True if curtain mode is enabled.
124 bool curtain_enabled_;
126 // IPC channel connected to the daemon process.
127 IPC::Sender* daemon_channel_;
129 // List of DesktopEnvironment instances we've told the daemon process about.
130 typedef std::map<int, DesktopSessionProxy*> ActiveConnectionsList;
131 ActiveConnectionsList active_connections_;
133 // Next desktop session ID. IDs are allocated sequentially starting from 0.
134 // This gives us more than 67 years of unique IDs assuming a new ID is
135 // allocated every second.
136 int next_id_;
138 // Factory for weak pointers to DesktopSessionConnector interface.
139 base::WeakPtrFactory<DesktopSessionConnector> connector_factory_;
141 // If true then the newly Create()ed desktop environments support touch
142 // events.
143 bool supports_touch_events_;
145 DISALLOW_COPY_AND_ASSIGN(IpcDesktopEnvironmentFactory);
148 } // namespace remoting
150 #endif // REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_H_