Chromium Code Reviews| Index: remoting/host/curtain_mac.cc |
| diff --git a/remoting/host/curtain_mac.cc b/remoting/host/curtain_mac.cc |
| index aef87c1150b047de29ba0767098bcaa739cb468a..cae5f4cd3896bf4d8e8393e47e7e820deb3555b3 100644 |
| --- a/remoting/host/curtain_mac.cc |
| +++ b/remoting/host/curtain_mac.cc |
| @@ -4,9 +4,12 @@ |
| #include "remoting/host/curtain.h" |
| +#include <ApplicationServices/ApplicationServices.h> |
| + |
| #include "base/basictypes.h" |
| #include "base/compiler_specific.h" |
| #include "base/logging.h" |
| +#include "base/mac/scoped_cftyperef.h" |
| namespace { |
| static const char* kCGSessionPath = |
| @@ -28,19 +31,27 @@ class CurtainMac : public Curtain { |
| }; |
| void CurtainMac::EnableCurtainMode(bool enable) { |
| - // Whether curtain mode is being enabled or disabled, switch out the session. |
| + // Whether curtain mode is being enabled or disabled, switch out the session |
| + // if the current user is on the console. |
|
Jamie
2011/10/31 22:17:47
For consistency, maybe say "if the user is switche
|
| // TODO(jamiewalch): If curtain mode is being enabled at the login screen, it |
| // should be deferred until the user logs in. |
| - pid_t child = fork(); |
| - if (child == 0) { |
| - execl(kCGSessionPath, kCGSessionPath, "-suspend", (char*)0); |
| - exit(1); |
| - } else if (child > 0) { |
| - int status = 0; |
| - waitpid(child, &status, 0); |
| - // To ensure that the system has plenty of time to notify the CGDisplay- |
| - // ReconfigurationCallback, sleep here. 1s is probably overkill. |
| - sleep(1); |
| + base::mac::ScopedCFTypeRef<CFDictionaryRef> session( |
| + CGSessionCopyCurrentDictionary()); |
| + if (CFDictionaryGetValue(session, |
| + kCGSessionOnConsoleKey) == kCFBooleanTrue) { |
| + LOG(ERROR) << "Enabling Curtain mode!"; |
|
Jamie
2011/10/31 22:17:47
Remove, or at least lower the log level (and get r
|
| + |
| + pid_t child = fork(); |
| + if (child == 0) { |
| + execl(kCGSessionPath, kCGSessionPath, "-suspend", (char*)0); |
| + exit(1); |
| + } else if (child > 0) { |
| + int status = 0; |
| + waitpid(child, &status, 0); |
| + // To ensure that the system has plenty of time to notify the CGDisplay- |
| + // ReconfigurationCallback, sleep here. 1s is probably overkill. |
| + sleep(1); |
| + } |
| } |
| } |