Chromium Code Reviews| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 base::ScopedCFTypeRef<CFDictionaryRef> session( | 125 base::ScopedCFTypeRef<CFDictionaryRef> session( |
| 126 CGSessionCopyCurrentDictionary()); | 126 CGSessionCopyCurrentDictionary()); |
| 127 | 127 |
| 128 // CGSessionCopyCurrentDictionary has been observed to return nullptr in some | 128 // CGSessionCopyCurrentDictionary has been observed to return nullptr in some |
| 129 // cases. Once the system is in this state, curtain mode will fail as the | 129 // cases. Once the system is in this state, curtain mode will fail as the |
| 130 // CGSession command thinks the session is not attached to the console. The | 130 // CGSession command thinks the session is not attached to the console. The |
| 131 // only known remedy is logout or reboot. Since we're not sure what causes | 131 // only known remedy is logout or reboot. Since we're not sure what causes |
| 132 // this, or how common it is, a crash report is useful in this case (note | 132 // this, or how common it is, a crash report is useful in this case (note |
| 133 // that the connection would have to be refused in any case, so this is no | 133 // that the connection would have to be refused in any case, so this is no |
| 134 // loss of functionality). | 134 // loss of functionality). |
| 135 CHECK(session != nullptr) | 135 // Error activating curtain-mode: CGSessionCopyCurrentDictionary() returned |
|
Sergey Ulanov
2016/12/11 23:11:45
This comment would be confusing, especially given
dcheng
2016/12/11 23:15:03
We've landed a change which should make this CL un
| |
| 136 << "Error activating curtain-mode: " | 136 // NULL. Logging out and back in should resolve this error. |
| 137 << "CGSessionCopyCurrentDictionary() returned NULL. " | 137 CHECK(session != nullptr); |
| 138 << "Logging out and back in should resolve this error."; | |
| 139 | 138 |
| 140 const void* on_console = CFDictionaryGetValue(session, | 139 const void* on_console = CFDictionaryGetValue(session, |
| 141 kCGSessionOnConsoleKey); | 140 kCGSessionOnConsoleKey); |
| 142 const void* logged_in = CFDictionaryGetValue(session, kCGSessionLoginDoneKey); | 141 const void* logged_in = CFDictionaryGetValue(session, kCGSessionLoginDoneKey); |
| 143 if (logged_in == kCFBooleanTrue && on_console == kCFBooleanTrue) { | 142 if (logged_in == kCFBooleanTrue && on_console == kCFBooleanTrue) { |
| 144 pid_t child = fork(); | 143 pid_t child = fork(); |
| 145 if (child == 0) { | 144 if (child == 0) { |
| 146 execl(kCGSessionPath, kCGSessionPath, "-suspend", nullptr); | 145 execl(kCGSessionPath, kCGSessionPath, "-suspend", nullptr); |
| 147 _exit(1); | 146 _exit(1); |
| 148 } else if (child > 0) { | 147 } else if (child > 0) { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 // static | 247 // static |
| 249 std::unique_ptr<CurtainMode> CurtainMode::Create( | 248 std::unique_ptr<CurtainMode> CurtainMode::Create( |
| 250 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 249 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
| 251 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 250 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
| 252 base::WeakPtr<ClientSessionControl> client_session_control) { | 251 base::WeakPtr<ClientSessionControl> client_session_control) { |
| 253 return base::WrapUnique(new CurtainModeMac(caller_task_runner, ui_task_runner, | 252 return base::WrapUnique(new CurtainModeMac(caller_task_runner, ui_task_runner, |
| 254 client_session_control)); | 253 client_session_control)); |
| 255 } | 254 } |
| 256 | 255 |
| 257 } // namespace remoting | 256 } // namespace remoting |
| OLD | NEW |