From: Andrzej Surdej Date: Wed, 2 Jan 2013 13:00:12 +0000 (+0100) Subject: Ewk callbacks registration/deregistration changed. X-Git-Tag: 2.1b_release~22^2~118 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d112897a346b17abaeed7fc1ec918f89f3e325b8;p=platform%2Fframework%2Fweb%2Fwrt.git Ewk callbacks registration/deregistration changed. [Issue#] LINUXNGWAP-597 [Problem] Previous implementation was too long due to rising callbacks count. [Cause] N/A [Solution] Global array was created and iterated when necessary. [Verification] To verify run wrt tests (wrt-tests-w3c, W3C Interface widget, custom handlers tests, web notification). Result should not decrease. Change-Id: I9b7976a455dbbe462a3851aef585ab735be8c762 --- diff --git a/src/view/webkit/view_logic.cpp b/src/view/webkit/view_logic.cpp index 8ccfc67..1c1c503 100644 --- a/src/view/webkit/view_logic.cpp +++ b/src/view/webkit/view_logic.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -83,64 +84,71 @@ const int MAX_NUM_CONTEXT_MENU_ITEMS = 10; 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 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), @@ -513,372 +521,26 @@ void ViewLogic::initializePluginLoading() 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) diff --git a/src/view/webkit/view_logic.h b/src/view/webkit/view_logic.h index 5369a26..4fc7492 100644 --- a/src/view/webkit/view_logic.h +++ b/src/view/webkit/view_logic.h @@ -24,6 +24,8 @@ #include #include +#include +#include #include #include @@ -224,8 +226,6 @@ class ViewLogic : public ViewModule::IViewModule void* eventInfo); // custom content/scheme handlers - void attachToCustomHandlersDao(); - void detachFromCustomHandlersDao(); static void protocolHandlerRegistrationCallback(void* data, Evas_Object* obj, void* eventInfo); @@ -246,6 +246,20 @@ class ViewLogic : public ViewModule::IViewModule Evas_Object* obj, void* eventInfo); + // database usage permission request callback + static void databaseUsagePermissionRequestCallback( + void* data, + Evas_Object* obj, + void* eventInfo); + // file System Permission Request Callback + static void fileSystemPermissionRequestCallback( + void* data, + Evas_Object* obj, + void* eventInfo); + + void attachToCustomHandlersDao(); + void detachFromCustomHandlersDao(); + // JS execute callback static void didRunJavaScriptCallback( Evas_Object* obj, @@ -257,16 +271,6 @@ class ViewLogic : public ViewModule::IViewModule // appcore event callback static int appcoreLowMemoryCallback(void *data); - // database usage permission request callback - static void databaseUsagePermissionRequestCallback( - void* data, - Evas_Object* obj, - void* eventInfo); - // file System Permission Request Callback - static void fileSystemPermissionRequestCallback( - void* data, - Evas_Object* obj, - void* eventInfo); //bundle void didRecieveMessageFromInjectedBundle( @@ -304,6 +308,8 @@ class ViewLogic : public ViewModule::IViewModule std::unique_ptr m_vibrationSupport; std::unique_ptr m_securityOriginSupport; bool m_attachedToCustomHandlerDao; + + static std::map m_ewkCallbacksMap; }; #endif //VIEW_LOGIC_H_