summaryrefslogtreecommitdiffstats
path: root/remoting/host/curtain_mac.cc
diff options
context:
space:
mode:
Diffstat (limited to 'remoting/host/curtain_mac.cc')
-rw-r--r--remoting/host/curtain_mac.cc25
1 files changed, 24 insertions, 1 deletions
diff --git a/remoting/host/curtain_mac.cc b/remoting/host/curtain_mac.cc
index b6c741a..aef87c1 100644
--- a/remoting/host/curtain_mac.cc
+++ b/remoting/host/curtain_mac.cc
@@ -8,6 +8,12 @@
#include "base/compiler_specific.h"
#include "base/logging.h"
+namespace {
+static const char* kCGSessionPath =
+ "/System/Library/CoreServices/Menu Extras/User.menu/Contents/Resources/"
+ "CGSession";
+}
+
namespace remoting {
namespace {
@@ -22,12 +28,29 @@ class CurtainMac : public Curtain {
};
void CurtainMac::EnableCurtainMode(bool enable) {
- NOTIMPLEMENTED();
+ // Whether curtain mode is being enabled or disabled, switch out the session.
+ // 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);
+ }
}
} // namespace
Curtain* Curtain::Create() {
+ // There's no need to check for curtain mode being enabled here because on
+ // the mac it's easy for a local user to recover if anything crashes while
+ // a session is active--they just have to enter a password to switch their
+ // session back in.
return new CurtainMac();
}