Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(713)

Side by Side Diff: remoting/host/remoting_me2me_host.cc

Issue 10116040: Remoting daemon process to support unofficial client ID (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed comments Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 const char kHostConfigSwitchName[] = "host-config"; 60 const char kHostConfigSwitchName[] = "host-config";
61 61
62 const FilePath::CharType kDefaultAuthConfigFile[] = 62 const FilePath::CharType kDefaultAuthConfigFile[] =
63 FILE_PATH_LITERAL("auth.json"); 63 FILE_PATH_LITERAL("auth.json");
64 const FilePath::CharType kDefaultHostConfigFile[] = 64 const FilePath::CharType kDefaultHostConfigFile[] =
65 FILE_PATH_LITERAL("host.json"); 65 FILE_PATH_LITERAL("host.json");
66 66
67 const int kMinPortNumber = 12400; 67 const int kMinPortNumber = 12400;
68 const int kMaxPortNumber = 12409; 68 const int kMaxPortNumber = 12409;
69 69
70 const remoting::OAuthClientInfo kUnofficialOAuth2ClientInfo = {
71 "440925447803-2pi3v45bff6tp1rde2f7q6lgbor3o5uj.apps.googleusercontent.com",
72 "W2ieEsG-R1gIA4MMurGrgMc_"
73 };
74
75 const remoting::OAuthClientInfo kOfficialOAuth2ClientInfo = {
76 "440925447803-avn2sj1kc099s0r7v62je5s339mu0am1.apps.googleusercontent.com",
77 "Bgur6DFiOMM1h8x-AQpuTQlK"
78 };
79
70 } // namespace 80 } // namespace
71 81
72 namespace remoting { 82 namespace remoting {
73 83
74 class HostProcess 84 class HostProcess
75 : public HeartbeatSender::Listener { 85 : public HeartbeatSender::Listener {
76 public: 86 public:
77 HostProcess() 87 HostProcess()
78 : message_loop_(MessageLoop::TYPE_UI), 88 : message_loop_(MessageLoop::TYPE_UI),
89 #ifdef OFFICIAL_BUILD
90 oauth_use_official_client_id_(true),
91 #else
92 oauth_use_official_client_id_(false),
93 #endif
79 allow_nat_traversal_(true), 94 allow_nat_traversal_(true),
80 restarting_(false), 95 restarting_(false),
81 exit_code_(kSuccessExitCode) { 96 exit_code_(kSuccessExitCode) {
82 context_.reset( 97 context_.reset(
83 new ChromotingHostContext(message_loop_.message_loop_proxy())); 98 new ChromotingHostContext(message_loop_.message_loop_proxy()));
84 context_->Start(); 99 context_->Start();
85 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); 100 network_change_notifier_.reset(net::NetworkChangeNotifier::Create());
86 config_updated_timer_.reset(new base::DelayTimer<HostProcess>( 101 config_updated_timer_.reset(new base::DelayTimer<HostProcess>(
87 FROM_HERE, base::TimeDelta::FromSeconds(2), this, 102 FROM_HERE, base::TimeDelta::FromSeconds(2), this,
88 &HostProcess::ConfigUpdated)); 103 &HostProcess::ConfigUpdated));
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 248
234 // Use an XMPP connection to the Talk network for session signalling. 249 // Use an XMPP connection to the Talk network for session signalling.
235 if (!auth_config.GetString(kXmppLoginConfigPath, &xmpp_login_) || 250 if (!auth_config.GetString(kXmppLoginConfigPath, &xmpp_login_) ||
236 !(auth_config.GetString(kXmppAuthTokenConfigPath, &xmpp_auth_token_) || 251 !(auth_config.GetString(kXmppAuthTokenConfigPath, &xmpp_auth_token_) ||
237 auth_config.GetString(kOAuthRefreshTokenConfigPath, 252 auth_config.GetString(kOAuthRefreshTokenConfigPath,
238 &oauth_refresh_token_))) { 253 &oauth_refresh_token_))) {
239 LOG(ERROR) << "XMPP credentials are not defined in the config."; 254 LOG(ERROR) << "XMPP credentials are not defined in the config.";
240 return false; 255 return false;
241 } 256 }
242 257
258 // It is okay to not have this value and we will use the default value
259 // depending on whether this is an official build or not.
Wez 2012/04/20 22:29:46 nit: Suggest "If the client-Id type to use is not
260 auth_config.GetBoolean(kOAuthUseOfficialClientIdConfigPath,
261 &oauth_use_official_client_id_);
262
243 if (!oauth_refresh_token_.empty()) { 263 if (!oauth_refresh_token_.empty()) {
244 xmpp_auth_token_ = ""; // This will be set to the access token later. 264 xmpp_auth_token_ = ""; // This will be set to the access token later.
245 xmpp_auth_service_ = "oauth2"; 265 xmpp_auth_service_ = "oauth2";
246 } else if (!auth_config.GetString(kXmppAuthServiceConfigPath, 266 } else if (!auth_config.GetString(kXmppAuthServiceConfigPath,
247 &xmpp_auth_service_)) { 267 &xmpp_auth_service_)) {
248 // For the me2me host, we default to ClientLogin token for chromiumsync 268 // 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 269 // because earlier versions of the host had no HTTP stack with which to
250 // request an OAuth2 access token. 270 // request an OAuth2 access token.
251 xmpp_auth_service_ = kChromotingTokenDefaultServiceName; 271 xmpp_auth_service_ = kChromotingTokenDefaultServiceName;
252 } 272 }
(...skipping 28 matching lines...) Expand all
281 301
282 if (!signal_strategy_.get()) { 302 if (!signal_strategy_.get()) {
283 signal_strategy_.reset( 303 signal_strategy_.reset(
284 new XmppSignalStrategy(context_->jingle_thread(), xmpp_login_, 304 new XmppSignalStrategy(context_->jingle_thread(), xmpp_login_,
285 xmpp_auth_token_, xmpp_auth_service_)); 305 xmpp_auth_token_, xmpp_auth_service_));
286 306
287 signaling_connector_.reset( 307 signaling_connector_.reset(
288 new SignalingConnector(signal_strategy_.get())); 308 new SignalingConnector(signal_strategy_.get()));
289 309
290 if (!oauth_refresh_token_.empty()) { 310 if (!oauth_refresh_token_.empty()) {
311 OAuthClientInfo client_info = kUnofficialOAuth2ClientInfo;
312
313 #ifdef OFFICIAL_BUILD
314 if (oauth_use_official_client_id_) {
315 client_info = kOfficialOAuth2ClientInfo;
316 }
317 #endif // OFFICIAL_BUILD
318
291 scoped_ptr<SignalingConnector::OAuthCredentials> oauth_credentials( 319 scoped_ptr<SignalingConnector::OAuthCredentials> oauth_credentials(
292 new SignalingConnector::OAuthCredentials( 320 new SignalingConnector::OAuthCredentials(
293 xmpp_login_, oauth_refresh_token_)); 321 xmpp_login_, oauth_refresh_token_, client_info));
294 signaling_connector_->EnableOAuth( 322 signaling_connector_->EnableOAuth(
295 oauth_credentials.Pass(), 323 oauth_credentials.Pass(),
296 base::Bind(&HostProcess::OnOAuthFailed, base::Unretained(this)), 324 base::Bind(&HostProcess::OnOAuthFailed, base::Unretained(this)),
297 context_->url_request_context_getter()); 325 context_->url_request_context_getter());
298 } 326 }
299 } 327 }
300 328
301 if (!desktop_environment_.get()) { 329 if (!desktop_environment_.get()) {
302 desktop_environment_ = 330 desktop_environment_ =
303 DesktopEnvironment::CreateForService(context_.get()); 331 DesktopEnvironment::CreateForService(context_.get());
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 FilePath host_config_path_; 394 FilePath host_config_path_;
367 395
368 std::string host_id_; 396 std::string host_id_;
369 HostKeyPair key_pair_; 397 HostKeyPair key_pair_;
370 protocol::SharedSecretHash host_secret_hash_; 398 protocol::SharedSecretHash host_secret_hash_;
371 std::string xmpp_login_; 399 std::string xmpp_login_;
372 std::string xmpp_auth_token_; 400 std::string xmpp_auth_token_;
373 std::string xmpp_auth_service_; 401 std::string xmpp_auth_service_;
374 402
375 std::string oauth_refresh_token_; 403 std::string oauth_refresh_token_;
404 bool oauth_use_official_client_id_;
376 405
377 scoped_ptr<policy_hack::NatPolicy> nat_policy_; 406 scoped_ptr<policy_hack::NatPolicy> nat_policy_;
378 bool allow_nat_traversal_; 407 bool allow_nat_traversal_;
379 scoped_ptr<base::files::FilePathWatcher> config_watcher_; 408 scoped_ptr<base::files::FilePathWatcher> config_watcher_;
380 scoped_ptr<base::DelayTimer<HostProcess> > config_updated_timer_; 409 scoped_ptr<base::DelayTimer<HostProcess> > config_updated_timer_;
381 410
382 bool restarting_; 411 bool restarting_;
383 412
384 scoped_ptr<XmppSignalStrategy> signal_strategy_; 413 scoped_ptr<XmppSignalStrategy> signal_strategy_;
385 scoped_ptr<SignalingConnector> signaling_connector_; 414 scoped_ptr<SignalingConnector> signaling_connector_;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 int CALLBACK WinMain(HINSTANCE instance, 464 int CALLBACK WinMain(HINSTANCE instance,
436 HINSTANCE previous_instance, 465 HINSTANCE previous_instance,
437 LPSTR command_line, 466 LPSTR command_line,
438 int show_command) { 467 int show_command) {
439 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting 468 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting
440 // the command line from GetCommandLineW(), so we can safely pass NULL here. 469 // the command line from GetCommandLineW(), so we can safely pass NULL here.
441 return main(0, NULL); 470 return main(0, NULL);
442 } 471 }
443 472
444 #endif 473 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698