Enhance createPopup() API to support key callback
authorJihoon Chung <jihoon.chung@samsaung.com>
Wed, 2 Oct 2013 02:57:14 +0000 (11:57 +0900)
committerHoseon LEE <hoseon46.lee@samsung.com>
Mon, 14 Oct 2013 11:19:44 +0000 (20:19 +0900)
[Issue#]   N/A
[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://review.tizendev.org/gerrit/#/c/88381/

[Remarks] Implementation details
    * CertificateSupportUtil::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: I48b09e85db36da9f9ca27a38e7a08ed27b29cbbc

src/view/common/view_logic_certificate_support.cpp
src/view/common/view_logic_certificate_support.h [changed mode: 0755->0644]
src/view/webkit/view_logic_certificate_confirm_support.cpp [changed mode: 0755->0644]

index a375f19..a4291e8 100644 (file)
@@ -25,6 +25,7 @@
 #include <memory>
 #include <Evas.h>
 #include <Elementary.h>
+#include <efl_assist.h>
 #include <dpl/log/log.h>
 #include <dpl/log/secure_log.h>
 #include <dpl/unused.h>
@@ -51,22 +52,29 @@ static void deleteCallback(void* data, Evas* e, Evas_Object* obj, void* eventInf
 {
     _D("called");
 
-    DPL_UNUSED_PARAM(data);
+    Assert(obj);
+
     DPL_UNUSED_PARAM(e);
     DPL_UNUSED_PARAM(eventInfo);
 
-    Assert(obj);
+    CallbackData* callbackData = static_cast<CallbackData*>(data);
+    if (callbackData) {
+        ea_object_event_callback_del(obj, EA_CALLBACK_BACK, callbackData->eaKeyCallback);
+        delete callbackData;
+    }
     evas_object_event_callback_del(obj, EVAS_CALLBACK_RESIZE, resizeCallback);
 }
+
 static void resizeCallback(void* data, Evas* e, Evas_Object* obj, void* eventInfo)
 {
     _D("called");
 
+    Assert(obj);
+
     DPL_UNUSED_PARAM(data);
     DPL_UNUSED_PARAM(e);
     DPL_UNUSED_PARAM(eventInfo);
 
-    Assert(obj);
     Evas_Object* popup = obj;
     int popupH;
     evas_object_geometry_get(popup, 0, 0, 0, &popupH);
@@ -154,8 +162,8 @@ Evas_Object* CertificateSupportUtil::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");
@@ -163,7 +171,13 @@ Evas_Object* CertificateSupportUtil::createPopup(
     Evas_Object* parentWindow = PopupUtil::getParentWindow(window);
     Evas_Object* popup = elm_popup_add(parentWindow);
 
-    evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, deleteCallback, NULL);
+    CallbackData* callbackData = NULL;
+    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<void*>(callbackData));
     evas_object_event_callback_add(popup, EVAS_CALLBACK_RESIZE, resizeCallback, NULL);
 
     elm_object_style_set(popup, "popup/default");
old mode 100755 (executable)
new mode 100644 (file)
index 8216c9b..15b541b
@@ -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);
old mode 100755 (executable)
new mode 100644 (file)
index 94ca270..ae93e66
@@ -59,6 +59,7 @@ void askUserForCertificatePermission(
                                      msg.c_str(),
                                      WRT_BODY_REMEMBER_PREFERENCE,
                                      popupCallback,
+                                     NULL,
                                      data);
 
     if (popup == NULL) {