| 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/basic_desktop_environment.h" | 5 #include "remoting/host/basic_desktop_environment.h" |
| 6 | 6 |
| 7 #include "base/bind.h" |
| 7 #include "base/logging.h" | 8 #include "base/logging.h" |
| 8 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 9 #include "media/video/capture/screen/screen_capturer.h" | 10 #include "media/video/capture/screen/screen_capturer.h" |
| 10 #include "remoting/host/audio_capturer.h" | 11 #include "remoting/host/audio_capturer.h" |
| 11 #include "remoting/host/client_session_control.h" | 12 #include "remoting/host/client_session_control.h" |
| 13 #include "remoting/host/host_window.h" |
| 14 #include "remoting/host/host_window_proxy.h" |
| 12 #include "remoting/host/input_injector.h" | 15 #include "remoting/host/input_injector.h" |
| 13 #include "remoting/host/local_input_monitor.h" | 16 #include "remoting/host/local_input_monitor.h" |
| 14 #include "remoting/host/screen_controls.h" | 17 #include "remoting/host/screen_controls.h" |
| 18 #include "remoting/host/ui_strings.h" |
| 19 |
| 20 #if defined(OS_POSIX) |
| 21 #include <sys/types.h> |
| 22 #include <unistd.h> |
| 23 #endif // defined(OS_POSIX) |
| 15 | 24 |
| 16 namespace remoting { | 25 namespace remoting { |
| 17 | 26 |
| 18 BasicDesktopEnvironment::~BasicDesktopEnvironment() { | 27 BasicDesktopEnvironment::~BasicDesktopEnvironment() { |
| 19 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 28 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 20 } | 29 } |
| 21 | 30 |
| 22 scoped_ptr<AudioCapturer> BasicDesktopEnvironment::CreateAudioCapturer() { | 31 scoped_ptr<AudioCapturer> BasicDesktopEnvironment::CreateAudioCapturer() { |
| 23 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 32 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 24 | 33 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 43 | 52 |
| 44 // The basic desktop environment does not use X DAMAGE, since it is | 53 // The basic desktop environment does not use X DAMAGE, since it is |
| 45 // broken on many systems - see http://crbug.com/73423. | 54 // broken on many systems - see http://crbug.com/73423. |
| 46 return media::ScreenCapturer::Create(); | 55 return media::ScreenCapturer::Create(); |
| 47 } | 56 } |
| 48 | 57 |
| 49 BasicDesktopEnvironment::BasicDesktopEnvironment( | 58 BasicDesktopEnvironment::BasicDesktopEnvironment( |
| 50 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 59 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
| 51 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, | 60 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
| 52 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 61 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
| 53 base::WeakPtr<ClientSessionControl> client_session_control) | 62 base::WeakPtr<ClientSessionControl> client_session_control, |
| 63 const UiStrings* ui_strings) |
| 54 : caller_task_runner_(caller_task_runner), | 64 : caller_task_runner_(caller_task_runner), |
| 55 input_task_runner_(input_task_runner), | 65 input_task_runner_(input_task_runner), |
| 56 ui_task_runner_(ui_task_runner) { | 66 ui_task_runner_(ui_task_runner), |
| 67 ui_strings_(ui_strings) { |
| 57 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 68 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 58 | 69 |
| 59 // Create the local input monitor. | 70 // Create the local input monitor. |
| 60 local_input_monitor_ = LocalInputMonitor::Create(caller_task_runner_, | 71 local_input_monitor_ = LocalInputMonitor::Create(caller_task_runner_, |
| 61 input_task_runner_, | 72 input_task_runner_, |
| 62 ui_task_runner_, | 73 ui_task_runner_, |
| 63 client_session_control); | 74 client_session_control); |
| 75 |
| 76 // The host UI should be created on the UI thread. |
| 77 bool want_user_interface = true; |
| 78 #if defined(OS_LINUX) |
| 79 want_user_interface = false; |
| 80 #elif defined(OS_MACOSX) |
| 81 // Don't try to display any UI on top of the system's login screen as this |
| 82 // is rejected by the Window Server on OS X 10.7.4, and prevents the |
| 83 // capturer from working (http://crbug.com/140984). |
| 84 |
| 85 // TODO(lambroslambrou): Use a better technique of detecting whether we're |
| 86 // running in the LoginWindow context, and refactor this into a separate |
| 87 // function to be used here and in CurtainMode::ActivateCurtain(). |
| 88 want_user_interface = getuid() != 0; |
| 89 #endif // OS_MACOSX |
| 90 |
| 91 // Create the disconnect window. |
| 92 if (want_user_interface) { |
| 93 disconnect_window_ = HostWindow::CreateDisconnectWindow(*ui_strings_); |
| 94 disconnect_window_.reset(new HostWindowProxy( |
| 95 caller_task_runner_, |
| 96 ui_task_runner_, |
| 97 disconnect_window_.Pass())); |
| 98 disconnect_window_->Start(client_session_control); |
| 99 } |
| 64 } | 100 } |
| 65 | 101 |
| 66 BasicDesktopEnvironmentFactory::BasicDesktopEnvironmentFactory( | 102 BasicDesktopEnvironmentFactory::BasicDesktopEnvironmentFactory( |
| 67 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 103 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
| 68 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, | 104 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
| 69 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) | 105 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
| 106 const UiStrings& ui_strings) |
| 70 : caller_task_runner_(caller_task_runner), | 107 : caller_task_runner_(caller_task_runner), |
| 71 input_task_runner_(input_task_runner), | 108 input_task_runner_(input_task_runner), |
| 72 ui_task_runner_(ui_task_runner) { | 109 ui_task_runner_(ui_task_runner), |
| 110 ui_strings_(ui_strings) { |
| 73 } | 111 } |
| 74 | 112 |
| 75 BasicDesktopEnvironmentFactory::~BasicDesktopEnvironmentFactory() { | 113 BasicDesktopEnvironmentFactory::~BasicDesktopEnvironmentFactory() { |
| 76 } | 114 } |
| 77 | 115 |
| 78 scoped_ptr<DesktopEnvironment> BasicDesktopEnvironmentFactory::Create( | 116 scoped_ptr<DesktopEnvironment> BasicDesktopEnvironmentFactory::Create( |
| 79 base::WeakPtr<ClientSessionControl> client_session_control) { | 117 base::WeakPtr<ClientSessionControl> client_session_control) { |
| 80 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 118 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 81 | 119 |
| 82 return scoped_ptr<DesktopEnvironment>( | 120 return scoped_ptr<DesktopEnvironment>( |
| 83 new BasicDesktopEnvironment(caller_task_runner(), | 121 new BasicDesktopEnvironment(caller_task_runner(), |
| 84 input_task_runner(), | 122 input_task_runner(), |
| 85 ui_task_runner(), | 123 ui_task_runner(), |
| 86 client_session_control)); | 124 client_session_control, |
| 125 &ui_strings_)); |
| 87 } | 126 } |
| 88 | 127 |
| 89 bool BasicDesktopEnvironmentFactory::SupportsAudioCapture() const { | 128 bool BasicDesktopEnvironmentFactory::SupportsAudioCapture() const { |
| 90 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 129 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 91 | 130 |
| 92 return AudioCapturer::IsSupported(); | 131 return AudioCapturer::IsSupported(); |
| 93 } | 132 } |
| 94 | 133 |
| 95 } // namespace remoting | 134 } // namespace remoting |
| OLD | NEW |