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 _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_ michael@0: #define _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_ michael@0: michael@0: #include "base/basictypes.h" michael@0: michael@0: #include michael@0: #include michael@0: michael@0: #include "nsAutoJSValHolder.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsDebug.h" michael@0: #include "nsString.h" michael@0: #include "nsJSPrincipals.h" michael@0: #include "nsContentUtils.h" michael@0: #include "js/TypeDecls.h" michael@0: michael@0: struct JSPrincipals; michael@0: michael@0: namespace mozilla { michael@0: namespace ipc { michael@0: michael@0: class XPCShellEnvironment michael@0: { michael@0: public: michael@0: static XPCShellEnvironment* CreateEnvironment(); michael@0: ~XPCShellEnvironment(); michael@0: michael@0: void ProcessFile(JSContext *cx, JS::Handle obj, michael@0: const char *filename, FILE *file, bool forceTTY); michael@0: bool EvaluateString(const nsString& aString, michael@0: nsString* aResult = nullptr); michael@0: michael@0: JSPrincipals* GetPrincipal() { michael@0: return nsJSPrincipals::get(nsContentUtils::GetSystemPrincipal()); michael@0: } michael@0: michael@0: JSObject* GetGlobalObject() { michael@0: return mGlobalHolder.ToJSObject(); michael@0: } michael@0: michael@0: void SetIsQuitting() { michael@0: mQuitting = true; michael@0: } michael@0: bool IsQuitting() { michael@0: return mQuitting; michael@0: } michael@0: michael@0: protected: michael@0: XPCShellEnvironment(); michael@0: bool Init(); michael@0: michael@0: private: michael@0: nsAutoJSValHolder mGlobalHolder; michael@0: michael@0: bool mQuitting; michael@0: }; michael@0: michael@0: } /* namespace ipc */ michael@0: } /* namespace mozilla */ michael@0: michael@0: #endif /* _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_ */