| 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_IT2ME_HOST_USER_INTERFACE_H_ |
| 6 #define REMOTING_HOST_DESKTOP_ENVIRONMENT_H_ | 6 #define REMOTING_HOST_IT2ME_HOST_USER_INTERFACE_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/compiler_specific.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/time.h" | 13 |
| 14 #include "remoting/base/scoped_thread_proxy.h" | 14 #include "remoting/base/scoped_thread_proxy.h" |
| 15 #include "remoting/host/host_status_observer.h" |
| 16 |
| 17 // Milliseconds before the continue window is shown. |
| 18 static const int kContinueWindowShowTimeoutMs = 10 * 60 * 1000; |
| 19 |
| 20 // Milliseconds before the continue window is automatically dismissed and |
| 21 // the connection is closed. |
| 22 static const int kContinueWindowHideTimeoutMs = 60 * 1000; |
| 15 | 23 |
| 16 namespace remoting { | 24 namespace remoting { |
| 17 | 25 |
| 18 class Capturer; | |
| 19 class ChromotingHost; | 26 class ChromotingHost; |
| 20 class ChromotingHostContext; | 27 class ChromotingHostContext; |
| 21 class ContinueWindow; | 28 class ContinueWindow; |
| 22 class Curtain; | |
| 23 class DisconnectWindow; | 29 class DisconnectWindow; |
| 24 class EventExecutor; | |
| 25 class LocalInputMonitor; | 30 class LocalInputMonitor; |
| 31 class SignalStrategy; |
| 26 | 32 |
| 27 class DesktopEnvironment { | 33 // This class implements the IT2Me-specific parts of the ChromotingHost: |
| 34 // Disconnect and Continue window popups. |
| 35 // IT2Me-specific handling of multiple connection attempts. |
| 36 class It2MeHostUserInterface : public HostStatusObserver { |
| 28 public: | 37 public: |
| 29 static DesktopEnvironment* Create(ChromotingHostContext* context); | 38 It2MeHostUserInterface(ChromotingHost* host, ChromotingHostContext* context); |
| 39 virtual ~It2MeHostUserInterface(); |
| 30 | 40 |
| 31 // DesktopEnvironment takes ownership of all the objects passed in. | 41 void Init(); |
| 32 DesktopEnvironment(ChromotingHostContext* context, | 42 |
| 33 Capturer* capturer, | 43 // HostStatusObserver implementation. These methods will be called from the |
| 34 EventExecutor* event_executor, | 44 // network thread. |
| 35 Curtain* curtain, | 45 virtual void OnSignallingConnected(SignalStrategy* signal_strategy, |
| 36 DisconnectWindow* disconnect_window, | 46 const std::string& full_jid) OVERRIDE; |
| 37 ContinueWindow* continue_window, | 47 virtual void OnSignallingDisconnected() OVERRIDE; |
| 38 LocalInputMonitor* monitor); | 48 virtual void OnClientAuthenticated(const std::string& jid) OVERRIDE; |
| 39 virtual ~DesktopEnvironment(); | 49 virtual void OnClientDisconnected(const std::string& jid) OVERRIDE; |
| 50 virtual void OnAccessDenied() OVERRIDE; |
| 51 virtual void OnShutdown() OVERRIDE; |
| 40 | 52 |
| 41 // Shuts down the object and all its resources synchronously. Must | 53 // Shuts down the object and all its resources synchronously. Must |
| 42 // be called on the UI thread. | 54 // be called on the UI thread. |
| 43 void Shutdown(); | 55 void Shutdown(); |
| 44 | 56 |
| 45 void set_host(ChromotingHost* host) { host_ = host; } | |
| 46 | |
| 47 Capturer* capturer() const { return capturer_.get(); } | |
| 48 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 | |
| 60 private: | 57 private: |
| 61 class TimerTask; | 58 class TimerTask; |
| 62 | 59 |
| 60 // Allow ChromotingHostTest::SetUp() to call InitFrom(). |
| 61 friend class ChromotingHostTest; |
| 62 |
| 63 // Used by unit-tests as an alternative to Init() so that mock versions of |
| 64 // internal objects can be used. This takes ownership of all objects passed |
| 65 // in. |
| 66 void InitFrom(DisconnectWindow* disconnect_window, |
| 67 ContinueWindow* continue_window, |
| 68 LocalInputMonitor* monitor); |
| 69 |
| 70 void OnConnect(const std::string& username); |
| 71 void OnLastDisconnect(); |
| 72 |
| 63 void ProcessOnConnect(const std::string& username); | 73 void ProcessOnConnect(const std::string& username); |
| 64 void ProcessOnLastDisconnect(); | 74 void ProcessOnLastDisconnect(); |
| 65 | 75 |
| 66 void MonitorLocalInputs(bool enable); | 76 void MonitorLocalInputs(bool enable); |
| 67 | 77 |
| 68 // Show or hide the Disconnect window on the UI thread. If |show| is false, | 78 // Show or hide the Disconnect window on the UI thread. If |show| is false, |
| 69 // hide the window, ignoring the |username| parameter. | 79 // hide the window, ignoring the |username| parameter. |
| 70 void ShowDisconnectWindow(bool show, const std::string& username); | 80 void ShowDisconnectWindow(bool show, const std::string& username); |
| 71 | 81 |
| 72 // Show or hide the Continue Sharing window on the UI thread. | 82 // Show or hide the Continue Sharing window on the UI thread. |
| 73 void ShowContinueWindow(bool show); | 83 void ShowContinueWindow(bool show); |
| 74 | 84 |
| 75 // Called by the ContinueWindow implementation (on the UI thread) when the | 85 // Called by the ContinueWindow implementation (on the UI thread) when the |
| 76 // user dismisses the Continue prompt. | 86 // 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); | 87 void ContinueSession(bool continue_session); |
| 80 | 88 |
| 81 void StartContinueWindowTimer(bool start); | 89 void StartContinueWindowTimer(bool start); |
| 82 | 90 |
| 83 void OnContinueWindowTimer(); | 91 void OnContinueWindowTimer(); |
| 84 void OnShutdownHostTimer(); | 92 void OnShutdownHostTimer(); |
| 85 | 93 |
| 86 // The host that owns this DesktopEnvironment. | |
| 87 ChromotingHost* host_; | 94 ChromotingHost* host_; |
| 88 | 95 |
| 89 // Host context used to make sure operations are run on the correct thread. | 96 // Host context used to make sure operations are run on the correct thread. |
| 90 // This is owned by the ChromotingHost. | 97 // This is owned by the ChromotingHost. |
| 91 ChromotingHostContext* context_; | 98 ChromotingHostContext* context_; |
| 92 | 99 |
| 93 // Capturer to be used by ScreenRecorder. | |
| 94 scoped_ptr<Capturer> capturer_; | |
| 95 | |
| 96 // Executes input events received from the client. | |
| 97 scoped_ptr<EventExecutor> event_executor_; | |
| 98 | |
| 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. | 100 // Provide a user interface allowing the host user to close the connection. |
| 103 scoped_ptr<DisconnectWindow> disconnect_window_; | 101 scoped_ptr<DisconnectWindow> disconnect_window_; |
| 104 | 102 |
| 105 // Provide a user interface requiring the user to periodically re-confirm | 103 // Provide a user interface requiring the user to periodically re-confirm |
| 106 // the connection. | 104 // the connection. |
| 107 scoped_ptr<ContinueWindow> continue_window_; | 105 scoped_ptr<ContinueWindow> continue_window_; |
| 108 | 106 |
| 109 // Monitor local inputs to allow remote inputs to be blocked while the local | 107 // Monitor local inputs to allow remote inputs to be blocked while the local |
| 110 // user is trying to do something. | 108 // user is trying to do something. |
| 111 scoped_ptr<LocalInputMonitor> local_input_monitor_; | 109 scoped_ptr<LocalInputMonitor> local_input_monitor_; |
| 112 | 110 |
| 113 bool is_monitoring_local_inputs_; | 111 bool is_monitoring_local_inputs_; |
| 114 | 112 |
| 115 // Timer controlling the "continue session" dialog. | 113 // Timer controlling the "continue session" dialog. |
| 116 scoped_ptr<TimerTask> timer_task_; | 114 scoped_ptr<TimerTask> timer_task_; |
| 117 | 115 |
| 118 ScopedThreadProxy ui_thread_proxy_; | 116 ScopedThreadProxy ui_thread_proxy_; |
| 119 | 117 |
| 120 DISALLOW_COPY_AND_ASSIGN(DesktopEnvironment); | 118 // The JID of the currently-authenticated user (or an empty string if no user |
| 119 // is connected). |
| 120 std::string authenticated_jid_; |
| 121 |
| 122 DISALLOW_COPY_AND_ASSIGN(It2MeHostUserInterface); |
| 121 }; | 123 }; |
| 122 | 124 |
| 123 } // namespace remoting | 125 } // namespace remoting |
| 124 | 126 |
| 125 #endif // REMOTING_HOST_DESKTOP_ENVIRONMENT_H_ | 127 #endif // REMOTING_HOST_IT2ME_HOST_USER_INTERFACE_H_ |
| OLD | NEW |