Chromium Code Reviews| 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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 | 69 |
| 70 } // namespace | 70 } // namespace |
| 71 | 71 |
| 72 namespace remoting { | 72 namespace remoting { |
| 73 | 73 |
| 74 class HostProcess | 74 class HostProcess |
| 75 : public HeartbeatSender::Listener { | 75 : public HeartbeatSender::Listener { |
| 76 public: | 76 public: |
| 77 HostProcess() | 77 HostProcess() |
| 78 : message_loop_(MessageLoop::TYPE_UI), | 78 : message_loop_(MessageLoop::TYPE_UI), |
| 79 #ifdef OFFICIAL_BUILD | |
| 80 oauth_use_official_client_id_(true), | |
| 81 #else | |
| 82 oauth_use_official_client_id_(false), | |
| 83 #endif | |
| 79 allow_nat_traversal_(true), | 84 allow_nat_traversal_(true), |
| 80 restarting_(false), | 85 restarting_(false), |
| 81 exit_code_(kSuccessExitCode) { | 86 exit_code_(kSuccessExitCode) { |
| 82 context_.reset( | 87 context_.reset( |
| 83 new ChromotingHostContext(message_loop_.message_loop_proxy())); | 88 new ChromotingHostContext(message_loop_.message_loop_proxy())); |
| 84 context_->Start(); | 89 context_->Start(); |
| 85 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); | 90 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); |
| 86 config_updated_timer_.reset(new base::DelayTimer<HostProcess>( | 91 config_updated_timer_.reset(new base::DelayTimer<HostProcess>( |
| 87 FROM_HERE, base::TimeDelta::FromSeconds(2), this, | 92 FROM_HERE, base::TimeDelta::FromSeconds(2), this, |
| 88 &HostProcess::ConfigUpdated)); | 93 &HostProcess::ConfigUpdated)); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 | 238 |
| 234 // Use an XMPP connection to the Talk network for session signalling. | 239 // Use an XMPP connection to the Talk network for session signalling. |
| 235 if (!auth_config.GetString(kXmppLoginConfigPath, &xmpp_login_) || | 240 if (!auth_config.GetString(kXmppLoginConfigPath, &xmpp_login_) || |
| 236 !(auth_config.GetString(kXmppAuthTokenConfigPath, &xmpp_auth_token_) || | 241 !(auth_config.GetString(kXmppAuthTokenConfigPath, &xmpp_auth_token_) || |
| 237 auth_config.GetString(kOAuthRefreshTokenConfigPath, | 242 auth_config.GetString(kOAuthRefreshTokenConfigPath, |
| 238 &oauth_refresh_token_))) { | 243 &oauth_refresh_token_))) { |
| 239 LOG(ERROR) << "XMPP credentials are not defined in the config."; | 244 LOG(ERROR) << "XMPP credentials are not defined in the config."; |
| 240 return false; | 245 return false; |
| 241 } | 246 } |
| 242 | 247 |
| 248 // It is okay to not have this value and we will use the default value | |
| 249 // depending on whether this is an official build or not. | |
| 250 auth_config.GetBoolean(kOAuthUseOfficialClientIdPath, | |
| 251 &oauth_use_official_client_id_); | |
| 252 | |
| 243 if (!oauth_refresh_token_.empty()) { | 253 if (!oauth_refresh_token_.empty()) { |
| 244 xmpp_auth_token_ = ""; // This will be set to the access token later. | 254 xmpp_auth_token_ = ""; // This will be set to the access token later. |
| 245 xmpp_auth_service_ = "oauth2"; | 255 xmpp_auth_service_ = "oauth2"; |
| 246 } else if (!auth_config.GetString(kXmppAuthServiceConfigPath, | 256 } else if (!auth_config.GetString(kXmppAuthServiceConfigPath, |
| 247 &xmpp_auth_service_)) { | 257 &xmpp_auth_service_)) { |
| 248 // For the me2me host, we default to ClientLogin token for chromiumsync | 258 // For the me2me host, we default to ClientLogin token for chromiumsync |
| 249 // because earlier versions of the host had no HTTP stack with which to | 259 // because earlier versions of the host had no HTTP stack with which to |
| 250 // request an OAuth2 access token. | 260 // request an OAuth2 access token. |
| 251 xmpp_auth_service_ = kChromotingTokenDefaultServiceName; | 261 xmpp_auth_service_ = kChromotingTokenDefaultServiceName; |
| 252 } | 262 } |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 281 | 291 |
| 282 if (!signal_strategy_.get()) { | 292 if (!signal_strategy_.get()) { |
| 283 signal_strategy_.reset( | 293 signal_strategy_.reset( |
| 284 new XmppSignalStrategy(context_->jingle_thread(), xmpp_login_, | 294 new XmppSignalStrategy(context_->jingle_thread(), xmpp_login_, |
| 285 xmpp_auth_token_, xmpp_auth_service_)); | 295 xmpp_auth_token_, xmpp_auth_service_)); |
| 286 | 296 |
| 287 signaling_connector_.reset( | 297 signaling_connector_.reset( |
| 288 new SignalingConnector(signal_strategy_.get())); | 298 new SignalingConnector(signal_strategy_.get())); |
| 289 | 299 |
| 290 if (!oauth_refresh_token_.empty()) { | 300 if (!oauth_refresh_token_.empty()) { |
| 301 OAuthClientInfo client_info; | |
| 302 OAuthClientInfo unofficial_client_info = { | |
| 303 "440925447803-2pi3v45bff6tp1rde2f7q6lgbor3o5uj" | |
| 304 ".apps.googleusercontent.com", | |
| 305 "W2ieEsG-R1gIA4MMurGrgMc_" | |
|
Wez
2012/04/19 00:13:04
Could this and the official info be a static const
Alpha Left Google
2012/04/20 22:13:50
Done.
| |
| 306 }; | |
| 307 | |
| 308 #ifdef OFFICIAL_BUILD | |
| 309 OAuthClientInfo official_client_info = { | |
| 310 "440925447803-avn2sj1kc099s0r7v62je5s339mu0am1" | |
| 311 ".apps.googleusercontent.com", | |
| 312 "Bgur6DFiOMM1h8x-AQpuTQlK" | |
| 313 }; | |
| 314 | |
| 315 if (oauth_use_official_client_id_) | |
| 316 client_info = official_client_info; | |
|
Sergey Ulanov
2012/04/19 01:57:32
need {} here
Alpha Left Google
2012/04/20 22:13:50
Now the #ifdef block is much simpler and {} is not
| |
| 317 else | |
| 318 #endif // OFFICIAL_BUILD | |
| 319 client_info = unofficial_client_info; | |
|
Wez
2012/04/19 00:13:04
If you move this above the #ifdef block then you d
Alpha Left Google
2012/04/20 22:13:50
Done.
| |
| 320 | |
| 291 scoped_ptr<SignalingConnector::OAuthCredentials> oauth_credentials( | 321 scoped_ptr<SignalingConnector::OAuthCredentials> oauth_credentials( |
| 292 new SignalingConnector::OAuthCredentials( | 322 new SignalingConnector::OAuthCredentials( |
| 293 xmpp_login_, oauth_refresh_token_)); | 323 xmpp_login_, oauth_refresh_token_, client_info)); |
| 294 signaling_connector_->EnableOAuth( | 324 signaling_connector_->EnableOAuth( |
| 295 oauth_credentials.Pass(), | 325 oauth_credentials.Pass(), |
| 296 base::Bind(&HostProcess::OnOAuthFailed, base::Unretained(this)), | 326 base::Bind(&HostProcess::OnOAuthFailed, base::Unretained(this)), |
| 297 context_->url_request_context_getter()); | 327 context_->url_request_context_getter()); |
| 298 } | 328 } |
| 299 } | 329 } |
| 300 | 330 |
| 301 if (!desktop_environment_.get()) { | 331 if (!desktop_environment_.get()) { |
| 302 desktop_environment_ = | 332 desktop_environment_ = |
| 303 DesktopEnvironment::CreateForService(context_.get()); | 333 DesktopEnvironment::CreateForService(context_.get()); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 366 FilePath host_config_path_; | 396 FilePath host_config_path_; |
| 367 | 397 |
| 368 std::string host_id_; | 398 std::string host_id_; |
| 369 HostKeyPair key_pair_; | 399 HostKeyPair key_pair_; |
| 370 protocol::SharedSecretHash host_secret_hash_; | 400 protocol::SharedSecretHash host_secret_hash_; |
| 371 std::string xmpp_login_; | 401 std::string xmpp_login_; |
| 372 std::string xmpp_auth_token_; | 402 std::string xmpp_auth_token_; |
| 373 std::string xmpp_auth_service_; | 403 std::string xmpp_auth_service_; |
| 374 | 404 |
| 375 std::string oauth_refresh_token_; | 405 std::string oauth_refresh_token_; |
| 406 bool oauth_use_official_client_id_; | |
| 376 | 407 |
| 377 scoped_ptr<policy_hack::NatPolicy> nat_policy_; | 408 scoped_ptr<policy_hack::NatPolicy> nat_policy_; |
| 378 bool allow_nat_traversal_; | 409 bool allow_nat_traversal_; |
| 379 scoped_ptr<base::files::FilePathWatcher> config_watcher_; | 410 scoped_ptr<base::files::FilePathWatcher> config_watcher_; |
| 380 scoped_ptr<base::DelayTimer<HostProcess> > config_updated_timer_; | 411 scoped_ptr<base::DelayTimer<HostProcess> > config_updated_timer_; |
| 381 | 412 |
| 382 bool restarting_; | 413 bool restarting_; |
| 383 | 414 |
| 384 scoped_ptr<XmppSignalStrategy> signal_strategy_; | 415 scoped_ptr<XmppSignalStrategy> signal_strategy_; |
| 385 scoped_ptr<SignalingConnector> signaling_connector_; | 416 scoped_ptr<SignalingConnector> signaling_connector_; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 435 int CALLBACK WinMain(HINSTANCE instance, | 466 int CALLBACK WinMain(HINSTANCE instance, |
| 436 HINSTANCE previous_instance, | 467 HINSTANCE previous_instance, |
| 437 LPSTR command_line, | 468 LPSTR command_line, |
| 438 int show_command) { | 469 int show_command) { |
| 439 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting | 470 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting |
| 440 // the command line from GetCommandLineW(), so we can safely pass NULL here. | 471 // the command line from GetCommandLineW(), so we can safely pass NULL here. |
| 441 return main(0, NULL); | 472 return main(0, NULL); |
| 442 } | 473 } |
| 443 | 474 |
| 444 #endif | 475 #endif |
| OLD | NEW |