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

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

Issue 10823083: [Chromoting] Implement the host domain policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 #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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 const int kMaxPortNumber = 12409; 79 const int kMaxPortNumber = 12409;
80 80
81 const char kUnofficialOAuth2ClientId[] = 81 const char kUnofficialOAuth2ClientId[] =
82 "440925447803-2pi3v45bff6tp1rde2f7q6lgbor3o5uj.apps.googleusercontent.com"; 82 "440925447803-2pi3v45bff6tp1rde2f7q6lgbor3o5uj.apps.googleusercontent.com";
83 const char kUnofficialOAuth2ClientSecret[] = "W2ieEsG-R1gIA4MMurGrgMc_"; 83 const char kUnofficialOAuth2ClientSecret[] = "W2ieEsG-R1gIA4MMurGrgMc_";
84 84
85 const char kOfficialOAuth2ClientId[] = 85 const char kOfficialOAuth2ClientId[] =
86 "440925447803-avn2sj1kc099s0r7v62je5s339mu0am1.apps.googleusercontent.com"; 86 "440925447803-avn2sj1kc099s0r7v62je5s339mu0am1.apps.googleusercontent.com";
87 const char kOfficialOAuth2ClientSecret[] = "Bgur6DFiOMM1h8x-AQpuTQlK"; 87 const char kOfficialOAuth2ClientSecret[] = "Bgur6DFiOMM1h8x-AQpuTQlK";
88 88
89 // Whether a given string ends with a given suffix.
90 bool EndsWith(std::string s, std::string suffix) {
91 if (s.length() < suffix.length()) {
92 return false;
93 }
94 return s.compare(s.length() - suffix.length(), suffix.length(), suffix) == 0;
95 }
96
89 } // namespace 97 } // namespace
90 98
91 namespace remoting { 99 namespace remoting {
92 100
93 class HostProcess 101 class HostProcess
94 : public HeartbeatSender::Listener { 102 : public HeartbeatSender::Listener {
95 public: 103 public:
96 HostProcess() 104 HostProcess()
97 : message_loop_(MessageLoop::TYPE_UI), 105 : message_loop_(MessageLoop::TYPE_UI),
98 #ifdef OFFICIAL_BUILD 106 #ifdef OFFICIAL_BUILD
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 324
317 void OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies) { 325 void OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies) {
318 if (!context_->network_task_runner()->BelongsToCurrentThread()) { 326 if (!context_->network_task_runner()->BelongsToCurrentThread()) {
319 context_->network_task_runner()->PostTask(FROM_HERE, base::Bind( 327 context_->network_task_runner()->PostTask(FROM_HERE, base::Bind(
320 &HostProcess::OnPolicyUpdate, base::Unretained(this), 328 &HostProcess::OnPolicyUpdate, base::Unretained(this),
321 base::Passed(&policies))); 329 base::Passed(&policies)));
322 return; 330 return;
323 } 331 }
324 332
325 bool bool_value; 333 bool bool_value;
334 std::string string_value;
335 if (policies->GetString(policy_hack::PolicyWatcher::kHostDomainPolicyName,
336 &string_value)) {
337 OnHostDomainPolicyUpdate(string_value);
338 }
326 if (policies->GetBoolean(policy_hack::PolicyWatcher::kNatPolicyName, 339 if (policies->GetBoolean(policy_hack::PolicyWatcher::kNatPolicyName,
327 &bool_value)) { 340 &bool_value)) {
328 OnNatPolicyUpdate(bool_value); 341 OnNatPolicyUpdate(bool_value);
329 } 342 }
330 } 343 }
331 344
345 void OnHostDomainPolicyUpdate(const std::string& host_domain) {
346 if (!context_->network_task_runner()->BelongsToCurrentThread()) {
347 context_->network_task_runner()->PostTask(FROM_HERE, base::Bind(
348 &HostProcess::OnHostDomainPolicyUpdate, base::Unretained(this),
349 host_domain));
350 return;
351 }
352
353 if (!host_domain.empty() &&
354 !EndsWith(xmpp_login_, std::string("@") + host_domain)) {
355 Shutdown(kInvalidHostDomainExitCode);
356 }
357 }
358
332 void OnNatPolicyUpdate(bool nat_traversal_enabled) { 359 void OnNatPolicyUpdate(bool nat_traversal_enabled) {
333 if (!context_->network_task_runner()->BelongsToCurrentThread()) { 360 if (!context_->network_task_runner()->BelongsToCurrentThread()) {
334 context_->network_task_runner()->PostTask(FROM_HERE, base::Bind( 361 context_->network_task_runner()->PostTask(FROM_HERE, base::Bind(
335 &HostProcess::OnNatPolicyUpdate, base::Unretained(this), 362 &HostProcess::OnNatPolicyUpdate, base::Unretained(this),
336 nat_traversal_enabled)); 363 nat_traversal_enabled));
337 return; 364 return;
338 } 365 }
339 366
340 bool policy_changed = allow_nat_traversal_ != nat_traversal_enabled; 367 bool policy_changed = allow_nat_traversal_ != nat_traversal_enabled;
341 allow_nat_traversal_ = nat_traversal_enabled; 368 allow_nat_traversal_ = nat_traversal_enabled;
342 369
343 if (host_) { 370 if (host_) {
344 // Restart the host if the policy has changed while the host was 371 // Restart the host if the policy has changed while the host was
345 // online. 372 // online.
346 if (policy_changed) 373 if (policy_changed)
347 RestartHost(); 374 RestartHost();
348 } else { 375 } else {
349 // Just start the host otherwise. 376 // Just start the host otherwise.
350 StartHost(); 377 StartHost();
351 } 378 }
352 } 379 }
353 380
354 void StartHost() { 381 void StartHost() {
355 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 382 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
356 DCHECK(!host_); 383 DCHECK(!host_);
357 384
385 if (shutting_down_)
386 return;
387
358 if (!signal_strategy_.get()) { 388 if (!signal_strategy_.get()) {
359 signal_strategy_.reset( 389 signal_strategy_.reset(
360 new XmppSignalStrategy(context_->url_request_context_getter(), 390 new XmppSignalStrategy(context_->url_request_context_getter(),
361 xmpp_login_, xmpp_auth_token_, 391 xmpp_login_, xmpp_auth_token_,
362 xmpp_auth_service_)); 392 xmpp_auth_service_));
363 393
364 signaling_connector_.reset(new SignalingConnector( 394 signaling_connector_.reset(new SignalingConnector(
365 signal_strategy_.get(), 395 signal_strategy_.get(),
366 base::Bind(&HostProcess::OnAuthFailed, base::Unretained(this)))); 396 base::Bind(&HostProcess::OnAuthFailed, base::Unretained(this))));
367 397
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 } 502 }
473 503
474 void Shutdown(int exit_code) { 504 void Shutdown(int exit_code) {
475 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 505 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
476 506
477 if (shutting_down_) 507 if (shutting_down_)
478 return; 508 return;
479 509
480 shutting_down_ = true; 510 shutting_down_ = true;
481 exit_code_ = exit_code; 511 exit_code_ = exit_code;
482 host_->Shutdown(base::Bind( 512 if (host_) {
483 &HostProcess::OnShutdownFinished, base::Unretained(this))); 513 host_->Shutdown(base::Bind(
514 &HostProcess::OnShutdownFinished, base::Unretained(this)));
515 } else {
516 OnShutdownFinished();
517 }
484 } 518 }
485 519
486 void OnShutdownFinished() { 520 void OnShutdownFinished() {
487 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 521 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
488 522
489 // Destroy networking objects while we are on the network thread. 523 // Destroy networking objects while we are on the network thread.
490 host_ = NULL; 524 host_ = NULL;
491 host_event_logger_.reset(); 525 host_event_logger_.reset();
492 log_to_server_.reset(); 526 log_to_server_.reset();
493 heartbeat_sender_.reset(); 527 heartbeat_sender_.reset();
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 user32.GetFunctionPointer("SetProcessDPIAware")); 653 user32.GetFunctionPointer("SetProcessDPIAware"));
620 set_process_dpi_aware(); 654 set_process_dpi_aware();
621 } 655 }
622 656
623 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting 657 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting
624 // the command line from GetCommandLineW(), so we can safely pass NULL here. 658 // the command line from GetCommandLineW(), so we can safely pass NULL here.
625 return main(0, NULL); 659 return main(0, NULL);
626 } 660 }
627 661
628 #endif // defined(OS_WIN) 662 #endif // defined(OS_WIN)
OLDNEW
« remoting/host/plugin/host_script_object.cc ('K') | « remoting/host/plugin/host_script_object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698