From e84ae6e2aa99ddacf3b77408bc5fb487aee93029 Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Tue, 11 Oct 2016 13:00:26 -0700 Subject: [PATCH] Add a method to determine whether we're in the Apple sandbox --- .../chrome/browser/process_singleton_posix.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/chromium_src/chrome/browser/process_singleton_posix.cc b/chromium_src/chrome/browser/process_singleton_posix.cc index bb999fb500cf..6bcc1f2734b7 100644 --- a/chromium_src/chrome/browser/process_singleton_posix.cc +++ b/chromium_src/chrome/browser/process_singleton_posix.cc @@ -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) {