security/sandbox/win/src/sandboxtarget/sandboxTarget.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim: set ts=2 et sw=2 tw=80: */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #ifndef __SECURITY_SANDBOX_SANDBOXTARGET_H__
     8 #define __SECURITY_SANDBOX_SANDBOXTARGET_H__
    10 #ifdef TARGET_SANDBOX_EXPORTS
    11 #define TARGET_SANDBOX_EXPORT __declspec(dllexport)
    12 #else
    13 #define TARGET_SANDBOX_EXPORT __declspec(dllimport)
    14 #endif
    15 namespace mozilla {
    18 class TARGET_SANDBOX_EXPORT SandboxTarget
    19 {
    20 public:
    21   typedef void (*StartSandboxPtr)();
    23   /**
    24    * Obtains a pointer to the singleton instance
    25    */
    26   static SandboxTarget* Instance()
    27   {
    28     static SandboxTarget sb;
    29     return &sb;
    30   }
    32   /**
    33    * Called by the application that will lower the sandbox token
    34    *
    35    * @param aStartSandboxCallback A callback function which will lower privs
    36    */
    37   void SetStartSandboxCallback(StartSandboxPtr aStartSandboxCallback)
    38   {
    39     mStartSandboxCallback = aStartSandboxCallback;
    40   }
    42   /**
    43    * Called by the library that wants to start the sandbox, which in turn
    44    * calls into the previously set StartSandboxCallback.
    45    */
    46   void StartSandbox()
    47   {
    48     if (mStartSandboxCallback) {
    49       mStartSandboxCallback();
    50     }
    51   }
    53 protected:
    54   SandboxTarget() :
    55     mStartSandboxCallback(nullptr)
    56   {
    57   }
    59   StartSandboxPtr mStartSandboxCallback;
    60 };
    63 } // mozilla
    65 #endif

mercurial