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> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 class PolicyService; | 25 class PolicyService; |
26 } // namespace policy | 26 } // namespace policy |
27 | 27 |
28 namespace remoting { | 28 namespace remoting { |
29 | 29 |
30 class ChromotingHost; | 30 class ChromotingHost; |
31 class ChromotingHostContext; | 31 class ChromotingHostContext; |
32 class DesktopEnvironmentFactory; | 32 class DesktopEnvironmentFactory; |
33 class HostEventLogger; | 33 class HostEventLogger; |
34 class HostStatusLogger; | 34 class HostStatusLogger; |
35 class PolicyWatcher; | |
36 class RegisterSupportHostRequest; | 35 class RegisterSupportHostRequest; |
37 class RsaKeyPair; | 36 class RsaKeyPair; |
38 | 37 |
39 // These state values are duplicated in host_session.js. Remember to update | 38 // These state values are duplicated in host_session.js. Remember to update |
40 // both copies when making changes. | 39 // both copies when making changes. |
41 enum It2MeHostState { | 40 enum It2MeHostState { |
42 kDisconnected, | 41 kDisconnected, |
43 kStarting, | 42 kStarting, |
44 kRequestedAccessCode, | 43 kRequestedAccessCode, |
45 kReceivedAccessCode, | 44 kReceivedAccessCode, |
(...skipping 11 matching lines...) Expand all Loading... |
57 public: | 56 public: |
58 virtual void OnClientAuthenticated(const std::string& client_username) = 0; | 57 virtual void OnClientAuthenticated(const std::string& client_username) = 0; |
59 virtual void OnStoreAccessCode(const std::string& access_code, | 58 virtual void OnStoreAccessCode(const std::string& access_code, |
60 base::TimeDelta access_code_lifetime) = 0; | 59 base::TimeDelta access_code_lifetime) = 0; |
61 virtual void OnNatPolicyChanged(bool nat_traversal_enabled) = 0; | 60 virtual void OnNatPolicyChanged(bool nat_traversal_enabled) = 0; |
62 virtual void OnStateChanged(It2MeHostState state, | 61 virtual void OnStateChanged(It2MeHostState state, |
63 const std::string& error_message) = 0; | 62 const std::string& error_message) = 0; |
64 }; | 63 }; |
65 | 64 |
66 It2MeHost(std::unique_ptr<ChromotingHostContext> context, | 65 It2MeHost(std::unique_ptr<ChromotingHostContext> context, |
67 std::unique_ptr<PolicyWatcher> policy_watcher, | |
68 std::unique_ptr<It2MeConfirmationDialogFactory> dialog_factory_, | 66 std::unique_ptr<It2MeConfirmationDialogFactory> dialog_factory_, |
69 base::WeakPtr<It2MeHost::Observer> observer, | 67 base::WeakPtr<It2MeHost::Observer> observer, |
70 std::unique_ptr<SignalStrategy> signal_strategy, | 68 std::unique_ptr<SignalStrategy> signal_strategy, |
71 const std::string& username, | 69 const std::string& username, |
72 const std::string& directory_bot_jid); | 70 const std::string& directory_bot_jid); |
73 | 71 |
74 // Methods called by the script object, from the plugin thread. | 72 // Methods called by the script object, from the plugin thread. |
75 | 73 |
76 // Creates It2Me host structures and starts the host. | 74 // Creates It2Me host structures and starts the host. |
77 virtual void Connect(); | 75 virtual void Connect(); |
(...skipping 13 matching lines...) Expand all Loading... |
91 void SetStateForTesting(It2MeHostState state, | 89 void SetStateForTesting(It2MeHostState state, |
92 const std::string& error_message) { | 90 const std::string& error_message) { |
93 SetState(state, error_message); | 91 SetState(state, error_message); |
94 } | 92 } |
95 | 93 |
96 // Returns the callback used for validating the connection. Do not run the | 94 // Returns the callback used for validating the connection. Do not run the |
97 // returned callback after this object has been destroyed. | 95 // returned callback after this object has been destroyed. |
98 protocol::ValidatingAuthenticator::ValidationCallback | 96 protocol::ValidatingAuthenticator::ValidationCallback |
99 GetValidationCallbackForTesting(); | 97 GetValidationCallbackForTesting(); |
100 | 98 |
| 99 // Called when initial policies are read, and when they change. |
| 100 void OnPolicyUpdate(std::unique_ptr<base::DictionaryValue> policies); |
| 101 |
101 protected: | 102 protected: |
102 friend class base::RefCountedThreadSafe<It2MeHost>; | 103 friend class base::RefCountedThreadSafe<It2MeHost>; |
103 | 104 |
104 ~It2MeHost() override; | 105 ~It2MeHost() override; |
105 | 106 |
106 ChromotingHostContext* host_context() { return host_context_.get(); } | 107 ChromotingHostContext* host_context() { return host_context_.get(); } |
107 base::WeakPtr<It2MeHost::Observer> observer() { return observer_; } | 108 base::WeakPtr<It2MeHost::Observer> observer() { return observer_; } |
108 | 109 |
109 private: | 110 private: |
110 // Updates state of the host. Can be called only on the network thread. | 111 // Updates state of the host. Can be called only on the network thread. |
(...skipping 11 matching lines...) Expand all Loading... |
122 void ReadPolicyAndConnect(); | 123 void ReadPolicyAndConnect(); |
123 | 124 |
124 // Called by ReadPolicyAndConnect once policies have been read. | 125 // Called by ReadPolicyAndConnect once policies have been read. |
125 void FinishConnect(); | 126 void FinishConnect(); |
126 | 127 |
127 // Called when the support host registration completes. | 128 // Called when the support host registration completes. |
128 void OnReceivedSupportID(const std::string& support_id, | 129 void OnReceivedSupportID(const std::string& support_id, |
129 const base::TimeDelta& lifetime, | 130 const base::TimeDelta& lifetime, |
130 const std::string& error_message); | 131 const std::string& error_message); |
131 | 132 |
132 // Called when initial policies are read, and when they change. | |
133 void OnPolicyUpdate(std::unique_ptr<base::DictionaryValue> policies); | |
134 | |
135 // Called when malformed policies are detected. | |
136 void OnPolicyError(); | |
137 | |
138 // Handlers for NAT traversal and domain policies. | 133 // Handlers for NAT traversal and domain policies. |
139 void UpdateNatPolicy(bool nat_traversal_enabled); | 134 void UpdateNatPolicy(bool nat_traversal_enabled); |
140 void UpdateHostDomainPolicy(const std::string& host_domain); | 135 void UpdateHostDomainPolicy(const std::string& host_domain); |
141 void UpdateClientDomainPolicy(const std::string& client_domain); | 136 void UpdateClientDomainPolicy(const std::string& client_domain); |
142 | 137 |
143 void DisconnectOnNetworkThread(); | 138 void DisconnectOnNetworkThread(); |
144 | 139 |
145 // Uses details of the connection and current policies to determine if the | 140 // Uses details of the connection and current policies to determine if the |
146 // connection should be accepted or rejected. | 141 // connection should be accepted or rejected. |
147 void ValidateConnectionDetails( | 142 void ValidateConnectionDetails( |
(...skipping 11 matching lines...) Expand all Loading... |
159 | 154 |
160 scoped_refptr<RsaKeyPair> host_key_pair_; | 155 scoped_refptr<RsaKeyPair> host_key_pair_; |
161 std::unique_ptr<RegisterSupportHostRequest> register_request_; | 156 std::unique_ptr<RegisterSupportHostRequest> register_request_; |
162 std::unique_ptr<HostStatusLogger> host_status_logger_; | 157 std::unique_ptr<HostStatusLogger> host_status_logger_; |
163 std::unique_ptr<DesktopEnvironmentFactory> desktop_environment_factory_; | 158 std::unique_ptr<DesktopEnvironmentFactory> desktop_environment_factory_; |
164 std::unique_ptr<HostEventLogger> host_event_logger_; | 159 std::unique_ptr<HostEventLogger> host_event_logger_; |
165 | 160 |
166 std::unique_ptr<ChromotingHost> host_; | 161 std::unique_ptr<ChromotingHost> host_; |
167 int failed_login_attempts_ = 0; | 162 int failed_login_attempts_ = 0; |
168 | 163 |
169 std::unique_ptr<PolicyWatcher> policy_watcher_; | |
170 std::unique_ptr<It2MeConfirmationDialogFactory> confirmation_dialog_factory_; | 164 std::unique_ptr<It2MeConfirmationDialogFactory> confirmation_dialog_factory_; |
171 std::unique_ptr<It2MeConfirmationDialogProxy> confirmation_dialog_proxy_; | 165 std::unique_ptr<It2MeConfirmationDialogProxy> confirmation_dialog_proxy_; |
172 | 166 |
173 // Host the current nat traversal policy setting. | 167 // Host the current nat traversal policy setting. |
174 bool nat_traversal_enabled_ = false; | 168 bool nat_traversal_enabled_ = false; |
175 | 169 |
176 // The client and host domain policy setting. | 170 // The client and host domain policy setting. |
177 std::string required_client_domain_; | 171 std::string required_client_domain_; |
178 std::string required_host_domain_; | 172 std::string required_host_domain_; |
179 | 173 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 const std::string& username, | 208 const std::string& username, |
215 const std::string& directory_bot_jid); | 209 const std::string& directory_bot_jid); |
216 | 210 |
217 private: | 211 private: |
218 DISALLOW_COPY_AND_ASSIGN(It2MeHostFactory); | 212 DISALLOW_COPY_AND_ASSIGN(It2MeHostFactory); |
219 }; | 213 }; |
220 | 214 |
221 } // namespace remoting | 215 } // namespace remoting |
222 | 216 |
223 #endif // REMOTING_HOST_IT2ME_IT2ME_HOST_H_ | 217 #endif // REMOTING_HOST_IT2ME_IT2ME_HOST_H_ |
OLD | NEW |