tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

XPCShellEnvironment.h (1368B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 #ifndef _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_
      6 #define _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_
      7 
      8 #include "base/basictypes.h"
      9 
     10 #include <stdio.h>
     11 
     12 #include "nsCOMPtr.h"
     13 #include "nsDebug.h"
     14 #include "nsString.h"
     15 #include "nsJSPrincipals.h"
     16 #include "nsContentUtils.h"
     17 #include "js/RootingAPI.h"
     18 #include "js/TypeDecls.h"
     19 
     20 struct JSPrincipals;
     21 
     22 namespace mozilla {
     23 namespace ipc {
     24 
     25 class XPCShellEnvironment {
     26 public:
     27  static XPCShellEnvironment* CreateEnvironment();
     28  ~XPCShellEnvironment();
     29 
     30  void ProcessFile(JSContext* cx, const char* filename, FILE* file,
     31                   bool forceTTY);
     32  bool EvaluateString(const nsAString& aString, nsString* aResult = nullptr);
     33 
     34  JSPrincipals* GetPrincipal() {
     35    return nsJSPrincipals::get(nsContentUtils::GetSystemPrincipal());
     36  }
     37 
     38  JSObject* GetGlobalObject() { return mGlobalHolder; }
     39 
     40  void SetIsQuitting() { mQuitting = true; }
     41  bool IsQuitting() { return mQuitting; }
     42 
     43 protected:
     44  XPCShellEnvironment();
     45  bool Init();
     46 
     47 private:
     48  JS::PersistentRooted<JSObject*> mGlobalHolder;
     49 
     50  bool mQuitting;
     51 };
     52 
     53 } /* namespace ipc */
     54 } /* namespace mozilla */
     55 
     56 #endif /* _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_ */