#include <dpl/log/log.h>
#include <dpl/optional.h>
#include <dpl/string.h>
+#include <dpl/foreach.h>
#include <appcore-common.h>
#include <pcrecpp.h>
const char * const IME_STATE_ON = "on";
const char * const IME_STATE_OFF = "off";
-// WKPageLoaderClient
-const char * const EWK_LOAD_STARTED = "load,started";
-const char * const EWK_LOAD_FINISHED = "load,finished";
-const char * const EWK_TITLE_CHANGED = "title,changed";
-const char * const EWK_LOAD_PROGRESS = "load,progress";
-const char * const EWK_LOAD_PROGRESS_FINISHED = "load,progress,finished";
-const char * const EWK_PROCESS_CRASHED = "process,crashed";
-// WKPageUIClient
-const char * const EWK_CREATE_WINDOW = "create,window";
-const char * const EWK_CLOSE_WINDOW = "close,window";
-// WKPagePolicyClient
-const char * const EWK_POLICY_NAVIGATION_DECIDE = "policy,navigation,decide";
-const char * const EWK_POLICY_NEWWINDOW_DECIDE = "policy,newwindow,decide";
-const char * const EWK_POLICY_RESPONSE_DECIDE = "policy,response,decide";
-// WKPageContextMenuClient
-const char * const EWK_CONTEXTMENU_CUSTOMIZE = "contextmenu,customize";
-// WKPageFormClient
-const char * const EWK_FORM_SUBMIT = "form,submit";
-// EWK Geolocation Callback
-const char * const EWK_REQUEST_GEOLOCATION_PERMISSION =
- "request,geolocation,permission";
-// EWK Notification Callback
-const char * const EWK_NOTIFICATION_SHOW = "notification,show";
-const char * const EWK_NOTIFICATION_CANCEL = "notification,cancel";
-const char * const EWK_NOTIFICATION_PERMISSION_REQUEST =
- "notification,permission,request";
-// EWK Vibration Callback
-const char * const EWK_VIBRATION_VIBRATE = "vibration,vibrate";
-const char * const EWK_VIBRATION_CANCEL = "vibration,cancel";
-
-const char * const EWK_CONTEXT_EXCEEDED_QUOATA = "database,quota,exceeded";
-const char * const EWK_FILESYSTEM_PERMISSION_REQUEST = "filesystem,permission,request";
-const char * const EWK_FULLSCREEN_ENTER = "fullscreen,enterfullscreen";
-const char * const EWK_FULLSCREEN_EXIT = "fullscreen,exitfullscreen";
-
-// IME Callback
-const char * const EWK_INPUTMETHOD_CHANGED = "inputmethod,changed";
-const char * const EWK_EDITORCLIENT_IME_OPENED = "editorclient,ime,opened";
-const char * const EWK_EDITORCLIENT_IME_CLOSED = "editorclient,ime,closed";
-
-// EWK Usermedia Callback
-const char * const EWK_USERMEDIA_PERMISSION_REQUEST = "usermedia,permission,request";
-
-// Custom handlers
-const char * const EWK_PROTOCOLHANDLER_REGISTRATION = "protocolhandler,registration,requested";
-const char * const EWK_PROTOCOLHANDLER_ISREGISTERED = "protocolhandler,isregistered";
-const char * const EWK_PROTOCOLHANDLER_UNREGISTRATION = "protocolhandler,unregistration,requested";
-const char * const EWK_CONTENTHANDLER_REGISTRATION = "contenthandler,registration,requested";
-const char * const EWK_CONTENTHANDLER_ISREGISTERED = "contenthandler,isregistered";
-const char * const EWK_CONTENTHANDLER_UNREGISTRATION = "contenthandler,unregistration,requested";
-
const char PROTOCOL_HANDLER_ASK_MSG[] = "Add protocol?";
const char PROTOCOL_HANDLER_ASK_TITLE[] = "Add protocol";
const char PROTOCOL_HANDLER_ASK_REMEMBER[] = "Remember dicision";
const char CONTENT_HANDLER_ASK_MSG[] = "Add content?";
const char CONTENT_HANDLER_ASK_TITLE[] = "Add content";
const char CONTENT_HANDLER_AKS_REMEMBER[] = "Remember dicision";
-}
+} // anonymous namespace
+
+std::map<const std::string, const Evas_Smart_Cb> ViewLogic::m_ewkCallbacksMap =
+{
+ {"load,started", &ViewLogic::loadStartedCallback},
+ {"load,finished", &ViewLogic::loadFinishedCallback},
+ {"title,changed", &ViewLogic::titleChangedCallback},
+ {"load,progress", &ViewLogic::loadProgressCallback},
+ {"load,progress,finished", &ViewLogic::loadProgressFinishedCallback},
+ {"process,crashed", &ViewLogic::processCrashedCallback},
+ // WKPageUIClient
+ {"create,window", &ViewLogic::createWindowCallback},
+ {"close,window", &ViewLogic::closeWindowCallback},
+ // WKPagePolicyClient
+ {"policy,navigation,decide", &ViewLogic::policyNavigationDecideCallback},
+ {"policy,newwindow,decide", &ViewLogic::policyNewWindowDecideCallback},
+ {"policy,response,decide", &ViewLogic::pageResponseDecideCallback},
+ // WKPageContextMenuClient
+ {"contextmenu,customize", &ViewLogic::contextmenuCustomizeCallback},
+ // WKPageFormClient
+ {"form,submit", &ViewLogic::formSubmitCallback},
+ // EWK Geolocation Callback
+ {"request,geolocation,permission", &ViewLogic::geolocationPermissionRequestCallback},
+ // EWK Notification Callback
+ {"notification,show", &ViewLogic::notificationShowCallback},
+ {"notification,cancel", &ViewLogic::notificationCancelCallback},
+ {"notification,permission,request", &ViewLogic::notificationPermissionRequestCallback},
+ // EWK Vibration Callback
+ {"vibration,vibrate", &ViewLogic::vibrationVibrateCallback},
+ {"vibration,cancel", &ViewLogic::vibrationCancelCallback},
+
+ {"database,quota,exceeded", &ViewLogic::databaseUsagePermissionRequestCallback},
+ {"filesystem,permission,request", &ViewLogic::fileSystemPermissionRequestCallback},
+ {"fullscreen,enterfullscreen", &ViewLogic::enterFullscreenCallback},
+ {"fullscreen,exitfullscreen", &ViewLogic::exitFullscreenCallback},
+ // IME Callback
+ // when ime start to be showed on the webview,
+ // this callback will be called
+ {"inputmethod,changed", &ViewLogic::imeChangedCallback},
+ // this callback will be called
+ // when ime finishes to be showed on the webview
+ // "event_info" arg of this callback is always NULL point
+ // if web content should know size of ime,
+ // use "inputmethod,changed" instead of this.
+ //
+ {"editorclient,ime,opened", &ViewLogic::imeOpenedCallback},
+ // when ime finished to be hidden,
+ // this callback will be called
+ {"editorclient,ime,closed", &ViewLogic::imeClosedCallback},
+ // EWK Usermedia Callback
+ {"usermedia,permission,request", &ViewLogic::usermediaPermissionRequestCallback},
+ // Custom handlers
+ {"protocolhandler,registration,requested", &ViewLogic::protocolHandlerRegistrationCallback},
+ {"protocolhandler,isregistered", &ViewLogic::protocolHandlerIsRegisteredCallback},
+ {"protocolhandler,unregistration,requested", &ViewLogic::protocolHandlerUnregistrationCallback},
+ {"contenthandler,registration,requested", &ViewLogic::contentHandlerRegistrationCallback},
+ {"contenthandler,isregistered", &ViewLogic::contentHandlerIsRegisteredCallback},
+ {"contenthandler,unregistration,requested", &ViewLogic::contentHandlerUnregistrationCallback}
+};
ViewLogic::ViewLogic():
m_ewkContext(0),
void ViewLogic::ewkClientInit(Evas_Object *wkView) {
Assert(NULL != wkView && "ewk_view not created at this point");
- // WKPageLoaderClient
- evas_object_smart_callback_add(
- wkView,
- EWK_LOAD_STARTED,
- loadStartedCallback,
- this);
- evas_object_smart_callback_add(
- wkView,
- EWK_LOAD_FINISHED,
- loadFinishedCallback,
- this);
- evas_object_smart_callback_add(
- wkView,
- EWK_TITLE_CHANGED,
- titleChangedCallback,
- this);
- evas_object_smart_callback_add(
- wkView,
- EWK_LOAD_PROGRESS,
- loadProgressCallback,
- this);
- evas_object_smart_callback_add(
- wkView,
- EWK_LOAD_PROGRESS_FINISHED,
- loadProgressFinishedCallback,
- this);
- evas_object_smart_callback_add(
- wkView,
- EWK_PROCESS_CRASHED,
- processCrashedCallback,
- this);
-
- // WKPageUIClient
- evas_object_smart_callback_add(
- wkView,
- EWK_CREATE_WINDOW,
- createWindowCallback,
- this);
- evas_object_smart_callback_add(
- wkView,
- EWK_CLOSE_WINDOW,
- closeWindowCallback,
- this);
-
- // WKPagePolicyClient
- evas_object_smart_callback_add(
- wkView,
- EWK_POLICY_NAVIGATION_DECIDE,
- policyNavigationDecideCallback,
- this);
- evas_object_smart_callback_add(
- wkView,
- EWK_POLICY_NEWWINDOW_DECIDE,
- policyNewWindowDecideCallback,
- this);
- evas_object_smart_callback_add(
- wkView,
- EWK_POLICY_RESPONSE_DECIDE,
- pageResponseDecideCallback,
- this);
-
- // WKPageContextMenuClient
- evas_object_smart_callback_add(
- wkView,
- EWK_CONTEXTMENU_CUSTOMIZE,
- contextmenuCustomizeCallback,
- this);
-
- // WKPageFormClient
- evas_object_smart_callback_add(
- wkView,
- EWK_FORM_SUBMIT,
- formSubmitCallback,
- this);
-
- // EWK Geolocation Callback
- evas_object_smart_callback_add(
- wkView,
- EWK_REQUEST_GEOLOCATION_PERMISSION,
- geolocationPermissionRequestCallback,
- this);
-
- // EWK Notification Callback
- evas_object_smart_callback_add(
- wkView,
- EWK_NOTIFICATION_SHOW,
- notificationShowCallback,
- this);
- evas_object_smart_callback_add(
- wkView,
- EWK_NOTIFICATION_CANCEL,
- notificationCancelCallback,
- this);
- evas_object_smart_callback_add(
- wkView,
- EWK_NOTIFICATION_PERMISSION_REQUEST,
- notificationPermissionRequestCallback,
- this);
- // EWK Vibration Callback
- evas_object_smart_callback_add(
- wkView,
- EWK_VIBRATION_VIBRATE,
- vibrationVibrateCallback,
- this);
- evas_object_smart_callback_add(
- wkView,
- EWK_VIBRATION_CANCEL,
- vibrationCancelCallback,
- this);
- evas_object_smart_callback_add(
- wkView,
- EWK_CONTEXT_EXCEEDED_QUOATA,
- databaseUsagePermissionRequestCallback,
- this);
- evas_object_smart_callback_add(
- wkView,
- EWK_FILESYSTEM_PERMISSION_REQUEST,
- fileSystemPermissionRequestCallback,
- this);
-
- // EWK Orientation Callback
- //ewk_view_orientation_lock_callback_set(
- // wkView,
- // orientationLockCallback,
- // this);
-
- // Fullscreen API callbacks
- evas_object_smart_callback_add(
- wkView,
- EWK_FULLSCREEN_ENTER,
- enterFullscreenCallback,
- this);
- evas_object_smart_callback_add(
- wkView,
- EWK_FULLSCREEN_EXIT,
- exitFullscreenCallback,
- this);
-
-
- // when ime start to be showed on the webview,
- // this callback will be called
- evas_object_smart_callback_add(
- wkView,
- EWK_INPUTMETHOD_CHANGED,
- imeChangedCallback,
- this);
-
- // this callback will be called
- // when ime finishes to be showed on the webview
- // "event_info" arg of this callback is always NULL point
- // if web content should know size of ime,
- // use "inputmethod,changed" instead of this.
- //
- evas_object_smart_callback_add(
- wkView,
- EWK_EDITORCLIENT_IME_OPENED,
- imeOpenedCallback,
- this);
-
- // when ime finished to be hidden,
- // this callback will be called
- evas_object_smart_callback_add(
- wkView,
- EWK_EDITORCLIENT_IME_CLOSED,
- imeClosedCallback,
- this);
-
- // usermedia callback
- evas_object_smart_callback_add(
- wkView,
- EWK_USERMEDIA_PERMISSION_REQUEST,
- usermediaPermissionRequestCallback,
- this);
-
- // custom content/scheme handlers
- evas_object_smart_callback_add(
- wkView,
- EWK_PROTOCOLHANDLER_REGISTRATION,
- protocolHandlerRegistrationCallback,
- this);
- evas_object_smart_callback_add(
- wkView,
- EWK_PROTOCOLHANDLER_ISREGISTERED,
- protocolHandlerIsRegisteredCallback,
- this);
- evas_object_smart_callback_add(
- wkView,
- EWK_PROTOCOLHANDLER_UNREGISTRATION,
- protocolHandlerUnregistrationCallback,
- this);
-
- evas_object_smart_callback_add(
- wkView,
- EWK_CONTENTHANDLER_REGISTRATION,
- contentHandlerRegistrationCallback,
- this);
- evas_object_smart_callback_add(
- wkView,
- EWK_CONTENTHANDLER_ISREGISTERED,
- contentHandlerIsRegisteredCallback,
- this);
- evas_object_smart_callback_add(
- wkView,
- EWK_CONTENTHANDLER_UNREGISTRATION,
- contentHandlerUnregistrationCallback,
- this);
+ FOREACH(it, m_ewkCallbacksMap) {
+ evas_object_smart_callback_add(
+ wkView,
+ it->first.c_str(),
+ it->second,
+ this);
+ }
}
void ViewLogic::ewkClientDeinit(Evas_Object *wkView) {
LogDebug("ewkClientDeinit");
Assert(NULL != wkView && "ewk_view not created at this point");
- // WKPageLoaderClient
- evas_object_smart_callback_del(
- wkView,
- EWK_LOAD_STARTED,
- loadStartedCallback);
- evas_object_smart_callback_del(
- wkView,
- EWK_LOAD_FINISHED,
- loadFinishedCallback);
- evas_object_smart_callback_del(
- wkView,
- EWK_TITLE_CHANGED,
- titleChangedCallback);
- evas_object_smart_callback_del(
- wkView,
- EWK_LOAD_PROGRESS,
- loadProgressCallback);
- evas_object_smart_callback_del(
- wkView,
- EWK_LOAD_PROGRESS_FINISHED,
- loadProgressFinishedCallback);
- evas_object_smart_callback_del(
- wkView,
- EWK_PROCESS_CRASHED,
- loadProgressCallback);
-
- // WKPageUIClient
- evas_object_smart_callback_del(
- wkView,
- EWK_CREATE_WINDOW,
- createWindowCallback);
- evas_object_smart_callback_del(
- wkView,
- EWK_CLOSE_WINDOW,
- closeWindowCallback);
-
- // WKPagePolicyClient
- evas_object_smart_callback_del(
- wkView,
- EWK_POLICY_NAVIGATION_DECIDE,
- policyNavigationDecideCallback);
- evas_object_smart_callback_del(
- wkView,
- EWK_POLICY_NEWWINDOW_DECIDE,
- policyNewWindowDecideCallback);
- evas_object_smart_callback_del(
- wkView,
- EWK_POLICY_RESPONSE_DECIDE,
- pageResponseDecideCallback);
-
- // WKPageContextMenuClient
- evas_object_smart_callback_del(
- wkView,
- EWK_CONTEXTMENU_CUSTOMIZE,
- contextmenuCustomizeCallback);
-
- // WKPageFormClient
- evas_object_smart_callback_del(
- wkView,
- EWK_FORM_SUBMIT,
- formSubmitCallback);
-
- // EWK Geolocation Callback
- evas_object_smart_callback_del(
- wkView,
- EWK_REQUEST_GEOLOCATION_PERMISSION,
- geolocationPermissionRequestCallback);
-
- // EWK Notification Callback
- evas_object_smart_callback_del(
- wkView,
- EWK_NOTIFICATION_SHOW,
- notificationShowCallback);
- evas_object_smart_callback_del(
- wkView,
- EWK_NOTIFICATION_CANCEL,
- notificationCancelCallback);
- evas_object_smart_callback_del(
- wkView,
- EWK_NOTIFICATION_PERMISSION_REQUEST,
- notificationPermissionRequestCallback);
-
- // EWK Vibration Callback
- evas_object_smart_callback_del(
- wkView,
- EWK_VIBRATION_VIBRATE,
- vibrationVibrateCallback);
- evas_object_smart_callback_del(
- wkView,
- EWK_VIBRATION_CANCEL,
- vibrationCancelCallback);
-
- evas_object_smart_callback_del(
- wkView,
- EWK_CONTEXT_EXCEEDED_QUOATA,
- databaseUsagePermissionRequestCallback);
- evas_object_smart_callback_del(
- wkView,
- EWK_FILESYSTEM_PERMISSION_REQUEST,
- fileSystemPermissionRequestCallback);
-
- // EWK Orientation Callback
- //ewk_view_orientation_lock_callback_set(
- // wkView,
- // NULL,
- // NULL);
-
- // ime change/show/hide callback
- evas_object_smart_callback_del(
- wkView,
- EWK_INPUTMETHOD_CHANGED,
- imeChangedCallback);
- evas_object_smart_callback_del(
- wkView,
- EWK_EDITORCLIENT_IME_OPENED,
- imeOpenedCallback);
- evas_object_smart_callback_del(
- wkView,
- EWK_EDITORCLIENT_IME_CLOSED,
- imeClosedCallback);
-
- // usermedia callback
- evas_object_smart_callback_del(
- wkView,
- EWK_USERMEDIA_PERMISSION_REQUEST,
- usermediaPermissionRequestCallback);
-
- // custom content/scheme handlers
- evas_object_smart_callback_del(
- wkView,
- EWK_PROTOCOLHANDLER_REGISTRATION,
- protocolHandlerRegistrationCallback);
- evas_object_smart_callback_del(
- wkView,
- EWK_PROTOCOLHANDLER_ISREGISTERED,
- protocolHandlerIsRegisteredCallback);
- evas_object_smart_callback_del(
- wkView,
- EWK_PROTOCOLHANDLER_UNREGISTRATION,
- protocolHandlerUnregistrationCallback);
-
- evas_object_smart_callback_del(
- wkView,
- EWK_CONTENTHANDLER_REGISTRATION,
- contentHandlerRegistrationCallback);
- evas_object_smart_callback_del(
- wkView,
- EWK_CONTENTHANDLER_ISREGISTERED,
- contentHandlerIsRegisteredCallback);
- evas_object_smart_callback_del(
- wkView,
- EWK_CONTENTHANDLER_UNREGISTRATION,
- contentHandlerUnregistrationCallback);
+ FOREACH(it, m_ewkCallbacksMap) {
+ evas_object_smart_callback_del(
+ wkView,
+ it->first.c_str(),
+ it->second);
+ }
}
void ViewLogic::createEwkView(Evas* canvas)