diff options
author | alexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-08 18:26:18 +0000 |
---|---|---|
committer | alexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-08 18:26:18 +0000 |
commit | 96361d07bcba1c8e8bea994e79e2cfddbcff80df (patch) | |
tree | 52abe8f819965bdb58bb0a35ae12f5d29fcb4581 /remoting | |
parent | d9e5e751c6f9dc412ce8b7f956e0a3ec3c2cdd9b (diff) | |
download | chromium_src-96361d07bcba1c8e8bea994e79e2cfddbcff80df.zip chromium_src-96361d07bcba1c8e8bea994e79e2cfddbcff80df.tar.gz chromium_src-96361d07bcba1c8e8bea994e79e2cfddbcff80df.tar.bz2 |
Do not show the in-session UI in a curtained session.
This CL refactors the existing curtain mode implementation for Mac/Linux and finalizes one for Windows. Changes:
- The curtain mode policy setting is passed to the desktop environment factory. This way it will be able to pass the flag down to the created desktop environment instances.
- The curtain mode object is hosted by the desktop environment for the duration of the session.
- When a session is curtained the in-session UI is not created and local input is not monitored.
BUG=104544, 166882
R=cdn@chromium.org, rmsousa@chromium.org
Review URL: https://codereview.chromium.org/14435009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198945 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
26 files changed, 384 insertions, 374 deletions
diff --git a/remoting/host/basic_desktop_environment.cc b/remoting/host/basic_desktop_environment.cc index b378479..2a05104 100644 --- a/remoting/host/basic_desktop_environment.cc +++ b/remoting/host/basic_desktop_environment.cc @@ -56,9 +56,7 @@ BasicDesktopEnvironment::CreateVideoCapturer() { BasicDesktopEnvironment::BasicDesktopEnvironment( scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, - scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, - base::WeakPtr<ClientSessionControl> client_session_control, - const UiStrings& ui_strings) + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) : caller_task_runner_(caller_task_runner), input_task_runner_(input_task_runner), ui_task_runner_(ui_task_runner) { @@ -79,18 +77,6 @@ BasicDesktopEnvironmentFactory::BasicDesktopEnvironmentFactory( BasicDesktopEnvironmentFactory::~BasicDesktopEnvironmentFactory() { } -scoped_ptr<DesktopEnvironment> BasicDesktopEnvironmentFactory::Create( - base::WeakPtr<ClientSessionControl> client_session_control) { - DCHECK(caller_task_runner_->BelongsToCurrentThread()); - - return scoped_ptr<DesktopEnvironment>( - new BasicDesktopEnvironment(caller_task_runner(), - input_task_runner(), - ui_task_runner(), - client_session_control, - ui_strings_)); -} - bool BasicDesktopEnvironmentFactory::SupportsAudioCapture() const { DCHECK(caller_task_runner_->BelongsToCurrentThread()); diff --git a/remoting/host/basic_desktop_environment.h b/remoting/host/basic_desktop_environment.h index 6202ba5..6d4a88a 100644 --- a/remoting/host/basic_desktop_environment.h +++ b/remoting/host/basic_desktop_environment.h @@ -38,9 +38,7 @@ class BasicDesktopEnvironment : public DesktopEnvironment { BasicDesktopEnvironment( scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, - scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, - base::WeakPtr<ClientSessionControl> client_session_control, - const UiStrings& ui_strings); + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner() const { return caller_task_runner_; @@ -79,8 +77,6 @@ class BasicDesktopEnvironmentFactory : public DesktopEnvironmentFactory { virtual ~BasicDesktopEnvironmentFactory(); // DesktopEnvironmentFactory implementation. - virtual scoped_ptr<DesktopEnvironment> Create( - base::WeakPtr<ClientSessionControl> client_session_control) OVERRIDE; virtual bool SupportsAudioCapture() const OVERRIDE; protected: diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc index 9cd6abc..d090e05 100644 --- a/remoting/host/chromoting_host.cc +++ b/remoting/host/chromoting_host.cc @@ -81,6 +81,7 @@ ChromotingHost::ChromotingHost( login_backoff_(&kDefaultBackoffPolicy), authenticating_client_(false), reject_authenticating_client_(false), + enable_curtaining_(false), weak_factory_(this) { DCHECK(network_task_runner_->BelongsToCurrentThread()); DCHECK(signal_strategy); @@ -141,6 +142,24 @@ void ChromotingHost::SetAuthenticatorFactory( session_manager_->set_authenticator_factory(authenticator_factory.Pass()); } +void ChromotingHost::SetEnableCurtaining(bool enable) { + DCHECK(network_task_runner_->BelongsToCurrentThread()); + + if (enable_curtaining_ == enable) + return; + + enable_curtaining_ = enable; + desktop_environment_factory_->SetEnableCurtaining(enable_curtaining_); + + // Disconnect all existing clients because they might be running not + // curtained. + // TODO(alexeypa): fix this such that the curtain is applied to the not + // curtained sessions or disconnect only the client connected to not + // curtained sessions. + if (enable_curtaining_) + DisconnectAllClients(); +} + void ChromotingHost::SetMaximumSessionDuration( const base::TimeDelta& max_session_duration) { max_session_duration_ = max_session_duration; diff --git a/remoting/host/chromoting_host.h b/remoting/host/chromoting_host.h index 9a37685..d72e99d 100644 --- a/remoting/host/chromoting_host.h +++ b/remoting/host/chromoting_host.h @@ -105,6 +105,10 @@ class ChromotingHost : public base::NonThreadSafe, void SetAuthenticatorFactory( scoped_ptr<protocol::AuthenticatorFactory> authenticator_factory); + // Enables/disables curtaining when one or more clients are connected. + // Takes immediate effect if clients are already connected. + void SetEnableCurtaining(bool enable); + // Sets the maximum duration of any session. By default, a session has no // maximum duration. void SetMaximumSessionDuration(const base::TimeDelta& max_session_duration); @@ -131,11 +135,6 @@ class ChromotingHost : public base::NonThreadSafe, // Sets desired configuration for the protocol. Must be called before Start(). void set_protocol_config(scoped_ptr<protocol::CandidateSessionConfig> config); - // Immediately disconnects all active clients. Host-internal components may - // shutdown asynchronously, but the caller is guaranteed not to receive - // callbacks for disconnected clients after this call returns. - void DisconnectAllClients(); - base::WeakPtr<ChromotingHost> AsWeakPtr() { return weak_factory_.GetWeakPtr(); } @@ -145,6 +144,11 @@ class ChromotingHost : public base::NonThreadSafe, typedef std::list<ClientSession*> ClientList; + // Immediately disconnects all active clients. Host-internal components may + // shutdown asynchronously, but the caller is guaranteed not to receive + // callbacks for disconnected clients after this call returns. + void DisconnectAllClients(); + // Unless specified otherwise all members of this class must be // used on the network thread only. @@ -180,6 +184,9 @@ class ChromotingHost : public base::NonThreadSafe, bool authenticating_client_; bool reject_authenticating_client_; + // True if the curtain mode is enabled. + bool enable_curtaining_; + // The maximum duration of any session. base::TimeDelta max_session_duration_; diff --git a/remoting/host/chromoting_messages.h b/remoting/host/chromoting_messages.h index 986879d..0c640ea 100644 --- a/remoting/host/chromoting_messages.h +++ b/remoting/host/chromoting_messages.h @@ -223,9 +223,10 @@ IPC_MESSAGE_CONTROL1(ChromotingDesktopNetworkMsg_AudioPacket, // Passes the client session data to the desktop session agent and starts it. // This must be the first message received from the host. -IPC_MESSAGE_CONTROL2(ChromotingNetworkDesktopMsg_StartSessionAgent, +IPC_MESSAGE_CONTROL3(ChromotingNetworkDesktopMsg_StartSessionAgent, std::string /* authenticated_jid */, - remoting::ScreenResolution /* resolution */) + remoting::ScreenResolution /* resolution */, + bool /* virtual_terminal */) // Notifies the desktop process that the shared memory buffer has been mapped to // the memory of the network process and so it can be safely dropped by diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc index 280a3c3..8636b7a 100644 --- a/remoting/host/client_session.cc +++ b/remoting/host/client_session.cc @@ -197,9 +197,15 @@ void ClientSession::OnConnectionAuthenticated( return; } - // Create the desktop environment. + // Create the desktop environment. Drop the connection if it could not be + // created for any reason (for instance the curtain could not initialize). desktop_environment_ = desktop_environment_factory_->Create(control_factory_.GetWeakPtr()); + if (!desktop_environment_) { + DisconnectSession(); + return; + } + host_capabilities_ = desktop_environment_->GetCapabilities(); // Ignore protocol::Capabilities messages from the client if it does not diff --git a/remoting/host/curtain_mode.h b/remoting/host/curtain_mode.h index 002fc11..ff15b1f 100644 --- a/remoting/host/curtain_mode.h +++ b/remoting/host/curtain_mode.h @@ -5,40 +5,36 @@ #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" +#include "base/memory/ref_counted.h" +#include "base/memory/scoped_ptr.h" +#include "base/memory/weak_ptr.h" + +namespace base { +class SingleThreadTaskRunner; +} // namespace base namespace remoting { -class ChromotingHost; +class ClientSessionControl; 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. + // Creates a platform-specific curtain mode implementation object that + // "curtains" the current session making sure it is not accessible from + // the local console. |client_session_control| can be used to drop + // the connection in the case if the session re-connects to the local console + // in mid-flight. static scoped_ptr<CurtainMode> Create( - const base::Closure& on_session_activate, - const base::Closure& on_error); - - // 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; + scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, + base::WeakPtr<ClientSessionControl> client_session_control); + + // Activates the curtain mode. Returns true if successful. + virtual bool Activate() = 0; protected: CurtainMode() {} diff --git a/remoting/host/curtain_mode_linux.cc b/remoting/host/curtain_mode_linux.cc index 34b4db0..9b54d05 100644 --- a/remoting/host/curtain_mode_linux.cc +++ b/remoting/host/curtain_mode_linux.cc @@ -8,31 +8,39 @@ #include "base/callback.h" #include "base/logging.h" +#include "base/single_thread_task_runner.h" +#include "remoting/host/client_session_control.h" namespace remoting { class CurtainModeLinux : public CurtainMode { public: - CurtainModeLinux(const base::Closure& on_session_activate, - const base::Closure& on_error); + CurtainModeLinux(); // Overriden from CurtainMode. - virtual void SetActivated(bool activated) OVERRIDE; + virtual bool Activate() OVERRIDE; private: // Returns true if the host is running under an Xvfb session. bool IsXvfbSession(); - base::Closure on_session_activate_; - base::Closure on_error_; - DISALLOW_COPY_AND_ASSIGN(CurtainModeLinux); }; -CurtainModeLinux::CurtainModeLinux(const base::Closure& on_session_activate, - const base::Closure& on_error) - : on_session_activate_(on_session_activate), - on_error_(on_error) { +CurtainModeLinux::CurtainModeLinux() { +} + +bool CurtainModeLinux::Activate() { + // We can't curtain the session in run-time in Linux. + // Either the session is running on Xvfb (i.e. always curtained), or it is + // attached to the physical console (i.e. impossible to curtain). + bool activated = IsXvfbSession(); + if (!activated) { + LOG(ERROR) << "Curtain-mode is not supported when running on non-Xvfb " + "X server"; + } + + return activated; } bool CurtainModeLinux::IsXvfbSession() { @@ -90,23 +98,12 @@ bool CurtainModeLinux::IsXvfbSession() { return found_xvfb_mouse && found_xvfb_keyboard && !found_other_devices; } -void CurtainModeLinux::SetActivated(bool activated) { - // We can't curtain the session in run-time in Linux. - // Either the session is running on Xvfb (i.e. always curtained), or it is - // attached to the physical console (i.e. impossible to curtain). - if (activated && !IsXvfbSession()) { - LOG(ERROR) << "Curtain-mode is not supported when running on non-Xvfb " - "X server"; - on_error_.Run(); - } -} - // static scoped_ptr<CurtainMode> CurtainMode::Create( - const base::Closure& on_session_activate, - const base::Closure& on_error) { - return scoped_ptr<CurtainMode>( - new CurtainModeLinux(on_session_activate, on_error)); + scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, + base::WeakPtr<ClientSessionControl> client_session_control) { + 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 bf3118b..b68ab11 100644 --- a/remoting/host/curtain_mode_mac.cc +++ b/remoting/host/curtain_mode_mac.cc @@ -9,72 +9,109 @@ #include <Security/Security.h> #include <unistd.h> +#include "base/bind.h" +#include "base/location.h" #include "base/logging.h" #include "base/mac/mac_util.h" #include "base/mac/scoped_cftyperef.h" +#include "base/single_thread_task_runner.h" +#include "remoting/host/client_session_control.h" namespace { + +using remoting::ClientSessionControl; + const char* kCGSessionPath = "/System/Library/CoreServices/Menu Extras/User.menu/Contents/Resources/" "CGSession"; -} - -namespace remoting { -class CurtainModeMac : public CurtainMode { +// Used to detach the current session from the local console and disconnect +// the connnection if it gets re-attached. +// +// Because the switch-in handler can only called on the main (UI) thread, this +// class installs the handler and detaches the current session from the console +// on the UI thread as well. +class SessionWatcher : public base::RefCountedThreadSafe<SessionWatcher> { public: - CurtainModeMac(const base::Closure& on_session_activate, - const base::Closure& on_error); - - virtual ~CurtainModeMac(); + SessionWatcher( + scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, + base::WeakPtr<ClientSessionControl> client_session_control); - // Overriden from CurtainMode. - virtual void SetActivated(bool activated) OVERRIDE; + void Start(); + void Stop(); 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(); + friend class base::RefCountedThreadSafe<SessionWatcher>; + virtual ~SessionWatcher(); + + // Detaches the session from the console and install the switch-in handler to + // detect when the session re-attaches back. + void ActivateCurtain(); - // Add or remove the switch-in event handler. + // Installs the switch-in handler. bool InstallEventHandler(); - bool RemoveEventHandler(); + + // Removes the switch-in handler. + void RemoveEventHandler(); + + // Disconnects the client session. + void DisconnectSession(); // 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_; + // Task runner on which public methods of this class must be called. + scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; + + // Task runner representing the thread receiving Carbon events. + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; + + // Used to disconnect the client session. + base::WeakPtr<ClientSessionControl> client_session_control_; + EventHandlerRef event_handler_; - DISALLOW_COPY_AND_ASSIGN(CurtainModeMac); + DISALLOW_COPY_AND_ASSIGN(SessionWatcher); }; -CurtainModeMac::CurtainModeMac(const base::Closure& on_session_activate, - const base::Closure& on_error) - : on_session_activate_(on_session_activate), - on_error_(on_error), +SessionWatcher::SessionWatcher( + scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, + base::WeakPtr<ClientSessionControl> client_session_control) + : caller_task_runner_(caller_task_runner), + ui_task_runner_(ui_task_runner), + client_session_control_(client_session_control), event_handler_(NULL) { } -CurtainModeMac::~CurtainModeMac() { - SetActivated(false); +void SessionWatcher::Start() { + DCHECK(caller_task_runner_->BelongsToCurrentThread()); + + // Activate curtain asynchronously since it has to be done on the UI thread. + // Because the curtain activation is asynchronous, it is possible that + // the connection will not be curtained for a brief moment. This seems to be + // unaviodable as long as the curtain enforcement depends on processing of + // the switch-in notifications. + ui_task_runner_->PostTask( + FROM_HERE, base::Bind(&SessionWatcher::ActivateCurtain, this)); } -void CurtainModeMac::SetActivated(bool activated) { - if (activated) { - if (!ActivateCurtain()) { - on_error_.Run(); - } - } else { - RemoveEventHandler(); - } +void SessionWatcher::Stop() { + DCHECK(caller_task_runner_->BelongsToCurrentThread()); + + client_session_control_.reset(); + ui_task_runner_->PostTask( + FROM_HERE, base::Bind(&SessionWatcher::RemoveEventHandler, this)); +} + +SessionWatcher::~SessionWatcher() { + DCHECK(!event_handler_); } -bool CurtainModeMac::ActivateCurtain() { +void SessionWatcher::ActivateCurtain() { // Curtain mode causes problems with the login screen on Lion only (starting // with 10.7.3), so disable it on that platform. There is a work-around, but // it involves modifying a system Plist pertaining to power-management, so @@ -85,14 +122,16 @@ bool CurtainModeMac::ActivateCurtain() { // curtain mode on suitable versions of Lion. if (base::mac::IsOSLion()) { LOG(ERROR) << "Host curtaining is not supported on Mac OS X 10.7."; - return false; + DisconnectSession(); + return; } // 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()) { LOG(ERROR) << "Failed to install the switch-in handler."; - return false; + DisconnectSession(); + return; } base::mac::ScopedCFTypeRef<CFDictionaryRef> session( @@ -120,56 +159,110 @@ bool CurtainModeMac::ActivateCurtain() { waitpid(child, &status, 0); if (status != 0) { LOG(ERROR) << kCGSessionPath << " failed."; - return false; + DisconnectSession(); + return; } } else { LOG(ERROR) << "fork() failed."; - return false; + DisconnectSession(); + return; } } +} + +bool SessionWatcher::InstallEventHandler() { + DCHECK(ui_task_runner_->BelongsToCurrentThread()); + DCHECK(!event_handler_); + + EventTypeSpec event; + event.eventClass = kEventClassSystem; + event.eventKind = kEventSystemUserSessionActivated; + OSStatus result = ::InstallApplicationEventHandler( + NewEventHandlerUPP(SessionActivateHandler), 1, &event, this, + &event_handler_); + if (result != noErr) { + event_handler_ = NULL; + DisconnectSession(); + return false; + } + return true; } -OSStatus CurtainModeMac::SessionActivateHandler(EventHandlerCallRef handler, - EventRef event, - void* user_data) { - CurtainModeMac* self = static_cast<CurtainModeMac*>(user_data); - self->OnSessionActivate(); +void SessionWatcher::RemoveEventHandler() { + DCHECK(ui_task_runner_->BelongsToCurrentThread()); + + if (event_handler_) { + ::RemoveEventHandler(event_handler_); + event_handler_ = NULL; + } +} + +void SessionWatcher::DisconnectSession() { + if (!caller_task_runner_->BelongsToCurrentThread()) { + caller_task_runner_->PostTask( + FROM_HERE, base::Bind(&SessionWatcher::DisconnectSession, this)); + return; + } + + if (client_session_control_) + client_session_control_->DisconnectSession(); +} + +OSStatus SessionWatcher::SessionActivateHandler(EventHandlerCallRef handler, + EventRef event, + void* user_data) { + static_cast<SessionWatcher*>(user_data)->DisconnectSession(); return noErr; } -void CurtainModeMac::OnSessionActivate() { - on_session_activate_.Run(); +} // namespace + +namespace remoting { + +class CurtainModeMac : public CurtainMode { + public: + CurtainModeMac( + scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, + base::WeakPtr<ClientSessionControl> client_session_control); + virtual ~CurtainModeMac(); + + // Overriden from CurtainMode. + virtual bool Activate() OVERRIDE; + + private: + scoped_refptr<SessionWatcher> session_watcher_; + + DISALLOW_COPY_AND_ASSIGN(CurtainModeMac); +}; + +CurtainModeMac::CurtainModeMac( + scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, + base::WeakPtr<ClientSessionControl> client_session_control) + : session_watcher_(new SessionWatcher(caller_task_runner, + ui_task_runner, + client_session_control)) { } -bool CurtainModeMac::InstallEventHandler() { - OSStatus result = noErr; - if (!event_handler_) { - EventTypeSpec event; - event.eventClass = kEventClassSystem; - event.eventKind = kEventSystemUserSessionActivated; - result = ::InstallApplicationEventHandler( - NewEventHandlerUPP(SessionActivateHandler), 1, &event, this, - &event_handler_); - } - return result == noErr; +CurtainModeMac::~CurtainModeMac() { + session_watcher_->Stop(); } -bool CurtainModeMac::RemoveEventHandler() { - OSStatus result = noErr; - if (event_handler_) { - result = ::RemoveEventHandler(event_handler_); - event_handler_ = NULL; - } - return result == noErr; +bool CurtainModeMac::Activate() { + session_watcher_->Start(); + return true; } // 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)); + scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, + base::WeakPtr<ClientSessionControl> client_session_control) { + return scoped_ptr<CurtainMode>(new CurtainModeMac(caller_task_runner, + ui_task_runner, + client_session_control)); } } // namespace remoting diff --git a/remoting/host/curtain_mode_win.cc b/remoting/host/curtain_mode_win.cc index fc4cb2f..79e2d6e 100644 --- a/remoting/host/curtain_mode_win.cc +++ b/remoting/host/curtain_mode_win.cc @@ -5,33 +5,46 @@ #include "remoting/host/curtain_mode.h" #include "base/logging.h" +#include "base/single_thread_task_runner.h" +#include "remoting/host/client_session_control.h" namespace remoting { class CurtainModeWin : public CurtainMode { public: - CurtainModeWin(const base::Closure& on_error) : on_error_(on_error) {} + CurtainModeWin(); + // Overriden from CurtainMode. - virtual void SetActivated(bool activated) OVERRIDE { - // Curtain-mode is not currently implemented for Windows. - if (activated) { - LOG(ERROR) << "Curtain-mode is not yet supported on Windows."; - on_error_.Run(); - } - } + virtual bool Activate() OVERRIDE; private: - base::Closure on_error_; - DISALLOW_COPY_AND_ASSIGN(CurtainModeWin); }; +CurtainModeWin::CurtainModeWin() { +} + +bool CurtainModeWin::Activate() { + DWORD session_id; + if (!ProcessIdToSessionId(GetCurrentProcessId(), &session_id)) { + LOG_GETLASTERROR(ERROR) << "Failed to map the current PID to session ID"; + return false; + } + + // The current session is curtained if it is not attached to the local + // console. + return WTSGetActiveConsoleSessionId() != session_id; +} + // static scoped_ptr<CurtainMode> CurtainMode::Create( - const base::Closure& on_session_activate, - const base::Closure& on_error) { - return scoped_ptr<CurtainMode>( - new CurtainModeWin(on_error)); + scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, + base::WeakPtr<ClientSessionControl> client_session_control) { + // |client_session_control| is not used because the client session is + // disconnected as soon as the session is re-attached to the local console. + // See RdpDesktopSession for more details. + return scoped_ptr<CurtainMode>(new CurtainModeWin()); } } // namespace remoting diff --git a/remoting/host/curtaining_host_observer.cc b/remoting/host/curtaining_host_observer.cc deleted file mode 100644 index 31bb411..0000000 --- a/remoting/host/curtaining_host_observer.cc +++ /dev/null @@ -1,40 +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. - -#include "remoting/host/curtaining_host_observer.h" - -#include "base/logging.h" -#include "remoting/host/curtain_mode.h" -#include "remoting/host/host_status_monitor.h" - -namespace remoting { - -CurtainingHostObserver::CurtainingHostObserver( - CurtainMode *curtain, base::WeakPtr<HostStatusMonitor> monitor) - : curtain_(curtain), monitor_(monitor) { - monitor_->AddStatusObserver(this); -} - -CurtainingHostObserver::~CurtainingHostObserver() { - if (monitor_) - monitor_->RemoveStatusObserver(this); - curtain_->SetActivated(false); -} - -void CurtainingHostObserver::SetEnableCurtaining(bool enable) { - enable_curtaining_ = enable; - curtain_->SetActivated(enable_curtaining_ && !active_clients_.empty()); -} - -void CurtainingHostObserver::OnClientAuthenticated(const std::string& jid) { - active_clients_.insert(jid); - curtain_->SetActivated(enable_curtaining_ && !active_clients_.empty()); -} - -void CurtainingHostObserver::OnClientDisconnected(const std::string& jid) { - active_clients_.erase(jid); - curtain_->SetActivated(enable_curtaining_ && !active_clients_.empty()); -} - -} // namespace remoting diff --git a/remoting/host/curtaining_host_observer.h b/remoting/host/curtaining_host_observer.h deleted file mode 100644 index 20771f4..0000000 --- a/remoting/host/curtaining_host_observer.h +++ /dev/null @@ -1,44 +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_CURTAINING_HOST_OBSERVER_H_ -#define REMOTING_HOST_CURTAINING_HOST_OBSERVER_H_ - -#include <set> -#include <string> - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "base/memory/scoped_ptr.h" -#include "base/memory/weak_ptr.h" -#include "remoting/host/host_status_observer.h" - -namespace remoting { - -class CurtainMode; -class HostStatusMonitor; - -class CurtainingHostObserver : public HostStatusObserver { - public: - CurtainingHostObserver(CurtainMode *curtain, - base::WeakPtr<HostStatusMonitor> monitor); - virtual ~CurtainingHostObserver(); - - // Enables/disables curtaining when one or more clients are connected. - // Takes immediate effect if clients are already connected. - void SetEnableCurtaining(bool enable); - - // HostStatusObserver interface. - virtual void OnClientAuthenticated(const std::string& jid) OVERRIDE; - virtual void OnClientDisconnected(const std::string& jid) OVERRIDE; - - private: - CurtainMode* curtain_; - base::WeakPtr<HostStatusMonitor> monitor_; - std::set<std::string> active_clients_; - bool enable_curtaining_; -}; - -} // namespace remoting -#endif diff --git a/remoting/host/desktop_environment.h b/remoting/host/desktop_environment.h index 0e8b480..660744a 100644 --- a/remoting/host/desktop_environment.h +++ b/remoting/host/desktop_environment.h @@ -54,11 +54,16 @@ class DesktopEnvironmentFactory { public: virtual ~DesktopEnvironmentFactory() {} - // Creates an instance of |DesktopEnvironment|. |client_session_control| must - // outlive |this|. + // Creates an instance of |DesktopEnvironment|. Returns a NULL pointer if + // the desktop environment could not be created for any reason (if the curtain + // failed to active for instance). |client_session_control| must outlive + // the created desktop environment. virtual scoped_ptr<DesktopEnvironment> Create( base::WeakPtr<ClientSessionControl> client_session_control) = 0; + // Enables or disables the curtain mode. + virtual void SetEnableCurtaining(bool enable) {} + // Returns |true| if created |DesktopEnvironment| instances support audio // capture. virtual bool SupportsAudioCapture() const = 0; diff --git a/remoting/host/desktop_process_unittest.cc b/remoting/host/desktop_process_unittest.cc index 60cc18b..558c18c 100644 --- a/remoting/host/desktop_process_unittest.cc +++ b/remoting/host/desktop_process_unittest.cc @@ -291,7 +291,7 @@ void DesktopProcessTest::SendCrashRequest() { void DesktopProcessTest::SendStartSessionAgent() { network_channel_->Send(new ChromotingNetworkDesktopMsg_StartSessionAgent( - "user@domain/rest-of-jid", ScreenResolution())); + "user@domain/rest-of-jid", ScreenResolution(), false)); } // Launches the desktop process and waits when it connects back. diff --git a/remoting/host/desktop_session_agent.cc b/remoting/host/desktop_session_agent.cc index c44fc8d..6dd811c 100644 --- a/remoting/host/desktop_session_agent.cc +++ b/remoting/host/desktop_session_agent.cc @@ -185,7 +185,8 @@ void DesktopSessionAgent::SetDisableInputs(bool disable_inputs) { void DesktopSessionAgent::OnStartSessionAgent( const std::string& authenticated_jid, - const ScreenResolution& resolution) { + const ScreenResolution& resolution, + bool virtual_terminal) { DCHECK(caller_task_runner()->BelongsToCurrentThread()); DCHECK(!started_); DCHECK(!audio_capturer_); @@ -197,6 +198,10 @@ void DesktopSessionAgent::OnStartSessionAgent( started_ = true; client_jid_ = authenticated_jid; + // Enable the curtain mode. + delegate_->desktop_environment_factory().SetEnableCurtaining( + virtual_terminal); + // Create a desktop environment for the new session. desktop_environment_ = delegate_->desktop_environment_factory().Create( control_factory_.GetWeakPtr()); diff --git a/remoting/host/desktop_session_agent.h b/remoting/host/desktop_session_agent.h index 7e6126f..a993520 100644 --- a/remoting/host/desktop_session_agent.h +++ b/remoting/host/desktop_session_agent.h @@ -126,7 +126,8 @@ class DesktopSessionAgent // Handles StartSessionAgent request from the client. void OnStartSessionAgent(const std::string& authenticated_jid, - const ScreenResolution& resolution); + const ScreenResolution& resolution, + bool virtual_terminal); // Handles CaptureFrame requests from the client. void OnCaptureFrame(); diff --git a/remoting/host/desktop_session_proxy.cc b/remoting/host/desktop_session_proxy.cc index a21e75f..63fcbd0 100644 --- a/remoting/host/desktop_session_proxy.cc +++ b/remoting/host/desktop_session_proxy.cc @@ -193,7 +193,9 @@ bool DesktopSessionProxy::AttachToDesktop( // Pass ID of the client (which is authenticated at this point) to the desktop // session agent and start the agent. SendToDesktop(new ChromotingNetworkDesktopMsg_StartSessionAgent( - client_session_control_->client_jid(), screen_resolution_)); + client_session_control_->client_jid(), + screen_resolution_, + virtual_terminal_)); return true; } diff --git a/remoting/host/ipc_desktop_environment.cc b/remoting/host/ipc_desktop_environment.cc index 3e625da..45de6d9 100644 --- a/remoting/host/ipc_desktop_environment.cc +++ b/remoting/host/ipc_desktop_environment.cc @@ -78,7 +78,7 @@ IpcDesktopEnvironmentFactory::IpcDesktopEnvironmentFactory( caller_task_runner_(caller_task_runner), capture_task_runner_(capture_task_runner), io_task_runner_(io_task_runner), - curtain_activated_(false), + curtain_enabled_(false), daemon_channel_(daemon_channel), connector_factory_(this), next_id_(0) { @@ -87,12 +87,6 @@ IpcDesktopEnvironmentFactory::IpcDesktopEnvironmentFactory( IpcDesktopEnvironmentFactory::~IpcDesktopEnvironmentFactory() { } -void IpcDesktopEnvironmentFactory::SetActivated(bool activated) { - DCHECK(caller_task_runner_->BelongsToCurrentThread()); - - curtain_activated_ = activated; -} - scoped_ptr<DesktopEnvironment> IpcDesktopEnvironmentFactory::Create( base::WeakPtr<ClientSessionControl> client_session_control) { DCHECK(caller_task_runner_->BelongsToCurrentThread()); @@ -104,7 +98,13 @@ scoped_ptr<DesktopEnvironment> IpcDesktopEnvironmentFactory::Create( io_task_runner_, client_session_control, connector_factory_.GetWeakPtr(), - curtain_activated_)); + curtain_enabled_)); +} + +void IpcDesktopEnvironmentFactory::SetEnableCurtaining(bool enable) { + DCHECK(caller_task_runner_->BelongsToCurrentThread()); + + curtain_enabled_ = enable; } bool IpcDesktopEnvironmentFactory::SupportsAudioCapture() const { diff --git a/remoting/host/ipc_desktop_environment.h b/remoting/host/ipc_desktop_environment.h index 8a7d7d2..f0d11b9 100644 --- a/remoting/host/ipc_desktop_environment.h +++ b/remoting/host/ipc_desktop_environment.h @@ -13,7 +13,6 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" -#include "remoting/host/curtain_mode.h" #include "remoting/host/desktop_environment.h" #include "remoting/host/desktop_session_connector.h" @@ -65,8 +64,7 @@ class IpcDesktopEnvironment : public DesktopEnvironment { // Used to create IpcDesktopEnvironment objects integrating with the desktop via // a helper process and talking to that process via IPC. class IpcDesktopEnvironmentFactory - : public CurtainMode, - public DesktopEnvironmentFactory, + : public DesktopEnvironmentFactory, public DesktopSessionConnector { public: // Passes a reference to the IPC channel connected to the daemon process and @@ -79,12 +77,10 @@ class IpcDesktopEnvironmentFactory IPC::Sender* daemon_channel); virtual ~IpcDesktopEnvironmentFactory(); - // CurtainMode implementation. - virtual void SetActivated(bool activated) OVERRIDE; - // DesktopEnvironmentFactory implementation. virtual scoped_ptr<DesktopEnvironment> Create( base::WeakPtr<ClientSessionControl> client_session_control) OVERRIDE; + virtual void SetEnableCurtaining(bool enable) OVERRIDE; virtual bool SupportsAudioCapture() const OVERRIDE; // DesktopSessionConnector implementation. @@ -117,8 +113,8 @@ class IpcDesktopEnvironmentFactory // Task runner used for running background I/O. scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; - // True if curtain mode is activated. - bool curtain_activated_; + // True if curtain mode is enabled. + bool curtain_enabled_; // IPC channel connected to the daemon process. IPC::Sender* daemon_channel_; diff --git a/remoting/host/it2me_desktop_environment.cc b/remoting/host/it2me_desktop_environment.cc index 2d6c183..6a289c9 100644 --- a/remoting/host/it2me_desktop_environment.cc +++ b/remoting/host/it2me_desktop_environment.cc @@ -30,9 +30,7 @@ It2MeDesktopEnvironment::It2MeDesktopEnvironment( const UiStrings& ui_strings) : BasicDesktopEnvironment(caller_task_runner, input_task_runner, - ui_task_runner, - client_session_control, - ui_strings) { + ui_task_runner) { DCHECK(caller_task_runner->BelongsToCurrentThread()); // Create the local input monitor. diff --git a/remoting/host/me2me_desktop_environment.cc b/remoting/host/me2me_desktop_environment.cc index 8d693d7..970e21e 100644 --- a/remoting/host/me2me_desktop_environment.cc +++ b/remoting/host/me2me_desktop_environment.cc @@ -8,6 +8,7 @@ #include "base/single_thread_task_runner.h" #include "media/video/capture/screen/screen_capturer.h" #include "remoting/host/client_session_control.h" +#include "remoting/host/curtain_mode.h" #include "remoting/host/desktop_resizer.h" #include "remoting/host/host_window.h" #include "remoting/host/host_window.h" @@ -48,27 +49,39 @@ Me2MeDesktopEnvironment::CreateVideoCapturer() { Me2MeDesktopEnvironment::Me2MeDesktopEnvironment( scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, - scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, - base::WeakPtr<ClientSessionControl> client_session_control, - const UiStrings& ui_strings) + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) : BasicDesktopEnvironment(caller_task_runner, input_task_runner, - ui_task_runner, - client_session_control, - ui_strings) { + ui_task_runner) { DCHECK(caller_task_runner->BelongsToCurrentThread()); +} + +bool Me2MeDesktopEnvironment::InitializeSecurity( + base::WeakPtr<ClientSessionControl> client_session_control, + const UiStrings& ui_strings, + bool curtain_enabled) { + DCHECK(caller_task_runner()->BelongsToCurrentThread()); + + // Detach the session from the local console if the caller requested. + if (curtain_enabled) { + curtain_ = CurtainMode::Create(caller_task_runner(), + ui_task_runner(), + client_session_control); + return curtain_->Activate(); + } + + // Otherwise, if the session is shared with the local user start monitoring + // the local input and create the in-session UI. // Create the local input monitor. - local_input_monitor_ = LocalInputMonitor::Create(caller_task_runner, - input_task_runner, - ui_task_runner, + local_input_monitor_ = LocalInputMonitor::Create(caller_task_runner(), + input_task_runner(), + ui_task_runner(), client_session_control); // The host UI should be created on the UI thread. bool want_user_interface = true; -#if defined(OS_LINUX) - want_user_interface = false; -#elif defined(OS_MACOSX) +#if defined(OS_MACOSX) // Don't try to display any UI on top of the system's login screen as this // is rejected by the Window Server on OS X 10.7.4, and prevents the // capturer from working (http://crbug.com/140984). @@ -83,11 +96,13 @@ Me2MeDesktopEnvironment::Me2MeDesktopEnvironment( if (want_user_interface) { disconnect_window_ = HostWindow::CreateDisconnectWindow(ui_strings); disconnect_window_.reset(new HostWindowProxy( - caller_task_runner, - ui_task_runner, + caller_task_runner(), + ui_task_runner(), disconnect_window_.Pass())); disconnect_window_->Start(client_session_control); } + + return true; } Me2MeDesktopEnvironmentFactory::Me2MeDesktopEnvironmentFactory( @@ -98,7 +113,8 @@ Me2MeDesktopEnvironmentFactory::Me2MeDesktopEnvironmentFactory( : BasicDesktopEnvironmentFactory(caller_task_runner, input_task_runner, ui_task_runner, - ui_strings) { + ui_strings), + curtain_enabled_(false) { } Me2MeDesktopEnvironmentFactory::~Me2MeDesktopEnvironmentFactory() { @@ -108,12 +124,23 @@ scoped_ptr<DesktopEnvironment> Me2MeDesktopEnvironmentFactory::Create( base::WeakPtr<ClientSessionControl> client_session_control) { DCHECK(caller_task_runner()->BelongsToCurrentThread()); - return scoped_ptr<DesktopEnvironment>( + scoped_ptr<Me2MeDesktopEnvironment> desktop_environment( new Me2MeDesktopEnvironment(caller_task_runner(), input_task_runner(), - ui_task_runner(), - client_session_control, - ui_strings())); + ui_task_runner())); + if (!desktop_environment->InitializeSecurity(client_session_control, + ui_strings(), + curtain_enabled_)) { + return scoped_ptr<DesktopEnvironment>(); + } + + return desktop_environment.PassAs<DesktopEnvironment>(); +} + +void Me2MeDesktopEnvironmentFactory::SetEnableCurtaining(bool enable) { + DCHECK(caller_task_runner()->BelongsToCurrentThread()); + + curtain_enabled_ = enable; } } // namespace remoting diff --git a/remoting/host/me2me_desktop_environment.h b/remoting/host/me2me_desktop_environment.h index d7aa708..316d5c3 100644 --- a/remoting/host/me2me_desktop_environment.h +++ b/remoting/host/me2me_desktop_environment.h @@ -9,6 +9,7 @@ namespace remoting { +class CurtainMode; class HostWindow; class LocalInputMonitor; @@ -27,11 +28,20 @@ class Me2MeDesktopEnvironment : public BasicDesktopEnvironment { Me2MeDesktopEnvironment( scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, - scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); + + // Initializes security features of the desktop environment (the curtain mode + // and in-session UI). + bool InitializeSecurity( base::WeakPtr<ClientSessionControl> client_session_control, - const UiStrings& ui_strings); + const UiStrings& ui_strings, + bool curtain_enabled); private: + // "Curtains" the session making sure it is disconnected from the local + // console. + scoped_ptr<CurtainMode> curtain_; + // Presents the disconnect window to the local user. scoped_ptr<HostWindow> disconnect_window_; @@ -54,8 +64,15 @@ class Me2MeDesktopEnvironmentFactory : public BasicDesktopEnvironmentFactory { // DesktopEnvironmentFactory interface. virtual scoped_ptr<DesktopEnvironment> Create( base::WeakPtr<ClientSessionControl> client_session_control) OVERRIDE; + virtual void SetEnableCurtaining(bool enable) OVERRIDE; + + protected: + bool curtain_enabled() const { return curtain_enabled_; } private: + // True if curtain mode is enabled. + bool curtain_enabled_; + DISALLOW_COPY_AND_ASSIGN(Me2MeDesktopEnvironmentFactory); }; diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc index 90aa6ad..6ee42b9 100644 --- a/remoting/host/remoting_me2me_host.cc +++ b/remoting/host/remoting_me2me_host.cc @@ -41,8 +41,6 @@ #include "remoting/host/chromoting_host_context.h" #include "remoting/host/chromoting_messages.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.h" #include "remoting/host/desktop_session_connector.h" #include "remoting/host/dns_blackhole_checker.h" @@ -205,7 +203,7 @@ class HostProcess bool OnUsernamePolicyUpdate(bool curtain_required, bool username_match_required); bool OnNatPolicyUpdate(bool nat_traversal_enabled); - bool OnCurtainPolicyUpdate(bool curtain_required); + void OnCurtainPolicyUpdate(bool curtain_required); bool OnHostTalkGadgetPrefixPolicyUpdate(const std::string& talkgadget_prefix); bool OnHostTokenUrlPolicyUpdate(const GURL& token_url, const GURL& token_validation_url); @@ -214,14 +212,6 @@ class HostProcess void OnAuthFailed(); - void OnCurtainModeFailed(); - - void OnRemoteSessionSwitchedToConsole(); - - // Invoked when the user uses the Disconnect windows to terminate - // the sessions, or when the local session is activated in curtain mode. - void OnDisconnectRequested(); - void RestartHost(); // Stops the host and shuts down the process with the specified |exit_code|. @@ -269,8 +259,6 @@ class HostProcess bool allow_nat_traversal_; std::string talkgadget_prefix_; - scoped_ptr<CurtainMode> curtain_; - scoped_ptr<CurtainingHostObserver> curtaining_host_observer_; bool curtain_required_; GURL token_url_; GURL token_validation_url_; @@ -305,14 +293,6 @@ HostProcess::HostProcess(scoped_ptr<ChromotingHostContext> context, #endif // defined(REMOTING_MULTI_PROCESS) self_(this), exit_code_out_(exit_code_out) { - // Create the platform-specific curtain-mode implementation. - // TODO(wez): Create this on the network thread? - curtain_ = CurtainMode::Create( - base::Bind(&HostProcess::OnRemoteSessionSwitchedToConsole, - base::Unretained(this)), - base::Bind(&HostProcess::OnCurtainModeFailed, - base::Unretained(this))); - StartOnUiThread(); } @@ -729,7 +709,7 @@ void HostProcess::OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies) { if (policies->GetBoolean( policy_hack::PolicyWatcher::kHostRequireCurtainPolicyName, &curtain_required)) { - restart_required |= OnCurtainPolicyUpdate(curtain_required); + OnCurtainPolicyUpdate(curtain_required); } if (policies->GetBoolean( policy_hack::PolicyWatcher::kHostMatchUsernamePolicyName, @@ -832,7 +812,7 @@ bool HostProcess::OnNatPolicyUpdate(bool nat_traversal_enabled) { return false; } -bool HostProcess::OnCurtainPolicyUpdate(bool curtain_required) { +void HostProcess::OnCurtainPolicyUpdate(bool curtain_required) { // Returns true if the host has to be restarted after this policy update. DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); @@ -851,7 +831,7 @@ bool HostProcess::OnCurtainPolicyUpdate(bool curtain_required) { LOG(ERROR) << "Running the host in the console login session is yet not " "supported."; ShutdownHost(kLoginScreenNotSupportedExitCode); - return false; + return; } } #endif @@ -862,17 +842,9 @@ bool HostProcess::OnCurtainPolicyUpdate(bool curtain_required) { else LOG(INFO) << "Policy does not require curtain-mode."; curtain_required_ = curtain_required; - if (curtaining_host_observer_) - curtaining_host_observer_->SetEnableCurtaining(curtain_required_); - - // The current Windows curtain mode implementation relies on this code - // restarting the host when the curtain mode policy changes. For example if - // the policy is enabled while someone is already connected to the console - // that session should be either curtained or disconnected. This code makes - // sure that the session will be disconnected by restarting the host. - return true; + if (host_) + host_->SetEnableCurtaining(curtain_required_); } - return false; } bool HostProcess::OnHostTalkGadgetPrefixPolicyUpdate( @@ -987,20 +959,7 @@ void HostProcess::StartHost() { HostEventLogger::Create(host_->AsWeakPtr(), kApplicationName); #endif // !defined(REMOTING_MULTI_PROCESS) -#if defined(REMOTING_RDP_SESSION) - // TODO(alexeypa): do not create |curtain_| in this case. - CurtainMode* curtain = static_cast<IpcDesktopEnvironmentFactory*>( - desktop_environment_factory_.get()); -#else // !defined(REMOTING_RDP_SESSION) - CurtainMode* curtain = curtain_.get(); -#endif // !defined(REMOTING_RDP_SESSION) - - // Create a host observer to enable/disable curtain mode as clients connect - // and disconnect. - curtaining_host_observer_.reset(new CurtainingHostObserver( - curtain, host_->AsWeakPtr())); - curtaining_host_observer_->SetEnableCurtaining(curtain_required_); - + host_->SetEnableCurtaining(curtain_required_); host_->Start(xmpp_login_); CreateAuthenticatorFactory(); @@ -1010,32 +969,6 @@ void HostProcess::OnAuthFailed() { ShutdownHost(kInvalidOauthCredentialsExitCode); } -void HostProcess::OnCurtainModeFailed() { - DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); - DCHECK(host_); - LOG(ERROR) << "Curtain mode failed to activate. Closing connection."; - host_->RejectAuthenticatingClient(); -} - -void HostProcess::OnRemoteSessionSwitchedToConsole() { - LOG(INFO) << "The remote session switched was to the console." - " Closing connection."; - OnDisconnectRequested(); -} - -// Invoked when the user uses the Disconnect windows to terminate -// the sessions, or when the local session is activated in curtain mode. -void HostProcess::OnDisconnectRequested() { - if (!context_->network_task_runner()->BelongsToCurrentThread()) { - context_->network_task_runner()->PostTask(FROM_HERE, - base::Bind(&HostProcess::OnDisconnectRequested, this)); - return; - } - if (host_) { - host_->DisconnectAllClients(); - } -} - void HostProcess::RestartHost() { DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); DCHECK_EQ(state_, HOST_STARTED); @@ -1071,7 +1004,6 @@ void HostProcess::ShutdownOnNetworkThread() { DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); host_.reset(); - curtaining_host_observer_.reset(); host_event_logger_.reset(); log_to_server_.reset(); heartbeat_sender_.reset(); diff --git a/remoting/host/win/session_desktop_environment.cc b/remoting/host/win/session_desktop_environment.cc index 4787ecb..33add388 100644 --- a/remoting/host/win/session_desktop_environment.cc +++ b/remoting/host/win/session_desktop_environment.cc @@ -33,14 +33,10 @@ SessionDesktopEnvironment::SessionDesktopEnvironment( scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, - base::WeakPtr<ClientSessionControl> client_session_control, - const UiStrings& ui_strings, const base::Closure& inject_sas) : Me2MeDesktopEnvironment(caller_task_runner, input_task_runner, - ui_task_runner, - client_session_control, - ui_strings), + ui_task_runner), inject_sas_(inject_sas) { } @@ -65,13 +61,18 @@ scoped_ptr<DesktopEnvironment> SessionDesktopEnvironmentFactory::Create( base::WeakPtr<ClientSessionControl> client_session_control) { DCHECK(caller_task_runner()->BelongsToCurrentThread()); - return scoped_ptr<DesktopEnvironment>( + scoped_ptr<SessionDesktopEnvironment> desktop_environment( new SessionDesktopEnvironment(caller_task_runner(), input_task_runner(), ui_task_runner(), - client_session_control, - ui_strings(), inject_sas_)); + if (!desktop_environment->InitializeSecurity(client_session_control, + ui_strings(), + curtain_enabled())) { + return scoped_ptr<DesktopEnvironment>(); + } + + return desktop_environment.PassAs<DesktopEnvironment>(); } } // namespace remoting diff --git a/remoting/host/win/session_desktop_environment.h b/remoting/host/win/session_desktop_environment.h index a05d409..1eb9c6a 100644 --- a/remoting/host/win/session_desktop_environment.h +++ b/remoting/host/win/session_desktop_environment.h @@ -30,8 +30,6 @@ class SessionDesktopEnvironment : public Me2MeDesktopEnvironment { scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, - base::WeakPtr<ClientSessionControl> client_session_control, - const UiStrings& ui_strings, const base::Closure& inject_sas); // Used to ask the daemon to inject Secure Attention Sequence. diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp index 791f1e6..6a4c6c3 100644 --- a/remoting/remoting.gyp +++ b/remoting/remoting.gyp @@ -562,8 +562,6 @@ ], 'sources': [ 'host/curtain_mode.h', - 'host/curtaining_host_observer.h', - 'host/curtaining_host_observer.cc', 'host/curtain_mode_linux.cc', 'host/curtain_mode_mac.cc', 'host/curtain_mode_win.cc', |