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.
5 #include "remoting/host/it2me_desktop_environment.h"
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"
15 #include <sys/types.h>
17 #endif // defined(OS_POSIX)
21 It2MeDesktopEnvironment::~It2MeDesktopEnvironment() {
22 DCHECK(caller_task_runner()->BelongsToCurrentThread());
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 const UiStrings
& ui_strings
)
31 : BasicDesktopEnvironment(caller_task_runner
,
34 DCHECK(caller_task_runner
->BelongsToCurrentThread());
36 // Create the local input monitor.
37 local_input_monitor_
= LocalInputMonitor::Create(caller_task_runner
,
40 client_session_control
);
42 // The host UI should be created on the UI thread.
43 bool want_user_interface
= true;
44 #if defined(OS_MACOSX)
45 // Don't try to display any UI on top of the system's login screen as this
46 // is rejected by the Window Server on OS X 10.7.4, and prevents the
47 // capturer from working (http://crbug.com/140984).
49 // TODO(lambroslambrou): Use a better technique of detecting whether we're
50 // running in the LoginWindow context, and refactor this into a separate
51 // function to be used here and in CurtainMode::ActivateCurtain().
52 want_user_interface
= getuid() != 0;
53 #endif // defined(OS_MACOSX)
55 // Create the continue and disconnect windows.
56 if (want_user_interface
) {
57 continue_window_
= HostWindow::CreateContinueWindow(ui_strings
);
58 continue_window_
.reset(new HostWindowProxy(
61 continue_window_
.Pass()));
62 continue_window_
->Start(client_session_control
);
64 disconnect_window_
= HostWindow::CreateDisconnectWindow(ui_strings
);
65 disconnect_window_
.reset(new HostWindowProxy(
68 disconnect_window_
.Pass()));
69 disconnect_window_
->Start(client_session_control
);
73 It2MeDesktopEnvironmentFactory::It2MeDesktopEnvironmentFactory(
74 scoped_refptr
<base::SingleThreadTaskRunner
> caller_task_runner
,
75 scoped_refptr
<base::SingleThreadTaskRunner
> input_task_runner
,
76 scoped_refptr
<base::SingleThreadTaskRunner
> ui_task_runner
,
77 const UiStrings
& ui_strings
)
78 : BasicDesktopEnvironmentFactory(caller_task_runner
,
84 It2MeDesktopEnvironmentFactory::~It2MeDesktopEnvironmentFactory() {
87 scoped_ptr
<DesktopEnvironment
> It2MeDesktopEnvironmentFactory::Create(
88 base::WeakPtr
<ClientSessionControl
> client_session_control
) {
89 DCHECK(caller_task_runner()->BelongsToCurrentThread());
91 return scoped_ptr
<DesktopEnvironment
>(
92 new It2MeDesktopEnvironment(caller_task_runner(),
95 client_session_control
,
99 } // namespace remoting