OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef REMOTING_HOST_DESKTOP_ENVIRONMENT_H_ | 5 #ifndef REMOTING_HOST_DESKTOP_ENVIRONMENT_H_ |
6 #define REMOTING_HOST_DESKTOP_ENVIRONMENT_H_ | 6 #define REMOTING_HOST_DESKTOP_ENVIRONMENT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/time.h" | 13 #include "base/time.h" |
14 #include "remoting/base/scoped_thread_proxy.h" | 14 #include "remoting/base/scoped_thread_proxy.h" |
15 | 15 |
16 namespace remoting { | 16 namespace remoting { |
17 | 17 |
18 class Capturer; | 18 class Capturer; |
19 class ChromotingHost; | 19 class ChromotingHost; |
20 class ChromotingHostContext; | 20 class ChromotingHostContext; |
21 class ContinueWindow; | |
22 class Curtain; | |
23 class DisconnectWindow; | |
24 class EventExecutor; | 21 class EventExecutor; |
25 class LocalInputMonitor; | |
26 | 22 |
27 class DesktopEnvironment { | 23 class DesktopEnvironment { |
28 public: | 24 public: |
29 static DesktopEnvironment* Create(ChromotingHostContext* context); | 25 static DesktopEnvironment* Create(ChromotingHostContext* context); |
30 | 26 |
31 // DesktopEnvironment takes ownership of all the objects passed in. | 27 // DesktopEnvironment takes ownership of all the objects passed in. |
32 DesktopEnvironment(ChromotingHostContext* context, | 28 DesktopEnvironment(ChromotingHostContext* context, |
33 Capturer* capturer, | 29 Capturer* capturer, |
34 EventExecutor* event_executor, | 30 EventExecutor* event_executor); |
35 Curtain* curtain, | |
36 DisconnectWindow* disconnect_window, | |
37 ContinueWindow* continue_window, | |
38 LocalInputMonitor* monitor); | |
39 virtual ~DesktopEnvironment(); | 31 virtual ~DesktopEnvironment(); |
40 | 32 |
41 // Shuts down the object and all its resources synchronously. Must | |
42 // be called on the UI thread. | |
43 void Shutdown(); | |
44 | |
45 void set_host(ChromotingHost* host) { host_ = host; } | 33 void set_host(ChromotingHost* host) { host_ = host; } |
46 | 34 |
47 Capturer* capturer() const { return capturer_.get(); } | 35 Capturer* capturer() const { return capturer_.get(); } |
48 EventExecutor* event_executor() const { return event_executor_.get(); } | 36 EventExecutor* event_executor() const { return event_executor_.get(); } |
49 Curtain* curtain() const { return curtain_.get(); } | |
50 | |
51 // Called whenever a new client has connected. | |
52 void OnConnect(const std::string& username); | |
53 | |
54 // Called when the last client has disconnected. | |
55 void OnLastDisconnect(); | |
56 | |
57 // Called when the remote connection has been paused/unpaused. | |
58 void OnPause(bool pause); | |
59 | 37 |
60 private: | 38 private: |
61 class TimerTask; | |
62 | |
63 void ProcessOnConnect(const std::string& username); | |
64 void ProcessOnLastDisconnect(); | |
65 | |
66 void MonitorLocalInputs(bool enable); | |
67 | |
68 // Show or hide the Disconnect window on the UI thread. If |show| is false, | |
69 // hide the window, ignoring the |username| parameter. | |
70 void ShowDisconnectWindow(bool show, const std::string& username); | |
71 | |
72 // Show or hide the Continue Sharing window on the UI thread. | |
73 void ShowContinueWindow(bool show); | |
74 | |
75 // Called by the ContinueWindow implementation (on the UI thread) when the | |
76 // user dismisses the Continue prompt. | |
77 // TODO(lambroslambrou): Move this method to the (to be written) | |
78 // It2MeObserver class. | |
79 void ContinueSession(bool continue_session); | |
80 | |
81 void StartContinueWindowTimer(bool start); | |
82 | |
83 void OnContinueWindowTimer(); | |
84 void OnShutdownHostTimer(); | |
85 | |
86 // The host that owns this DesktopEnvironment. | 39 // The host that owns this DesktopEnvironment. |
87 ChromotingHost* host_; | 40 ChromotingHost* host_; |
88 | 41 |
89 // Host context used to make sure operations are run on the correct thread. | 42 // Host context used to make sure operations are run on the correct thread. |
90 // This is owned by the ChromotingHost. | 43 // This is owned by the ChromotingHost. |
91 ChromotingHostContext* context_; | 44 ChromotingHostContext* context_; |
92 | 45 |
93 // Capturer to be used by ScreenRecorder. | 46 // Capturer to be used by ScreenRecorder. |
94 scoped_ptr<Capturer> capturer_; | 47 scoped_ptr<Capturer> capturer_; |
95 | 48 |
96 // Executes input events received from the client. | 49 // Executes input events received from the client. |
97 scoped_ptr<EventExecutor> event_executor_; | 50 scoped_ptr<EventExecutor> event_executor_; |
98 | 51 |
99 // Curtain ensures privacy for the remote user. | |
100 scoped_ptr<Curtain> curtain_; | |
101 | |
102 // Provide a user interface allowing the host user to close the connection. | |
103 scoped_ptr<DisconnectWindow> disconnect_window_; | |
104 | |
105 // Provide a user interface requiring the user to periodically re-confirm | |
106 // the connection. | |
107 scoped_ptr<ContinueWindow> continue_window_; | |
108 | |
109 // Monitor local inputs to allow remote inputs to be blocked while the local | |
110 // user is trying to do something. | |
111 scoped_ptr<LocalInputMonitor> local_input_monitor_; | |
112 | |
113 bool is_monitoring_local_inputs_; | |
114 | |
115 // Timer controlling the "continue session" dialog. | |
116 scoped_ptr<TimerTask> timer_task_; | |
117 | |
118 ScopedThreadProxy ui_thread_proxy_; | |
119 | |
120 DISALLOW_COPY_AND_ASSIGN(DesktopEnvironment); | 52 DISALLOW_COPY_AND_ASSIGN(DesktopEnvironment); |
121 }; | 53 }; |
122 | 54 |
123 } // namespace remoting | 55 } // namespace remoting |
124 | 56 |
125 #endif // REMOTING_HOST_DESKTOP_ENVIRONMENT_H_ | 57 #endif // REMOTING_HOST_DESKTOP_ENVIRONMENT_H_ |
OLD | NEW |