virtual void Backward() = 0;
virtual void Reload() = 0;
virtual void Forward() = 0;
+ /**
+ * fire custom javascript event
+ */
+ virtual void FireJavascriptEvent(int event, void* data) = 0;
+
virtual ~IRunnableWidgetObject() {};
};
change.commit();
}
+void RunnableWidgetObject::FireJavascriptEvent(int event, void* data)
+{
+ State::StateChange change = m_guardstate->allowFireJavascriptEvent();
+ m_view->fireJavascriptEvent(event, data);
+
+ change.commit();
+}
+
void RunnableWidgetObject::setNewState(std::shared_ptr<State::RunnableWidgetObjectState> sptr)
{
LogInfo("RunnableWidgetObject changes state to: " << sptr->toString());
void Backward();
void Reload();
void Forward();
+ void FireJavascriptEvent(int event, void* data);
private:
"Reload cannot be called in current state ");
}
+StateChange RunnableWidgetObjectState::allowFireJavascriptEvent()
+{
+ ThrowMsg(IRunnableWidgetObject::MethodInvocationForbidden,
+ "FireJavascriptEvent cannot be called in current state ");
+}
+
InitialState::InitialState(RunnableWidgetObject & object) : RunnableWidgetObjectState(object)
{
}
return StateChange::NoChange;
}
+StateChange ShowedState::allowFireJavascriptEvent()
+{
+ return StateChange::NoChange;
+}
+
SuspendedState::SuspendedState(RunnableWidgetObject & object) : RunnableWidgetObjectState(object)
{
}
virtual StateChange allowBackward();
virtual StateChange allowForward();
virtual StateChange allowReload();
+ virtual StateChange allowFireJavascriptEvent();
virtual std::string toString() const = 0;
virtual RunnableWidgetObject & getObject() const;
StateChange allowForward();
StateChange allowReload();
StateChange allowReset();
+ StateChange allowFireJavascriptEvent();
};
/**
}
void dispatchJavaScriptEvent(JSGlobalContextRef context,
- WrtPlugins::W3C::CustomEventType eventType)
+ WrtPlugins::W3C::CustomEventType eventType,
+ void* data)
{
LogDebug("dispatching javascript event");
PluginLogicSingleton::Instance().dispatchJavaScriptEvent(context,
- eventType);
+ eventType,
+ data);
}
void loadFrame(JSGlobalContextRef context)
const char* encodedBundle,
const char* theme);
void dispatchJavaScriptEvent(JSGlobalContextRef context,
- WrtPlugins::W3C::CustomEventType eventType);
+ WrtPlugins::W3C::CustomEventType eventType,
+ void* data);
void loadFrame(JSGlobalContextRef context);
void unloadFrame(JSGlobalContextRef context);
} // PluginModule
virtual void forward() = 0;
virtual void reloadStartPage() = 0;
virtual Evas_Object* getCurrentWebview() = 0;
+ virtual void fireJavascriptEvent(int event, void* data) = 0;
virtual void setUserCallbacks(const WRT::UserDelegatesPtr& cbs) = 0;
};
void dispatchJavaScriptEvent(
Ewk_Context* ewkContext,
- WrtPlugins::W3C::CustomEventType eventType)
+ WrtPlugins::W3C::CustomEventType eventType,
+ void *data)
{
+ using namespace WrtPlugins::W3C;
std::stringstream str;
str << eventType;
- std::string msgString = str.str();
+ // if needed, arguments for event should be set here
+ // do something
+ std::string msgString = str.str();
const char* msg = msgString.c_str();
const char* name = BundleMessages::DISPATCH_JAVASCRIPT_EVENT;
const char* theme = NULL);
void dispatchJavaScriptEvent(
Ewk_Context* ewkContext,
- WrtPlugins::W3C::CustomEventType eventType);
+ WrtPlugins::W3C::CustomEventType eventType,
+ void* data);
} // namespace PluginModuleSupport
#endif /* WRT_SRC_VIEW_WEBKIT2_PLUGIN_MODULE_SUPPORT_H_ */
#include <scheme_action_map_type.h>
#include <scheme_action_map_data.h>
+#include <js_overlay_types.h>
+
// URI localization on WebProcess side
#include "bundle_uri_handling.h"
// set information from ui process
auto text = toString(static_cast<WKStringRef>(messageBody));
int eventType;
+ void *args = NULL;
std::stringstream ss(text);
ss >> eventType;
+ // set arguments to be sent to js handler of this custom event
+ // do something
+
//apply for each context
PageGlobalContext::iterator it = m_pageGlobalContext.begin();
for (; it != m_pageGlobalContext.end(); ++it)
{
PluginModule::dispatchJavaScriptEvent(
it->second,
- static_cast<WrtPlugins::W3C::CustomEventType>(eventType));
+ static_cast<WrtPlugins::W3C::CustomEventType>(eventType),
+ args);
+ }
+
+ if (args) {
+ delete args;
}
}
}
// dispatch 'appservice' js event
PluginModuleSupport::dispatchJavaScriptEvent(
m_ewkContext,
- WrtPlugins::W3C::ServiceCustomEvent);
+ WrtPlugins::W3C::ServiceCustomEvent,
+ NULL);
ewk_view_reload(m_currentEwkView);
} else {
m_currentUri = DPL::ToUTF8String(*servicedUri);
return m_currentEwkView;
}
+void ViewLogic::fireJavascriptEvent(int event, void* data)
+{
+ PluginModuleSupport::dispatchJavaScriptEvent(
+ m_ewkContext,
+ static_cast<WrtPlugins::W3C::CustomEventType>(event),
+ data);
+}
+
void ViewLogic::setUserCallbacks(const WRT::UserDelegatesPtr& cbs)
{
m_cbs = cbs;
This->m_cbs->loadFinish(true);
}
+ // set only encoded bundle
+ double scale = elm_config_scale_get();
+ PluginModuleSupport::setCustomProperties(
+ This->m_ewkContext,
+ &scale,
+ ApplicationDataSingleton::Instance().getEncodedBundle());
// check if 'appsevice' event is registed at the current frames.
// If so, dispatch the event to frames.
PluginModuleSupport::dispatchJavaScriptEvent(
This->m_ewkContext,
- WrtPlugins::W3C::ServiceCustomEvent);
+ WrtPlugins::W3C::ServiceCustomEvent,
+ NULL);
}
void ViewLogic::titleChangedCallback(
void forward();
void reloadStartPage();
Evas_Object* getCurrentWebview();
+ void fireJavascriptEvent(int event, void* data);
void setUserCallbacks(const WRT::UserDelegatesPtr& cbs);
// Ewk_Context operations
PKG_CHECK_MODULES(CLIENT_DEP
dpl-wrt-dao-ro
+ wrt-plugin-js-overlay
REQUIRED
)