| 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/desktop_session_win.h" | 5 #include "remoting/host/desktop_session_win.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <sddl.h> | 8 #include <sddl.h> |
| 9 | 9 |
| 10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
| 17 #include "base/stringprintf.h" | 17 #include "base/stringprintf.h" |
| 18 #include "base/threading/thread_checker.h" | 18 #include "base/threading/thread_checker.h" |
| 19 #include "base/timer.h" | 19 #include "base/timer.h" |
| 20 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
| 21 #include "base/win/scoped_comptr.h" | 21 #include "base/win/scoped_comptr.h" |
| 22 #include "base/win/scoped_handle.h" | 22 #include "base/win/scoped_handle.h" |
| 23 #include "base/win/windows_version.h" |
| 23 #include "ipc/ipc_message_macros.h" | 24 #include "ipc/ipc_message_macros.h" |
| 24 #include "ipc/ipc_platform_file.h" | 25 #include "ipc/ipc_platform_file.h" |
| 25 #include "net/base/ip_endpoint.h" | 26 #include "net/base/ip_endpoint.h" |
| 26 #include "remoting/base/auto_thread_task_runner.h" | 27 #include "remoting/base/auto_thread_task_runner.h" |
| 27 // MIDL-generated declarations and definitions. | 28 // MIDL-generated declarations and definitions. |
| 28 #include "remoting/host/chromoting_lib.h" | 29 #include "remoting/host/chromoting_lib.h" |
| 29 #include "remoting/host/chromoting_messages.h" | 30 #include "remoting/host/chromoting_messages.h" |
| 30 #include "remoting/host/daemon_process.h" | 31 #include "remoting/host/daemon_process.h" |
| 31 #include "remoting/host/desktop_session.h" | 32 #include "remoting/host/desktop_session.h" |
| 32 #include "remoting/host/host_main.h" | 33 #include "remoting/host/host_main.h" |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 daemon_process()->CloseDesktopSession(id()); | 510 daemon_process()->CloseDesktopSession(id()); |
| 510 } | 511 } |
| 511 | 512 |
| 512 void DesktopSessionWin::OnSessionAttached(uint32 session_id) { | 513 void DesktopSessionWin::OnSessionAttached(uint32 session_id) { |
| 513 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 514 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 514 DCHECK(!launcher_); | 515 DCHECK(!launcher_); |
| 515 DCHECK(monitoring_notifications_); | 516 DCHECK(monitoring_notifications_); |
| 516 | 517 |
| 517 ReportElapsedTime("attached"); | 518 ReportElapsedTime("attached"); |
| 518 | 519 |
| 520 // Launch elevated on Win8 to be able to inject Alt+Tab. |
| 521 bool launch_elevated = base::win::GetVersion() >= base::win::VERSION_WIN8; |
| 522 |
| 519 // Get the name of the executable the desktop process will run. | 523 // Get the name of the executable the desktop process will run. |
| 520 base::FilePath desktop_binary; | 524 base::FilePath desktop_binary; |
| 521 if (!GetInstalledBinaryPath(kDesktopBinaryName, &desktop_binary)) { | 525 bool result; |
| 526 if (launch_elevated) { |
| 527 result = GetInstalledBinaryPath(kDesktopBinaryName, &desktop_binary); |
| 528 } else { |
| 529 result = GetInstalledBinaryPath(kHostBinaryName, &desktop_binary); |
| 530 } |
| 531 |
| 532 if (!result) { |
| 522 OnPermanentError(); | 533 OnPermanentError(); |
| 523 return; | 534 return; |
| 524 } | 535 } |
| 525 | 536 |
| 526 session_attach_timer_.Stop(); | 537 session_attach_timer_.Stop(); |
| 527 | 538 |
| 528 scoped_ptr<CommandLine> target(new CommandLine(desktop_binary)); | 539 scoped_ptr<CommandLine> target(new CommandLine(desktop_binary)); |
| 529 target->AppendSwitchASCII(kProcessTypeSwitchName, kProcessTypeDesktop); | 540 target->AppendSwitchASCII(kProcessTypeSwitchName, kProcessTypeDesktop); |
| 530 // Copy the command line switches enabling verbose logging. | 541 // Copy the command line switches enabling verbose logging. |
| 531 target->CopySwitchesFrom(*CommandLine::ForCurrentProcess(), | 542 target->CopySwitchesFrom(*CommandLine::ForCurrentProcess(), |
| 532 kCopiedSwitchNames, | 543 kCopiedSwitchNames, |
| 533 arraysize(kCopiedSwitchNames)); | 544 arraysize(kCopiedSwitchNames)); |
| 534 | 545 |
| 535 // Create a delegate capable of launching a process in a different session. | 546 // Create a delegate capable of launching a process in a different session. |
| 536 scoped_ptr<WtsSessionProcessDelegate> delegate( | 547 scoped_ptr<WtsSessionProcessDelegate> delegate( |
| 537 new WtsSessionProcessDelegate( | 548 new WtsSessionProcessDelegate(io_task_runner_, |
| 538 caller_task_runner_, io_task_runner_, target.Pass(), session_id, true, | 549 target.Pass(), |
| 539 WideToUTF8(kDaemonIpcSecurityDescriptor))); | 550 launch_elevated, |
| 551 WideToUTF8(kDaemonIpcSecurityDescriptor))); |
| 552 if (!delegate->Initialize(session_id)) { |
| 553 OnPermanentError(); |
| 554 return; |
| 555 } |
| 540 | 556 |
| 541 // Create a launcher for the desktop process, using the per-session delegate. | 557 // Create a launcher for the desktop process, using the per-session delegate. |
| 542 launcher_.reset(new WorkerProcessLauncher( | 558 launcher_.reset(new WorkerProcessLauncher(delegate.Pass(), this)); |
| 543 caller_task_runner_, delegate.Pass(), this)); | |
| 544 } | 559 } |
| 545 | 560 |
| 546 void DesktopSessionWin::OnSessionDetached() { | 561 void DesktopSessionWin::OnSessionDetached() { |
| 547 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 562 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 548 | 563 |
| 549 launcher_.reset(); | 564 launcher_.reset(); |
| 550 | 565 |
| 551 if (monitoring_notifications_) { | 566 if (monitoring_notifications_) { |
| 552 ReportElapsedTime("detached"); | 567 ReportElapsedTime("detached"); |
| 553 | 568 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 exploded.hour, | 605 exploded.hour, |
| 591 exploded.minute, | 606 exploded.minute, |
| 592 exploded.second, | 607 exploded.second, |
| 593 exploded.millisecond, | 608 exploded.millisecond, |
| 594 passed.c_str()); | 609 passed.c_str()); |
| 595 | 610 |
| 596 last_timestamp_ = now; | 611 last_timestamp_ = now; |
| 597 } | 612 } |
| 598 | 613 |
| 599 } // namespace remoting | 614 } // namespace remoting |
| OLD | NEW |