| 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. " |
| 150 << "Logging out and back in should resolve this error."; |
| 148 | 151 |
| 149 const void* on_console = CFDictionaryGetValue(session, | 152 const void* on_console = CFDictionaryGetValue(session, |
| 150 kCGSessionOnConsoleKey); | 153 kCGSessionOnConsoleKey); |
| 151 const void* logged_in = CFDictionaryGetValue(session, kCGSessionLoginDoneKey); | 154 const void* logged_in = CFDictionaryGetValue(session, kCGSessionLoginDoneKey); |
| 152 if (logged_in == kCFBooleanTrue && on_console == kCFBooleanTrue) { | 155 if (logged_in == kCFBooleanTrue && on_console == kCFBooleanTrue) { |
| 153 pid_t child = fork(); | 156 pid_t child = fork(); |
| 154 if (child == 0) { | 157 if (child == 0) { |
| 155 execl(kCGSessionPath, kCGSessionPath, "-suspend", nullptr); | 158 execl(kCGSessionPath, kCGSessionPath, "-suspend", nullptr); |
| 156 _exit(1); | 159 _exit(1); |
| 157 } else if (child > 0) { | 160 } else if (child > 0) { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 // static | 261 // static |
| 259 scoped_ptr<CurtainMode> CurtainMode::Create( | 262 scoped_ptr<CurtainMode> CurtainMode::Create( |
| 260 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 263 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
| 261 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 264 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
| 262 base::WeakPtr<ClientSessionControl> client_session_control) { | 265 base::WeakPtr<ClientSessionControl> client_session_control) { |
| 263 return make_scoped_ptr(new CurtainModeMac( | 266 return make_scoped_ptr(new CurtainModeMac( |
| 264 caller_task_runner, ui_task_runner, client_session_control)); | 267 caller_task_runner, ui_task_runner, client_session_control)); |
| 265 } | 268 } |
| 266 | 269 |
| 267 } // namespace remoting | 270 } // namespace remoting |
| OLD | NEW |