#ifndef InjectedScriptManager_h
#define InjectedScriptManager_h
#include "bindings/v8/ScriptState.h"
#include "wtf/Forward.h"
#include "wtf/HashMap.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
class DOMWindow;
class InjectedScript;
class InjectedScriptHost;
class ScriptObject;
class InjectedScriptManager {
WTF_MAKE_NONCOPYABLE(InjectedScriptManager); WTF_MAKE_FAST_ALLOCATED;
public:
static PassOwnPtr<InjectedScriptManager> createForPage();
static PassOwnPtr<InjectedScriptManager> createForWorker();
~InjectedScriptManager();
void disconnect();
InjectedScriptHost* injectedScriptHost();
InjectedScript injectedScriptFor(ScriptState*);
InjectedScript injectedScriptForId(int);
int injectedScriptIdFor(ScriptState*);
InjectedScript injectedScriptForObjectId(const String& objectId);
void discardInjectedScripts();
void discardInjectedScriptsFor(DOMWindow*);
void releaseObjectGroup(const String& objectGroup);
typedef bool (*InspectedStateAccessCheck)(ScriptState*);
InspectedStateAccessCheck inspectedStateAccessCheck() const { return m_inspectedStateAccessCheck; }
struct CallbackData;
static void setWeakCallback(const v8::WeakCallbackData<v8::Object, CallbackData>&);
private:
explicit InjectedScriptManager(InspectedStateAccessCheck);
String injectedScriptSource();
ScriptObject createInjectedScript(const String& source, ScriptState*, int id);
static bool canAccessInspectedWindow(ScriptState*);
static bool canAccessInspectedWorkerGlobalScope(ScriptState*);
int m_nextInjectedScriptId;
typedef HashMap<int, InjectedScript> IdToInjectedScriptMap;
IdToInjectedScriptMap m_idToInjectedScript;
RefPtr<InjectedScriptHost> m_injectedScriptHost;
InspectedStateAccessCheck m_inspectedStateAccessCheck;
typedef HashMap<ScriptState*, int> ScriptStateToId;
ScriptStateToId m_scriptStateToId;
};
}
#endif