#include <CommonsJavaScript/JSDOMExceptionFactory.h>
#include <StorageEvent/StorageEventMgr.h>
#include <StorageEvent/IStorageEvent.h>
-#include <js-overlay/js_iframe_support.h>
-#include <js-overlay/js_overlay_addEventListener.h>
+#include <dispatch-event/dispatch_event_support.h>
+
+// import temporarily from JSContextRefPrivate.h
+extern "C" JSGlobalContextRef JSContextGetGlobalContext(JSContextRef ctx);
using namespace std;
using namespace WrtDeviceApis;
std::string key = converter.toString(arguments[0]);
- auto event = modifyItemAndCreateEvent(ModificationType::RemoveItem,
- thisObject,
- key);
-
- auto iframe = IFrameSupport::
- getIFrameObjectForWidget(getWidgetObject(thisObject));
+ DPL::Optional<std::string> oldValue = getIStorage(thisObject)->getValue(key);
+ getIStorage(thisObject)->removeItem(key);
+ DPL::Optional<std::string> newValue = getIStorage(thisObject)->getValue(key);
- Assert(iframe && "Iframe is NULL");
+ JSContextRef g_context = JSContextGetGlobalContext(context);
+ std::string oldValueStr = "";
+ std::string newValueStr = "";
- AddEventListenerSupport::
- CallStorageListenersFromDifferentIFrames(iframe, event);
+ if (!!oldValue) { oldValueStr = *oldValue; }
+ if (!!newValue) { newValueStr = *newValue; }
+
+ DispatchEventSupport::dispatchStorageEvent(g_context, key, oldValueStr, newValueStr, "");
LogDebug("end");
return JSValueMakeNull(context);
std::string key = converter.toString(arguments[0]);
std::string value = converter.tryString(arguments[1]);
- auto event = modifyItemAndCreateEvent(ModificationType::SetItem,
- thisObject,
- key,
- value);
+ DPL::Optional<std::string> oldValue = getIStorage(thisObject)->getValue(key);
+ getIStorage(thisObject)->setItem(key, value, false);
+ DPL::Optional<std::string> newValue = getIStorage(thisObject)->getValue(key);
- auto iframe = IFrameSupport::
- getIFrameObjectForWidget(getWidgetObject(thisObject));
- Assert(iframe && "Iframe is NULL");
+ JSContextRef g_context = JSContextGetGlobalContext(context);
+ std::string oldValueStr = "";
+ std::string newValueStr = "";
- AddEventListenerSupport::
- CallStorageListenersFromDifferentIFrames(iframe, event);
+ if (!!oldValue) { oldValueStr = *oldValue; }
+ if (!!newValue) { newValueStr = *newValue; }
+
+ DispatchEventSupport::dispatchStorageEvent(g_context, key, oldValueStr, newValueStr, "");
LogDebug("end");
Try {
getIStorage(thisObject)->clear(false);
- auto iframe = IFrameSupport::
- getIFrameObjectForWidget(getWidgetObject(thisObject));
-
- Assert(iframe && "Iframe is NULL");
-
- //create event object
- IStorageEventPtr storageEvent = getStorageEvent();
+ JSContextRef g_context = JSContextGetGlobalContext(context);
- AddEventListenerSupport::
- CallStorageListenersFromDifferentIFrames(iframe, storageEvent);
+ DispatchEventSupport::dispatchStorageEvent(g_context, "", "", "", "");
LogDebug("end");
std::string key = converter.toString(propertyName);
std::string value = converter.toString(jvalue);
- auto event = modifyItemAndCreateEvent(ModificationType::SetItem,
- object,
- key,
- value);
+ DPL::Optional<std::string> oldValue = getIStorage(object)->getValue(key);
+ getIStorage(object)->setItem(key, value, false);
+ DPL::Optional<std::string> newValue = getIStorage(object)->getValue(key);
- auto iframe = IFrameSupport::
- getIFrameObjectForWidget(getWidgetObject(object));
- Assert(iframe && "Iframe is NULL");
+ JSContextRef g_context = JSContextGetGlobalContext(context);
+ std::string oldValueStr = "";
+ std::string newValueStr = "";
- AddEventListenerSupport::
- CallStorageListenersFromDifferentIFrames(iframe, event);
+ if (!!oldValue) { oldValueStr = *oldValue; }
+ if (!!newValue) { newValueStr = *newValue; }
+
+ DispatchEventSupport::dispatchStorageEvent(g_context, key, oldValueStr, newValueStr, "");
LogDebug("end");