PageConsoleAgent.cpp [plain text]
#include "config.h"
#if ENABLE(INSPECTOR)
#include "PageConsoleAgent.h"
#include "DOMWindow.h"
#include "InjectedScriptHost.h"
#include "InjectedScriptManager.h"
#include "InspectorAgent.h"
#include "InspectorDOMAgent.h"
#include "Node.h"
#include "ScriptObject.h"
namespace WebCore {
PageConsoleAgent::PageConsoleAgent(InstrumentingAgents* instrumentingAgents, InspectorAgent* inspectorAgent, InspectorCompositeState* state, InjectedScriptManager* injectedScriptManager, InspectorDOMAgent* domAgent)
: InspectorConsoleAgent(instrumentingAgents, state, injectedScriptManager)
, m_inspectorAgent(inspectorAgent)
, m_inspectorDOMAgent(domAgent)
{
}
PageConsoleAgent::~PageConsoleAgent()
{
m_inspectorAgent = 0;
m_inspectorDOMAgent = 0;
}
void PageConsoleAgent::clearMessages(ErrorString* errorString)
{
m_inspectorDOMAgent->releaseDanglingNodes();
InspectorConsoleAgent::clearMessages(errorString);
}
class InspectableNode : public InjectedScriptHost::InspectableObject {
public:
explicit InspectableNode(Node* node) : m_node(node) { }
virtual ScriptValue get(ScriptState* state)
{
return InjectedScriptHost::nodeAsScriptValue(state, m_node);
}
private:
Node* m_node;
};
void PageConsoleAgent::addInspectedNode(ErrorString* errorString, int nodeId)
{
Node* node = m_inspectorDOMAgent->nodeForId(nodeId);
if (!node || node->isInShadowTree()) {
*errorString = "nodeId is not valid";
return;
}
m_injectedScriptManager->injectedScriptHost()->addInspectedObject(adoptPtr(new InspectableNode(node)));
}
bool PageConsoleAgent::developerExtrasEnabled()
{
return m_inspectorAgent->developerExtrasEnabled();
}
}
#endif // ENABLE(INSPECTOR)