| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // This file implements the Windows service controlling Me2Me host processes | 5 // This file implements the Windows service controlling Me2Me host processes |
| 6 // running within user sessions. | 6 // running within user sessions. |
| 7 | 7 |
| 8 #include "remoting/host/desktop_process.h" | 8 #include "remoting/host/desktop_process.h" |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 14 #include "base/debug/alias.h" | 14 #include "base/debug/alias.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
| 18 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 20 #include "ipc/attachment_broker_unprivileged.h" | 20 #include "ipc/attachment_broker_unprivileged.h" |
| 21 #include "ipc/ipc_channel_proxy.h" | 21 #include "ipc/ipc_channel_proxy.h" |
| 22 #include "remoting/base/auto_thread.h" | 22 #include "remoting/base/auto_thread.h" |
| 23 #include "remoting/base/auto_thread_task_runner.h" | 23 #include "remoting/base/auto_thread_task_runner.h" |
| 24 #include "remoting/host/chromoting_messages.h" | 24 #include "remoting/host/chromoting_messages.h" |
| 25 #include "remoting/host/desktop_environment.h" | 25 #include "remoting/host/desktop_environment.h" |
| 26 #include "remoting/host/desktop_session_agent.h" | 26 #include "remoting/host/desktop_session_agent.h" |
| 27 | 27 |
| 28 #if defined(OS_WIN) |
| 29 #include "base/win/windows_version.h" |
| 30 #endif // defined(OS_WIN) |
| 31 |
| 28 namespace remoting { | 32 namespace remoting { |
| 29 | 33 |
| 30 DesktopProcess::DesktopProcess( | 34 DesktopProcess::DesktopProcess( |
| 31 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, | 35 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, |
| 32 scoped_refptr<AutoThreadTaskRunner> input_task_runner, | 36 scoped_refptr<AutoThreadTaskRunner> input_task_runner, |
| 33 const std::string& daemon_channel_name) | 37 const std::string& daemon_channel_name) |
| 34 : caller_task_runner_(caller_task_runner), | 38 : caller_task_runner_(caller_task_runner), |
| 35 input_task_runner_(input_task_runner), | 39 input_task_runner_(input_task_runner), |
| 36 daemon_channel_name_(daemon_channel_name) { | 40 daemon_channel_name_(daemon_channel_name) { |
| 37 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 41 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 54 | 58 |
| 55 OnChannelError(); | 59 OnChannelError(); |
| 56 } | 60 } |
| 57 | 61 |
| 58 void DesktopProcess::InjectSas() { | 62 void DesktopProcess::InjectSas() { |
| 59 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 63 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 60 | 64 |
| 61 daemon_channel_->Send(new ChromotingDesktopDaemonMsg_InjectSas()); | 65 daemon_channel_->Send(new ChromotingDesktopDaemonMsg_InjectSas()); |
| 62 } | 66 } |
| 63 | 67 |
| 68 void DesktopProcess::LockWorkStation() { |
| 69 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 70 #if defined(OS_WIN) |
| 71 if (base::win::OSInfo::GetInstance()->version_type() == |
| 72 base::win::VersionType::SUITE_HOME) { |
| 73 return; |
| 74 } |
| 75 |
| 76 if (!::LockWorkStation()) { |
| 77 LOG(ERROR) << "LockWorkStation() failed: " << ::GetLastError(); |
| 78 } |
| 79 #else |
| 80 NOTREACHED(); |
| 81 #endif // defined(OS_WIN) |
| 82 } |
| 83 |
| 64 bool DesktopProcess::OnMessageReceived(const IPC::Message& message) { | 84 bool DesktopProcess::OnMessageReceived(const IPC::Message& message) { |
| 65 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 85 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 66 | 86 |
| 67 bool handled = true; | 87 bool handled = true; |
| 68 IPC_BEGIN_MESSAGE_MAP(DesktopProcess, message) | 88 IPC_BEGIN_MESSAGE_MAP(DesktopProcess, message) |
| 69 IPC_MESSAGE_HANDLER(ChromotingDaemonMsg_Crash, OnCrash) | 89 IPC_MESSAGE_HANDLER(ChromotingDaemonMsg_Crash, OnCrash) |
| 70 IPC_MESSAGE_UNHANDLED(handled = false) | 90 IPC_MESSAGE_UNHANDLED(handled = false) |
| 71 IPC_END_MESSAGE_MAP() | 91 IPC_END_MESSAGE_MAP() |
| 72 | 92 |
| 73 CHECK(handled) << "Received unexpected IPC type: " << message.type(); | 93 CHECK(handled) << "Received unexpected IPC type: " << message.type(); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 base::snprintf(message, sizeof(message), | 184 base::snprintf(message, sizeof(message), |
| 165 "Requested by %s at %s, line %d.", | 185 "Requested by %s at %s, line %d.", |
| 166 function_name.c_str(), file_name.c_str(), line_number); | 186 function_name.c_str(), file_name.c_str(), line_number); |
| 167 base::debug::Alias(message); | 187 base::debug::Alias(message); |
| 168 | 188 |
| 169 // The daemon requested us to crash the process. | 189 // The daemon requested us to crash the process. |
| 170 CHECK(false) << message; | 190 CHECK(false) << message; |
| 171 } | 191 } |
| 172 | 192 |
| 173 } // namespace remoting | 193 } // namespace remoting |
| OLD | NEW |