2012-05-21 11:12:37 +00: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 06:33:10 +00:00
|
|
|
|
|
|
|
#ifndef _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_
|
|
|
|
#define _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_
|
|
|
|
|
|
|
|
#include "base/basictypes.h"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <stdio.h>
|
2009-08-28 23:16:19 +00:00
|
|
|
|
|
|
|
#include "nsAutoJSValHolder.h"
|
2009-07-11 06:33:10 +00:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsDebug.h"
|
2009-08-28 23:16:19 +00:00
|
|
|
#include "nsStringGlue.h"
|
2009-07-23 22:27:17 +00:00
|
|
|
|
2009-07-11 06:33:10 +00:00
|
|
|
struct JSContext;
|
2012-12-31 20:40:21 +00:00
|
|
|
class JSObject;
|
2009-07-11 06:33:10 +00:00
|
|
|
struct JSPrincipals;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace ipc {
|
|
|
|
|
|
|
|
class XPCShellEnvironment
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static XPCShellEnvironment* CreateEnvironment();
|
2009-08-28 23:16:19 +00:00
|
|
|
~XPCShellEnvironment();
|
2009-07-11 06:33:10 +00:00
|
|
|
|
2009-07-29 21:12:15 +00:00
|
|
|
bool EvaluateString(const nsString& aString,
|
2012-07-30 14:20:58 +00:00
|
|
|
nsString* aResult = nullptr);
|
2009-07-11 06:33:10 +00:00
|
|
|
|
|
|
|
JSPrincipals* GetPrincipal() {
|
2013-07-17 01:16:31 +00:00
|
|
|
return mJSPrincipals;
|
2009-07-11 06:33:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
JSObject* GetGlobalObject() {
|
|
|
|
return mGlobalHolder.ToJSObject();
|
|
|
|
}
|
|
|
|
|
2013-07-17 01:16:31 +00:00
|
|
|
JSContext* GetContext() {
|
|
|
|
return mCx;
|
|
|
|
}
|
|
|
|
|
2009-07-11 06:33:10 +00:00
|
|
|
void SetIsQuitting() {
|
|
|
|
mQuitting = JS_TRUE;
|
|
|
|
}
|
|
|
|
JSBool IsQuitting() {
|
|
|
|
return mQuitting;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
XPCShellEnvironment();
|
|
|
|
bool Init();
|
|
|
|
|
|
|
|
private:
|
2013-07-17 01:16:31 +00:00
|
|
|
JSContext* mCx;
|
2009-07-11 06:33:10 +00:00
|
|
|
nsAutoJSValHolder mGlobalHolder;
|
2013-07-17 01:16:31 +00:00
|
|
|
JSPrincipals* mJSPrincipals;
|
2009-07-11 06:33:10 +00:00
|
|
|
|
|
|
|
JSBool mQuitting;
|
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace ipc */
|
|
|
|
} /* namespace mozilla */
|
|
|
|
|
2009-11-06 20:43:39 +00:00
|
|
|
#endif /* _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_ */
|