Chromium Code Reviews| 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 #include "remoting/host/win/wts_console_session_process_driver.h" | 5 #include "remoting/host/win/wts_console_session_process_driver.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
| 12 #include "base/win/windows_version.h" | |
| 12 #include "ipc/ipc_message.h" | 13 #include "ipc/ipc_message.h" |
| 13 #include "ipc/ipc_message_macros.h" | 14 #include "ipc/ipc_message_macros.h" |
| 14 #include "remoting/host/chromoting_messages.h" | 15 #include "remoting/host/chromoting_messages.h" |
| 15 #include "remoting/host/host_main.h" | 16 #include "remoting/host/host_main.h" |
| 16 #include "remoting/host/ipc_constants.h" | 17 #include "remoting/host/ipc_constants.h" |
| 17 #include "remoting/host/sas_injector.h" | 18 #include "remoting/host/sas_injector.h" |
| 18 #include "remoting/host/win/worker_process_launcher.h" | 19 #include "remoting/host/win/worker_process_launcher.h" |
| 19 #include "remoting/host/win/wts_session_process_delegate.h" | 20 #include "remoting/host/win/wts_session_process_delegate.h" |
| 20 #include "remoting/host/win/wts_terminal_monitor.h" | 21 #include "remoting/host/win/wts_terminal_monitor.h" |
| 21 | 22 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 | 83 |
| 83 void WtsConsoleSessionProcessDriver::OnSessionAttached(uint32 session_id) { | 84 void WtsConsoleSessionProcessDriver::OnSessionAttached(uint32 session_id) { |
| 84 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 85 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 85 | 86 |
| 86 if (stoppable_state() != Stoppable::kRunning) { | 87 if (stoppable_state() != Stoppable::kRunning) { |
| 87 return; | 88 return; |
| 88 } | 89 } |
| 89 | 90 |
| 90 DCHECK(launcher_.get() == NULL); | 91 DCHECK(launcher_.get() == NULL); |
| 91 | 92 |
| 92 // Get the host binary name. | 93 // Launch elevated on Win8 to be able to inject Alt+Tab. |
|
garykac
2013/05/15 23:24:30
Is it worth sharing this code with desktop_session
alexeypa (please no reviews)
2013/05/16 17:50:04
WtsConsoleSessionProcessDriver is not used any mor
| |
| 94 bool launch_elevated = base::win::GetVersion() >= base::win::VERSION_WIN8; | |
| 95 | |
| 96 // Get the name of the executable the desktop process will run. | |
| 93 base::FilePath desktop_binary; | 97 base::FilePath desktop_binary; |
| 94 if (!GetInstalledBinaryPath(kDesktopBinaryName, &desktop_binary)) { | 98 bool result; |
| 99 if (launch_elevated) { | |
| 100 result = GetInstalledBinaryPath(kDesktopBinaryName, &desktop_binary); | |
| 101 } else { | |
| 102 result = GetInstalledBinaryPath(kHostBinaryName, &desktop_binary); | |
| 103 } | |
| 104 | |
| 105 if (!result) { | |
| 95 Stop(); | 106 Stop(); |
| 96 return; | 107 return; |
| 97 } | 108 } |
| 98 | 109 |
| 99 scoped_ptr<CommandLine> target(new CommandLine(desktop_binary)); | 110 scoped_ptr<CommandLine> target(new CommandLine(desktop_binary)); |
| 100 target->AppendSwitchASCII(kProcessTypeSwitchName, kProcessTypeHost); | 111 target->AppendSwitchASCII(kProcessTypeSwitchName, kProcessTypeHost); |
| 101 target->CopySwitchesFrom(*CommandLine::ForCurrentProcess(), | 112 target->CopySwitchesFrom(*CommandLine::ForCurrentProcess(), |
| 102 kCopiedSwitchNames, | 113 kCopiedSwitchNames, |
| 103 arraysize(kCopiedSwitchNames)); | 114 arraysize(kCopiedSwitchNames)); |
| 104 | 115 |
| 105 // Create a Delegate capable of launching an elevated process in the session. | 116 // Create a Delegate capable of launching an elevated process in the session. |
| 106 scoped_ptr<WtsSessionProcessDelegate> delegate( | 117 scoped_ptr<WtsSessionProcessDelegate> delegate( |
| 107 new WtsSessionProcessDelegate(caller_task_runner_, | 118 new WtsSessionProcessDelegate(io_task_runner_, |
| 108 io_task_runner_, | |
| 109 target.Pass(), | 119 target.Pass(), |
| 110 session_id, | 120 launch_elevated, |
| 111 true, | |
| 112 kDaemonIpcSecurityDescriptor)); | 121 kDaemonIpcSecurityDescriptor)); |
| 122 if (!delegate->Initialize(session_id)) { | |
| 123 Stop(); | |
| 124 return; | |
| 125 } | |
| 113 | 126 |
| 114 // Use the Delegate to launch the host process. | 127 // Use the Delegate to launch the host process. |
| 115 launcher_.reset(new WorkerProcessLauncher( | 128 launcher_.reset(new WorkerProcessLauncher(delegate.Pass(), this)); |
| 116 caller_task_runner_, delegate.Pass(), this)); | |
| 117 } | 129 } |
| 118 | 130 |
| 119 void WtsConsoleSessionProcessDriver::OnSessionDetached() { | 131 void WtsConsoleSessionProcessDriver::OnSessionDetached() { |
| 120 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 132 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 121 DCHECK(launcher_.get() != NULL); | 133 DCHECK(launcher_.get() != NULL); |
| 122 | 134 |
| 123 launcher_.reset(); | 135 launcher_.reset(); |
| 124 } | 136 } |
| 125 | 137 |
| 126 void WtsConsoleSessionProcessDriver::DoStop() { | 138 void WtsConsoleSessionProcessDriver::DoStop() { |
| 127 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 139 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 128 | 140 |
| 129 launcher_.reset(); | 141 launcher_.reset(); |
| 130 CompleteStopping(); | 142 CompleteStopping(); |
| 131 } | 143 } |
| 132 | 144 |
| 133 void WtsConsoleSessionProcessDriver::OnSendSasToConsole() { | 145 void WtsConsoleSessionProcessDriver::OnSendSasToConsole() { |
| 134 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 146 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 135 | 147 |
| 136 if (!launcher_) | 148 if (!launcher_) |
| 137 return; | 149 return; |
| 138 | 150 |
| 139 if (!sas_injector_) | 151 if (!sas_injector_) |
| 140 sas_injector_ = SasInjector::Create(); | 152 sas_injector_ = SasInjector::Create(); |
| 141 if (!sas_injector_->InjectSas()) | 153 if (!sas_injector_->InjectSas()) |
| 142 LOG(ERROR) << "Failed to inject Secure Attention Sequence."; | 154 LOG(ERROR) << "Failed to inject Secure Attention Sequence."; |
| 143 } | 155 } |
| 144 | 156 |
| 145 } // namespace remoting | 157 } // namespace remoting |
| OLD | NEW |