summaryrefslogtreecommitdiffstats
path: root/remoting/host
diff options
context:
space:
mode:
authorrmsousa@chromium.org <rmsousa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-06 02:06:34 +0000
committerrmsousa@chromium.org <rmsousa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-06 02:06:34 +0000
commit1603be0c4d285afbbb8326859c04ccaafdfe0e81 (patch)
tree60a4dacf72bd3dfe010af7bd2d92126f64c433dc /remoting/host
parentecac5739b92ef9668e9361c7af69ac0a04837f0b (diff)
downloadchromium_src-1603be0c4d285afbbb8326859c04ccaafdfe0e81.zip
chromium_src-1603be0c4d285afbbb8326859c04ccaafdfe0e81.tar.gz
chromium_src-1603be0c4d285afbbb8326859c04ccaafdfe0e81.tar.bz2
Curtain policy cross-platform plumbing and fixes
This moves everything into a cross-platform plumbing, makes the curtain policy lifetime the same as the other HostStatusObservers (to avoid issues with host restarts), and changes the OnPolicyUpdated handler to restart the host at most once. BUG=153590 Review URL: https://chromiumcodereview.appspot.com/10914298 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160546 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host')
-rw-r--r--remoting/host/curtain_mode.h60
-rw-r--r--remoting/host/curtain_mode_linux.cc31
-rw-r--r--remoting/host/curtain_mode_mac.cc88
-rw-r--r--remoting/host/curtain_mode_mac.h65
-rw-r--r--remoting/host/curtain_mode_win.cc31
-rw-r--r--remoting/host/curtaining_host_observer.cc37
-rw-r--r--remoting/host/curtaining_host_observer.h37
-rw-r--r--remoting/host/remoting_me2me_host.cc128
8 files changed, 311 insertions, 166 deletions
diff --git a/remoting/host/curtain_mode.h b/remoting/host/curtain_mode.h
new file mode 100644
index 0000000..aeb9b14
--- /dev/null
+++ b/remoting/host/curtain_mode.h
@@ -0,0 +1,60 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef REMOTING_HOST_CURTAIN_MODE_H_
+#define REMOTING_HOST_CURTAIN_MODE_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/callback.h"
+#include "base/compiler_specific.h"
+
+namespace remoting {
+
+class ChromotingHost;
+
+class CurtainMode {
+ public:
+ virtual ~CurtainMode() {}
+
+ // Creates a CurtainMode object, with callbacks to be invoked when the
+ // switched-out session is switched back to the console, or in case of errors
+ // activating the curtain. Typically, remote clients should be disconnected in
+ // both cases: for errors, because the privacy guarantee of curtain-mode
+ // cannot be honoured; for switch-in, to ensure that only one connection
+ // (console or remote) exists to a session.
+ static scoped_ptr<CurtainMode> Create(
+ const base::Closure& on_session_activate,
+ const base::Closure& on_error);
+
+ // Sets/gets whether the curtain mode is required by policy.
+ // TODO(rmsousa): Remove this piece of implementation from the interface once
+ // we have a good way to do so.
+ void set_required(bool required) { required_ = required; }
+ bool required() { return required_; }
+
+ // Activate or deactivate curtain mode.
+ // If activated is true (meaning a remote client has just logged in), the
+ // implementation must immediately activate the curtain, or call on_error if
+ // it cannot do so. If a console user logs in while the curtain is activated,
+ // the implementation must call on_session_activate (from any thread).
+ // If activated is false (meaning the remote client has disconnected), the
+ // implementation must not remove the curtain (since at this point we can make
+ // no guarantees about whether the user intended to leave the console locked),
+ // and must not call on_session_activate when the console user logs in.
+ virtual void SetActivated(bool activated) = 0;
+
+ protected:
+ CurtainMode() : required_(false) {}
+
+ private:
+ bool required_;
+
+ DISALLOW_COPY_AND_ASSIGN(CurtainMode);
+};
+
+} // namespace remoting
+
+#endif
diff --git a/remoting/host/curtain_mode_linux.cc b/remoting/host/curtain_mode_linux.cc
new file mode 100644
index 0000000..5c3f269
--- /dev/null
+++ b/remoting/host/curtain_mode_linux.cc
@@ -0,0 +1,31 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/host/curtain_mode.h"
+
+#include "base/logging.h"
+
+namespace remoting {
+
+class CurtainModeLinux : public CurtainMode {
+ public:
+ CurtainModeLinux() {}
+ // Overriden from CurtainMode.
+ virtual void SetActivated(bool activated) OVERRIDE {
+ NOTIMPLEMENTED();
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CurtainModeLinux);
+};
+
+// static
+scoped_ptr<CurtainMode> CurtainMode::Create(
+ const base::Closure& on_session_activate,
+ const base::Closure& on_error) {
+ return scoped_ptr<CurtainMode>(
+ new CurtainModeLinux());
+}
+
+} // namespace remoting
diff --git a/remoting/host/curtain_mode_mac.cc b/remoting/host/curtain_mode_mac.cc
index a7dedff..b80c3db 100644
--- a/remoting/host/curtain_mode_mac.cc
+++ b/remoting/host/curtain_mode_mac.cc
@@ -2,10 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "remoting/host/curtain_mode_mac.h"
+#include "remoting/host/curtain_mode.h"
#include <ApplicationServices/ApplicationServices.h>
+#include <Carbon/Carbon.h>
#include <Security/Security.h>
+#include <unistd.h>
#include "base/logging.h"
#include "base/mac/scoped_cftyperef.h"
@@ -18,31 +20,60 @@ const char* kCGSessionPath =
namespace remoting {
-CurtainMode::CurtainMode(const base::Closure& on_session_activate,
- const base::Closure& on_error)
+class CurtainModeMac : public CurtainMode {
+ public:
+ CurtainModeMac(const base::Closure& on_session_activate,
+ const base::Closure& on_error);
+
+ virtual ~CurtainModeMac();
+
+ // Overriden from CurtainMode.
+ virtual void SetActivated(bool activated) OVERRIDE;
+
+ private:
+ // If the current session is attached to the console and is not showing
+ // the logon screen then switch it out to ensure privacy.
+ bool ActivateCurtain();
+
+ // Add or remove the switch-in event handler.
+ bool InstallEventHandler();
+ bool RemoveEventHandler();
+
+ // Handlers for the switch-in event.
+ static OSStatus SessionActivateHandler(EventHandlerCallRef handler,
+ EventRef event,
+ void* user_data);
+ void OnSessionActivate();
+
+ base::Closure on_session_activate_;
+ base::Closure on_error_;
+ EventHandlerRef event_handler_;
+
+ DISALLOW_COPY_AND_ASSIGN(CurtainModeMac);
+};
+
+CurtainModeMac::CurtainModeMac(const base::Closure& on_session_activate,
+ const base::Closure& on_error)
: on_session_activate_(on_session_activate),
on_error_(on_error),
- connection_active_(false),
event_handler_(NULL) {
}
-CurtainMode::~CurtainMode() {
- SetEnabled(false);
+CurtainModeMac::~CurtainModeMac() {
+ SetActivated(false);
}
-void CurtainMode::SetEnabled(bool enabled) {
- if (enabled) {
- if (connection_active_) {
- if (!ActivateCurtain()) {
- on_error_.Run();
- }
+void CurtainModeMac::SetActivated(bool activated) {
+ if (activated) {
+ if (!ActivateCurtain()) {
+ on_error_.Run();
}
} else {
RemoveEventHandler();
}
}
-bool CurtainMode::ActivateCurtain() {
+bool CurtainModeMac::ActivateCurtain() {
// Try to install the switch-in handler. Do this before switching out the
// current session so that the console session is not affected if it fails.
if (!InstallEventHandler()) {
@@ -74,32 +105,19 @@ bool CurtainMode::ActivateCurtain() {
return true;
}
-// TODO(jamiewalch): This code assumes at most one client connection at a time.
-// Add OnFirstClientConnected and OnLastClientDisconnected optional callbacks
-// to the HostStatusObserver interface to address this.
-void CurtainMode::OnClientAuthenticated(const std::string& jid) {
- connection_active_ = true;
- SetEnabled(true);
-}
-
-void CurtainMode::OnClientDisconnected(const std::string& jid) {
- SetEnabled(false);
- connection_active_ = false;
-}
-
-OSStatus CurtainMode::SessionActivateHandler(EventHandlerCallRef handler,
+OSStatus CurtainModeMac::SessionActivateHandler(EventHandlerCallRef handler,
EventRef event,
void* user_data) {
- CurtainMode* self = static_cast<CurtainMode*>(user_data);
+ CurtainModeMac* self = static_cast<CurtainModeMac*>(user_data);
self->OnSessionActivate();
return noErr;
}
-void CurtainMode::OnSessionActivate() {
+void CurtainModeMac::OnSessionActivate() {
on_session_activate_.Run();
}
-bool CurtainMode::InstallEventHandler() {
+bool CurtainModeMac::InstallEventHandler() {
OSStatus result = noErr;
if (!event_handler_) {
EventTypeSpec event;
@@ -112,7 +130,7 @@ bool CurtainMode::InstallEventHandler() {
return result == noErr;
}
-bool CurtainMode::RemoveEventHandler() {
+bool CurtainModeMac::RemoveEventHandler() {
OSStatus result = noErr;
if (event_handler_) {
result = ::RemoveEventHandler(event_handler_);
@@ -120,4 +138,12 @@ bool CurtainMode::RemoveEventHandler() {
return result == noErr;
}
+// static
+scoped_ptr<CurtainMode> CurtainMode::Create(
+ const base::Closure& on_session_activate,
+ const base::Closure& on_error) {
+ return scoped_ptr<CurtainMode>(
+ new CurtainModeMac(on_session_activate, on_error));
+}
+
} // namespace remoting
diff --git a/remoting/host/curtain_mode_mac.h b/remoting/host/curtain_mode_mac.h
deleted file mode 100644
index b439b11..0000000
--- a/remoting/host/curtain_mode_mac.h
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef REMOTING_HOST_CURTAIN_MODE_MAC_H_
-#define REMOTING_HOST_CURTAIN_MODE_MAC_H_
-
-#include <Carbon/Carbon.h>
-
-#include <string>
-
-#include "base/callback.h"
-#include "base/compiler_specific.h"
-#include "remoting/host/host_status_observer.h"
-
-namespace remoting {
-
-class CurtainMode : public HostStatusObserver {
- public:
- // Set callbacks to be invoked when the switched-out session is switched back
- // to the console, or in case of errors activating curtain-mode. Typically,
- // remote clients should be disconnected in both cases: for errors, because
- // the privacy guarantee of curtain-mode cannot be honoured; for switch-in,
- // to ensure that only one connection (console or remote) exists to a session.
- // Note that only the session's owner (or someone who knows the password) can
- // attach it to the console, so this is safe.
- CurtainMode(const base::Closure& on_session_activate,
- const base::Closure& on_error);
- virtual ~CurtainMode();
-
- // Enable or disable curtain-mode. Note that disabling curtain-mode does not
- // deactivate the curtain, but it does remove the switch-in handler, meaning
- // that on_session_activate will not be invoked if curtain-mode is disabled.
- // Conversely, enabling curtain-mode *does* activate the curtain if there is
- // a connected client at the time.
- void SetEnabled(bool enabled);
-
- // Overridden from HostStatusObserver
- virtual void OnClientAuthenticated(const std::string& jid) OVERRIDE;
- virtual void OnClientDisconnected(const std::string& jid) OVERRIDE;
-
- private:
- // If the current session is attached to the console and is not showing
- // the logon screen then switch it out to ensure privacy.
- bool ActivateCurtain();
-
- // Add or remove the switch-in event handler.
- bool InstallEventHandler();
- bool RemoveEventHandler();
-
- // Handlers for the switch-in event.
- static OSStatus SessionActivateHandler(EventHandlerCallRef handler,
- EventRef event,
- void* user_data);
- void OnSessionActivate();
-
- base::Closure on_session_activate_;
- base::Closure on_error_;
- bool connection_active_;
- EventHandlerRef event_handler_;
-};
-
-}
-
-#endif
diff --git a/remoting/host/curtain_mode_win.cc b/remoting/host/curtain_mode_win.cc
new file mode 100644
index 0000000..f3ebcd2
--- /dev/null
+++ b/remoting/host/curtain_mode_win.cc
@@ -0,0 +1,31 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/host/curtain_mode.h"
+
+#include "base/logging.h"
+
+namespace remoting {
+
+class CurtainModeWin : public CurtainMode {
+ public:
+ CurtainModeWin() {}
+ // Overriden from CurtainMode.
+ virtual void SetActivated(bool activated) OVERRIDE {
+ NOTIMPLEMENTED();
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CurtainModeWin);
+};
+
+// static
+scoped_ptr<CurtainMode> CurtainMode::Create(
+ const base::Closure& on_session_activate,
+ const base::Closure& on_error) {
+ return scoped_ptr<CurtainMode>(
+ new CurtainModeWin());
+}
+
+} // namespace remoting
diff --git a/remoting/host/curtaining_host_observer.cc b/remoting/host/curtaining_host_observer.cc
new file mode 100644
index 0000000..298c595
--- /dev/null
+++ b/remoting/host/curtaining_host_observer.cc
@@ -0,0 +1,37 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/host/curtaining_host_observer.h"
+
+#include "base/logging.h"
+#include "remoting/host/curtain_mode.h"
+#include "remoting/host/chromoting_host.h"
+
+namespace remoting {
+
+CurtainingHostObserver::CurtainingHostObserver(
+ CurtainMode *curtain, scoped_refptr<ChromotingHost> host)
+ : curtain_(curtain), host_(host) {
+ host_->AddStatusObserver(this);
+}
+
+CurtainingHostObserver::~CurtainingHostObserver() {
+ host_->RemoveStatusObserver(this);
+ curtain_->SetActivated(false);
+}
+
+// TODO(jamiewalch): This code assumes at most one client connection at a time.
+// Add OnFirstClientConnected and OnLastClientDisconnected optional callbacks
+// to the HostStatusObserver interface to address this.
+void CurtainingHostObserver::OnClientAuthenticated(const std::string& jid) {
+ if (curtain_->required()) {
+ curtain_->SetActivated(true);
+ }
+}
+
+void CurtainingHostObserver::OnClientDisconnected(const std::string& jid) {
+ curtain_->SetActivated(false);
+}
+
+} // namespace remoting
diff --git a/remoting/host/curtaining_host_observer.h b/remoting/host/curtaining_host_observer.h
new file mode 100644
index 0000000..92c740a
--- /dev/null
+++ b/remoting/host/curtaining_host_observer.h
@@ -0,0 +1,37 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef REMOTING_HOST_CURTAINING_HOST_OBSERVER_H_
+#define REMOTING_HOST_CURTAINING_HOST_OBSERVER_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "remoting/host/host_status_observer.h"
+
+namespace remoting {
+
+class CurtainMode;
+class ChromotingHost;
+
+class CurtainingHostObserver : public HostStatusObserver {
+ public:
+ CurtainingHostObserver(CurtainMode *curtain,
+ scoped_refptr<ChromotingHost> host);
+ virtual ~CurtainingHostObserver();
+
+ // From HostStatusObserver.
+ virtual void OnClientAuthenticated(const std::string& jid) OVERRIDE;
+ virtual void OnClientDisconnected(const std::string& jid) OVERRIDE;
+
+ private:
+ CurtainMode* curtain_;
+ scoped_refptr<ChromotingHost> host_;
+};
+
+} // namespace remoting
+#endif
diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc
index 81e8f25..98b810c 100644
--- a/remoting/host/remoting_me2me_host.cc
+++ b/remoting/host/remoting_me2me_host.cc
@@ -37,7 +37,8 @@
#include "remoting/host/chromoting_host_context.h"
#include "remoting/host/chromoting_messages.h"
#include "remoting/host/config_file_watcher.h"
-#include "remoting/host/config_file_watcher.h"
+#include "remoting/host/curtain_mode.h"
+#include "remoting/host/curtaining_host_observer.h"
#include "remoting/host/desktop_environment_factory.h"
#include "remoting/host/desktop_resizer.h"
#include "remoting/host/dns_blackhole_checker.h"
@@ -67,7 +68,6 @@
#if defined(OS_MACOSX)
#include "base/mac/scoped_cftyperef.h"
#include "base/mac/scoped_nsautorelease_pool.h"
-#include "remoting/host/curtain_mode_mac.h"
#endif // defined(OS_MACOSX)
#if defined(OS_LINUX)
@@ -116,7 +116,7 @@ class HostProcess
public IPC::Listener,
public ConfigFileWatcher::Delegate {
public:
- HostProcess(scoped_ptr<ChromotingHostContext> context)
+ explicit HostProcess(scoped_ptr<ChromotingHostContext> context)
: context_(context.Pass()),
config_(FilePath()),
#ifdef OFFICIAL_BUILD
@@ -135,16 +135,14 @@ class HostProcess
context_->input_task_runner(), context_->ui_task_runner())),
#endif // !defined(OS_WIN)
desktop_resizer_(DesktopResizer::Create()),
- exit_code_(kSuccessExitCode)
-#if defined(OS_MACOSX)
- , curtain_(base::Bind(&HostProcess::OnDisconnectRequested,
- base::Unretained(this)),
- base::Bind(&HostProcess::OnDisconnectRequested,
- base::Unretained(this)))
-#endif
- {
+ exit_code_(kSuccessExitCode) {
network_change_notifier_.reset(net::NetworkChangeNotifier::Create());
- }
+ curtain_ = CurtainMode::Create(
+ base::Bind(&HostProcess::OnDisconnectRequested,
+ base::Unretained(this)),
+ base::Bind(&HostProcess::OnDisconnectRequested,
+ base::Unretained(this)));
+}
bool InitWithCommandLine(const CommandLine* cmd_line) {
// Connect to the daemon process.
@@ -396,6 +394,7 @@ class HostProcess
}
void OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies) {
+ // TODO(rmsousa): Consolidate all On*PolicyUpdate methods into this one.
if (!context_->network_task_runner()->BelongsToCurrentThread()) {
context_->network_task_runner()->PostTask(FROM_HERE, base::Bind(
&HostProcess::OnPolicyUpdate, base::Unretained(this),
@@ -403,73 +402,62 @@ class HostProcess
return;
}
- if (!host_) {
- StartHost();
- }
-
+ bool restart_required = false;
bool bool_value;
std::string string_value;
if (policies->GetString(policy_hack::PolicyWatcher::kHostDomainPolicyName,
&string_value)) {
- OnHostDomainPolicyUpdate(string_value);
+ restart_required |= OnHostDomainPolicyUpdate(string_value);
}
if (policies->GetBoolean(policy_hack::PolicyWatcher::kNatPolicyName,
&bool_value)) {
- OnNatPolicyUpdate(bool_value);
+ restart_required |= OnNatPolicyUpdate(bool_value);
}
if (policies->GetString(
policy_hack::PolicyWatcher::kHostTalkGadgetPrefixPolicyName,
&string_value)) {
- OnHostTalkGadgetPrefixPolicyUpdate(string_value);
+ restart_required |= OnHostTalkGadgetPrefixPolicyUpdate(string_value);
}
- // TODO(rmsousa): This must be called last. crbug.com/146716 includes a
- // refactoring to remove this requirement.
if (policies->GetBoolean(
policy_hack::PolicyWatcher::kHostRequireCurtainPolicyName,
&bool_value)) {
- OnCurtainPolicyUpdate(bool_value);
+ restart_required |= OnCurtainPolicyUpdate(bool_value);
+ }
+ if (!host_) {
+ StartHost();
+ } else if (restart_required) {
+ RestartHost();
}
}
- void OnHostDomainPolicyUpdate(const std::string& host_domain) {
- if (!context_->network_task_runner()->BelongsToCurrentThread()) {
- context_->network_task_runner()->PostTask(FROM_HERE, base::Bind(
- &HostProcess::OnHostDomainPolicyUpdate, base::Unretained(this),
- host_domain));
- return;
- }
+ bool OnHostDomainPolicyUpdate(const std::string& host_domain) {
+ // Returns true if the host has to be restarted after this policy update.
+ DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
if (!host_domain.empty() &&
!EndsWith(xmpp_login_, std::string("@") + host_domain, false)) {
Shutdown(kInvalidHostDomainExitCode);
}
+ return false;
}
- void OnNatPolicyUpdate(bool nat_traversal_enabled) {
- if (!context_->network_task_runner()->BelongsToCurrentThread()) {
- context_->network_task_runner()->PostTask(FROM_HERE, base::Bind(
- &HostProcess::OnNatPolicyUpdate, base::Unretained(this),
- nat_traversal_enabled));
- return;
- }
-
- bool policy_changed = allow_nat_traversal_ != nat_traversal_enabled;
- allow_nat_traversal_ = nat_traversal_enabled;
+ bool OnNatPolicyUpdate(bool nat_traversal_enabled) {
+ // Returns true if the host has to be restarted after this policy update.
+ DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
- if (policy_changed) {
- RestartHost();
+ if (allow_nat_traversal_ != nat_traversal_enabled) {
+ allow_nat_traversal_ = nat_traversal_enabled;
+ LOG(INFO) << "Updated NAT policy.";
+ return true;
}
+ return false;
}
- void OnCurtainPolicyUpdate(bool curtain_required) {
-#if defined(OS_MACOSX)
- if (!context_->network_task_runner()->BelongsToCurrentThread()) {
- context_->network_task_runner()->PostTask(FROM_HERE, base::Bind(
- &HostProcess::OnCurtainPolicyUpdate, base::Unretained(this),
- curtain_required));
- return;
- }
+ bool OnCurtainPolicyUpdate(bool curtain_required) {
+ // Returns true if the host has to be restarted after this policy update.
+ DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
+#if defined(OS_MACOSX)
if (curtain_required) {
// If curtain mode is required, then we can't currently support remoting
// the login screen. This is because we don't curtain the login screen
@@ -480,32 +468,29 @@ class HostProcess
// daemon architecture (crbug.com/134894)
if (getuid() == 0) {
Shutdown(kLoginScreenNotSupportedExitCode);
- return;
+ return false;
}
-
- host_->AddStatusObserver(&curtain_);
- curtain_.SetEnabled(true);
- } else {
- curtain_.SetEnabled(false);
- host_->RemoveStatusObserver(&curtain_);
}
#endif
+ if (curtain_->required() != curtain_required) {
+ LOG(INFO) << "Updated curtain policy.";
+ curtain_->set_required(curtain_required);
+ return true;
+ }
+ return false;
}
- void OnHostTalkGadgetPrefixPolicyUpdate(
+ bool OnHostTalkGadgetPrefixPolicyUpdate(
const std::string& talkgadget_prefix) {
- if (!context_->network_task_runner()->BelongsToCurrentThread()) {
- context_->network_task_runner()->PostTask(FROM_HERE, base::Bind(
- &HostProcess::OnHostTalkGadgetPrefixPolicyUpdate,
- base::Unretained(this), talkgadget_prefix));
- return;
- }
+ // Returns true if the host has to be restarted after this policy update.
+ DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
if (talkgadget_prefix != talkgadget_prefix_) {
- LOG(INFO) << "Restarting host due to updated talkgadget policy:";
+ LOG(INFO) << "Updated talkgadget policy.";
talkgadget_prefix_ = talkgadget_prefix;
- RestartHost();
+ return true;
}
+ return false;
}
void StartHost() {
@@ -587,6 +572,9 @@ class HostProcess
resizing_host_observer_.reset(
new ResizingHostObserver(desktop_resizer_.get(), host_));
+ curtaining_host_observer_.reset(new CurtainingHostObserver(
+ curtain_.get(), host_));
+
if (host_user_interface_.get()) {
host_user_interface_->Start(
host_, base::Bind(&HostProcess::OnDisconnectRequested,
@@ -603,7 +591,7 @@ class HostProcess
}
// Invoked when the user uses the Disconnect windows to terminate
- // the sessions.
+ // the sessions, or when the local session is activated in curtain mode.
void OnDisconnectRequested() {
if (!context_->network_task_runner()->BelongsToCurrentThread()) {
context_->network_task_runner()->PostTask(FROM_HERE, base::Bind(
@@ -672,6 +660,7 @@ class HostProcess
void ResetHost() {
DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
+ curtaining_host_observer_.reset();
host_event_logger_.reset();
log_to_server_.reset();
heartbeat_sender_.reset();
@@ -702,6 +691,9 @@ class HostProcess
bool allow_nat_traversal_;
std::string talkgadget_prefix_;
+ scoped_ptr<CurtainMode> curtain_;
+ scoped_ptr<CurtainingHostObserver> curtaining_host_observer_;
+
bool restarting_;
bool shutting_down_;
@@ -719,10 +711,6 @@ class HostProcess
scoped_refptr<ChromotingHost> host_;
int exit_code_;
-
-#if defined(OS_MACOSX)
- remoting::CurtainMode curtain_;
-#endif // defined(OS_MACOSX)
};
} // namespace remoting