Add a method to determine whether we're in the Apple sandbox
authorPaul Betts <paul@paulbetts.org>
Tue, 11 Oct 2016 20:00:26 +0000 (13:00 -0700)
committerPaul Betts <paul@paulbetts.org>
Tue, 11 Oct 2016 20:06:29 +0000 (13:06 -0700)
chromium_src/chrome/browser/process_singleton_posix.cc

index bb999fb..6bcc1f2 100644 (file)
@@ -348,6 +348,21 @@ bool CheckCookie(const base::FilePath& path, const base::FilePath& cookie) {
   return (cookie == ReadLink(path));
 }
 
+bool IsAppSandboxed() {
+#if defined(OS_MACOSX)
+  // NB: There is no sane API for this, we have to just guess by
+  // reading tea leaves
+  base::FilePath home_dir;
+  if (!PathService.Get(base::DIR_HOME, &home_dir)) {
+    return false;
+  }
+
+  return home_dir.value().find("Library/Containers") != std::string::npos;
+#else
+  return false;
+#endif  // defined(OS_MACOSX)
+}
+
 bool ConnectSocket(ScopedSocket* socket,
                    const base::FilePath& socket_path,
                    const base::FilePath& cookie_path) {