OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef REMOTING_HOST_HOST_USER_INTERFACE_H_ |
| 6 #define REMOTING_HOST_HOST_USER_INTERFACE_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "base/callback.h" |
| 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/scoped_ptr.h" |
| 14 |
| 15 #include "remoting/base/scoped_thread_proxy.h" |
| 16 #include "remoting/host/host_status_observer.h" |
| 17 |
| 18 namespace remoting { |
| 19 |
| 20 class ChromotingHost; |
| 21 class ChromotingHostContext; |
| 22 class DisconnectWindow; |
| 23 class LocalInputMonitor; |
| 24 class SignalStrategy; |
| 25 |
| 26 class HostUserInterface : public HostStatusObserver { |
| 27 public: |
| 28 HostUserInterface(ChromotingHostContext* context); |
| 29 virtual ~HostUserInterface(); |
| 30 |
| 31 virtual void Start(ChromotingHost* host, |
| 32 const base::Closure& disconnect_callback); |
| 33 |
| 34 // HostStatusObserver implementation. These methods will be called from the |
| 35 // network thread. |
| 36 virtual void OnClientAuthenticated(const std::string& jid) OVERRIDE; |
| 37 virtual void OnClientDisconnected(const std::string& jid) OVERRIDE; |
| 38 virtual void OnAccessDenied(const std::string& jid) OVERRIDE; |
| 39 virtual void OnShutdown() OVERRIDE; |
| 40 |
| 41 protected: |
| 42 const std::string& get_authenticated_jid() const { |
| 43 return authenticated_jid_; |
| 44 } |
| 45 ChromotingHost* get_host() const { return host_; } |
| 46 |
| 47 // Message loop accessors. |
| 48 base::MessageLoopProxy* network_message_loop() const; |
| 49 base::MessageLoopProxy* ui_message_loop() const; |
| 50 |
| 51 // Invokes the session disconnect callback passed to Start(). |
| 52 void DisconnectSession() const; |
| 53 |
| 54 virtual void ProcessOnClientAuthenticated(const std::string& username); |
| 55 virtual void ProcessOnClientDisconnected(); |
| 56 |
| 57 // Used by unit-tests as an alternative to Start() so that mock versions of |
| 58 // internal objects can be used. |
| 59 void StartForTest( |
| 60 ChromotingHost* host, |
| 61 const base::Closure& disconnect_callback, |
| 62 scoped_ptr<DisconnectWindow> disconnect_window, |
| 63 scoped_ptr<LocalInputMonitor> local_input_monitor); |
| 64 |
| 65 private: |
| 66 // Invoked from the UI thread when the user clicks on the Disconnect button |
| 67 // to disconnect the session. |
| 68 void OnDisconnectCallback(); |
| 69 |
| 70 void MonitorLocalInputs(bool enable); |
| 71 |
| 72 // Show or hide the Disconnect window on the UI thread. If |show| is false, |
| 73 // hide the window, ignoring the |username| parameter. |
| 74 void ShowDisconnectWindow(bool show, const std::string& username); |
| 75 |
| 76 // The JID of the currently-authenticated user (or an empty string if no user |
| 77 // is connected). |
| 78 std::string authenticated_jid_; |
| 79 |
| 80 ChromotingHost* host_; |
| 81 |
| 82 // Host context used to make sure operations are run on the correct thread. |
| 83 // This is owned by the ChromotingHost. |
| 84 ChromotingHostContext* context_; |
| 85 |
| 86 // Used to ask the host to disconnect the session. |
| 87 base::Closure disconnect_callback_; |
| 88 |
| 89 // Provide a user interface allowing the host user to close the connection. |
| 90 scoped_ptr<DisconnectWindow> disconnect_window_; |
| 91 |
| 92 // Monitor local inputs to allow remote inputs to be blocked while the local |
| 93 // user is trying to do something. |
| 94 scoped_ptr<LocalInputMonitor> local_input_monitor_; |
| 95 |
| 96 bool is_monitoring_local_inputs_; |
| 97 |
| 98 ScopedThreadProxy ui_thread_proxy_; |
| 99 |
| 100 DISALLOW_COPY_AND_ASSIGN(HostUserInterface); |
| 101 }; |
| 102 |
| 103 } // namespace remoting |
| 104 |
| 105 #endif // REMOTING_HOST_HOST_USER_INTERFACE_H_ |
OLD | NEW |