summaryrefslogtreecommitdiffstats
path: root/remoting/host
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-26 17:35:30 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-26 17:35:30 +0000
commitec5ed95d919f26d71e1a8346fac834f55dc76ddf (patch)
tree84dbcbd238eb8dc91bba3c206012d93b2442fc9b /remoting/host
parentc42283689c77cf16b1ab2cf3b0d258d90d769c0c (diff)
downloadchromium_src-ec5ed95d919f26d71e1a8346fac834f55dc76ddf.zip
chromium_src-ec5ed95d919f26d71e1a8346fac834f55dc76ddf.tar.gz
chromium_src-ec5ed95d919f26d71e1a8346fac834f55dc76ddf.tar.bz2
Expose nat_traversal flag to host and client plugins.
BUG=90213 TEST=None Review URL: http://codereview.chromium.org/7471054 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94119 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host')
-rw-r--r--remoting/host/chromoting_host.cc21
-rw-r--r--remoting/host/chromoting_host.h47
-rw-r--r--remoting/host/chromoting_host_unittest.cc4
-rw-r--r--remoting/host/plugin/host_script_object.cc8
-rw-r--r--remoting/host/simple_host_process.cc14
5 files changed, 44 insertions, 50 deletions
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc
index f951f60..ddd4f99 100644
--- a/remoting/host/chromoting_host.cc
+++ b/remoting/host/chromoting_host.cc
@@ -38,32 +38,26 @@ namespace remoting {
// static
ChromotingHost* ChromotingHost::Create(ChromotingHostContext* context,
MutableHostConfig* config,
- AccessVerifier* access_verifier,
- Logger* logger) {
- DesktopEnvironment* desktop_env = DesktopEnvironment::Create(context);
- return Create(context, config, desktop_env, access_verifier, logger);
-}
-
-// static
-ChromotingHost* ChromotingHost::Create(ChromotingHostContext* context,
- MutableHostConfig* config,
DesktopEnvironment* environment,
AccessVerifier* access_verifier,
- Logger* logger) {
+ Logger* logger,
+ bool allow_nat_traversal) {
return new ChromotingHost(context, config, environment, access_verifier,
- logger);
+ logger, allow_nat_traversal);
}
ChromotingHost::ChromotingHost(ChromotingHostContext* context,
MutableHostConfig* config,
DesktopEnvironment* environment,
AccessVerifier* access_verifier,
- Logger* logger)
+ Logger* logger,
+ bool allow_nat_traversal)
: context_(context),
config_(config),
desktop_environment_(environment),
access_verifier_(access_verifier),
logger_(logger),
+ allow_nat_traversal_(allow_nat_traversal),
state_(kInitial),
protocol_config_(protocol::CandidateSessionConfig::CreateDefault()),
is_curtained_(false),
@@ -228,7 +222,8 @@ void ChromotingHost::OnStateChange(
server->Init(local_jid_, signal_strategy_.get(),
NewCallback(this, &ChromotingHost::OnNewClientSession),
- key_pair.CopyPrivateKey(), key_pair.GenerateCertificate());
+ key_pair.CopyPrivateKey(), key_pair.GenerateCertificate(),
+ allow_nat_traversal_);
session_manager_.reset(server);
diff --git a/remoting/host/chromoting_host.h b/remoting/host/chromoting_host.h
index 45910ed..f280914 100644
--- a/remoting/host/chromoting_host.h
+++ b/remoting/host/chromoting_host.h
@@ -68,19 +68,16 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>,
public ClientSession::EventHandler,
public SignalStrategy::StatusObserver {
public:
- // Factory methods that must be used to create ChromotingHost instances.
- // Default capturer and input stub are used if it is not specified.
- // Returned instance takes ownership of |access_verifier| and |environment|,
- // and adds a reference to |config|. It does NOT take ownership of |context|.
- static ChromotingHost* Create(ChromotingHostContext* context,
- MutableHostConfig* config,
- AccessVerifier* access_verifier,
- Logger* logger);
+ // Factory methods that must be used to create ChromotingHost
+ // instances. Returned instance takes ownership of
+ // |access_verifier| and |environment|. It does NOT take ownership
+ // of |context| and |logger|.
static ChromotingHost* Create(ChromotingHostContext* context,
MutableHostConfig* config,
DesktopEnvironment* environment,
AccessVerifier* access_verifier,
- Logger* logger);
+ Logger* logger,
+ bool allow_nat_traversal);
// Asynchronously start the host process.
//
@@ -152,22 +149,23 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>,
typedef std::vector<HostStatusObserver*> StatusObserverList;
typedef std::vector<scoped_refptr<ClientSession> > ClientList;
+ enum State {
+ kInitial,
+ kStarted,
+ kStopping,
+ kStopped,
+ };
+
// Takes ownership of |access_verifier| and |environment|, and adds a
// reference to |config|. Does NOT take ownership of |context|.
ChromotingHost(ChromotingHostContext* context,
MutableHostConfig* config,
DesktopEnvironment* environment,
AccessVerifier* access_verifier,
- Logger* logger);
+ Logger* logger,
+ bool allow_nat_traversal);
virtual ~ChromotingHost();
- enum State {
- kInitial,
- kStarted,
- kStopping,
- kStopped,
- };
-
// This method is called if a client is disconnected from the host.
void OnClientDisconnected(protocol::ConnectionToClient* client);
@@ -188,26 +186,21 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>,
void ShutdownRecorder();
void ShutdownFinish();
- // The context that the chromoting host runs on.
+ // Parameters specified when the host was created.
ChromotingHostContext* context_;
-
scoped_refptr<MutableHostConfig> config_;
-
scoped_ptr<DesktopEnvironment> desktop_environment_;
+ scoped_ptr<AccessVerifier> access_verifier_;
+ Logger* logger_;
+ bool allow_nat_traversal_;
+ // Connection objects.
scoped_ptr<SignalStrategy> signal_strategy_;
-
std::string local_jid_;
-
scoped_ptr<protocol::SessionManager> session_manager_;
StatusObserverList status_observers_;
- scoped_ptr<AccessVerifier> access_verifier_;
-
- // Logger (owned by the HostNPScriptObject).
- Logger* logger_;
-
// The connections to remote clients.
ClientList clients_;
diff --git a/remoting/host/chromoting_host_unittest.cc b/remoting/host/chromoting_host_unittest.cc
index 9d238fa..453e4cc 100644
--- a/remoting/host/chromoting_host_unittest.cc
+++ b/remoting/host/chromoting_host_unittest.cc
@@ -106,8 +106,8 @@ class ChromotingHostTest : public testing::Test {
local_input_monitor_);
MockAccessVerifier* access_verifier = new MockAccessVerifier();
- host_ = ChromotingHost::Create(&context_, config_,
- desktop, access_verifier, logger_.get());
+ host_ = ChromotingHost::Create(&context_, config_, desktop,
+ access_verifier, logger_.get(), false);
credentials_.set_type(protocol::PASSWORD);
credentials_.set_username("user");
credentials_.set_credential("password");
diff --git a/remoting/host/plugin/host_script_object.cc b/remoting/host/plugin/host_script_object.cc
index afbf232..cfb3b9c 100644
--- a/remoting/host/plugin/host_script_object.cc
+++ b/remoting/host/plugin/host_script_object.cc
@@ -11,6 +11,7 @@
#include "remoting/base/auth_token_util.h"
#include "remoting/host/chromoting_host.h"
#include "remoting/host/chromoting_host_context.h"
+#include "remoting/host/desktop_environment.h"
#include "remoting/host/host_config.h"
#include "remoting/host/host_key_pair.h"
#include "remoting/host/in_memory_host_config.h"
@@ -374,9 +375,12 @@ void HostNPScriptObject::ConnectInternal(
}
// Create the Host.
+ DesktopEnvironment* desktop_environment =
+ DesktopEnvironment::Create(&host_context_);
+ // TODO(sergeyu): Use firewall traversal policy settings here.
scoped_refptr<ChromotingHost> host =
- ChromotingHost::Create(&host_context_, host_config,
- access_verifier.release(), logger_.get());
+ ChromotingHost::Create(&host_context_, host_config, desktop_environment,
+ access_verifier.release(), logger_.get(), false);
host->AddStatusObserver(this);
host->AddStatusObserver(register_request.get());
host->set_it2me(true);
diff --git a/remoting/host/simple_host_process.cc b/remoting/host/simple_host_process.cc
index a5664dd..e58fd59 100644
--- a/remoting/host/simple_host_process.cc
+++ b/remoting/host/simple_host_process.cc
@@ -178,6 +178,7 @@ class SimpleHost {
// Construct a chromoting host.
scoped_refptr<ChromotingHost> host;
logger_.reset(new remoting::Logger());
+ DesktopEnvironment* desktop_environment;
if (fake_) {
remoting::Capturer* capturer =
new remoting::CapturerFake();
@@ -191,16 +192,17 @@ class SimpleHost {
remoting::ContinueWindow::Create();
remoting::LocalInputMonitor* local_input_monitor =
remoting::LocalInputMonitor::Create();
- host = ChromotingHost::Create(
- &context, config,
+ desktop_environment =
new DesktopEnvironment(&context, capturer, event_executor, curtain,
disconnect_window, continue_window,
- local_input_monitor),
- access_verifier.release(), logger_.get());
+ local_input_monitor);
} else {
- host = ChromotingHost::Create(&context, config,
- access_verifier.release(), logger_.get());
+ desktop_environment = DesktopEnvironment::Create(&context);
}
+
+ host = ChromotingHost::Create(&context, config, desktop_environment,
+ access_verifier.release(), logger_.get(),
+ false);
host->set_it2me(is_it2me_);
if (protocol_config_.get()) {