InspectorDOMStorageResource.cpp [plain text]
#include "config.h"
#if ENABLE(DOM_STORAGE)
#include "InspectorDOMStorageResource.h"
#include "Document.h"
#include "Frame.h"
#include "ScriptFunctionCall.h"
#include "ScriptObjectQuarantine.h"
#include "ScriptValue.h"
#include "Storage.h"
using namespace JSC;
namespace WebCore {
InspectorDOMStorageResource::InspectorDOMStorageResource(Storage* domStorage, bool isLocalStorage, Frame* frame)
: m_domStorage(domStorage)
, m_isLocalStorage(isLocalStorage)
, m_frame(frame)
{
}
bool InspectorDOMStorageResource::isSameHostAndType(Frame* frame, bool isLocalStorage) const
{
return equalIgnoringCase(m_frame->document()->securityOrigin()->host(), frame->document()->securityOrigin()->host()) && m_isLocalStorage == isLocalStorage;
}
void InspectorDOMStorageResource::bind(ScriptState* scriptState, const ScriptObject& webInspector)
{
if (!m_scriptObject.hasNoValue())
return;
ASSERT(scriptState);
ASSERT(!webInspector.hasNoValue());
if (!scriptState || webInspector.hasNoValue())
return;
ScriptFunctionCall resourceConstructor(scriptState, webInspector, "DOMStorage");
ScriptObject domStorage;
if (!getQuarantinedScriptObject(m_frame.get(), m_domStorage.get(), domStorage))
return;
resourceConstructor.appendArgument(domStorage);
resourceConstructor.appendArgument(m_frame->document()->securityOrigin()->host());
resourceConstructor.appendArgument(m_isLocalStorage);
bool hadException = false;
m_scriptObject = resourceConstructor.construct(hadException);
if (hadException)
return;
ScriptFunctionCall addDOMStorage(scriptState, webInspector, "addDOMStorage");
addDOMStorage.appendArgument(m_scriptObject);
addDOMStorage.call(hadException);
}
void InspectorDOMStorageResource::unbind()
{
m_scriptObject = ScriptObject();
}
}
#endif