2012-05-21 04:12:37 -07: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-10 23:33:10 -07:00
|
|
|
|
|
|
|
#ifndef _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_
|
|
|
|
#define _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_
|
|
|
|
|
|
|
|
#include "base/basictypes.h"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <stdio.h>
|
2009-08-28 16:16:19 -07:00
|
|
|
|
|
|
|
#include "nsAutoJSValHolder.h"
|
2009-07-10 23:33:10 -07:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsDebug.h"
|
2009-08-28 16:16:19 -07:00
|
|
|
#include "nsStringGlue.h"
|
2013-07-16 20:38:46 -07:00
|
|
|
#include "nsJSPrincipals.h"
|
|
|
|
#include "nsContentUtils.h"
|
2013-08-27 19:59:14 -07:00
|
|
|
#include "js/TypeDecls.h"
|
2009-07-23 15:27:17 -07:00
|
|
|
|
2009-07-10 23:33:10 -07:00
|
|
|
struct JSPrincipals;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace ipc {
|
|
|
|
|
|
|
|
class XPCShellEnvironment
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static XPCShellEnvironment* CreateEnvironment();
|
2009-08-28 16:16:19 -07:00
|
|
|
~XPCShellEnvironment();
|
2009-07-10 23:33:10 -07:00
|
|
|
|
2013-07-16 20:38:45 -07:00
|
|
|
void ProcessFile(JSContext *cx, JS::Handle<JSObject*> obj,
|
2013-08-08 15:53:04 -07:00
|
|
|
const char *filename, FILE *file, bool forceTTY);
|
2009-07-29 14:12:15 -07:00
|
|
|
bool EvaluateString(const nsString& aString,
|
2012-07-30 07:20:58 -07:00
|
|
|
nsString* aResult = nullptr);
|
2009-07-10 23:33:10 -07:00
|
|
|
|
|
|
|
JSPrincipals* GetPrincipal() {
|
2013-07-16 20:38:46 -07:00
|
|
|
return nsJSPrincipals::get(nsContentUtils::GetSystemPrincipal());
|
2009-07-10 23:33:10 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
JSObject* GetGlobalObject() {
|
|
|
|
return mGlobalHolder.ToJSObject();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetIsQuitting() {
|
2013-08-06 23:59:54 -07:00
|
|
|
mQuitting = true;
|
2009-07-10 23:33:10 -07:00
|
|
|
}
|
2013-08-08 15:53:04 -07:00
|
|
|
bool IsQuitting() {
|
2009-07-10 23:33:10 -07:00
|
|
|
return mQuitting;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
XPCShellEnvironment();
|
|
|
|
bool Init();
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsAutoJSValHolder mGlobalHolder;
|
|
|
|
|
2013-08-08 15:53:04 -07:00
|
|
|
bool mQuitting;
|
2009-07-10 23:33:10 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace ipc */
|
|
|
|
} /* namespace mozilla */
|
|
|
|
|
2009-11-06 12:43:39 -08:00
|
|
|
#endif /* _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_ */
|