From: Krzysztof Jackiewicz Date: Thu, 29 Nov 2012 09:43:24 +0000 (+0100) Subject: Custom handler callbacks connected to JS API. X-Git-Tag: 2.1b_release~22^2~193 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=243547e9a2a32539f5ef07f7d641a8f4df51a69f;p=platform%2Fframework%2Fweb%2Fwrt.git Custom handler callbacks connected to JS API. [Issue#] N/A [Feature] Custom handler callbacks has to be connected to JS API [Problem] N/A [Cause] N/A [Solution] Callbacks connected. [Verification] Run manual test: http://slp-info.sec.samsung.net/gerrit/#/c/119846/ Press all buttons and see if logs from handlers are displayed correctly. Change-Id: I8bacfd01db14d44360e67bfa3e92ca2d7f8f585f --- diff --git a/src/view/webkit/view_logic.cpp b/src/view/webkit/view_logic.cpp index 1d32022..a38fbda 100644 --- a/src/view/webkit/view_logic.cpp +++ b/src/view/webkit/view_logic.cpp @@ -113,6 +113,14 @@ const char * const EWK_FULLSCREEN_EXIT = "fullscreen,exitfullscreen"; // IME Callback const char * const EWK_INPUTMETHOD_CHANGED = "inputmethod,changed"; const char * const EWK_EDITORCLIENT_IME_CLOSED = "editorclient,ime,closed"; + +// 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"; } ViewLogic::ViewLogic(): @@ -662,6 +670,39 @@ void ViewLogic::ewkClientInit(Evas_Object *wkView) { EWK_EDITORCLIENT_IME_CLOSED, imeCloseCallback, 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); } void ViewLogic::ewkClientDeinit(Evas_Object *wkView) { @@ -784,6 +825,33 @@ void ViewLogic::ewkClientDeinit(Evas_Object *wkView) { wkView, EWK_EDITORCLIENT_IME_CLOSED, imeCloseCallback); + + // 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); } void ViewLogic::createEwkView(Evas* canvas) @@ -1587,6 +1655,84 @@ void ViewLogic::imeCloseCallback( &args); } +// helper method +void ViewLogic::debugCustomHandlerData(void* data) +{ + Assert(data); + Ewk_Custom_Handlers_Data* handler = + static_cast(data); + const char* base_url = ewk_custom_handlers_data_base_url_get(handler); + if (base_url) { + LogDebug("base url: " << base_url); + } + const char* url = ewk_custom_handlers_data_url_get(handler); + if (url) { + LogDebug("url: " << url); + } + const char* target = ewk_custom_handlers_data_target_get(handler); + if (target) { + LogDebug("target: " << target); + } + const char* title = ewk_custom_handlers_data_title_get(handler); + if (title) { + LogDebug("title: " << title); + } +} + +void ViewLogic::protocolHandlerRegistrationCallback(void* data, + Evas_Object* obj, + void* eventInfo) +{ + LogDebug("enter"); + debugCustomHandlerData(eventInfo); + // TODO to be continued... +} + +void ViewLogic::protocolHandlerIsRegisteredCallback(void* data, + Evas_Object* obj, + void* eventInfo) +{ + LogDebug("enter"); + debugCustomHandlerData(eventInfo); + // TODO to be continued... +} + +void ViewLogic::protocolHandlerUnregistrationCallback(void* data, + Evas_Object* obj, + void* eventInfo) +{ + LogDebug("enter"); + debugCustomHandlerData(eventInfo); + // TODO to be continued... +} + +void ViewLogic::contentHandlerRegistrationCallback(void* data, + Evas_Object* obj, + void* eventInfo) +{ + LogDebug("enter"); + debugCustomHandlerData(eventInfo); + // TODO to be continued... +} + +void ViewLogic::contentHandlerIsRegisteredCallback(void* data, + Evas_Object* obj, + void* eventInfo) +{ + LogDebug("enter"); + debugCustomHandlerData(eventInfo); + // TODO to be continued... +} + +void ViewLogic::contentHandlerUnregistrationCallback(void* data, + Evas_Object* obj, + void* eventInfo) +{ + LogDebug("enter"); + debugCustomHandlerData(eventInfo); + // TODO to be continued... +} + void ViewLogic::didRunJavaScriptCallback( Evas_Object* /*obj*/, const char* result, diff --git a/src/view/webkit/view_logic.h b/src/view/webkit/view_logic.h index a7f2884..84fce92 100644 --- a/src/view/webkit/view_logic.h +++ b/src/view/webkit/view_logic.h @@ -215,6 +215,29 @@ class ViewLogic : public ViewModule::IViewModule Evas_Object* obj, void* eventInfo); + static void debugCustomHandlerData(void* data); + + // custom content/scheme handlers + static void protocolHandlerRegistrationCallback(void* data, + Evas_Object* obj, + void* eventInfo); + static void protocolHandlerIsRegisteredCallback(void* data, + Evas_Object* obj, + void* eventInfo); + static void protocolHandlerUnregistrationCallback(void* data, + Evas_Object* obj, + void* eventInfo); + + static void contentHandlerRegistrationCallback(void* data, + Evas_Object* obj, + void* eventInfo); + static void contentHandlerIsRegisteredCallback(void* data, + Evas_Object* obj, + void* eventInfo); + static void contentHandlerUnregistrationCallback(void* data, + Evas_Object* obj, + void* eventInfo); + // JS execute callback static void didRunJavaScriptCallback( Evas_Object* obj,