michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef __SECURITY_SANDBOX_SANDBOXTARGET_H__ michael@0: #define __SECURITY_SANDBOX_SANDBOXTARGET_H__ michael@0: michael@0: #ifdef TARGET_SANDBOX_EXPORTS michael@0: #define TARGET_SANDBOX_EXPORT __declspec(dllexport) michael@0: #else michael@0: #define TARGET_SANDBOX_EXPORT __declspec(dllimport) michael@0: #endif michael@0: namespace mozilla { michael@0: michael@0: michael@0: class TARGET_SANDBOX_EXPORT SandboxTarget michael@0: { michael@0: public: michael@0: typedef void (*StartSandboxPtr)(); michael@0: michael@0: /** michael@0: * Obtains a pointer to the singleton instance michael@0: */ michael@0: static SandboxTarget* Instance() michael@0: { michael@0: static SandboxTarget sb; michael@0: return &sb; michael@0: } michael@0: michael@0: /** michael@0: * Called by the application that will lower the sandbox token michael@0: * michael@0: * @param aStartSandboxCallback A callback function which will lower privs michael@0: */ michael@0: void SetStartSandboxCallback(StartSandboxPtr aStartSandboxCallback) michael@0: { michael@0: mStartSandboxCallback = aStartSandboxCallback; michael@0: } michael@0: michael@0: /** michael@0: * Called by the library that wants to start the sandbox, which in turn michael@0: * calls into the previously set StartSandboxCallback. michael@0: */ michael@0: void StartSandbox() michael@0: { michael@0: if (mStartSandboxCallback) { michael@0: mStartSandboxCallback(); michael@0: } michael@0: } michael@0: michael@0: protected: michael@0: SandboxTarget() : michael@0: mStartSandboxCallback(nullptr) michael@0: { michael@0: } michael@0: michael@0: StartSandboxPtr mStartSandboxCallback; michael@0: }; michael@0: michael@0: michael@0: } // mozilla michael@0: michael@0: #endif