Chromium Code Reviews| 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 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "remoting/host/host_status_observer.h" | 14 #include "remoting/host/host_status_observer.h" |
| 15 #include "remoting/host/it2me/it2me_confirmation_dialog.h" | 15 #include "remoting/host/it2me/it2me_confirmation_dialog.h" |
| 16 #include "remoting/host/it2me/it2me_confirmation_dialog_proxy.h" | 16 #include "remoting/host/it2me/it2me_confirmation_dialog_proxy.h" |
| 17 #include "remoting/protocol/validating_authenticator.h" | |
| 17 #include "remoting/signaling/xmpp_signal_strategy.h" | 18 #include "remoting/signaling/xmpp_signal_strategy.h" |
| 18 | 19 |
| 19 namespace base { | 20 namespace base { |
| 20 class DictionaryValue; | 21 class DictionaryValue; |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace policy { | 24 namespace policy { |
| 24 class PolicyService; | 25 class PolicyService; |
| 25 } // namespace policy | 26 } // namespace policy |
| 26 | 27 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 // remoting::HostStatusObserver implementation. | 86 // remoting::HostStatusObserver implementation. |
| 86 void OnAccessDenied(const std::string& jid) override; | 87 void OnAccessDenied(const std::string& jid) override; |
| 87 void OnClientConnected(const std::string& jid) override; | 88 void OnClientConnected(const std::string& jid) override; |
| 88 void OnClientDisconnected(const std::string& jid) override; | 89 void OnClientDisconnected(const std::string& jid) override; |
| 89 | 90 |
| 90 void SetStateForTesting(It2MeHostState state, | 91 void SetStateForTesting(It2MeHostState state, |
| 91 const std::string& error_message) { | 92 const std::string& error_message) { |
| 92 SetState(state, error_message); | 93 SetState(state, error_message); |
| 93 } | 94 } |
| 94 | 95 |
| 96 // Updates the current policies based on |policies|. Runs |done_callback| on | |
| 97 // the calling thread once the policies have been updated. | |
| 98 void SetPolicyForTesting(std::unique_ptr<base::DictionaryValue> policies, | |
| 99 const base::Closure& done_callback); | |
| 100 | |
| 101 // Returns the callback used for validating the connection. Do not run the | |
| 102 // returned callback after this object has been destroyed. | |
| 103 const protocol::ValidatingAuthenticator::ValidationCallback& | |
| 104 GetValidationCallbackForTesting() { | |
| 105 return validation_callback_; | |
| 106 } | |
| 107 | |
| 95 protected: | 108 protected: |
| 96 friend class base::RefCountedThreadSafe<It2MeHost>; | 109 friend class base::RefCountedThreadSafe<It2MeHost>; |
| 97 | 110 |
| 98 ~It2MeHost() override; | 111 ~It2MeHost() override; |
| 99 | 112 |
| 100 ChromotingHostContext* host_context() { return host_context_.get(); } | 113 ChromotingHostContext* host_context() { return host_context_.get(); } |
| 101 scoped_refptr<base::SingleThreadTaskRunner> task_runner() { | 114 scoped_refptr<base::SingleThreadTaskRunner> task_runner() { |
| 102 return task_runner_; | 115 return task_runner_; |
| 103 } | 116 } |
| 104 base::WeakPtr<It2MeHost::Observer> observer() { return observer_; } | 117 base::WeakPtr<It2MeHost::Observer> observer() { return observer_; } |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 134 // Called when malformed policies are detected. | 147 // Called when malformed policies are detected. |
| 135 void OnPolicyError(); | 148 void OnPolicyError(); |
| 136 | 149 |
| 137 // Handlers for NAT traversal and domain policies. | 150 // Handlers for NAT traversal and domain policies. |
| 138 void UpdateNatPolicy(bool nat_traversal_enabled); | 151 void UpdateNatPolicy(bool nat_traversal_enabled); |
| 139 void UpdateHostDomainPolicy(const std::string& host_domain); | 152 void UpdateHostDomainPolicy(const std::string& host_domain); |
| 140 void UpdateClientDomainPolicy(const std::string& client_domain); | 153 void UpdateClientDomainPolicy(const std::string& client_domain); |
| 141 | 154 |
| 142 void DisconnectOnNetworkThread(); | 155 void DisconnectOnNetworkThread(); |
| 143 | 156 |
| 157 // Uses details of the connection and current policies to detemine if the | |
| 158 // connection should be accepted or rejected. | |
| 159 void ValidateConnectionDetails( | |
| 160 const std::string& remote_jid, | |
| 161 const protocol::ValidatingAuthenticator::ResultCallback& result_callback); | |
| 162 | |
| 144 // Caller supplied fields. | 163 // Caller supplied fields. |
| 145 std::unique_ptr<ChromotingHostContext> host_context_; | 164 std::unique_ptr<ChromotingHostContext> host_context_; |
| 146 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 165 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 147 base::WeakPtr<It2MeHost::Observer> observer_; | 166 base::WeakPtr<It2MeHost::Observer> observer_; |
| 148 XmppSignalStrategy::XmppServerConfig xmpp_server_config_; | 167 XmppSignalStrategy::XmppServerConfig xmpp_server_config_; |
| 149 std::string directory_bot_jid_; | 168 std::string directory_bot_jid_; |
| 150 | 169 |
| 151 It2MeHostState state_; | 170 It2MeHostState state_; |
| 152 | 171 |
| 153 scoped_refptr<RsaKeyPair> host_key_pair_; | 172 scoped_refptr<RsaKeyPair> host_key_pair_; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 175 // that on startup, we do not accidentally start a connection before we have | 194 // that on startup, we do not accidentally start a connection before we have |
| 176 // queried our policy restrictions. | 195 // queried our policy restrictions. |
| 177 bool policy_received_; | 196 bool policy_received_; |
| 178 | 197 |
| 179 // On startup, it is possible to have Connect() called before the policy read | 198 // On startup, it is possible to have Connect() called before the policy read |
| 180 // is completed. Rather than just failing, we thunk the connection call so | 199 // is completed. Rather than just failing, we thunk the connection call so |
| 181 // it can be executed after at least one successful policy read. This | 200 // it can be executed after at least one successful policy read. This |
| 182 // variable contains the thunk if it is necessary. | 201 // variable contains the thunk if it is necessary. |
| 183 base::Closure pending_connect_; | 202 base::Closure pending_connect_; |
| 184 | 203 |
| 204 // Called after the client machine initiates the connection process and is | |
|
Jamie
2016/08/26 23:31:02
s/is//
joedow
2016/08/30 00:08:24
Acknowledged.
| |
| 205 // determines whether to reject the connection or allow it to continue. | |
| 206 protocol::ValidatingAuthenticator::ValidationCallback validation_callback_; | |
|
Jamie
2016/08/26 23:31:02
Is it necessary to store this, rather than rebindi
joedow
2016/08/30 00:08:24
Probably not, I was thinking it would simplify thi
| |
| 207 | |
| 185 DISALLOW_COPY_AND_ASSIGN(It2MeHost); | 208 DISALLOW_COPY_AND_ASSIGN(It2MeHost); |
| 186 }; | 209 }; |
| 187 | 210 |
| 188 // Having a factory interface makes it possible for the test to provide a mock | 211 // Having a factory interface makes it possible for the test to provide a mock |
| 189 // implementation of the It2MeHost. | 212 // implementation of the It2MeHost. |
| 190 class It2MeHostFactory { | 213 class It2MeHostFactory { |
| 191 public: | 214 public: |
| 192 It2MeHostFactory(); | 215 It2MeHostFactory(); |
| 193 virtual ~It2MeHostFactory(); | 216 virtual ~It2MeHostFactory(); |
| 194 | 217 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 206 const std::string& directory_bot_jid); | 229 const std::string& directory_bot_jid); |
| 207 | 230 |
| 208 private: | 231 private: |
| 209 policy::PolicyService* policy_service_; | 232 policy::PolicyService* policy_service_; |
| 210 DISALLOW_COPY_AND_ASSIGN(It2MeHostFactory); | 233 DISALLOW_COPY_AND_ASSIGN(It2MeHostFactory); |
| 211 }; | 234 }; |
| 212 | 235 |
| 213 } // namespace remoting | 236 } // namespace remoting |
| 214 | 237 |
| 215 #endif // REMOTING_HOST_IT2ME_IT2ME_HOST_H_ | 238 #endif // REMOTING_HOST_IT2ME_IT2ME_HOST_H_ |
| OLD | NEW |