WebStorageEventDispatcherImpl.cpp [plain text]
#include "config.h"
#include "WebStorageEventDispatcherImpl.h"
#include "KURL.h"
#include "SecurityOrigin.h"
#include "StorageAreaProxy.h"
#include "platform/WebURL.h"
#include <wtf/PassOwnPtr.h>
namespace WebKit {
extern const char* pageGroupName;
void WebStorageEventDispatcher::dispatchLocalStorageEvent(
const WebString& key, const WebString& oldValue,
const WebString& newValue, const WebURL& origin,
const WebURL& pageURL, WebStorageArea* sourceAreaInstance,
bool originatedInProcess)
{
RefPtr<WebCore::SecurityOrigin> securityOrigin = WebCore::SecurityOrigin::create(origin);
WebCore::StorageAreaProxy::dispatchLocalStorageEvent(
pageGroupName, key, oldValue, newValue, securityOrigin.get(), pageURL,
sourceAreaInstance, originatedInProcess);
}
void WebStorageEventDispatcher::dispatchSessionStorageEvent(
const WebString& key, const WebString& oldValue,
const WebString& newValue, const WebURL& origin,
const WebURL& pageURL, const WebStorageNamespace& sessionNamespace,
WebStorageArea* sourceAreaInstance, bool originatedInProcess)
{
RefPtr<WebCore::SecurityOrigin> securityOrigin = WebCore::SecurityOrigin::create(origin);
WebCore::StorageAreaProxy::dispatchSessionStorageEvent(
pageGroupName, key, oldValue, newValue, securityOrigin.get(), pageURL,
sessionNamespace, sourceAreaInstance, originatedInProcess);
}
WebStorageEventDispatcher* WebStorageEventDispatcher::create()
{
return new WebStorageEventDispatcherImpl();
}
WebStorageEventDispatcherImpl::WebStorageEventDispatcherImpl()
: m_eventDispatcher(adoptPtr(new WebCore::StorageEventDispatcherImpl(pageGroupName)))
{
ASSERT(m_eventDispatcher);
}
void WebStorageEventDispatcherImpl::dispatchStorageEvent(const WebString& key, const WebString& oldValue,
const WebString& newValue, const WebString& origin,
const WebURL& pageURL, bool isLocalStorage)
{
WebCore::StorageType storageType = isLocalStorage ? WebCore::LocalStorage : WebCore::SessionStorage;
RefPtr<WebCore::SecurityOrigin> securityOrigin = WebCore::SecurityOrigin::createFromString(origin);
m_eventDispatcher->dispatchStorageEvent(key, oldValue, newValue, securityOrigin.get(), pageURL, storageType);
}
}