From 04133d355a187d115d03f1e475a2db8ec606230c Mon Sep 17 00:00:00 2001 From: Jihoon Chung Date: Fri, 27 Sep 2013 19:37:36 +0900 Subject: [PATCH] Enhance createPopup() API to support key callback [Issue#] P130927-03479 [Problem] A web page underneath pop-up moves to the previous page when user expects the pop-up closed. This happens when a user select back-key when the permission request pop-up is on the screen. [Cause] Permission request pop-up does not handle the key callback. Moreover, the key event (which is not consumed) is passed onto the webview evas_object. As a result, the default behavior (i.e. dispatch tizenhwkey event) happens. [Solution] Add key callback handler to popup evas_object. Destory popup and pass "deny" to webkit that waits permission request result, when Back-key event callback is called. [SCMRequest] Needed by https://tizendev.org/gerrit/#/c/91230/ [Remarks] Implementation details * SecurityOriginSupportUtil::createPopup extend an argument to receive key callback. (Evas_Smart_Cb keyCallback) * Add "EVAS_CALLBACK_DEL" callback to remove before popup is removed. This behavior will prevent crash. Sometimes ecore dispatch event which is in the queue even callback data is already released. Change-Id: I4aeaf6ee4e2a9219ec3fd27c886673a2ba88a452 --- src/view/common/CMakeLists.txt | 1 + .../common/view_logic_security_origin_support.cpp | 36 ++++++++++++++++++++-- .../common/view_logic_security_origin_support.h | 1 + src/view/webkit/view_logic_geolocation_support.cpp | 1 + ...w_logic_web_notification_permission_support.cpp | 1 + src/view/webkit/view_logic_web_storage_support.cpp | 1 + 6 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/view/common/CMakeLists.txt b/src/view/common/CMakeLists.txt index 0588a06..3338fb0 100644 --- a/src/view/common/CMakeLists.txt +++ b/src/view/common/CMakeLists.txt @@ -23,6 +23,7 @@ PKG_CHECK_MODULES(SYS_VIEW_COMMON_DEP cert-svc-vcore capi-appfw-app-manager capi-web-url-download + efl-assist eina elementary evas diff --git a/src/view/common/view_logic_security_origin_support.cpp b/src/view/common/view_logic_security_origin_support.cpp index 900b9d8..0bab2f3 100644 --- a/src/view/common/view_logic_security_origin_support.cpp +++ b/src/view/common/view_logic_security_origin_support.cpp @@ -25,8 +25,11 @@ #include #include #include -#include +#include #include +#include +#include +#include #include #include #include @@ -34,6 +37,24 @@ #include namespace ViewModule { +namespace { +struct CallbackData { + Evas_Smart_Cb eaKeyCallback; +}; + +static void deleteCallback(void* data, Evas* e, Evas_Object* obj, void* eventInfo); +static void deleteCallback(void* data, Evas* e, Evas_Object* obj, void* eventInfo) +{ + DPL_UNUSED_PARAM(e); + DPL_UNUSED_PARAM(eventInfo); + + Assert(data); + CallbackData* callbackData = static_cast(data); + Assert(obj); + ea_object_event_callback_del(obj, EA_CALLBACK_BACK, callbackData->eaKeyCallback); + delete callbackData; +} +} class SecurityOriginSupportImplementation { @@ -88,13 +109,22 @@ Evas_Object* SecurityOriginSupportUtil::createPopup( Evas_Object* window, const char* bodyText, const char* checkText, - Evas_Smart_Cb - buttonCallback, + Evas_Smart_Cb buttonCallback, + Evas_Smart_Cb keyCallback, void* data) { LogDebug("createPopup"); Evas_Object* parentWindow = PopupUtil::getParentWindow(window); Evas_Object* popup = elm_popup_add(parentWindow); + + if (keyCallback) { + CallbackData* callbackData = new CallbackData; + callbackData->eaKeyCallback = keyCallback; + + ea_object_event_callback_add(popup, EA_CALLBACK_BACK, keyCallback, data); + evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, deleteCallback, static_cast(callbackData)); + } + elm_object_style_set(popup, "popup/default"); evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, diff --git a/src/view/common/view_logic_security_origin_support.h b/src/view/common/view_logic_security_origin_support.h index b8867bc..d10900e 100644 --- a/src/view/common/view_logic_security_origin_support.h +++ b/src/view/common/view_logic_security_origin_support.h @@ -70,6 +70,7 @@ Evas_Object* createPopup(Evas_Object* window, const char* bodyText, const char* checkText, Evas_Smart_Cb buttonCallback, + Evas_Smart_Cb keyCallback, void* data); Evas_Object* getPopup(Evas_Object* button); Evas_Object* getCheck(Evas_Object* popup); diff --git a/src/view/webkit/view_logic_geolocation_support.cpp b/src/view/webkit/view_logic_geolocation_support.cpp index 6ed0497..547a193 100644 --- a/src/view/webkit/view_logic_geolocation_support.cpp +++ b/src/view/webkit/view_logic_geolocation_support.cpp @@ -68,6 +68,7 @@ void askUserForGeolocationPermission( body.c_str(), WRT_BODY_REMEMBER_PREFERENCE, popupCallback, + NULL, data); if (popup == NULL) { diff --git a/src/view/webkit/view_logic_web_notification_permission_support.cpp b/src/view/webkit/view_logic_web_notification_permission_support.cpp index aade0fa..670358a 100644 --- a/src/view/webkit/view_logic_web_notification_permission_support.cpp +++ b/src/view/webkit/view_logic_web_notification_permission_support.cpp @@ -65,6 +65,7 @@ bool askUserPermission(Evas_Object* parent, PermissionData* data) body.c_str(), WRT_BODY_REMEMBER_PREFERENCE, popupCallback, + NULL, data); if (popup == NULL) { delete data; diff --git a/src/view/webkit/view_logic_web_storage_support.cpp b/src/view/webkit/view_logic_web_storage_support.cpp index 1786e52..e0f812d 100644 --- a/src/view/webkit/view_logic_web_storage_support.cpp +++ b/src/view/webkit/view_logic_web_storage_support.cpp @@ -76,6 +76,7 @@ void askUserForWebStorageCreatePermission( body.c_str(), WRT_BODY_REMEMBER_PREFERENCE, popupCallback, + NULL, data); if (popup == NULL) { -- 2.7.4