Register a key callback to handle back key event with W3C permission popup
authorJihoon Chung <jihoon.chung@samsaung.com>
Tue, 1 Oct 2013 14:14:34 +0000 (23:14 +0900)
committerHoseon LEE <hoseon46.lee@samsung.com>
Mon, 14 Oct 2013 11:19:31 +0000 (20:19 +0900)
    - This applies to the permission request popup for W3C Web Storage.

[Issue#]   N/A
[Problem]  A web page underneath pop-up moves to the previous page when user expects the pop-up closed.
[Cause]    The permission request pop-up did not handle the back-key callback.
[Solution] Register the key callback.

[SCMRequest] N/A

Change-Id: I0d14b6092678724f1462e8153754a7efe3ec5819

src/view/webkit/view_logic_web_storage_support.cpp

index e0f812d..71853f4 100644 (file)
@@ -23,6 +23,7 @@
 #include <string>
 #include <sstream>
 #include <dpl/log/secure_log.h>
+#include <dpl/unused.h>
 #include <dpl/assert.h>
 #include <wrt-commons/security-origin-dao/security_origin_dao_types.h>
 #include <wrt-commons/security-origin-dao/security_origin_dao.h>
@@ -50,7 +51,9 @@ struct WebStoragePermissionData {
 void askUserForWebStorageCreatePermission(
     Evas_Object* window,
     PermissionData* data);
+void setPermissionResult(PermissionData* permData, Result result);
 static void popupCallback(void* data, Evas_Object* obj, void* eventInfo);
+static void eaKeyCallback(void* data, Evas_Object* obj, void* eventInfo);
 
 void askUserForWebStorageCreatePermission(
     Evas_Object* window,
@@ -76,7 +79,7 @@ void askUserForWebStorageCreatePermission(
                                      body.c_str(),
                                      WRT_BODY_REMEMBER_PREFERENCE,
                                      popupCallback,
-                                     NULL,
+                                     eaKeyCallback,
                                      data);
 
     if (popup == NULL) {
@@ -88,32 +91,58 @@ void askUserForWebStorageCreatePermission(
     }
 }
 
-void popupCallback(void* data, Evas_Object* obj, void* /*eventInfo*/)
+void setPermissionResult(PermissionData* permData, Result result)
 {
-    Assert(data);
-    PermissionData* permData = static_cast<PermissionData*>(data);
+    Assert(permData);
     WebStoragePermissionData* webStoragePermissionData =
         static_cast<WebStoragePermissionData*>(permData->m_data);
-    Evas_Object* ewkView =
-        static_cast<Evas_Object*>(webStoragePermissionData->m_ewkView);
 
-    Evas_Object* popup = getPopup(obj);
-    Result result = getResult(obj);
-    _D("result : %d", result);
     if (result != RESULT_UNKNOWN) {
-        permData->m_originDao->setSecurityOriginData(permData->m_originData,
-                                                     result);
+        permData->m_originDao->setSecurityOriginData(permData->m_originData, result);
     }
-    Eina_Bool ret =
-        (result == RESULT_ALLOW_ALWAYS || result == RESULT_ALLOW_ONCE) ?
-            EINA_TRUE : EINA_FALSE;
-    webStoragePermissionData->m_replyEAPI(ewkView, ret);
+    Eina_Bool ret = (result == RESULT_ALLOW_ALWAYS || result == RESULT_ALLOW_ONCE) ? EINA_TRUE : EINA_FALSE;
+    webStoragePermissionData->m_replyEAPI(webStoragePermissionData->m_ewkView, ret);
+}
+
+void popupCallback(void* data, Evas_Object* obj, void* eventInfo)
+{
+    Assert(data);
+    Assert(obj);
 
+    DPL_UNUSED_PARAM(eventInfo);
+
+    PermissionData* permData = static_cast<PermissionData*>(data);
+    setPermissionResult(permData, getResult(obj));
+    WebStoragePermissionData* webStoragePermissionData =
+        static_cast<WebStoragePermissionData*>(permData->m_data);
     delete webStoragePermissionData;
     delete permData;
+
+    Evas_Object* popup = getPopup(obj);
     evas_object_hide(popup);
     evas_object_del(popup);
 }
+
+void eaKeyCallback(void* data, Evas_Object* obj, void* eventInfo)
+{
+    _D("called");
+
+    Assert(data);
+    Assert(obj);
+
+    DPL_UNUSED_PARAM(eventInfo);
+
+    PermissionData* permData = static_cast<PermissionData*>(data);
+    setPermissionResult(permData, RESULT_DENY_ONCE);
+
+    WebStoragePermissionData* webStoragePermissionData =
+        static_cast<WebStoragePermissionData*>(permData->m_data);
+    delete webStoragePermissionData;
+    delete permData;
+
+    evas_object_hide(obj);
+    evas_object_del(obj);
+}
 } // namespace
 
 void WebStorageSupport::createPermissionRequest(