Index: remoting/host/chromoting_host.cc |
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc |
index 1e958cc6aee81e45599d3cbe0f609f4f764bc3dc..4b6cf904363afd78f2e6e3a97cca0a24cd7175ab 100644 |
--- a/remoting/host/chromoting_host.cc |
+++ b/remoting/host/chromoting_host.cc |
@@ -49,6 +49,7 @@ ChromotingHost::ChromotingHost(ChromotingHostContext* context, |
desktop_environment_(environment), |
config_(config), |
allow_nat_traversal_(allow_nat_traversal), |
+ have_shared_secret_(false), |
stopping_recorders_(0), |
state_(kInitial), |
protocol_config_(protocol::CandidateSessionConfig::CreateDefault()), |
@@ -136,6 +137,7 @@ void ChromotingHost::Shutdown(const base::Closure& shutdown_task) { |
// deletion. |
context_->network_message_loop()->DeleteSoon( |
FROM_HERE, session_manager_.release()); |
+ have_shared_secret_ = false; |
} |
// Stop XMPP connection synchronously. |
@@ -163,10 +165,14 @@ void ChromotingHost::AddStatusObserver(HostStatusObserver* observer) { |
void ChromotingHost::SetSharedSecret(const std::string& shared_secret) { |
DCHECK(context_->network_message_loop()->BelongsToCurrentThread()); |
- session_manager_->set_authenticator_factory( |
- new protocol::V1HostAuthenticatorFactory( |
- key_pair_.GenerateCertificate(), key_pair_.private_key(), |
- shared_secret)); |
+ shared_secret_ = shared_secret; |
+ have_shared_secret_ = true; |
+ if (session_manager_.get()) { |
+ session_manager_->set_authenticator_factory( |
+ new protocol::V1HostAuthenticatorFactory( |
+ key_pair_.GenerateCertificate(), key_pair_.private_key(), |
+ shared_secret_)); |
+ } |
} |
//////////////////////////////////////////////////////////////////////////// |
@@ -278,6 +284,12 @@ void ChromotingHost::OnStateChange( |
this, allow_nat_traversal_); |
session_manager_.reset(server); |
+ if (have_shared_secret_) { |
Sergey Ulanov
2011/12/01 21:10:13
nit: I don't think we need this flag. !shared_secr
Lambros
2011/12/01 21:29:21
!shared_secret_.empty() wouldn't work. remoting_m
|
+ session_manager_->set_authenticator_factory( |
+ new protocol::V1HostAuthenticatorFactory( |
+ key_pair_.GenerateCertificate(), key_pair_.private_key(), |
+ shared_secret_)); |
+ } |
for (StatusObserverList::iterator it = status_observers_.begin(); |
it != status_observers_.end(); ++it) { |