1 // Copyright 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "remoting/host/it2me_desktop_environment.h" 6 7 #include "base/logging.h" 8 #include "base/single_thread_task_runner.h" 9 #include "remoting/host/client_session_control.h" 10 #include "remoting/host/host_window.h" 11 #include "remoting/host/host_window_proxy.h" 12 #include "remoting/host/local_input_monitor.h" 13 14 #if defined(OS_POSIX) 15 #include <sys/types.h> 16 #include <unistd.h> 17 #endif // defined(OS_POSIX) 18 19 namespace remoting { 20 21 It2MeDesktopEnvironment::~It2MeDesktopEnvironment() { 22 DCHECK(caller_task_runner()->BelongsToCurrentThread()); 23 } 24 25 It2MeDesktopEnvironment::It2MeDesktopEnvironment( 26 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, 27 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, 28 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, 29 base::WeakPtr<ClientSessionControl> client_session_control) 30 : BasicDesktopEnvironment(caller_task_runner, 31 input_task_runner, 32 ui_task_runner) { 33 DCHECK(caller_task_runner->BelongsToCurrentThread()); 34 35 // Create the local input monitor. 36 local_input_monitor_ = LocalInputMonitor::Create(caller_task_runner, 37 input_task_runner, 38 ui_task_runner, 39 client_session_control); 40 41 // The host UI should be created on the UI thread. 42 bool want_user_interface = true; 43 #if defined(OS_MACOSX) 44 // Don't try to display any UI on top of the system's login screen as this 45 // is rejected by the Window Server on OS X 10.7.4, and prevents the 46 // capturer from working (http://crbug.com/140984). 47 48 // TODO(lambroslambrou): Use a better technique of detecting whether we're 49 // running in the LoginWindow context, and refactor this into a separate 50 // function to be used here and in CurtainMode::ActivateCurtain(). 51 want_user_interface = getuid() != 0; 52 #endif // defined(OS_MACOSX) 53 54 // Create the continue and disconnect windows. 55 if (want_user_interface) { 56 continue_window_ = HostWindow::CreateContinueWindow(); 57 continue_window_.reset(new HostWindowProxy( 58 caller_task_runner, 59 ui_task_runner, 60 continue_window_.Pass())); 61 continue_window_->Start(client_session_control); 62 63 disconnect_window_ = HostWindow::CreateDisconnectWindow(); 64 disconnect_window_.reset(new HostWindowProxy( 65 caller_task_runner, 66 ui_task_runner, 67 disconnect_window_.Pass())); 68 disconnect_window_->Start(client_session_control); 69 } 70 } 71 72 It2MeDesktopEnvironmentFactory::It2MeDesktopEnvironmentFactory( 73 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, 74 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, 75 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) 76 : BasicDesktopEnvironmentFactory(caller_task_runner, 77 input_task_runner, 78 ui_task_runner) { 79 } 80 81 It2MeDesktopEnvironmentFactory::~It2MeDesktopEnvironmentFactory() { 82 } 83 84 scoped_ptr<DesktopEnvironment> It2MeDesktopEnvironmentFactory::Create( 85 base::WeakPtr<ClientSessionControl> client_session_control) { 86 DCHECK(caller_task_runner()->BelongsToCurrentThread()); 87 88 return scoped_ptr<DesktopEnvironment>( 89 new It2MeDesktopEnvironment(caller_task_runner(), 90 input_task_runner(), 91 ui_task_runner(), 92 client_session_control)); 93 } 94 95 } // namespace remoting 96