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 #include "remoting/host/it2me/it2me_host.h" | 5 #include "remoting/host/it2me/it2me_host.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 | 325 |
326 bool nat_policy; | 326 bool nat_policy; |
327 if (policies->GetBoolean(policy::key::kRemoteAccessHostFirewallTraversal, | 327 if (policies->GetBoolean(policy::key::kRemoteAccessHostFirewallTraversal, |
328 &nat_policy)) { | 328 &nat_policy)) { |
329 UpdateNatPolicy(nat_policy); | 329 UpdateNatPolicy(nat_policy); |
330 } | 330 } |
331 std::string host_domain; | 331 std::string host_domain; |
332 if (policies->GetString(policy::key::kRemoteAccessHostDomain, &host_domain)) { | 332 if (policies->GetString(policy::key::kRemoteAccessHostDomain, &host_domain)) { |
333 UpdateHostDomainPolicy(host_domain); | 333 UpdateHostDomainPolicy(host_domain); |
334 } | 334 } |
| 335 std::string client_domain; |
| 336 if (policies->GetString(policy::key::kRemoteAccessHostClientDomain, |
| 337 &client_domain)) { |
| 338 UpdateClientDomainPolicy(client_domain); |
| 339 } |
335 | 340 |
336 policy_received_ = true; | 341 policy_received_ = true; |
337 | 342 |
338 if (!pending_connect_.is_null()) { | 343 if (!pending_connect_.is_null()) { |
339 base::ResetAndReturn(&pending_connect_).Run(); | 344 base::ResetAndReturn(&pending_connect_).Run(); |
340 } | 345 } |
341 } | 346 } |
342 | 347 |
343 void It2MeHost::OnPolicyError() { | 348 void It2MeHost::OnPolicyError() { |
344 // TODO(lukasza): Report the policy error to the user. crbug.com/433009 | 349 // TODO(lukasza): Report the policy error to the user. crbug.com/433009 |
(...skipping 25 matching lines...) Expand all Loading... |
370 VLOG(2) << "UpdateHostDomainPolicy: " << host_domain; | 375 VLOG(2) << "UpdateHostDomainPolicy: " << host_domain; |
371 | 376 |
372 // When setting a host domain policy, force disconnect any existing session. | 377 // When setting a host domain policy, force disconnect any existing session. |
373 if (!host_domain.empty() && IsConnected()) { | 378 if (!host_domain.empty() && IsConnected()) { |
374 Shutdown(); | 379 Shutdown(); |
375 } | 380 } |
376 | 381 |
377 required_host_domain_ = host_domain; | 382 required_host_domain_ = host_domain; |
378 } | 383 } |
379 | 384 |
| 385 void It2MeHost::UpdateClientDomainPolicy(const std::string& client_domain) { |
| 386 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); |
| 387 |
| 388 VLOG(2) << "UpdateClientDomainPolicy: " << client_domain; |
| 389 |
| 390 // When setting a client domain policy, disconnect any existing session. |
| 391 if (!client_domain.empty() && IsConnected()) { |
| 392 Shutdown(); |
| 393 } |
| 394 |
| 395 required_client_domain_ = client_domain; |
| 396 } |
| 397 |
380 It2MeHost::~It2MeHost() { | 398 It2MeHost::~It2MeHost() { |
381 // Check that resources that need to be torn down on the UI thread are gone. | 399 // Check that resources that need to be torn down on the UI thread are gone. |
382 DCHECK(!desktop_environment_factory_.get()); | 400 DCHECK(!desktop_environment_factory_.get()); |
383 DCHECK(!policy_watcher_.get()); | 401 DCHECK(!policy_watcher_.get()); |
384 } | 402 } |
385 | 403 |
386 void It2MeHost::SetState(It2MeHostState state, | 404 void It2MeHost::SetState(It2MeHostState state, |
387 const std::string& error_message) { | 405 const std::string& error_message) { |
388 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); | 406 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); |
389 | 407 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 if (local_certificate.empty()) { | 470 if (local_certificate.empty()) { |
453 std::string error_message = "Failed to generate host certificate."; | 471 std::string error_message = "Failed to generate host certificate."; |
454 LOG(ERROR) << error_message; | 472 LOG(ERROR) << error_message; |
455 SetState(kError, error_message); | 473 SetState(kError, error_message); |
456 Shutdown(); | 474 Shutdown(); |
457 return; | 475 return; |
458 } | 476 } |
459 | 477 |
460 scoped_ptr<protocol::AuthenticatorFactory> factory( | 478 scoped_ptr<protocol::AuthenticatorFactory> factory( |
461 new protocol::It2MeHostAuthenticatorFactory( | 479 new protocol::It2MeHostAuthenticatorFactory( |
462 local_certificate, host_key_pair_, access_code)); | 480 local_certificate, host_key_pair_, access_code, |
| 481 required_client_domain_)); |
463 host_->SetAuthenticatorFactory(std::move(factory)); | 482 host_->SetAuthenticatorFactory(std::move(factory)); |
464 | 483 |
465 // Pass the Access Code to the script object before changing state. | 484 // Pass the Access Code to the script object before changing state. |
466 task_runner_->PostTask( | 485 task_runner_->PostTask( |
467 FROM_HERE, base::Bind(&It2MeHost::Observer::OnStoreAccessCode, | 486 FROM_HERE, base::Bind(&It2MeHost::Observer::OnStoreAccessCode, |
468 observer_, access_code, lifetime)); | 487 observer_, access_code, lifetime)); |
469 | 488 |
470 SetState(kReceivedAccessCode, ""); | 489 SetState(kReceivedAccessCode, ""); |
471 } | 490 } |
472 | 491 |
(...skipping 19 matching lines...) Expand all Loading... |
492 scoped_ptr<It2MeConfirmationDialogFactory> confirmation_dialog_factory( | 511 scoped_ptr<It2MeConfirmationDialogFactory> confirmation_dialog_factory( |
493 new It2MeConfirmationDialogFactory()); | 512 new It2MeConfirmationDialogFactory()); |
494 scoped_ptr<PolicyWatcher> policy_watcher = | 513 scoped_ptr<PolicyWatcher> policy_watcher = |
495 PolicyWatcher::Create(policy_service_, context->file_task_runner()); | 514 PolicyWatcher::Create(policy_service_, context->file_task_runner()); |
496 return new It2MeHost(std::move(context), std::move(policy_watcher), | 515 return new It2MeHost(std::move(context), std::move(policy_watcher), |
497 std::move(confirmation_dialog_factory), observer, | 516 std::move(confirmation_dialog_factory), observer, |
498 xmpp_server_config, directory_bot_jid); | 517 xmpp_server_config, directory_bot_jid); |
499 } | 518 } |
500 | 519 |
501 } // namespace remoting | 520 } // namespace remoting |
OLD | NEW |