Chromium Code Reviews| 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> | |
| 9 | |
| 8 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/threading/thread.h" | |
| 13 #include "base/timer.h" | |
| 10 | 14 |
| 11 namespace remoting { | 15 namespace remoting { |
| 12 | 16 |
| 13 class Capturer; | 17 class Capturer; |
| 18 class ChromotingHost; | |
| 19 class ChromotingHostContext; | |
| 14 class ContinueWindow; | 20 class ContinueWindow; |
| 15 class Curtain; | 21 class Curtain; |
| 16 class DisconnectWindow; | 22 class DisconnectWindow; |
| 17 class EventExecutor; | 23 class EventExecutor; |
| 18 class LocalInputMonitor; | 24 class LocalInputMonitor; |
| 19 | 25 |
| 20 class DesktopEnvironment { | 26 class DesktopEnvironment { |
| 21 public: | 27 public: |
| 28 static DesktopEnvironment* Create(ChromotingHostContext* context); | |
| 29 | |
| 22 // DesktopEnvironment takes ownership of all the objects passed the ctor. | 30 // DesktopEnvironment takes ownership of all the objects passed the ctor. |
| 23 DesktopEnvironment(Capturer* capturer, EventExecutor* event_executor, | 31 DesktopEnvironment(ChromotingHostContext* context, |
| 24 Curtain* curtain, DisconnectWindow* disconnect_window, | 32 Capturer* capturer, |
| 33 EventExecutor* event_executor, | |
| 34 Curtain* curtain, | |
| 35 DisconnectWindow* disconnect_window, | |
| 25 ContinueWindow* continue_window, | 36 ContinueWindow* continue_window, |
| 26 LocalInputMonitor* monitor); | 37 LocalInputMonitor* monitor); |
| 27 virtual ~DesktopEnvironment(); | 38 virtual ~DesktopEnvironment(); |
| 28 | 39 |
| 40 void set_host(ChromotingHost* host) { host_ = host; } | |
| 41 | |
| 29 Capturer* capturer() const { return capturer_.get(); } | 42 Capturer* capturer() const { return capturer_.get(); } |
| 30 EventExecutor* event_executor() const { return event_executor_.get(); } | 43 EventExecutor* event_executor() const { return event_executor_.get(); } |
| 31 Curtain* curtain() const { return curtain_.get(); } | 44 Curtain* curtain() const { return curtain_.get(); } |
| 32 DisconnectWindow* disconnect_window() { return disconnect_window_.get(); } | 45 |
| 33 ContinueWindow* continue_window() { return continue_window_.get(); } | 46 // Called whenever a new client has connected. |
| 34 LocalInputMonitor* local_input_monitor() { | 47 void OnConnect(const std::string& username); |
| 35 return local_input_monitor_.get(); | 48 |
| 36 } | 49 // Called when the last client has disconnected. |
| 50 void OnLastDisconnect(); | |
| 51 | |
| 52 // Called when the remote connection has been paused/unpaused. | |
| 53 void OnPause(bool pause); | |
| 37 | 54 |
| 38 private: | 55 private: |
| 56 void MonitorLocalInputs(bool enable); | |
| 57 | |
| 58 // Show or hide the Disconnect window on the UI thread. If |show| is false, | |
| 59 // hide the window, ignoring the |username| parameter. | |
| 60 void ShowDisconnectWindow(bool show, const std::string& username); | |
| 61 | |
| 62 // Show or hide the Continue Sharing window on the UI thread. | |
| 63 void ShowContinueWindow(bool show); | |
| 64 | |
| 65 void StartContinueWindowTimer(bool start); | |
| 66 | |
| 67 void ContinueWindowTimerFunc(); | |
| 68 | |
| 69 // The host that owns this DesktopEnvironment. | |
| 70 ChromotingHost* host_; | |
| 71 | |
| 72 // Host context used to make sure operations are run on the correct thread. | |
| 73 // This is owned by the ChromotingHost. | |
| 74 ChromotingHostContext* context_; | |
| 75 | |
| 39 // Capturer to be used by ScreenRecorder. | 76 // Capturer to be used by ScreenRecorder. |
| 40 scoped_ptr<Capturer> capturer_; | 77 scoped_ptr<Capturer> capturer_; |
| 41 | 78 |
| 42 // Executes input events received from the client. | 79 // Executes input events received from the client. |
| 43 scoped_ptr<EventExecutor> event_executor_; | 80 scoped_ptr<EventExecutor> event_executor_; |
| 44 | 81 |
| 45 // Curtain ensures privacy for the remote user. | 82 // Curtain ensures privacy for the remote user. |
| 46 scoped_ptr<Curtain> curtain_; | 83 scoped_ptr<Curtain> curtain_; |
| 47 | 84 |
| 48 // Provide a user interface allowing the host user to close the connection. | 85 // Provide a user interface allowing the host user to close the connection. |
| 49 scoped_ptr<DisconnectWindow> disconnect_window_; | 86 scoped_ptr<DisconnectWindow> disconnect_window_; |
| 50 | 87 |
| 51 // Provide a user interface requiring the user to periodically re-confirm | 88 // Provide a user interface requiring the user to periodically re-confirm |
| 52 // the connection. | 89 // the connection. |
| 53 scoped_ptr<ContinueWindow> continue_window_; | 90 scoped_ptr<ContinueWindow> continue_window_; |
| 54 | 91 |
| 55 // Monitor local inputs to allow remote inputs to be blocked while the local | 92 // Monitor local inputs to allow remote inputs to be blocked while the local |
| 56 // user is trying to do something. | 93 // user is trying to do something. |
| 57 scoped_ptr<LocalInputMonitor> local_input_monitor_; | 94 scoped_ptr<LocalInputMonitor> local_input_monitor_; |
| 58 | 95 |
| 96 bool is_monitoring_local_inputs_; | |
| 97 | |
| 98 // Timer controlling the "continue session" dialog. The timer is started when | |
| 99 // a connection is made or re-confirmed. On expiry, inputs to the host are | |
| 100 // blocked and the dialog is shown. | |
| 101 base::OneShotTimer<DesktopEnvironment> continue_window_timer_; | |
| 102 | |
| 59 DISALLOW_COPY_AND_ASSIGN(DesktopEnvironment); | 103 DISALLOW_COPY_AND_ASSIGN(DesktopEnvironment); |
| 60 }; | 104 }; |
| 61 | 105 |
| 62 } // namespace remoting | 106 } // namespace remoting |
| 63 | 107 |
| 108 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::DesktopEnvironment); | |
|
Sergey Ulanov
2011/07/08 23:12:24
Oh, no! DISABLE_RUNNABLE_METHOD_REFCOUNT is evil!
| |
| 109 | |
| 64 #endif // REMOTING_HOST_DESKTOP_ENVIRONMENT_H_ | 110 #endif // REMOTING_HOST_DESKTOP_ENVIRONMENT_H_ |
| OLD | NEW |