OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_IT2ME_HOST_USER_INTERFACE_H_ | 5 #ifndef REMOTING_HOST_IT2ME_HOST_USER_INTERFACE_H_ |
6 #define REMOTING_HOST_IT2ME_HOST_USER_INTERFACE_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/callback.h" |
11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
13 | 14 |
14 #include "remoting/base/scoped_thread_proxy.h" | 15 #include "remoting/host/host_user_interface.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; | |
23 | 16 |
24 namespace remoting { | 17 namespace remoting { |
25 | 18 |
26 class ChromotingHost; | |
27 class ChromotingHostContext; | |
28 class ContinueWindow; | 19 class ContinueWindow; |
29 class DisconnectWindow; | |
30 class LocalInputMonitor; | |
31 class SignalStrategy; | |
32 | 20 |
33 // This class implements the IT2Me-specific parts of the ChromotingHost: | 21 // This class implements the IT2Me-specific parts of the ChromotingHost: |
34 // Disconnect and Continue window popups. | 22 // Disconnect and Continue window popups. |
35 // IT2Me-specific handling of multiple connection attempts. | 23 // IT2Me-specific handling of multiple connection attempts. |
36 class It2MeHostUserInterface : public HostStatusObserver { | 24 class It2MeHostUserInterface : public HostUserInterface { |
37 public: | 25 public: |
38 It2MeHostUserInterface(ChromotingHost* host, ChromotingHostContext* context); | 26 It2MeHostUserInterface(ChromotingHostContext* context); |
39 virtual ~It2MeHostUserInterface(); | 27 virtual ~It2MeHostUserInterface(); |
40 | 28 |
41 void Init(); | 29 virtual void Start(ChromotingHost* host, |
| 30 const base::Closure& disconnect_callback) OVERRIDE; |
42 | 31 |
43 // HostStatusObserver implementation. These methods will be called from the | 32 // HostStatusObserver implementation. These methods will be called from the |
44 // network thread. | 33 // network thread. |
45 virtual void OnClientAuthenticated(const std::string& jid) OVERRIDE; | 34 virtual void OnClientAuthenticated(const std::string& jid) OVERRIDE; |
46 virtual void OnClientDisconnected(const std::string& jid) OVERRIDE; | |
47 virtual void OnAccessDenied(const std::string& jid) OVERRIDE; | |
48 virtual void OnShutdown() OVERRIDE; | |
49 | 35 |
50 // Shuts down the object and all its resources synchronously. Must | 36 protected: |
51 // be called on the UI thread. | 37 virtual void ProcessOnClientAuthenticated( |
52 void Shutdown(); | 38 const std::string& username) OVERRIDE; |
| 39 virtual void ProcessOnClientDisconnected() OVERRIDE; |
53 | 40 |
54 private: | 41 private: |
55 class TimerTask; | 42 class TimerTask; |
56 | 43 |
57 // Allow ChromotingHostTest::SetUp() to call InitFrom(). | 44 // Allow ChromotingHostTest::SetUp() to call StartForTest(). |
58 friend class ChromotingHostTest; | 45 friend class ChromotingHostTest; |
59 | 46 |
60 // Used by unit-tests as an alternative to Init() so that mock versions of | 47 // Used by unit-tests as an alternative to Start() so that mock versions of |
61 // internal objects can be used. | 48 // internal objects can be used. |
62 void InitFrom(scoped_ptr<DisconnectWindow> disconnect_window, | 49 void StartForTest( |
63 scoped_ptr<ContinueWindow> continue_window, | 50 ChromotingHost* host, |
64 scoped_ptr<LocalInputMonitor> monitor); | 51 const base::Closure& disconnect_callback, |
65 | 52 scoped_ptr<DisconnectWindow> disconnect_window, |
66 void ProcessOnClientAuthenticated(const std::string& username); | 53 scoped_ptr<ContinueWindow> continue_window, |
67 void ProcessOnClientDisconnected(); | 54 scoped_ptr<LocalInputMonitor> local_input_monitor); |
68 | |
69 void MonitorLocalInputs(bool enable); | |
70 | |
71 // Show or hide the Disconnect window on the UI thread. If |show| is false, | |
72 // hide the window, ignoring the |username| parameter. | |
73 void ShowDisconnectWindow(bool show, const std::string& username); | |
74 | |
75 // Show or hide the Continue Sharing window on the UI thread. | |
76 void ShowContinueWindow(bool show); | |
77 | 55 |
78 // Called by the ContinueWindow implementation (on the UI thread) when the | 56 // Called by the ContinueWindow implementation (on the UI thread) when the |
79 // user dismisses the Continue prompt. | 57 // user dismisses the Continue prompt. |
80 void ContinueSession(bool continue_session); | 58 void ContinueSession(bool continue_session); |
81 | |
82 void StartContinueWindowTimer(bool start); | |
83 | |
84 void OnContinueWindowTimer(); | 59 void OnContinueWindowTimer(); |
85 void OnShutdownHostTimer(); | 60 void OnShutdownHostTimer(); |
86 | 61 |
87 ChromotingHost* host_; | 62 // Show or hide the Continue Sharing window on the UI thread. |
88 | 63 void ShowContinueWindow(bool show); |
89 // Host context used to make sure operations are run on the correct thread. | 64 void StartContinueWindowTimer(bool start); |
90 // This is owned by the ChromotingHost. | |
91 ChromotingHostContext* context_; | |
92 | |
93 // Provide a user interface allowing the host user to close the connection. | |
94 scoped_ptr<DisconnectWindow> disconnect_window_; | |
95 | 65 |
96 // Provide a user interface requiring the user to periodically re-confirm | 66 // Provide a user interface requiring the user to periodically re-confirm |
97 // the connection. | 67 // the connection. |
98 scoped_ptr<ContinueWindow> continue_window_; | 68 scoped_ptr<ContinueWindow> continue_window_; |
99 | 69 |
100 // Monitor local inputs to allow remote inputs to be blocked while the local | |
101 // user is trying to do something. | |
102 scoped_ptr<LocalInputMonitor> local_input_monitor_; | |
103 | |
104 bool is_monitoring_local_inputs_; | |
105 | |
106 // Timer controlling the "continue session" dialog. | 70 // Timer controlling the "continue session" dialog. |
107 scoped_ptr<TimerTask> timer_task_; | 71 scoped_ptr<TimerTask> timer_task_; |
108 | 72 |
109 ScopedThreadProxy ui_thread_proxy_; | |
110 | |
111 // The JID of the currently-authenticated user (or an empty string if no user | |
112 // is connected). | |
113 std::string authenticated_jid_; | |
114 | |
115 DISALLOW_COPY_AND_ASSIGN(It2MeHostUserInterface); | 73 DISALLOW_COPY_AND_ASSIGN(It2MeHostUserInterface); |
116 }; | 74 }; |
117 | 75 |
118 } // namespace remoting | 76 } // namespace remoting |
119 | 77 |
120 #endif // REMOTING_HOST_IT2ME_HOST_USER_INTERFACE_H_ | 78 #endif // REMOTING_HOST_IT2ME_HOST_USER_INTERFACE_H_ |
OLD | NEW |