summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authoralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-07 01:08:09 +0000
committeralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-07 01:08:09 +0000
commit0dffd55966192b3cc0dd2216b75426be50e6cd55 (patch)
tree2b5849f27ffaa1feaa7c576aa61fa61f258334e0 /remoting
parente3ba66cd5a854a9af7282d5bf425059a1044bf89 (diff)
downloadchromium_src-0dffd55966192b3cc0dd2216b75426be50e6cd55.zip
chromium_src-0dffd55966192b3cc0dd2216b75426be50e6cd55.tar.gz
chromium_src-0dffd55966192b3cc0dd2216b75426be50e6cd55.tar.bz2
Added support of Secure Attention Sequence in multiprocess mode.
BUG=134694 Review URL: https://chromiumcodereview.appspot.com/11447021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171664 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/host/chromoting_messages.h4
-rw-r--r--remoting/host/desktop_process.cc20
-rw-r--r--remoting/host/desktop_process.h10
-rw-r--r--remoting/host/desktop_session_agent.cc16
-rw-r--r--remoting/host/desktop_session_agent.h29
-rw-r--r--remoting/host/desktop_session_agent_posix.cc9
-rw-r--r--remoting/host/desktop_session_agent_win.cc25
-rw-r--r--remoting/host/desktop_session_win.cc17
-rw-r--r--remoting/host/desktop_session_win.h6
9 files changed, 117 insertions, 19 deletions
diff --git a/remoting/host/chromoting_messages.h b/remoting/host/chromoting_messages.h
index 2a58f55..be100a6 100644
--- a/remoting/host/chromoting_messages.h
+++ b/remoting/host/chromoting_messages.h
@@ -91,6 +91,10 @@ IPC_MESSAGE_CONTROL3(ChromotingDaemonDesktopMsg_Crash,
IPC_MESSAGE_CONTROL1(ChromotingDesktopDaemonMsg_DesktopAttached,
IPC::PlatformFileForTransit /* desktop_pipe */)
+// Asks the daemon to inject Secure Attention Sequence (SAS) in the session
+// where the desktop process is running.
+IPC_MESSAGE_CONTROL0(ChromotingDesktopDaemonMsg_InjectSas)
+
//-----------------------------------------------------------------------------
// Chromoting messages sent from the desktop to the network process.
diff --git a/remoting/host/desktop_process.cc b/remoting/host/desktop_process.cc
index 6997e22..464b7d4 100644
--- a/remoting/host/desktop_process.cc
+++ b/remoting/host/desktop_process.cc
@@ -34,6 +34,18 @@ DesktopProcess::~DesktopProcess() {
DCHECK(!desktop_agent_);
}
+void DesktopProcess::OnNetworkProcessDisconnected() {
+ DCHECK(caller_task_runner_->BelongsToCurrentThread());
+
+ OnChannelError();
+}
+
+void DesktopProcess::InjectSas() {
+ DCHECK(caller_task_runner_->BelongsToCurrentThread());
+
+ daemon_channel_->Send(new ChromotingDesktopDaemonMsg_InjectSas());
+}
+
bool DesktopProcess::OnMessageReceived(const IPC::Message& message) {
DCHECK(caller_task_runner_->BelongsToCurrentThread());
@@ -84,13 +96,9 @@ bool DesktopProcess::Start() {
io_task_runner,
video_capture_task_runner);
- // Start the agent and create an IPC channel to talk to it. It is safe to
- // use base::Unretained(this) here because the message loop below will run
- // until |desktop_agent_| is completely destroyed.
+ // Start the agent and create an IPC channel to talk to it.
IPC::PlatformFileForTransit desktop_pipe;
- if (!desktop_agent_->Start(base::Bind(&DesktopProcess::OnChannelError,
- base::Unretained(this)),
- &desktop_pipe)) {
+ if (!desktop_agent_->Start(AsWeakPtr(), &desktop_pipe)) {
desktop_agent_ = NULL;
caller_task_runner_ = NULL;
return false;
diff --git a/remoting/host/desktop_process.h b/remoting/host/desktop_process.h
index e95971e..606dab5 100644
--- a/remoting/host/desktop_process.h
+++ b/remoting/host/desktop_process.h
@@ -11,7 +11,9 @@
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "ipc/ipc_listener.h"
+#include "remoting/host/desktop_session_agent.h"
namespace IPC {
class ChannelProxy;
@@ -22,12 +24,18 @@ namespace remoting {
class AutoThreadTaskRunner;
class DesktopSessionAgent;
-class DesktopProcess : public IPC::Listener {
+class DesktopProcess : public DesktopSessionAgent::Delegate,
+ public IPC::Listener,
+ public base::SupportsWeakPtr<DesktopProcess> {
public:
DesktopProcess(scoped_refptr<AutoThreadTaskRunner> caller_task_runner,
const std::string& daemon_channel_name);
virtual ~DesktopProcess();
+ // DesktopSessionAgent::Delegate implementation.
+ virtual void OnNetworkProcessDisconnected() OVERRIDE;
+ virtual void InjectSas() OVERRIDE;
+
// IPC::Listener implementation.
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
diff --git a/remoting/host/desktop_session_agent.cc b/remoting/host/desktop_session_agent.cc
index bb5024d..53daced 100644
--- a/remoting/host/desktop_session_agent.cc
+++ b/remoting/host/desktop_session_agent.cc
@@ -60,6 +60,9 @@ void DesktopSesssionClipboardStub::InjectClipboardEvent(
} // namespace
+DesktopSessionAgent::Delegate::~Delegate() {
+}
+
DesktopSessionAgent::~DesktopSessionAgent() {
DCHECK(!network_channel_);
DCHECK(!video_capturer_);
@@ -100,7 +103,8 @@ void DesktopSessionAgent::OnChannelError() {
network_channel_.reset();
// Notify the caller that the channel has been disconnected.
- disconnected_task_.Run();
+ if (delegate_.get())
+ delegate_->OnNetworkProcessDisconnected();
}
scoped_refptr<SharedBuffer> DesktopSessionAgent::CreateSharedBuffer(
@@ -188,19 +192,19 @@ void DesktopSessionAgent::InjectClipboardEvent(
new ChromotingDesktopNetworkMsg_InjectClipboardEvent(serialized_event));
}
-bool DesktopSessionAgent::Start(const base::Closure& disconnected_task,
+bool DesktopSessionAgent::Start(const base::WeakPtr<Delegate>& delegate,
IPC::PlatformFileForTransit* desktop_pipe_out) {
DCHECK(caller_task_runner()->BelongsToCurrentThread());
+ DCHECK(delegate_.get() == NULL);
- disconnected_task_ = disconnected_task;
+ delegate_ = delegate;
// Create an IPC channel to communicate with the network process.
if (!CreateChannelForNetworkProcess(desktop_pipe_out, &network_channel_))
return false;
// Create and start the event executor.
- event_executor_ = EventExecutor::Create(input_task_runner(),
- caller_task_runner());
+ event_executor_ = CreateEventExecutor();
scoped_ptr<protocol::ClipboardStub> clipboard_stub(
new DesktopSesssionClipboardStub(this));
event_executor_->Start(clipboard_stub.Pass());
@@ -214,6 +218,8 @@ bool DesktopSessionAgent::Start(const base::Closure& disconnected_task,
void DesktopSessionAgent::Stop() {
DCHECK(caller_task_runner()->BelongsToCurrentThread());
+ delegate_.reset();
+
// Make sure the channel is closed.
network_channel_.reset();
diff --git a/remoting/host/desktop_session_agent.h b/remoting/host/desktop_session_agent.h
index d7d5c90..96c23cc 100644
--- a/remoting/host/desktop_session_agent.h
+++ b/remoting/host/desktop_session_agent.h
@@ -12,6 +12,7 @@
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "ipc/ipc_listener.h"
#include "ipc/ipc_platform_file.h"
#include "remoting/base/shared_buffer.h"
@@ -38,6 +39,18 @@ class DesktopSessionAgent
public SharedBufferFactory,
public VideoFrameCapturer::Delegate {
public:
+ class Delegate {
+ public:
+ virtual ~Delegate();
+
+ // Notifies the delegate that the network-to-desktop channel has been
+ // disconnected.
+ virtual void OnNetworkProcessDisconnected() = 0;
+
+ // Request the delegate to inject Secure Attention Sequence.
+ virtual void InjectSas() = 0;
+ };
+
static scoped_refptr<DesktopSessionAgent> Create(
scoped_refptr<AutoThreadTaskRunner> caller_task_runner,
scoped_refptr<AutoThreadTaskRunner> input_task_runner,
@@ -66,10 +79,7 @@ class DesktopSessionAgent
// Creates desktop integration components and a connected IPC channel to be
// used to access them. The client end of the channel is returned in
// the variable pointed by |desktop_pipe_out|.
- //
- // |disconnected_task| is invoked on |caller_task_runner_| to notify
- // the caller that the network-to-desktop channel has been disconnected.
- bool Start(const base::Closure& disconnected_task,
+ bool Start(const base::WeakPtr<Delegate>& delegate,
IPC::PlatformFileForTransit* desktop_pipe_out);
// Stops the agent asynchronously.
@@ -91,6 +101,9 @@ class DesktopSessionAgent
IPC::PlatformFileForTransit* client_out,
scoped_ptr<IPC::ChannelProxy>* server_out) = 0;
+ // Creates an event executor specific to the platform.
+ virtual scoped_ptr<EventExecutor> CreateEventExecutor() = 0;
+
// Handles CaptureFrame requests from the client.
void OnCaptureFrame();
@@ -132,6 +145,10 @@ class DesktopSessionAgent
return video_capture_task_runner_;
}
+ const base::WeakPtr<Delegate>& delegate() const {
+ return delegate_;
+ }
+
private:
// Task runner on which public methods of this class should be called.
scoped_refptr<AutoThreadTaskRunner> caller_task_runner_;
@@ -145,9 +162,7 @@ class DesktopSessionAgent
// Task runner dedicated to running methods of |video_capturer_|.
scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner_;
- // Runs on |caller_task_runner_| to notify the caller that the network-to-
- // desktop channel has been disconnected.
- base::Closure disconnected_task_;
+ base::WeakPtr<Delegate> delegate_;
// Executes keyboard, mouse and clipboard events.
scoped_ptr<EventExecutor> event_executor_;
diff --git a/remoting/host/desktop_session_agent_posix.cc b/remoting/host/desktop_session_agent_posix.cc
index d357d23..0d4f8b2 100644
--- a/remoting/host/desktop_session_agent_posix.cc
+++ b/remoting/host/desktop_session_agent_posix.cc
@@ -14,6 +14,7 @@
#include "ipc/ipc_channel.h"
#include "ipc/ipc_channel_proxy.h"
#include "remoting/base/auto_thread_task_runner.h"
+#include "remoting/host/event_executor.h"
namespace remoting {
@@ -33,6 +34,7 @@ class DesktopSessionAgentPosix : public DesktopSessionAgent {
virtual bool CreateChannelForNetworkProcess(
IPC::PlatformFileForTransit* client_out,
scoped_ptr<IPC::ChannelProxy>* server_out) OVERRIDE;
+ virtual scoped_ptr<EventExecutor> CreateEventExecutor() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(DesktopSessionAgentPosix);
@@ -88,6 +90,13 @@ bool DesktopSessionAgentPosix::CreateChannelForNetworkProcess(
return true;
}
+scoped_ptr<EventExecutor> DesktopSessionAgentPosix::CreateEventExecutor() {
+ DCHECK(caller_task_runner()->BelongsToCurrentThread());
+
+ return EventExecutor::Create(input_task_runner(),
+ caller_task_runner()).Pass();
+}
+
// static
scoped_refptr<DesktopSessionAgent> DesktopSessionAgent::Create(
scoped_refptr<AutoThreadTaskRunner> caller_task_runner,
diff --git a/remoting/host/desktop_session_agent_win.cc b/remoting/host/desktop_session_agent_win.cc
index 0117439..c67343d 100644
--- a/remoting/host/desktop_session_agent_win.cc
+++ b/remoting/host/desktop_session_agent_win.cc
@@ -13,7 +13,9 @@
#include "ipc/ipc_channel.h"
#include "ipc/ipc_channel_proxy.h"
#include "remoting/base/auto_thread_task_runner.h"
+#include "remoting/host/event_executor.h"
#include "remoting/host/win/launch_process_with_token.h"
+#include "remoting/host/win/session_event_executor.h"
using base::win::ScopedHandle;
@@ -35,6 +37,11 @@ class DesktopSessionAgentWin : public DesktopSessionAgent {
virtual bool CreateChannelForNetworkProcess(
IPC::PlatformFileForTransit* client_out,
scoped_ptr<IPC::ChannelProxy>* server_out) OVERRIDE;
+ virtual scoped_ptr<EventExecutor> CreateEventExecutor() OVERRIDE;
+
+ // Requests the daemon to inject Secure Attention Sequence into the current
+ // session.
+ void InjectSas();
private:
DISALLOW_COPY_AND_ASSIGN(DesktopSessionAgentWin);
@@ -87,6 +94,24 @@ bool DesktopSessionAgentWin::CreateChannelForNetworkProcess(
return true;
}
+scoped_ptr<EventExecutor> DesktopSessionAgentWin::CreateEventExecutor() {
+ DCHECK(caller_task_runner()->BelongsToCurrentThread());
+
+ scoped_ptr<EventExecutor> event_executor =
+ EventExecutor::Create(input_task_runner(), caller_task_runner());
+ event_executor.reset(new SessionEventExecutorWin(
+ input_task_runner(), event_executor.Pass(), caller_task_runner(),
+ base::Bind(&DesktopSessionAgentWin::InjectSas, this)));
+ return event_executor.Pass();
+}
+
+void DesktopSessionAgentWin::InjectSas() {
+ DCHECK(caller_task_runner()->BelongsToCurrentThread());
+
+ if (delegate().get())
+ delegate()->InjectSas();
+}
+
// static
scoped_refptr<DesktopSessionAgent> DesktopSessionAgent::Create(
scoped_refptr<AutoThreadTaskRunner> caller_task_runner,
diff --git a/remoting/host/desktop_session_win.cc b/remoting/host/desktop_session_win.cc
index 8472e12..ac28764 100644
--- a/remoting/host/desktop_session_win.cc
+++ b/remoting/host/desktop_session_win.cc
@@ -9,6 +9,7 @@
#include "remoting/base/auto_thread_task_runner.h"
#include "remoting/host/chromoting_messages.h"
#include "remoting/host/daemon_process.h"
+#include "remoting/host/sas_injector.h"
#include "remoting/host/win/worker_process_launcher.h"
#include "remoting/host/win/wts_console_monitor.h"
#include "remoting/host/win/wts_session_process_delegate.h"
@@ -72,6 +73,8 @@ bool DesktopSessionWin::OnMessageReceived(const IPC::Message& message) {
IPC_BEGIN_MESSAGE_MAP(DesktopSessionWin, message)
IPC_MESSAGE_HANDLER(ChromotingDesktopDaemonMsg_DesktopAttached,
OnDesktopSessionAgentAttached)
+ IPC_MESSAGE_HANDLER(ChromotingDesktopDaemonMsg_InjectSas,
+ OnInjectSas)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
@@ -128,6 +131,20 @@ void DesktopSessionWin::OnDesktopSessionAgentAttached(
}
}
+void DesktopSessionWin::OnInjectSas() {
+ DCHECK(main_task_runner_->BelongsToCurrentThread());
+
+ // Do not try to inject SAS if the desktop process is not running. This can
+ // happen when the session has detached from the console for instance.
+ if (!launcher_)
+ return;
+
+ if (!sas_injector_)
+ sas_injector_ = SasInjector::Create();
+ if (!sas_injector_->InjectSas())
+ LOG(ERROR) << "Failed to inject Secure Attention Sequence.";
+}
+
void DesktopSessionWin::RestartDesktopProcess(
const tracked_objects::Location& location) {
DCHECK(main_task_runner_->BelongsToCurrentThread());
diff --git a/remoting/host/desktop_session_win.h b/remoting/host/desktop_session_win.h
index a8b35d53..89343c9 100644
--- a/remoting/host/desktop_session_win.h
+++ b/remoting/host/desktop_session_win.h
@@ -22,6 +22,7 @@ namespace remoting {
class AutoThreadTaskRunner;
class DaemonProcess;
+class SasInjector;
class WorkerProcessLauncher;
class WtsConsoleMonitor;
@@ -60,6 +61,9 @@ class DesktopSessionWin
// ChromotingDesktopDaemonMsg_DesktopAttached handler.
void OnDesktopSessionAgentAttached(IPC::PlatformFileForTransit desktop_pipe);
+ // ChromotingDesktopDaemonMsg_InjectSas handler.
+ void OnInjectSas();
+
// Restarts the desktop process.
void RestartDesktopProcess(const tracked_objects::Location& location);
@@ -81,6 +85,8 @@ class DesktopSessionWin
// Pointer used to unsubscribe from session attach and detach events.
WtsConsoleMonitor* monitor_;
+ scoped_ptr<SasInjector> sas_injector_;
+
DISALLOW_COPY_AND_ASSIGN(DesktopSessionWin);
};