| 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 <cstdint> | 7 #include <cstdint> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 using protocol::ValidatingAuthenticator; | 53 using protocol::ValidatingAuthenticator; |
| 54 typedef ValidatingAuthenticator::Result ValidationResult; | 54 typedef ValidatingAuthenticator::Result ValidationResult; |
| 55 typedef ValidatingAuthenticator::ValidationCallback ValidationCallback; | 55 typedef ValidatingAuthenticator::ValidationCallback ValidationCallback; |
| 56 | 56 |
| 57 } // namespace | 57 } // namespace |
| 58 | 58 |
| 59 It2MeHost::It2MeHost( | 59 It2MeHost::It2MeHost( |
| 60 std::unique_ptr<ChromotingHostContext> host_context, | 60 std::unique_ptr<ChromotingHostContext> host_context, |
| 61 std::unique_ptr<PolicyWatcher> policy_watcher, | 61 std::unique_ptr<PolicyWatcher> policy_watcher, |
| 62 std::unique_ptr<It2MeConfirmationDialogFactory> confirmation_dialog_factory, | 62 std::unique_ptr<It2MeConfirmationDialog> confirmation_dialog, |
| 63 base::WeakPtr<It2MeHost::Observer> observer, | 63 base::WeakPtr<It2MeHost::Observer> observer, |
| 64 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, | 64 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, |
| 65 const std::string& directory_bot_jid) | 65 const std::string& directory_bot_jid) |
| 66 : host_context_(std::move(host_context)), | 66 : host_context_(std::move(host_context)), |
| 67 task_runner_(host_context_->ui_task_runner()), | 67 task_runner_(host_context_->ui_task_runner()), |
| 68 observer_(observer), | 68 observer_(observer), |
| 69 xmpp_server_config_(xmpp_server_config), | 69 xmpp_server_config_(xmpp_server_config), |
| 70 directory_bot_jid_(directory_bot_jid), | 70 directory_bot_jid_(directory_bot_jid), |
| 71 policy_watcher_(std::move(policy_watcher)), | 71 policy_watcher_(std::move(policy_watcher)), |
| 72 confirmation_dialog_factory_(std::move(confirmation_dialog_factory)) { | 72 confirmation_dialog_(std::move(confirmation_dialog)) { |
| 73 DCHECK(task_runner_->BelongsToCurrentThread()); | 73 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 74 } | 74 } |
| 75 | 75 |
| 76 It2MeHost::~It2MeHost() { | 76 It2MeHost::~It2MeHost() { |
| 77 // Check that resources that need to be torn down on the UI thread are gone. | 77 // Check that resources that need to be torn down on the UI thread are gone. |
| 78 DCHECK(!desktop_environment_factory_.get()); | 78 DCHECK(!desktop_environment_factory_.get()); |
| 79 DCHECK(!policy_watcher_.get()); | 79 DCHECK(!policy_watcher_.get()); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void It2MeHost::Connect() { | 82 void It2MeHost::Connect() { |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 std::string("@") + required_client_domain_, | 508 std::string("@") + required_client_domain_, |
| 509 base::CompareCase::INSENSITIVE_ASCII)) { | 509 base::CompareCase::INSENSITIVE_ASCII)) { |
| 510 LOG(ERROR) << "Rejecting incoming connection from " << remote_jid | 510 LOG(ERROR) << "Rejecting incoming connection from " << remote_jid |
| 511 << ": Domain mismatch."; | 511 << ": Domain mismatch."; |
| 512 result_callback.Run(ValidationResult::ERROR_INVALID_ACCOUNT); | 512 result_callback.Run(ValidationResult::ERROR_INVALID_ACCOUNT); |
| 513 return; | 513 return; |
| 514 } | 514 } |
| 515 } | 515 } |
| 516 | 516 |
| 517 // Show a confirmation dialog to the user to allow them to confirm/reject it. | 517 // Show a confirmation dialog to the user to allow them to confirm/reject it. |
| 518 std::unique_ptr<It2MeConfirmationDialog> confirmation_dialog = | |
| 519 confirmation_dialog_factory_->Create(); | |
| 520 | |
| 521 confirmation_dialog_proxy_.reset(new It2MeConfirmationDialogProxy( | 518 confirmation_dialog_proxy_.reset(new It2MeConfirmationDialogProxy( |
| 522 host_context_->ui_task_runner(), std::move(confirmation_dialog))); | 519 host_context_->ui_task_runner(), std::move(confirmation_dialog_))); |
| 523 | 520 |
| 524 confirmation_dialog_proxy_->Show( | 521 confirmation_dialog_proxy_->Show( |
| 525 client_username, base::Bind(&It2MeHost::OnConfirmationResult, | 522 client_username, base::Bind(&It2MeHost::OnConfirmationResult, |
| 526 base::Unretained(this), result_callback)); | 523 base::Unretained(this), result_callback)); |
| 527 } | 524 } |
| 528 | 525 |
| 529 void It2MeHost::OnConfirmationResult( | 526 void It2MeHost::OnConfirmationResult( |
| 530 const protocol::ValidatingAuthenticator::ResultCallback& result_callback, | 527 const protocol::ValidatingAuthenticator::ResultCallback& result_callback, |
| 531 It2MeConfirmationDialog::Result result) { | 528 It2MeConfirmationDialog::Result result) { |
| 532 switch (result) { | 529 switch (result) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 545 It2MeHostFactory::~It2MeHostFactory() {} | 542 It2MeHostFactory::~It2MeHostFactory() {} |
| 546 | 543 |
| 547 scoped_refptr<It2MeHost> It2MeHostFactory::CreateIt2MeHost( | 544 scoped_refptr<It2MeHost> It2MeHostFactory::CreateIt2MeHost( |
| 548 std::unique_ptr<ChromotingHostContext> context, | 545 std::unique_ptr<ChromotingHostContext> context, |
| 549 policy::PolicyService* policy_service, | 546 policy::PolicyService* policy_service, |
| 550 base::WeakPtr<It2MeHost::Observer> observer, | 547 base::WeakPtr<It2MeHost::Observer> observer, |
| 551 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, | 548 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, |
| 552 const std::string& directory_bot_jid) { | 549 const std::string& directory_bot_jid) { |
| 553 DCHECK(context->ui_task_runner()->BelongsToCurrentThread()); | 550 DCHECK(context->ui_task_runner()->BelongsToCurrentThread()); |
| 554 | 551 |
| 555 std::unique_ptr<It2MeConfirmationDialogFactory> confirmation_dialog_factory( | |
| 556 new It2MeConfirmationDialogFactory()); | |
| 557 std::unique_ptr<PolicyWatcher> policy_watcher = | 552 std::unique_ptr<PolicyWatcher> policy_watcher = |
| 558 PolicyWatcher::Create(policy_service, context->file_task_runner()); | 553 PolicyWatcher::Create(policy_service, context->file_task_runner()); |
| 559 return new It2MeHost(std::move(context), std::move(policy_watcher), | 554 return new It2MeHost(std::move(context), std::move(policy_watcher), |
| 560 std::move(confirmation_dialog_factory), observer, | 555 It2MeConfirmationDialog::Create(), observer, |
| 561 xmpp_server_config, directory_bot_jid); | 556 xmpp_server_config, directory_bot_jid); |
| 562 } | 557 } |
| 563 | 558 |
| 564 } // namespace remoting | 559 } // namespace remoting |
| OLD | NEW |