2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-07-11 10:33:10 +04:00
|
|
|
|
|
|
|
#ifndef _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_
|
|
|
|
#define _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_
|
|
|
|
|
|
|
|
#include "base/basictypes.h"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <stdio.h>
|
2009-08-29 03:16:19 +04:00
|
|
|
|
2009-07-11 10:33:10 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsDebug.h"
|
2013-09-23 21:25:00 +04:00
|
|
|
#include "nsString.h"
|
2013-07-17 07:38:46 +04:00
|
|
|
#include "nsJSPrincipals.h"
|
|
|
|
#include "nsContentUtils.h"
|
2015-01-23 13:23:57 +03:00
|
|
|
#include "js/RootingAPI.h"
|
2013-08-28 06:59:14 +04:00
|
|
|
#include "js/TypeDecls.h"
|
2009-07-24 02:27:17 +04:00
|
|
|
|
2009-07-11 10:33:10 +04:00
|
|
|
struct JSPrincipals;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace ipc {
|
|
|
|
|
|
|
|
class XPCShellEnvironment {
|
|
|
|
public:
|
|
|
|
static XPCShellEnvironment* CreateEnvironment();
|
2009-08-29 03:16:19 +04:00
|
|
|
~XPCShellEnvironment();
|
2018-12-14 21:10:35 +03:00
|
|
|
|
2015-03-14 08:36:16 +03:00
|
|
|
void ProcessFile(JSContext* cx, const char* filename, FILE* file,
|
|
|
|
bool forceTTY);
|
2009-07-30 01:12:15 +04:00
|
|
|
bool EvaluateString(const nsString& aString, nsString* aResult = nullptr);
|
2018-12-14 21:10:35 +03:00
|
|
|
|
2009-07-11 10:33:10 +04:00
|
|
|
JSPrincipals* GetPrincipal() {
|
2013-07-17 07:38:46 +04:00
|
|
|
return nsJSPrincipals::get(nsContentUtils::GetSystemPrincipal());
|
2009-07-11 10:33:10 +04:00
|
|
|
}
|
2018-12-14 21:10:35 +03:00
|
|
|
|
2009-07-11 10:33:10 +04:00
|
|
|
JSObject* GetGlobalObject() { return mGlobalHolder; }
|
2018-12-14 21:10:35 +03:00
|
|
|
|
2009-07-11 10:33:10 +04:00
|
|
|
void SetIsQuitting() { mQuitting = true; }
|
2013-08-09 02:53:04 +04:00
|
|
|
bool IsQuitting() { return mQuitting; }
|
2018-12-14 21:10:35 +03:00
|
|
|
|
2009-07-11 10:33:10 +04:00
|
|
|
protected:
|
|
|
|
XPCShellEnvironment();
|
|
|
|
bool Init();
|
2018-12-14 21:10:35 +03:00
|
|
|
|
2009-07-11 10:33:10 +04:00
|
|
|
private:
|
2015-01-23 13:23:57 +03:00
|
|
|
JS::PersistentRooted<JSObject*> mGlobalHolder;
|
2018-12-14 21:10:35 +03:00
|
|
|
|
2013-08-09 02:53:04 +04:00
|
|
|
bool mQuitting;
|
2009-07-11 10:33:10 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace ipc */
|
|
|
|
} /* namespace mozilla */
|
|
|
|
|
2009-11-06 23:43:39 +03:00
|
|
|
#endif /* _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_ */
|