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_HOST_USER_INTERFACE_H_ | 5 #ifndef REMOTING_HOST_HOST_USER_INTERFACE_H_ |
6 #define REMOTING_HOST_HOST_USER_INTERFACE_H_ | 6 #define REMOTING_HOST_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/callback.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "remoting/host/host_status_observer.h" | 16 #include "remoting/host/host_status_observer.h" |
| 17 #include "remoting/host/ui_strings.h" |
17 | 18 |
18 namespace base { | 19 namespace base { |
19 class SingleThreadTaskRunner; | 20 class SingleThreadTaskRunner; |
20 } // namespace base | 21 } // namespace base |
21 | 22 |
22 namespace remoting { | 23 namespace remoting { |
23 | 24 |
24 class ChromotingHost; | 25 class ChromotingHost; |
25 class DisconnectWindow; | 26 class DisconnectWindow; |
26 class LocalInputMonitor; | 27 class LocalInputMonitor; |
27 | 28 |
28 class HostUserInterface : public HostStatusObserver { | 29 class HostUserInterface : public HostStatusObserver { |
29 public: | 30 public: |
30 HostUserInterface( | 31 HostUserInterface( |
31 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, | 32 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
32 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); | 33 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
| 34 const UiStrings& ui_strings); |
33 virtual ~HostUserInterface(); | 35 virtual ~HostUserInterface(); |
34 | 36 |
35 // Initialize the OS-specific UI objects. | 37 // Initialize the OS-specific UI objects. |
36 // Init must be called from |ui_task_runner_|. | 38 // Init must be called from |ui_task_runner_|. |
37 virtual void Init(); | 39 virtual void Init(); |
38 | 40 |
39 // Start the HostUserInterface for |host|. |disconnect_callback| will be | 41 // Start the HostUserInterface for |host|. |disconnect_callback| will be |
40 // called on |ui_task_runner| to notify the caller that the connection should | 42 // called on |ui_task_runner| to notify the caller that the connection should |
41 // be disconnected. |host| must remain valid until OnShutdown() is called. | 43 // be disconnected. |host| must remain valid until OnShutdown() is called. |
42 // Start must be called from |network_task_runner_|. | 44 // Start must be called from |network_task_runner_|. |
43 virtual void Start(ChromotingHost* host, | 45 virtual void Start(ChromotingHost* host, |
44 const base::Closure& disconnect_callback); | 46 const base::Closure& disconnect_callback); |
45 | 47 |
46 // HostStatusObserver implementation. These methods will be called from the | 48 // HostStatusObserver implementation. These methods will be called from the |
47 // network thread. | 49 // network thread. |
48 virtual void OnClientAuthenticated(const std::string& jid) OVERRIDE; | 50 virtual void OnClientAuthenticated(const std::string& jid) OVERRIDE; |
49 virtual void OnClientDisconnected(const std::string& jid) OVERRIDE; | 51 virtual void OnClientDisconnected(const std::string& jid) OVERRIDE; |
50 virtual void OnAccessDenied(const std::string& jid) OVERRIDE; | 52 virtual void OnAccessDenied(const std::string& jid) OVERRIDE; |
51 virtual void OnShutdown() OVERRIDE; | 53 virtual void OnShutdown() OVERRIDE; |
52 | 54 |
53 protected: | 55 protected: |
54 const std::string& get_authenticated_jid() const { | 56 const std::string& get_authenticated_jid() const { |
55 return authenticated_jid_; | 57 return authenticated_jid_; |
56 } | 58 } |
57 ChromotingHost* get_host() const { return host_; } | 59 ChromotingHost* get_host() const { return host_; } |
58 | 60 |
| 61 const UiStrings& ui_strings() const { return ui_strings_; } |
| 62 |
59 base::SingleThreadTaskRunner* network_task_runner() const; | 63 base::SingleThreadTaskRunner* network_task_runner() const; |
60 base::SingleThreadTaskRunner* ui_task_runner() const; | 64 base::SingleThreadTaskRunner* ui_task_runner() const; |
61 | 65 |
62 // Invokes the session disconnect callback passed to Start(). | 66 // Invokes the session disconnect callback passed to Start(). |
63 void DisconnectSession() const; | 67 void DisconnectSession() const; |
64 | 68 |
65 virtual void ProcessOnClientAuthenticated(const std::string& username); | 69 virtual void ProcessOnClientAuthenticated(const std::string& username); |
66 virtual void ProcessOnClientDisconnected(); | 70 virtual void ProcessOnClientDisconnected(); |
67 | 71 |
68 ChromotingHost* host_; | 72 ChromotingHost* host_; |
(...skipping 21 matching lines...) Expand all Loading... |
90 | 94 |
91 // Thread on which the ChromotingHost processes network events. | 95 // Thread on which the ChromotingHost processes network events. |
92 // Notifications from the host, and some calls into it, use this thread. | 96 // Notifications from the host, and some calls into it, use this thread. |
93 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; | 97 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; |
94 | 98 |
95 // Thread on which to run the user interface. | 99 // Thread on which to run the user interface. |
96 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | 100 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
97 | 101 |
98 bool is_monitoring_local_inputs_; | 102 bool is_monitoring_local_inputs_; |
99 | 103 |
| 104 // TODO(alexeypa): move |ui_strings_| to DesktopEnvironmentFactory. |
| 105 UiStrings ui_strings_; |
| 106 |
100 // WeakPtr used to avoid tasks accessing the client after it is deleted. | 107 // WeakPtr used to avoid tasks accessing the client after it is deleted. |
101 base::WeakPtrFactory<HostUserInterface> weak_factory_; | 108 base::WeakPtrFactory<HostUserInterface> weak_factory_; |
102 base::WeakPtr<HostUserInterface> weak_ptr_; | 109 base::WeakPtr<HostUserInterface> weak_ptr_; |
103 | 110 |
104 DISALLOW_COPY_AND_ASSIGN(HostUserInterface); | 111 DISALLOW_COPY_AND_ASSIGN(HostUserInterface); |
105 }; | 112 }; |
106 | 113 |
107 } // namespace remoting | 114 } // namespace remoting |
108 | 115 |
109 #endif // REMOTING_HOST_HOST_USER_INTERFACE_H_ | 116 #endif // REMOTING_HOST_HOST_USER_INTERFACE_H_ |
OLD | NEW |