[Release] wrt_0.8.235
[platform/framework/web/wrt.git] / src / view / webkit / view_logic.cpp
index d32b485..9dd358d 100644 (file)
@@ -31,6 +31,7 @@
 #include <dpl/foreach.h>
 
 #include <Elementary.h>
+#include <efl_assist.h>
 #include <pcrecpp.h>
 #include <sysman.h>
 #include <widget_model.h>
@@ -70,6 +71,7 @@
 #include <wrt-commons/custom-handler-dao-ro/CustomHandlerDatabase.h>
 #include <wrt-commons/custom-handler-dao-rw/custom_handler_dao.h>
 #include <popup-runner/PopupInvoker.h>
+#include <plugins-ipc-message/ipc_message_support.h>
 
 #include <appsvc/appsvc.h>
 #include <utilX.h>
@@ -561,6 +563,45 @@ void ViewLogic::checkAsyncMessageFromBundle(const char* name, const char* body)
         }
         ewk_cookie_manager_cookies_clear(cookieManager);
     }
+    else if (!strcmp(name, IPCMessageSupport::TIZEN_CHANGE_USERAGENT))
+    {
+        std::string msgBody = (body) ? (body) : "";
+
+        std::string strId = msgBody.substr(0, msgBody.find_first_of('_'));
+        std::string strBody = msgBody.substr(msgBody.find_first_of('_')+1);
+
+        LogDebug("Id: " << strId << ", Body:" << strBody);
+
+        ewk_view_user_agent_set(m_currentEwkView, strBody.c_str());
+
+        LogDebug("get UA: " << ewk_view_user_agent_get(m_currentEwkView));
+
+        IPCMessageSupport::replyAsyncMessageToWebProcess(m_ewkContext, atoi(strId.c_str()), "success");
+
+        return;
+    }
+    else if (!strcmp(name, IPCMessageSupport::TIZEN_DELETE_ALL_COOKIES))
+    {
+        std::string msgBody = (body) ? (body) : "";
+
+        std::string strId = msgBody.substr(0, msgBody.find_first_of('_'));
+        std::string strBody = msgBody.substr(msgBody.find_first_of('_')+1);
+
+        Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(m_ewkContext);
+
+        if (!cookieManager)
+        {
+            LogError("Fail to get cookieManager");
+            IPCMessageSupport::replyAsyncMessageToWebProcess(m_ewkContext, atoi(strId.c_str()), "error");
+
+            return;
+        }
+        ewk_cookie_manager_cookies_clear(cookieManager);
+
+        IPCMessageSupport::replyAsyncMessageToWebProcess(m_ewkContext, atoi(strId.c_str()), "success");
+
+        return;
+    }
 }
 
 void ViewLogic::downloadData(const char* url)
@@ -655,11 +696,14 @@ void ViewLogic::ewkClientInit(Evas_Object *wkView)
         wkView,
         exceededLocalFileSystemQuotaCallback,
         this);
-    evas_object_event_callback_add(
-        wkView,
-        EVAS_CALLBACK_KEY_UP,
-        keyupCallback,
-        this);
+    ea_object_event_callback_add(wkView,
+                                 EA_CALLBACK_BACK,
+                                 eaKeyCallback,
+                                 this);
+    ea_object_event_callback_add(wkView,
+                                 EA_CALLBACK_MORE,
+                                 eaKeyCallback,
+                                 this);
 }
 
 void ViewLogic::ewkClientDeinit(Evas_Object *wkView)
@@ -678,9 +722,12 @@ void ViewLogic::ewkClientDeinit(Evas_Object *wkView)
     ewk_view_exceeded_database_quota_callback_set(wkView, NULL, NULL);
     ewk_view_exceeded_indexed_database_quota_callback_set(wkView, NULL, NULL);
     ewk_view_exceeded_local_file_system_quota_callback_set(wkView, NULL, NULL);
-    evas_object_event_callback_del(wkView,
-                                   EVAS_CALLBACK_KEY_UP,
-                                   keyupCallback);
+    ea_object_event_callback_del(wkView,
+                                 EA_CALLBACK_BACK,
+                                 eaKeyCallback);
+    ea_object_event_callback_del(wkView,
+                                 EA_CALLBACK_MORE,
+                                 eaKeyCallback);
     if (m_orientationThresholdTimer) {
         ecore_timer_del(m_orientationThresholdTimer);
         m_orientationThresholdTimer = NULL;
@@ -1985,36 +2032,32 @@ void ViewLogic::didRunJavaScriptCallback(
     LogInfo("result = " << result);
 }
 
-void ViewLogic::keyupCallback(void* data,
-                              Evas* /*e*/,
-                              Evas_Object* obj,
-                              void* eventInfo)
+void ViewLogic::eaKeyCallback(void* data, Evas_Object* obj, void* eventInfo)
 {
     Assert(data);
     ViewLogic* This = static_cast<ViewLogic*>(data);
 
-    Assert(eventInfo);
-    Evas_Event_Key_Up* keyEvent =
-        static_cast<Evas_Event_Key_Up*>(eventInfo);
+    Ea_Callback_Type keyType =
+        static_cast<Ea_Callback_Type>(reinterpret_cast<int>(eventInfo));
 
-    LogInfo("Key = [" << keyEvent->keyname << "]");
-    if (!strcmp(keyEvent->keyname, KEY_BACK)) {
-        if (This->m_model->SettingList.Get().getHWkeyEvent() ==
-            HWkeyEvent_Enable)
-        {
-            DispatchEventSupport::dispatchHwKeyEvent(obj, "back");
-        }
-        This->m_cbs->hwkey("back");
-    } else if (!strcmp(keyEvent->keyname, KEY_MENU)) {
-        if (This->m_model->SettingList.Get().getHWkeyEvent() ==
-            HWkeyEvent_Enable)
-        {
-            DispatchEventSupport::dispatchHwKeyEvent(obj, "menu");
-        }
-        This->m_cbs->hwkey("menu");
+    LogInfo("Key = [" << keyType << "]");
+
+    std::string keyName;
+    if (keyType == EA_CALLBACK_BACK) {
+        keyName = KeyName::BACK;
+    } else if (keyType == EA_CALLBACK_MORE) {
+        keyName = KeyName::MENU;
+    } else {
+        return;
     }
-    return;
 
+    if (This->m_model->SettingList.Get().getHWkeyEvent() == HWkeyEvent_Enable)
+    {
+        DispatchEventSupport::dispatchHwKeyEvent(obj, keyName);
+    }
+    This->m_cbs->hwkey(keyName);
+
+    return;
 }
 
 Eina_Bool ViewLogic::windowCloseIdlerCallback(void* data)