ScriptController.h [plain text]
#ifndef ScriptController_h
#define ScriptController_h
#include "JSDOMWindowShell.h"
#include "ScriptInstance.h"
#include <runtime/Protect.h>
#include <wtf/RefPtr.h>
#if PLATFORM(MAC)
#include <wtf/RetainPtr.h>
#ifdef __OBJC__
@class WebScriptObject;
#else
class WebScriptObject;
#endif
#endif
struct NPObject;
namespace JSC {
class JSGlobalObject;
namespace Bindings {
class RootObject;
}
}
namespace WebCore {
class Event;
class EventListener;
class HTMLPlugInElement;
class Frame;
class Node;
class ScriptSourceCode;
class ScriptValue;
class String;
class Widget;
class XSSAuditor;
typedef HashMap<void*, RefPtr<JSC::Bindings::RootObject> > RootObjectMap;
class ScriptController {
public:
ScriptController(Frame*);
~ScriptController();
bool haveWindowShell() const { return m_windowShell; }
JSDOMWindowShell* windowShell()
{
initScriptIfNeeded();
return m_windowShell;
}
JSDOMWindow* globalObject()
{
initScriptIfNeeded();
return m_windowShell->window();
}
ScriptValue evaluate(const ScriptSourceCode&);
void setEventHandlerLineNumber(int lineno) { m_handlerLineNumber = lineno; }
int eventHandlerLineNumber() { return m_handlerLineNumber; }
void setProcessingTimerCallback(bool b) { m_processingTimerCallback = b; }
bool processingUserGesture() const;
bool anyPageIsProcessingUserGesture() const;
bool isEnabled();
void attachDebugger(JSC::Debugger*);
void setPaused(bool b) { m_paused = b; }
bool isPaused() const { return m_paused; }
void setAllowPopupsFromPlugin(bool allowPopupsFromPlugin) { m_allowPopupsFromPlugin = allowPopupsFromPlugin; }
bool allowPopupsFromPlugin() const { return m_allowPopupsFromPlugin; }
const String* sourceURL() const { return m_sourceURL; }
void clearWindowShell();
void updateDocument();
void updateSecurityOrigin();
void clearScriptObjects();
void cleanupScriptObjectsForPlugin(void*);
void updatePlatformScriptObjects();
PassScriptInstance createScriptInstanceForWidget(Widget*);
JSC::Bindings::RootObject* bindingRootObject();
PassRefPtr<JSC::Bindings::RootObject> createRootObject(void* nativeHandle);
#if PLATFORM(MAC)
#if ENABLE(MAC_JAVA_BRIDGE)
static void initJavaJSBindings();
#endif
WebScriptObject* windowScriptObject();
#endif
JSC::JSObject* jsObjectForPluginElement(HTMLPlugInElement*);
#if ENABLE(NETSCAPE_PLUGIN_API)
NPObject* createScriptObjectForPluginElement(HTMLPlugInElement*);
NPObject* windowScriptNPObject();
#endif
XSSAuditor* xssAuditor() { return m_XSSAuditor.get(); }
private:
void initScriptIfNeeded()
{
if (!m_windowShell)
initScript();
}
void initScript();
void disconnectPlatformScriptObjects();
bool processingUserGestureEvent() const;
bool isJavaScriptAnchorNavigation() const;
JSC::ProtectedPtr<JSDOMWindowShell> m_windowShell;
Frame* m_frame;
int m_handlerLineNumber;
const String* m_sourceURL;
bool m_processingTimerCallback;
bool m_paused;
bool m_allowPopupsFromPlugin;
RefPtr<JSC::Bindings::RootObject> m_bindingRootObject;
RootObjectMap m_rootObjects;
#if ENABLE(NETSCAPE_PLUGIN_API)
NPObject* m_windowScriptNPObject;
#endif
#if PLATFORM(MAC)
RetainPtr<WebScriptObject> m_windowScriptObject;
#endif
OwnPtr<XSSAuditor> m_XSSAuditor;
};
}
#endif // ScriptController_h