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 <ApplicationServices/ApplicationServices.h> | 7 #include <ApplicationServices/ApplicationServices.h> |
8 #include <Carbon/Carbon.h> | 8 #include <Carbon/Carbon.h> |
9 #include <Security/Security.h> | 9 #include <Security/Security.h> |
10 #include <unistd.h> | 10 #include <unistd.h> |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 base::ScopedCFTypeRef<CFDictionaryRef> session( | 137 base::ScopedCFTypeRef<CFDictionaryRef> session( |
138 CGSessionCopyCurrentDictionary()); | 138 CGSessionCopyCurrentDictionary()); |
139 | 139 |
140 // CGSessionCopyCurrentDictionary has been observed to return nullptr in some | 140 // CGSessionCopyCurrentDictionary has been observed to return nullptr in some |
141 // cases. Once the system is in this state, curtain mode will fail as the | 141 // cases. Once the system is in this state, curtain mode will fail as the |
142 // CGSession command thinks the session is not attached to the console. The | 142 // CGSession command thinks the session is not attached to the console. The |
143 // only known remedy is logout or reboot. Since we're not sure what causes | 143 // only known remedy is logout or reboot. Since we're not sure what causes |
144 // this, or how common it is, a crash report is useful in this case (note | 144 // this, or how common it is, a crash report is useful in this case (note |
145 // that the connection would have to be refused in any case, so this is no | 145 // that the connection would have to be refused in any case, so this is no |
146 // loss of functionality). | 146 // loss of functionality). |
147 CHECK(session != nullptr); | 147 CHECK(session != nullptr) |
148 << "Error activating curtain-mode: " | |
149 << "CGSessionCopyCurrentDictionary() returned NULL."; | |
Jamie
2015/03/24 19:24:47
Can you add a message to the effect that logging o
| |
148 | 150 |
149 const void* on_console = CFDictionaryGetValue(session, | 151 const void* on_console = CFDictionaryGetValue(session, |
150 kCGSessionOnConsoleKey); | 152 kCGSessionOnConsoleKey); |
151 const void* logged_in = CFDictionaryGetValue(session, kCGSessionLoginDoneKey); | 153 const void* logged_in = CFDictionaryGetValue(session, kCGSessionLoginDoneKey); |
152 if (logged_in == kCFBooleanTrue && on_console == kCFBooleanTrue) { | 154 if (logged_in == kCFBooleanTrue && on_console == kCFBooleanTrue) { |
153 pid_t child = fork(); | 155 pid_t child = fork(); |
154 if (child == 0) { | 156 if (child == 0) { |
155 execl(kCGSessionPath, kCGSessionPath, "-suspend", nullptr); | 157 execl(kCGSessionPath, kCGSessionPath, "-suspend", nullptr); |
156 _exit(1); | 158 _exit(1); |
157 } else if (child > 0) { | 159 } else if (child > 0) { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
258 // static | 260 // static |
259 scoped_ptr<CurtainMode> CurtainMode::Create( | 261 scoped_ptr<CurtainMode> CurtainMode::Create( |
260 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 262 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
261 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 263 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
262 base::WeakPtr<ClientSessionControl> client_session_control) { | 264 base::WeakPtr<ClientSessionControl> client_session_control) { |
263 return make_scoped_ptr(new CurtainModeMac( | 265 return make_scoped_ptr(new CurtainModeMac( |
264 caller_task_runner, ui_task_runner, client_session_control)); | 266 caller_task_runner, ui_task_runner, client_session_control)); |
265 } | 267 } |
266 | 268 |
267 } // namespace remoting | 269 } // namespace remoting |
OLD | NEW |