OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_IT2ME_HOST_H_ | 5 #ifndef REMOTING_HOST_IT2ME_IT2ME_HOST_H_ |
6 #define REMOTING_HOST_IT2ME_IT2ME_HOST_H_ | 6 #define REMOTING_HOST_IT2ME_IT2ME_HOST_H_ |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
12 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
13 #include "remoting/host/host_status_observer.h" | 14 #include "remoting/host/host_status_observer.h" |
14 #include "remoting/host/it2me/it2me_confirmation_dialog.h" | 15 #include "remoting/host/it2me/it2me_confirmation_dialog.h" |
15 #include "remoting/host/it2me/it2me_confirmation_dialog_proxy.h" | 16 #include "remoting/host/it2me/it2me_confirmation_dialog_proxy.h" |
16 #include "remoting/signaling/xmpp_signal_strategy.h" | 17 #include "remoting/signaling/xmpp_signal_strategy.h" |
17 | 18 |
18 namespace base { | 19 namespace base { |
19 class DictionaryValue; | 20 class DictionaryValue; |
20 } | 21 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 class Observer { | 55 class Observer { |
55 public: | 56 public: |
56 virtual void OnClientAuthenticated(const std::string& client_username) = 0; | 57 virtual void OnClientAuthenticated(const std::string& client_username) = 0; |
57 virtual void OnStoreAccessCode(const std::string& access_code, | 58 virtual void OnStoreAccessCode(const std::string& access_code, |
58 base::TimeDelta access_code_lifetime) = 0; | 59 base::TimeDelta access_code_lifetime) = 0; |
59 virtual void OnNatPolicyChanged(bool nat_traversal_enabled) = 0; | 60 virtual void OnNatPolicyChanged(bool nat_traversal_enabled) = 0; |
60 virtual void OnStateChanged(It2MeHostState state, | 61 virtual void OnStateChanged(It2MeHostState state, |
61 const std::string& error_message) = 0; | 62 const std::string& error_message) = 0; |
62 }; | 63 }; |
63 | 64 |
64 It2MeHost( | 65 It2MeHost(std::unique_ptr<ChromotingHostContext> context, |
65 scoped_ptr<ChromotingHostContext> context, | 66 std::unique_ptr<PolicyWatcher> policy_watcher, |
66 scoped_ptr<PolicyWatcher> policy_watcher, | 67 std::unique_ptr<It2MeConfirmationDialogFactory> |
67 scoped_ptr<It2MeConfirmationDialogFactory> confirmation_dialog_factory, | 68 confirmation_dialog_factory, |
68 base::WeakPtr<It2MeHost::Observer> observer, | 69 base::WeakPtr<It2MeHost::Observer> observer, |
69 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, | 70 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, |
70 const std::string& directory_bot_jid); | 71 const std::string& directory_bot_jid); |
71 | 72 |
72 // Methods called by the script object, from the plugin thread. | 73 // Methods called by the script object, from the plugin thread. |
73 | 74 |
74 // Creates It2Me host structures and starts the host. | 75 // Creates It2Me host structures and starts the host. |
75 virtual void Connect(); | 76 virtual void Connect(); |
76 | 77 |
77 // Disconnects and shuts down the host. | 78 // Disconnects and shuts down the host. |
78 virtual void Disconnect(); | 79 virtual void Disconnect(); |
79 | 80 |
80 // TODO (weitaosu): Remove RequestNatPolicy from It2MeHost. | 81 // TODO (weitaosu): Remove RequestNatPolicy from It2MeHost. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 | 122 |
122 // Called by ReadPolicyAndConnect once policies have been read. | 123 // Called by ReadPolicyAndConnect once policies have been read. |
123 void FinishConnect(); | 124 void FinishConnect(); |
124 | 125 |
125 // Called when the support host registration completes. | 126 // Called when the support host registration completes. |
126 void OnReceivedSupportID(const std::string& support_id, | 127 void OnReceivedSupportID(const std::string& support_id, |
127 const base::TimeDelta& lifetime, | 128 const base::TimeDelta& lifetime, |
128 const std::string& error_message); | 129 const std::string& error_message); |
129 | 130 |
130 // Called when initial policies are read, and when they change. | 131 // Called when initial policies are read, and when they change. |
131 void OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies); | 132 void OnPolicyUpdate(std::unique_ptr<base::DictionaryValue> policies); |
132 | 133 |
133 // Called when malformed policies are detected. | 134 // Called when malformed policies are detected. |
134 void OnPolicyError(); | 135 void OnPolicyError(); |
135 | 136 |
136 // Handlers for NAT traversal and domain policies. | 137 // Handlers for NAT traversal and domain policies. |
137 void UpdateNatPolicy(bool nat_traversal_enabled); | 138 void UpdateNatPolicy(bool nat_traversal_enabled); |
138 void UpdateHostDomainPolicy(const std::string& host_domain); | 139 void UpdateHostDomainPolicy(const std::string& host_domain); |
139 void UpdateClientDomainPolicy(const std::string& client_domain); | 140 void UpdateClientDomainPolicy(const std::string& client_domain); |
140 | 141 |
141 void Shutdown(); | 142 void Shutdown(); |
142 | 143 |
143 // Caller supplied fields. | 144 // Caller supplied fields. |
144 scoped_ptr<ChromotingHostContext> host_context_; | 145 std::unique_ptr<ChromotingHostContext> host_context_; |
145 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 146 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
146 base::WeakPtr<It2MeHost::Observer> observer_; | 147 base::WeakPtr<It2MeHost::Observer> observer_; |
147 XmppSignalStrategy::XmppServerConfig xmpp_server_config_; | 148 XmppSignalStrategy::XmppServerConfig xmpp_server_config_; |
148 std::string directory_bot_jid_; | 149 std::string directory_bot_jid_; |
149 | 150 |
150 It2MeHostState state_; | 151 It2MeHostState state_; |
151 | 152 |
152 scoped_refptr<RsaKeyPair> host_key_pair_; | 153 scoped_refptr<RsaKeyPair> host_key_pair_; |
153 scoped_ptr<SignalStrategy> signal_strategy_; | 154 std::unique_ptr<SignalStrategy> signal_strategy_; |
154 scoped_ptr<RegisterSupportHostRequest> register_request_; | 155 std::unique_ptr<RegisterSupportHostRequest> register_request_; |
155 scoped_ptr<HostStatusLogger> host_status_logger_; | 156 std::unique_ptr<HostStatusLogger> host_status_logger_; |
156 scoped_ptr<DesktopEnvironmentFactory> desktop_environment_factory_; | 157 std::unique_ptr<DesktopEnvironmentFactory> desktop_environment_factory_; |
157 scoped_ptr<HostEventLogger> host_event_logger_; | 158 std::unique_ptr<HostEventLogger> host_event_logger_; |
158 | 159 |
159 scoped_ptr<ChromotingHost> host_; | 160 std::unique_ptr<ChromotingHost> host_; |
160 int failed_login_attempts_; | 161 int failed_login_attempts_; |
161 | 162 |
162 scoped_ptr<PolicyWatcher> policy_watcher_; | 163 std::unique_ptr<PolicyWatcher> policy_watcher_; |
163 scoped_ptr<It2MeConfirmationDialogFactory> confirmation_dialog_factory_; | 164 std::unique_ptr<It2MeConfirmationDialogFactory> confirmation_dialog_factory_; |
164 scoped_ptr<It2MeConfirmationDialogProxy> confirmation_dialog_proxy_; | 165 std::unique_ptr<It2MeConfirmationDialogProxy> confirmation_dialog_proxy_; |
165 | 166 |
166 // Host the current nat traversal policy setting. | 167 // Host the current nat traversal policy setting. |
167 bool nat_traversal_enabled_; | 168 bool nat_traversal_enabled_; |
168 | 169 |
169 // The client and host domain policy setting. | 170 // The client and host domain policy setting. |
170 std::string required_client_domain_; | 171 std::string required_client_domain_; |
171 std::string required_host_domain_; | 172 std::string required_host_domain_; |
172 | 173 |
173 // Indicates whether or not a policy has ever been read. This is to ensure | 174 // Indicates whether or not a policy has ever been read. This is to ensure |
174 // that on startup, we do not accidentally start a connection before we have | 175 // that on startup, we do not accidentally start a connection before we have |
(...skipping 17 matching lines...) Expand all Loading... |
192 virtual ~It2MeHostFactory(); | 193 virtual ~It2MeHostFactory(); |
193 | 194 |
194 // |policy_service| is used for creating the policy watcher for new | 195 // |policy_service| is used for creating the policy watcher for new |
195 // instances of It2MeHost on ChromeOS. The caller must ensure that | 196 // instances of It2MeHost on ChromeOS. The caller must ensure that |
196 // |policy_service| is valid throughout the lifetime of the It2MeHostFactory | 197 // |policy_service| is valid throughout the lifetime of the It2MeHostFactory |
197 // and each created It2MeHost object. This is currently possible because | 198 // and each created It2MeHost object. This is currently possible because |
198 // |policy_service| is a global singleton available from the browser process. | 199 // |policy_service| is a global singleton available from the browser process. |
199 virtual void set_policy_service(policy::PolicyService* policy_service); | 200 virtual void set_policy_service(policy::PolicyService* policy_service); |
200 | 201 |
201 virtual scoped_refptr<It2MeHost> CreateIt2MeHost( | 202 virtual scoped_refptr<It2MeHost> CreateIt2MeHost( |
202 scoped_ptr<ChromotingHostContext> context, | 203 std::unique_ptr<ChromotingHostContext> context, |
203 base::WeakPtr<It2MeHost::Observer> observer, | 204 base::WeakPtr<It2MeHost::Observer> observer, |
204 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, | 205 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, |
205 const std::string& directory_bot_jid); | 206 const std::string& directory_bot_jid); |
206 | 207 |
207 private: | 208 private: |
208 policy::PolicyService* policy_service_; | 209 policy::PolicyService* policy_service_; |
209 DISALLOW_COPY_AND_ASSIGN(It2MeHostFactory); | 210 DISALLOW_COPY_AND_ASSIGN(It2MeHostFactory); |
210 }; | 211 }; |
211 | 212 |
212 } // namespace remoting | 213 } // namespace remoting |
213 | 214 |
214 #endif // REMOTING_HOST_IT2ME_IT2ME_HOST_H_ | 215 #endif // REMOTING_HOST_IT2ME_IT2ME_HOST_H_ |
OLD | NEW |