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/curtain_mode.h" | 5 #include "remoting/host/curtain_mode.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
11 #include "base/win/windows_version.h" | |
12 #include "remoting/host/client_session_control.h" | 11 #include "remoting/host/client_session_control.h" |
13 | 12 |
14 namespace remoting { | 13 namespace remoting { |
15 | 14 |
16 class CurtainModeWin : public CurtainMode { | 15 class CurtainModeWin : public CurtainMode { |
17 public: | 16 public: |
18 CurtainModeWin(); | 17 CurtainModeWin(); |
19 | 18 |
20 // Overriden from CurtainMode. | 19 // Overriden from CurtainMode. |
21 bool Activate() override; | 20 bool Activate() override; |
22 | 21 |
23 private: | 22 private: |
24 DISALLOW_COPY_AND_ASSIGN(CurtainModeWin); | 23 DISALLOW_COPY_AND_ASSIGN(CurtainModeWin); |
25 }; | 24 }; |
26 | 25 |
27 CurtainModeWin::CurtainModeWin() { | 26 CurtainModeWin::CurtainModeWin() { |
28 } | 27 } |
29 | 28 |
30 bool CurtainModeWin::Activate() { | 29 bool CurtainModeWin::Activate() { |
31 if (base::win::GetVersion() < base::win::VERSION_VISTA) { | |
32 LOG(ERROR) << "Curtain mode is not supported on Windows XP/2003"; | |
33 return false; | |
34 } | |
35 | |
36 DWORD session_id; | 30 DWORD session_id; |
37 if (!ProcessIdToSessionId(GetCurrentProcessId(), &session_id)) { | 31 if (!ProcessIdToSessionId(GetCurrentProcessId(), &session_id)) { |
38 PLOG(ERROR) << "Failed to map the current PID to session ID"; | 32 PLOG(ERROR) << "Failed to map the current PID to session ID"; |
39 return false; | 33 return false; |
40 } | 34 } |
41 | 35 |
42 // The current session is curtained if it is not attached to the local | 36 // The current session is curtained if it is not attached to the local |
43 // console. | 37 // console. |
44 return WTSGetActiveConsoleSessionId() != session_id; | 38 return WTSGetActiveConsoleSessionId() != session_id; |
45 } | 39 } |
46 | 40 |
47 // static | 41 // static |
48 std::unique_ptr<CurtainMode> CurtainMode::Create( | 42 std::unique_ptr<CurtainMode> CurtainMode::Create( |
49 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 43 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
50 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 44 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
51 base::WeakPtr<ClientSessionControl> client_session_control) { | 45 base::WeakPtr<ClientSessionControl> client_session_control) { |
52 // |client_session_control| is not used because the client session is | 46 // |client_session_control| is not used because the client session is |
53 // disconnected as soon as the session is re-attached to the local console. | 47 // disconnected as soon as the session is re-attached to the local console. |
54 // See RdpDesktopSession for more details. | 48 // See RdpDesktopSession for more details. |
55 return base::WrapUnique(new CurtainModeWin()); | 49 return base::WrapUnique(new CurtainModeWin()); |
56 } | 50 } |
57 | 51 |
58 } // namespace remoting | 52 } // namespace remoting |
OLD | NEW |