| 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 // This file implements a standalone host process for Me2Me. | 5 // This file implements a standalone host process for Me2Me. |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 bool OnUsernamePolicyUpdate(bool curtain_required, | 209 bool OnUsernamePolicyUpdate(bool curtain_required, |
| 210 bool username_match_required); | 210 bool username_match_required); |
| 211 bool OnNatPolicyUpdate(bool nat_traversal_enabled); | 211 bool OnNatPolicyUpdate(bool nat_traversal_enabled); |
| 212 void OnCurtainPolicyUpdate(bool curtain_required); | 212 void OnCurtainPolicyUpdate(bool curtain_required); |
| 213 bool OnHostTalkGadgetPrefixPolicyUpdate(const std::string& talkgadget_prefix); | 213 bool OnHostTalkGadgetPrefixPolicyUpdate(const std::string& talkgadget_prefix); |
| 214 bool OnHostTokenUrlPolicyUpdate( | 214 bool OnHostTokenUrlPolicyUpdate( |
| 215 const GURL& token_url, | 215 const GURL& token_url, |
| 216 const GURL& token_validation_url, | 216 const GURL& token_validation_url, |
| 217 const std::string& token_validation_cert_issuer); | 217 const std::string& token_validation_cert_issuer); |
| 218 bool OnPairingPolicyUpdate(bool pairing_enabled); | 218 bool OnPairingPolicyUpdate(bool pairing_enabled); |
| 219 bool OnGnubbyAuthPolicyUpdate(bool enable_gnubby_auth); |
| 219 | 220 |
| 220 void StartHost(); | 221 void StartHost(); |
| 221 | 222 |
| 222 void OnAuthFailed(); | 223 void OnAuthFailed(); |
| 223 | 224 |
| 224 void RestartHost(); | 225 void RestartHost(); |
| 225 | 226 |
| 226 // Stops the host and shuts down the process with the specified |exit_code|. | 227 // Stops the host and shuts down the process with the specified |exit_code|. |
| 227 void ShutdownHost(HostExitCodes exit_code); | 228 void ShutdownHost(HostExitCodes exit_code); |
| 228 | 229 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 std::string serialized_config_; | 267 std::string serialized_config_; |
| 267 std::string host_owner_; | 268 std::string host_owner_; |
| 268 bool use_service_account_; | 269 bool use_service_account_; |
| 269 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_; | 270 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_; |
| 270 bool allow_nat_traversal_; | 271 bool allow_nat_traversal_; |
| 271 std::string talkgadget_prefix_; | 272 std::string talkgadget_prefix_; |
| 272 bool allow_pairing_; | 273 bool allow_pairing_; |
| 273 | 274 |
| 274 bool curtain_required_; | 275 bool curtain_required_; |
| 275 ThirdPartyAuthConfig third_party_auth_config_; | 276 ThirdPartyAuthConfig third_party_auth_config_; |
| 277 bool enable_gnubby_auth_; |
| 276 | 278 |
| 277 scoped_ptr<XmppSignalStrategy> signal_strategy_; | 279 scoped_ptr<XmppSignalStrategy> signal_strategy_; |
| 278 scoped_ptr<SignalingConnector> signaling_connector_; | 280 scoped_ptr<SignalingConnector> signaling_connector_; |
| 279 scoped_ptr<HeartbeatSender> heartbeat_sender_; | 281 scoped_ptr<HeartbeatSender> heartbeat_sender_; |
| 280 scoped_ptr<HostStatusSender> host_status_sender_; | 282 scoped_ptr<HostStatusSender> host_status_sender_; |
| 281 scoped_ptr<HostChangeNotificationListener> host_change_notification_listener_; | 283 scoped_ptr<HostChangeNotificationListener> host_change_notification_listener_; |
| 282 scoped_ptr<LogToServer> log_to_server_; | 284 scoped_ptr<LogToServer> log_to_server_; |
| 283 scoped_ptr<HostEventLogger> host_event_logger_; | 285 scoped_ptr<HostEventLogger> host_event_logger_; |
| 284 | 286 |
| 285 scoped_ptr<ChromotingHost> host_; | 287 scoped_ptr<ChromotingHost> host_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 296 }; | 298 }; |
| 297 | 299 |
| 298 HostProcess::HostProcess(scoped_ptr<ChromotingHostContext> context, | 300 HostProcess::HostProcess(scoped_ptr<ChromotingHostContext> context, |
| 299 int* exit_code_out) | 301 int* exit_code_out) |
| 300 : context_(context.Pass()), | 302 : context_(context.Pass()), |
| 301 state_(HOST_INITIALIZING), | 303 state_(HOST_INITIALIZING), |
| 302 use_service_account_(false), | 304 use_service_account_(false), |
| 303 allow_nat_traversal_(true), | 305 allow_nat_traversal_(true), |
| 304 allow_pairing_(true), | 306 allow_pairing_(true), |
| 305 curtain_required_(false), | 307 curtain_required_(false), |
| 308 enable_gnubby_auth_(false), |
| 306 #if defined(REMOTING_MULTI_PROCESS) | 309 #if defined(REMOTING_MULTI_PROCESS) |
| 307 desktop_session_connector_(NULL), | 310 desktop_session_connector_(NULL), |
| 308 #endif // defined(REMOTING_MULTI_PROCESS) | 311 #endif // defined(REMOTING_MULTI_PROCESS) |
| 309 self_(this), | 312 self_(this), |
| 310 exit_code_out_(exit_code_out), | 313 exit_code_out_(exit_code_out), |
| 311 signal_parent_(false) { | 314 signal_parent_(false) { |
| 312 StartOnUiThread(); | 315 StartOnUiThread(); |
| 313 } | 316 } |
| 314 | 317 |
| 315 HostProcess::~HostProcess() { | 318 HostProcess::~HostProcess() { |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 &token_validation_cert_issuer)) { | 796 &token_validation_cert_issuer)) { |
| 794 restart_required |= OnHostTokenUrlPolicyUpdate( | 797 restart_required |= OnHostTokenUrlPolicyUpdate( |
| 795 GURL(token_url_string), GURL(token_validation_url_string), | 798 GURL(token_url_string), GURL(token_validation_url_string), |
| 796 token_validation_cert_issuer); | 799 token_validation_cert_issuer); |
| 797 } | 800 } |
| 798 if (policies->GetBoolean( | 801 if (policies->GetBoolean( |
| 799 policy_hack::PolicyWatcher::kHostAllowClientPairing, | 802 policy_hack::PolicyWatcher::kHostAllowClientPairing, |
| 800 &bool_value)) { | 803 &bool_value)) { |
| 801 restart_required |= OnPairingPolicyUpdate(bool_value); | 804 restart_required |= OnPairingPolicyUpdate(bool_value); |
| 802 } | 805 } |
| 806 if (policies->GetBoolean( |
| 807 policy_hack::PolicyWatcher::kHostAllowGnubbyAuthPolicyName, |
| 808 &bool_value)) { |
| 809 restart_required |= OnGnubbyAuthPolicyUpdate(bool_value); |
| 810 } |
| 803 | 811 |
| 804 if (state_ == HOST_INITIALIZING) { | 812 if (state_ == HOST_INITIALIZING) { |
| 805 StartHost(); | 813 StartHost(); |
| 806 } else if (state_ == HOST_STARTED && restart_required) { | 814 } else if (state_ == HOST_STARTED && restart_required) { |
| 807 RestartHost(); | 815 RestartHost(); |
| 808 } | 816 } |
| 809 } | 817 } |
| 810 | 818 |
| 811 bool HostProcess::OnHostDomainPolicyUpdate(const std::string& host_domain) { | 819 bool HostProcess::OnHostDomainPolicyUpdate(const std::string& host_domain) { |
| 812 // Returns true if the host has to be restarted after this policy update. | 820 // Returns true if the host has to be restarted after this policy update. |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 958 return false; | 966 return false; |
| 959 | 967 |
| 960 if (allow_pairing) | 968 if (allow_pairing) |
| 961 HOST_LOG << "Policy enables client pairing."; | 969 HOST_LOG << "Policy enables client pairing."; |
| 962 else | 970 else |
| 963 HOST_LOG << "Policy disables client pairing."; | 971 HOST_LOG << "Policy disables client pairing."; |
| 964 allow_pairing_ = allow_pairing; | 972 allow_pairing_ = allow_pairing; |
| 965 return true; | 973 return true; |
| 966 } | 974 } |
| 967 | 975 |
| 976 bool HostProcess::OnGnubbyAuthPolicyUpdate(bool enable_gnubby_auth) { |
| 977 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
| 978 |
| 979 if (enable_gnubby_auth_ == enable_gnubby_auth) |
| 980 return false; |
| 981 |
| 982 if (enable_gnubby_auth) { |
| 983 HOST_LOG << "Policy enables gnubby auth."; |
| 984 } else { |
| 985 HOST_LOG << "Policy disables gnubby auth."; |
| 986 } |
| 987 enable_gnubby_auth_ = enable_gnubby_auth; |
| 988 |
| 989 return true; |
| 990 } |
| 991 |
| 968 void HostProcess::StartHost() { | 992 void HostProcess::StartHost() { |
| 969 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 993 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
| 970 DCHECK(!host_); | 994 DCHECK(!host_); |
| 971 DCHECK(!signal_strategy_.get()); | 995 DCHECK(!signal_strategy_.get()); |
| 972 DCHECK(state_ == HOST_INITIALIZING || state_ == HOST_STOPPING_TO_RESTART || | 996 DCHECK(state_ == HOST_INITIALIZING || state_ == HOST_STOPPING_TO_RESTART || |
| 973 state_ == HOST_STOPPED) << state_; | 997 state_ == HOST_STOPPED) << state_; |
| 974 state_ = HOST_STARTED; | 998 state_ = HOST_STARTED; |
| 975 | 999 |
| 976 signal_strategy_.reset( | 1000 signal_strategy_.reset( |
| 977 new XmppSignalStrategy(net::ClientSocketFactory::GetDefaultFactory(), | 1001 new XmppSignalStrategy(net::ClientSocketFactory::GetDefaultFactory(), |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 // Set up repoting the host status notifications. | 1066 // Set up repoting the host status notifications. |
| 1043 #if defined(REMOTING_MULTI_PROCESS) | 1067 #if defined(REMOTING_MULTI_PROCESS) |
| 1044 host_event_logger_.reset( | 1068 host_event_logger_.reset( |
| 1045 new IpcHostEventLogger(host_->AsWeakPtr(), daemon_channel_.get())); | 1069 new IpcHostEventLogger(host_->AsWeakPtr(), daemon_channel_.get())); |
| 1046 #else // !defined(REMOTING_MULTI_PROCESS) | 1070 #else // !defined(REMOTING_MULTI_PROCESS) |
| 1047 host_event_logger_ = | 1071 host_event_logger_ = |
| 1048 HostEventLogger::Create(host_->AsWeakPtr(), kApplicationName); | 1072 HostEventLogger::Create(host_->AsWeakPtr(), kApplicationName); |
| 1049 #endif // !defined(REMOTING_MULTI_PROCESS) | 1073 #endif // !defined(REMOTING_MULTI_PROCESS) |
| 1050 | 1074 |
| 1051 host_->SetEnableCurtaining(curtain_required_); | 1075 host_->SetEnableCurtaining(curtain_required_); |
| 1076 host_->SetEnableGnubbyAuth(enable_gnubby_auth_); |
| 1052 host_->Start(host_owner_); | 1077 host_->Start(host_owner_); |
| 1053 | 1078 |
| 1054 CreateAuthenticatorFactory(); | 1079 CreateAuthenticatorFactory(); |
| 1055 } | 1080 } |
| 1056 | 1081 |
| 1057 void HostProcess::OnAuthFailed() { | 1082 void HostProcess::OnAuthFailed() { |
| 1058 ShutdownHost(kInvalidOauthCredentialsExitCode); | 1083 ShutdownHost(kInvalidOauthCredentialsExitCode); |
| 1059 } | 1084 } |
| 1060 | 1085 |
| 1061 void HostProcess::RestartHost() { | 1086 void HostProcess::RestartHost() { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1189 return exit_code; | 1214 return exit_code; |
| 1190 } | 1215 } |
| 1191 | 1216 |
| 1192 } // namespace remoting | 1217 } // namespace remoting |
| 1193 | 1218 |
| 1194 #if !defined(OS_WIN) | 1219 #if !defined(OS_WIN) |
| 1195 int main(int argc, char** argv) { | 1220 int main(int argc, char** argv) { |
| 1196 return remoting::HostMain(argc, argv); | 1221 return remoting::HostMain(argc, argv); |
| 1197 } | 1222 } |
| 1198 #endif // !defined(OS_WIN) | 1223 #endif // !defined(OS_WIN) |
| OLD | NEW |