Merge "fix: use EINA_* booleans instread of TRUE/FALSE" into tizen
[platform/framework/web/wrt.git] / src / view / webkit / view_logic.cpp
index 3ed737d..8957136 100644 (file)
 #include <dpl/foreach.h>
 
 #include <Elementary.h>
+#include <efl_assist.h>
 #include <pcrecpp.h>
 #include <sysman.h>
 #include <widget_model.h>
+#include <dpl/log/secure_log.h>
 #include <system_settings.h>
 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
 #include <dpl/utils/wrt_global_settings.h>
 
-#include <common/application_data.h>
+#include <application_data.h>
 #include <common/application_launcher.h>
 #include <common/message_support.h>
 #include <common/scheme.h>
@@ -58,7 +60,9 @@
 #include <view_logic_orientation_support.h>
 #include <view_logic_scheme_support.h>
 #include <view_logic_usermedia_support.h>
+#include <view_logic_web_notification_data.h>
 #include <view_logic_web_notification_support.h>
+#include <view_logic_web_notification_permission_support.h>
 #include <view_logic_web_storage_support.h>
 
 #include <EWebKit2.h>
 #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 <appsvc/appsvc.h>
-#include <utilX.h>
-
-#ifdef MULTIPROCESS_SERVICE_SUPPORT_INLINE
-#include "view_logic_service_support.h"
-
-extern "C" int appsvc_allow_transient_app(bundle *b, Ecore_X_Window id);
-extern "C" int appsvc_request_transient_app(bundle *b, Ecore_X_Window callee_id, appsvc_host_res_fn cbfunc, void *data);
-#endif
+#include <plugins-ipc-message/ipc_message_support.h>
+#include <appsvc.h>
 
 namespace {
 // IME State value
@@ -96,7 +92,7 @@ const char CONTENT_HANDLER_AKS_REMEMBER[] = "Remember dicision";
 const char* const DEFAULT_ENCODING = "UTF-8";
 #ifdef CSP_ENABLED
 const char* const DEFAULT_CSP_POLICY =
-    "default-src '*'; script-src 'self'; style-src 'self'; object-src 'none';";
+    "default-src *; script-src 'self'; style-src 'self'; object-src 'none';";
 #endif
 // SCHEME
 const char * const SCHEME_BOX_SLASH = "box://";
@@ -107,7 +103,6 @@ std::map<const std::string,
          const Evas_Smart_Cb> ViewLogic::m_ewkCallbacksMap = {
     { "load,started", &ViewLogic::loadStartedCallback },
     { "load,finished", &ViewLogic::loadFinishedCallback },
-    { "title,changed", &ViewLogic::titleChangedCallback },
     { "load,progress,started", &ViewLogic::loadProgressStartedCallback },
     { "load,progress", &ViewLogic::loadProgressCallback },
     { "load,progress,finished", &ViewLogic::loadProgressFinishedCallback },
@@ -172,7 +167,11 @@ std::map<const std::string,
     { "mediacontrol,rotate,vertical",
       &ViewLogic::mediacontrolRotateVertical },
     { "mediacontrol,rotate,exit",
-      &ViewLogic::mediacontrolRotateExit }
+      &ViewLogic::mediacontrolRotateExit },
+    { "popup,reply,wait,start",
+      &ViewLogic::popupReplyWaitStart },
+    { "popup,reply,wait,finish",
+      &ViewLogic::popupReplyWaitFinish },
 };
 
 ViewLogic::ViewLogic() :
@@ -191,8 +190,11 @@ ViewLogic::ViewLogic() :
     m_deferredRotateAngle(
         ViewModule::OrientationSupport::DEFERRED_ORIENTATION_EMPTY),
     m_orientationThresholdTimer(NULL),
+    m_isPopupReplyWait(false),
+    m_isFullscreenByPlatform(false),
     m_appsSupport(new ViewModule::AppsSupport()),
-    m_vibrationSupport(new ViewModule::VibrationSupport())
+    m_vibrationSupport(new ViewModule::VibrationSupport()),
+    m_webNotificationSupport(new ViewModule::WebNotificationSupport())
 {
     ApplicationLauncherSingleton::Instance().Touch();
 }
@@ -214,7 +216,7 @@ bool ViewLogic::createWebView(Ewk_Context* context,
     const char *theme = elm_theme_get(NULL);
     if (theme) {
         m_theme = theme;
-        LogInfo("theme is " << m_theme);
+        LogDebug("theme is " << m_theme);
     }
 
     // set members
@@ -230,18 +232,6 @@ bool ViewLogic::createWebView(Ewk_Context* context,
     return true;
 }
 
-#ifdef MULTIPROCESS_SERVICE_SUPPORT_INLINE
-int ViewLogic::appServiceCallerIsKilled(void *data)
-{
-    Assert(data);
-    ViewLogic *This = static_cast<ViewLogic *>(data);
-    if (!This->m_cbs->webkitExit.empty()) {
-        This->m_cbs->webkitExit();
-    }
-    return 0;
-}
-#endif
-
 void ViewLogic::prepareView(WidgetModel* m, const std::string &startUrl)
 {
     LogDebug("View prepare");
@@ -252,36 +242,6 @@ void ViewLogic::prepareView(WidgetModel* m, const std::string &startUrl)
     Assert(NULL != m_ewkContext);
     Assert(m_window);
 
-#ifdef MULTIPROCESS_SERVICE_SUPPORT_INLINE
-    if (ServiceSupport::isService(m_model))
-    {
-        bundle *b = ApplicationDataSingleton::Instance().getBundle();
-        if (ServiceSupport::Disposition::INLINE == ServiceSupport::disposition(m_model))
-        {
-            LogDebug("Set up INLINE disposition");
-            int pid = ServiceSupport::callerPID(b);
-            if (pid) {
-                unsigned windowId = ServiceSupport::xWindowByPid(pid);
-                appsvc_allow_transient_app(b, windowId);
-                appsvc_request_transient_app(b, elm_win_xwindow_get(m_window), appServiceCallerIsKilled, this);
-            }
-        }
-        else
-        {
-            LogDebug("Set up WINDOW disposition");
-        }
-    }
-    else
-    {
-        LogDebug("Starting regular widget");
-    }
-#endif
-
-    if (m_model->SettingList.Get().getAccessibility() == Accessibility_Enable)
-    {
-        elm_access_object_register(m_currentEwkView, m_window);
-    }
-
     ADD_PROFILING_POINT("initializeSupport", "start");
     initializeSupport();
     ADD_PROFILING_POINT("initializeSupport", "stop");
@@ -303,7 +263,7 @@ void ViewLogic::showWidget()
         LogError("Localized current URI doesn't exist");
         return;
     }
-    LogInfo("url : " << url);
+    LogDebug("url : " << url);
 
     // load page
     ewk_view_url_set(m_currentEwkView, url.c_str());
@@ -319,10 +279,11 @@ void ViewLogic::hideWidget()
     ViewModule::StorageSupport::deinitializeStorage(m_model);
     m_appsSupport->deinitialize();
     m_vibrationSupport->deinitialize();
+    m_webNotificationSupport->deinitialize();
     system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_FONT_TYPE);
 
     while (!m_ewkViewList.empty()) {
-        LogInfo("pop webview: " << m_ewkViewList.back());
+        LogDebug("pop webview: " << m_ewkViewList.back());
         removeEwkView(m_ewkViewList.back());
     }
     m_ewkViewList.clear();
@@ -330,20 +291,25 @@ void ViewLogic::hideWidget()
 
 void ViewLogic::suspendWidget()
 {
-    LogInfo("Pausing widget");
+    LogDebug("Pausing widget");
     Assert(m_model);
 
     if (!m_currentEwkView) {
         LogWarning("Cannot suspend widget without view");
     } else {
         setEwkViewInvisible(m_currentEwkView);
+
         if (!m_isBackgroundSupport) {
+            FOREACH(it, m_ewkViewList) {
+                if (*it != m_currentEwkView) {
+                    suspendWebkit(*it);
+                }
+            }
+
             suspendWebkit(m_currentEwkView);
         }
     }
 
-    evas_object_focus_set(m_currentEwkView, EINA_FALSE);
-
     // call user callback
     if (!m_cbs->suspend.empty()) {
         m_cbs->suspend(true);
@@ -352,12 +318,20 @@ void ViewLogic::suspendWidget()
 
 void ViewLogic::resumeWidget()
 {
-    LogInfo("Resume widget");
+    LogDebug("Resume widget");
     Assert(m_model);
 
-    if (m_currentEwkView) {
+    if (m_currentEwkView)
+    {
         setEwkViewVisible(m_currentEwkView);
+
         if (!m_isBackgroundSupport) {
+            FOREACH(it, m_ewkViewList) {
+                if (*it != m_currentEwkView) {
+                    resumeWebkit(*it);
+                }
+            }
+
             resumeWebkit(m_currentEwkView);
         }
     }
@@ -368,7 +342,6 @@ void ViewLogic::resumeWidget()
      *  elm_win_raise(m_window);
      * }
      */
-    evas_object_focus_set(m_currentEwkView, EINA_TRUE);
 
     // call user callback
     if (!m_cbs->resume.empty()) {
@@ -378,37 +351,56 @@ void ViewLogic::resumeWidget()
 
 void ViewLogic::resetWidget()
 {
-    LogInfo("Resetting Widget");
-
-    // destory all webview
-    while (!m_ewkViewList.empty()) {
-        LogInfo("pop webview: " << m_ewkViewList.back());
-        removeEwkView(m_ewkViewList.back());
-    }
-    m_ewkViewList.clear();
-
-    // create new webview
-    createEwkView(evas_object_evas_get(m_window));
-    ewkClientInit(m_currentEwkView);
-    prepareEwkView(m_currentEwkView);
-
-    // check if current url is service url for this tizen service
-    std::string url =
-        ViewModule::UriSupport::getUri(m_model, m_startUrl);
+    LogDebug("Resetting Widget");
 
-    initializePluginLoading();
-
-    // webview activated
-    ewk_view_url_set(m_currentEwkView, url.c_str());
-    elm_win_activate(m_window);
-    evas_object_focus_set(m_currentEwkView, EINA_TRUE);
+    // handling case of WebProcess is locked
+    if (m_isPopupReplyWait) {
+        // resume web application
+        LogDebug("WebProcess is locked");
+        if (m_currentEwkView) {
+            setEwkViewVisible(m_currentEwkView);
+            if (!m_isBackgroundSupport) {
+                resumeWebkit(m_currentEwkView);
+            }
+        }
+        // webview activated
+        elm_win_activate(m_window);
 
-    // call user callback
-    if (!m_cbs->reset.empty()) {
-        m_cbs->reset(true);
-    }
-    if (!m_cbs->bufferSet.empty()) {
-        m_cbs->bufferSet(m_currentEwkView);
+        // call user callback
+        if (!m_cbs->reset.empty()) {
+            m_cbs->reset(false);
+        }
+    } else {
+        // reset web application
+        // destory all webview
+        while (!m_ewkViewList.empty()) {
+            LogDebug("pop webview: " << m_ewkViewList.back());
+            removeEwkView(m_ewkViewList.back());
+        }
+        m_ewkViewList.clear();
+        m_currentEwkView = NULL;
+
+        // create new webview
+        createEwkView(evas_object_evas_get(m_window));
+        ewkClientInit(m_currentEwkView);
+        prepareEwkView(m_currentEwkView);
+
+        // check if current url is service url for this tizen service
+        std::string url =
+            ViewModule::UriSupport::getUri(m_model, m_startUrl);
+
+        initializePluginLoading();
+        // webview activated
+        ewk_view_url_set(m_currentEwkView, url.c_str());
+        elm_win_activate(m_window);
+
+        // call user callback
+        if (!m_cbs->reset.empty()) {
+            m_cbs->reset(true);
+        }
+        if (!m_cbs->bufferSet.empty()) {
+            m_cbs->bufferSet(m_currentEwkView);
+        }
     }
 }
 
@@ -419,11 +411,11 @@ void ViewLogic::backward()
     } else {
         if (1 >= m_ewkViewList.size()) {
             // If there is no previous page, widget move to backgroud.
-            LogInfo("Widget move to backgroud");
+            LogDebug("Widget move to backgroud");
             elm_win_lower(m_window);
         } else {
             // Back to previous webview
-            LogInfo("Widget move to previous webview");
+            LogDebug("Widget move to previous webview");
             m_closedEwkView = m_currentEwkView;
             ecore_idler_add(windowCloseIdlerCallback, this);
         }
@@ -432,7 +424,7 @@ void ViewLogic::backward()
 
 void ViewLogic::reloadStartPage()
 {
-    LogInfo("Reload Start Page");
+    LogDebug("Reload Start Page");
     // prevent fail to load plugin bundle side
     m_isBackgroundReload = true;
 
@@ -460,12 +452,12 @@ void ViewLogic::reloadStartPage()
     if (!m_cbs->bufferSet.empty()) {
         m_cbs->bufferSet(m_currentEwkView);
     }
-    LogInfo("Reloading Start Page is done!");
+    LogDebug("Reloading Start Page is done!");
 }
 
 Evas_Object* ViewLogic::getCurrentWebview()
 {
-    LogInfo("get current webview");
+    LogDebug("get current webview");
     return m_currentEwkView;
 }
 
@@ -502,7 +494,7 @@ void ViewLogic::checkSyncMessageFromBundle(
                     *returnData = strdup(ret.c_str());
                 }
             } else {
-                LogInfo("X window isn't exist");
+                LogDebug("X window isn't exist");
             }
         }
     }
@@ -510,10 +502,8 @@ void ViewLogic::checkSyncMessageFromBundle(
 
 void ViewLogic::checkAsyncMessageFromBundle(const char* name, const char* body)
 {
-    LogDebug("checkAsyncMessageFromBundle called");
     Assert(name);
-
-    LogDebug("received : " << name);
+    _D("received : %s", name);
 
     if (!strcmp(name, Message::ToUIProcess::BLOCKED_URL)) {
         // Currently WebProcess informs obly about blocked
@@ -521,31 +511,68 @@ void ViewLogic::checkAsyncMessageFromBundle(const char* name, const char* body)
         // done by WebProcess itself (see: wrt-injected-bundle.cpp
         // and bundle_uri_handling.cpp)
         requestUrlBlocked(std::string(body));
-    }
-#ifdef MULTIPROCESS_SERVICE_SUPPORT_INLINE
-    else if (!strcmp(name, Message::ToUIProcess::SEND_WEBPROCESS_PID)) {
-        std::stringstream ss(body);
-        unsigned int pid = 0;
-        ss >> pid;
-        ServiceSupport::setWebProcessPidWindowProperty(
-            elm_win_xwindow_get(m_window),
-            pid);
-    }
-#endif
-    else if (!strcmp(name, Message::TizenScheme::CLEAR_ALL_COOKIES)) {
+    } else if (!strcmp(name, Message::TizenScheme::CLEAR_ALL_COOKIES)) {
+        Ewk_Cookie_Manager* cookieManager =
+            ewk_context_cookie_manager_get(m_ewkContext);
+        if (!cookieManager) {
+            _E("Fail to get cookieManager");
+            return;
+        }
+        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);
+        _D("Id: %s , Body %s", strId.c_str(), strBody.c_str());
+
+        ewk_view_user_agent_set(m_currentEwkView, strBody.c_str());
+        _D("get UA: %s", 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");
+            _E("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;
+    } else if (!strcmp(name, IPCMessageSupport::TIZEN_EXIT) ||
+               !strcmp(name, IPCMessageSupport::TIZEN_HIDE))
+    {
+        bool ret =
+            ViewModule::SchemeSupport::HandleTizenScheme(name,
+                                                         m_window,
+                                                         m_currentEwkView);
+        if (ret == false) {
+            _E("Fail to handle tizen scheme %s", name);
+        }
+        // Not need to send reply
+        return;
+    } else {
+        _W("Not defined message");
     }
 }
 
 void ViewLogic::downloadData(const char* url)
 {
-    LogInfo("enter");
+    LogDebug("enter");
     if (!url) {
         return;
     }
@@ -554,7 +581,7 @@ void ViewLogic::downloadData(const char* url)
 
 void ViewLogic::activateVibration(bool on, uint64_t time)
 {
-    LogInfo("enter");
+    LogDebug("enter");
     if (on) {
         m_vibrationSupport->startVibration(static_cast<long>(time));
     } else {
@@ -569,20 +596,19 @@ void ViewLogic::initializeSupport()
         == BackgroundSupport_Enable)
     {
         LogDebug("Background support enabled, set process active");
-        pid_t pid = getpid();
-        sysman_inform_active(pid);
+        sysman_inform_active(getpid());
         m_isBackgroundSupport = true;
     }
     system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_FONT_TYPE,
                                    systemSettingsChangedCallback,
                                    this);
 
-    m_schemeSupport.reset(new SchemeSupport(m_model->Type.Get().appType));
     ViewModule::StorageSupport::initializeStorage(m_model);
     m_appsSupport->initialize(m_model, elm_win_xwindow_get(m_window));
     m_securityOriginSupport.reset(new ViewModule::SecurityOriginSupport(m_model));
     m_certificateSupport.reset(new ViewModule::CertificateSupport(m_model));
     m_vibrationSupport->initialize();
+    m_webNotificationSupport->initialize(m_model->TzPkgId.Get());
 }
 
 void ViewLogic::initializePluginLoading()
@@ -635,11 +661,21 @@ 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);
+#if 0 // FIXME!!! elm_access_object_register has not landed yet
+    // Always register access object even application doesn't support
+    // accessibility. In case of accessibility isn't supported, efl_assist
+    // shows warning message by syspopup.
+    // initScreenReaderSupport is related method. (window_data.cpp)
+    elm_access_object_register(wkView, m_window);
+#endif
 }
 
 void ViewLogic::ewkClientDeinit(Evas_Object *wkView)
@@ -658,13 +694,19 @@ 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;
     }
+    // FIXME!!!! elm_access_object_unregister has not landed in
+    //           tizen 3.0 elementary yet
+    // elm_access_object_unregister(wkView);
 }
 
 bool ViewLogic::createEwkView(Evas* canvas)
@@ -697,7 +739,7 @@ bool ViewLogic::createEwkView(Evas* canvas)
         setEwkViewInvisible(m_currentEwkView);
     }
 
-    LogInfo("push webview: " << newEwkView);
+    LogDebug("push webview: " << newEwkView);
     m_ewkViewList.push_back(newEwkView);
     m_currentEwkView = newEwkView;
     return true;
@@ -749,15 +791,23 @@ void ViewLogic::prepareEwkView(Evas_Object *wkView)
     std::string encoding = DEFAULT_ENCODING;
     OptionalWidgetStartFileInfo fileInfo =
         W3CFileLocalization::getStartFileInfo(m_model->TizenId);
+#if 0 // FIXME!!!! ewk_settings_is_encoding_valid has not landed yet
     if (!fileInfo.IsNull()) {
-        encoding = DPL::ToUTF8String((*fileInfo).encoding);
-        LogInfo("Found custom encoding in DB: " << encoding);
+            std::string file_encoding = DPL::ToUTF8String((*fileInfo).encoding);
+
+            if(EINA_TRUE == ewk_settings_is_encoding_valid(
+                                                        file_encoding.c_str())){
+                encoding = file_encoding;
+                _D("Found custom encoding in DB: %s", encoding.c_str());
+            }
+
     }
-    LogInfo("Setting encoding: " << encoding);
+#endif
+    _D("Setting encoding: %s", encoding.c_str());
     if (ewk_settings_default_encoding_set(settings,encoding.c_str())) {
-        LogInfo("Encoding set properly");
+        _D("Encoding set properly");
     } else {
-        LogError("Error while setting encoding");
+        _E("Error while setting encoding");
     }
 
 #ifdef CSP_ENABLED
@@ -793,7 +843,7 @@ void ViewLogic::prepareEwkView(Evas_Object *wkView)
 
 void ViewLogic::removeEwkView(Evas_Object *wkView)
 {
-    LogInfo("removeEwkView called");
+    LogDebug("removeEwkView called");
     Assert(wkView);
     Assert(0 != m_ewkViewList.size());
 
@@ -806,36 +856,9 @@ void ViewLogic::removeEwkView(Evas_Object *wkView)
     m_ewkViewList.remove(wkView);
 }
 
-void ViewLogic::resumeEwkView(Evas_Object *wkView)
-{
-    LogInfo("resumeEwkView called");
-    Assert(wkView);
-
-    // register webview callback
-    ewkClientInit(wkView);
-
-    // resume webkit
-    resumeWebkit(wkView);
-
-    return;
-}
-
-void ViewLogic::suspendEwkView(Evas_Object *wkView)
-{
-    LogInfo("suspendEwkView called");
-    Assert(wkView);
-
-    // suspend webkit
-    suspendWebkit(wkView);
-
-    // unregister webview callbacks
-    ewkClientDeinit(wkView);
-    return;
-}
-
 void ViewLogic::setEwkViewInvisible(Evas_Object *wkView)
 {
-    LogInfo("setEwkViewInvisible called");
+    LogDebug("setEwkViewInvisible called");
     Assert(wkView);
 
     ewk_view_page_visibility_state_set(wkView,
@@ -846,7 +869,7 @@ void ViewLogic::setEwkViewInvisible(Evas_Object *wkView)
 
 void ViewLogic::setEwkViewVisible(Evas_Object *wkView)
 {
-    LogInfo("setEwkViewVisible called");
+    LogDebug("setEwkViewVisible called");
     Assert(wkView);
 
     ewk_view_page_visibility_state_set(wkView,
@@ -857,20 +880,25 @@ void ViewLogic::setEwkViewVisible(Evas_Object *wkView)
 
 void ViewLogic::resumeWebkit(Evas_Object *wkView)
 {
-    LogDebug("resumeWebkit");
+    LogDebug("resumeWebkit : " << wkView);
     Assert(wkView);
 
     ewk_view_resume(wkView);
+    // FIXME!!!! ewk_view_foreground_set has not landed yet
+    // ewk_view_foreground_set(wkView, true);
 
     return;
 }
 
 void ViewLogic::suspendWebkit(Evas_Object *wkView)
 {
-    LogDebug("suspendWebkit");
+    LogDebug("suspendWebkit : " << wkView);
     Assert(wkView);
 
     ewk_view_suspend(wkView);
+    // FIXME!!!! ewk_view_foreground_set has not landed in the
+    //           tizen 3.0 elementary project yet
+    // ewk_view_foreground_set(wkView, false);
 
     return;
 }
@@ -898,7 +926,6 @@ void ViewLogic::loadFinishedCallback(
     LogDebug("loadFinishedCallback called");
     Assert(data);
     ViewLogic* This = static_cast<ViewLogic*>(data);
-    evas_object_focus_set(This->m_currentEwkView, EINA_TRUE);
 
     // Fill id/password
     const char* url = ewk_view_url_get(This->m_currentEwkView);
@@ -927,45 +954,12 @@ void ViewLogic::loadFinishedCallback(
     }
 }
 
-void ViewLogic::titleChangedCallback(
-    void* data,
-    Evas_Object* obj,
-    void* eventInfo)
-{
-    LogDebug("titleChangedCallback called");
-    Assert(data);
-    ViewLogic* This = static_cast<ViewLogic*>(data);
-    Assert(eventInfo);
-    const char* title = static_cast<char*>(eventInfo);
-
-    if (0 == strlen(title)) {
-        LogDebug("title data is empty");
-        This->m_currentTitle = std::string();
-        return;
-    }
-    LogDebug("Title = [" << title << "]");
-    bool ret = This->m_schemeSupport->HandleTizenScheme(
-                                             title,
-                                             This->m_window,
-                                             This->m_currentEwkView);
-    // if result is true, this is tizen scheme
-    // and then, title is reset to page's real title
-    if (ret) {
-        std::string script = "document.title = \"";
-        script += This->m_currentTitle;
-        script +="\";";
-        ewk_view_script_execute(obj, script.c_str(), didRunJavaScriptCallback, This);
-    } else {
-        This->m_currentTitle = std::string(title);
-    }
-}
-
 void ViewLogic::loadProgressStartedCallback(
     void* data,
     Evas_Object* /*obj*/,
     void* /*eventInfo*/)
 {
-    LogDebug("loadProgressStartedCallback called");
+    _D("loadProgressStartedCallback called");
     Assert(data);
     ViewLogic* This = static_cast<ViewLogic*>(data);
     if (!This->m_cbs->progressStarted.empty()) {
@@ -979,7 +973,7 @@ void ViewLogic::loadProgressCallback(
     Evas_Object* obj,
     void* eventInfo)
 {
-    LogDebug("loadProgressCallback called");
+    _D("loadProgressCallback called");
     Assert(data);
     Assert(eventInfo);
     ViewLogic const * const view = static_cast<ViewLogic const * const>(data);
@@ -1009,7 +1003,7 @@ void ViewLogic::processCrashedCallback(
     Evas_Object* /*obj*/,
     void* eventInfo)
 {
-    LogInfo("processCrashedCallback");
+    LogDebug("processCrashedCallback");
     Assert(data);
     ViewLogic const * const view =
         static_cast<ViewLogic const * const>(data);
@@ -1112,11 +1106,10 @@ void ViewLogic::policyNavigationDecideCallback(
         }
     }
 
-    if (This->m_schemeSupport->filterURIByScheme(policyDecision,
-                                                 false,
-                                                 This->m_model,
-                                                 This->m_window,
-                                                 This->m_currentEwkView))
+    if (ViewModule::SchemeSupport::filterURIByScheme(policyDecision,
+                                                     false,
+                                                     This->m_window,
+                                                     This->m_currentEwkView))
     {
         LogDebug("use");
         ewk_policy_decision_use(policyDecision);
@@ -1135,7 +1128,7 @@ void ViewLogic::policyNavigationDecideCallback(
              * and the previous one is shown. This is not an elegant solution
              * but we don't have a better one.
              */
-            LogInfo("Scheme has been handled externally. Removing empty view.");
+            LogDebug("Scheme has been handled externally. Removing empty view.");
             if (ewk_view_back_possible(This->m_currentEwkView)) {
                 // go back to previous WKPage
                 ewk_view_back(This->m_currentEwkView);
@@ -1175,11 +1168,10 @@ void ViewLogic::policyNewWindowDecideCallback(
         }
     }
 
-    if (This->m_schemeSupport->filterURIByScheme(policyDecision,
-                                                 true,
-                                                 This->m_model,
-                                                 This->m_window,
-                                                 This->m_currentEwkView))
+    if (ViewModule::SchemeSupport::filterURIByScheme(policyDecision,
+                                                     true,
+                                                     This->m_window,
+                                                     This->m_currentEwkView))
     {
         ewk_policy_decision_use(policyDecision);
     } else {
@@ -1297,6 +1289,10 @@ void ViewLogic::contextmenuCustomizeCallback(
                 ewk_context_menu_item_remove(menu, item);
                 continue;
 
+            case EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_IMAGE_TO_DISK:
+                ewk_context_menu_item_remove(menu, item);
+                continue;
+
             default:
                 idx++;
                 break;
@@ -1331,49 +1327,44 @@ void ViewLogic::notificationShowCallback(
     Evas_Object* /*obj*/,
     void* eventInfo)
 {
-    LogDebug("notificationShowCallback called");
-    Assert(data);
-    ViewLogic* This = static_cast<ViewLogic*>(data);
-
     Assert(eventInfo);
-    Ewk_Notification* noti = static_cast<Ewk_Notification*>(eventInfo);
-
-    using namespace ViewModule::WebNotification;
+    Ewk_Notification* ewkNotification =
+        static_cast<Ewk_Notification*>(eventInfo);
+    ViewModule::WebNotificationDataPtr notiData(
+        new ViewModule::WebNotificationData(ewkNotification));
 
-    WebNotificationDataPtr notiData(
-        new WebNotificationData(
-            This->m_model,
-            ewk_notification_id_get(noti)));
+    _D("notification id : %u", notiData->getEwkNotiId());
+    _D("notification iconURL : %s", notiData->getIconUrl());
+    _D("notification title : %s", notiData->getTitle());
+    _D("notification body : %s", notiData->getBody());
 
-    DPL::OptionalString string =
-        DPL::FromUTF8String(ewk_notification_icon_url_get(noti));
-    if (!string.IsNull()) {
-        notiData->m_iconURL = DPL::ToUTF8String(*string);
-    }
-    string = DPL::FromUTF8String(ewk_notification_title_get(noti));
-    if (!string.IsNull()) {
-        notiData->m_title = DPL::ToUTF8String(*string);
-    }
-    string = DPL::FromUTF8String(ewk_notification_body_get(noti));
-    if (!string.IsNull()) {
-        notiData->m_body = DPL::ToUTF8String(*string);
+    Assert(data);
+    ViewLogic* This = static_cast<ViewLogic*>(data);
+    if (This->m_webNotificationSupport->show(notiData)) {
+        ewk_notification_showed(This->m_ewkContext, notiData->getEwkNotiId());
     }
-
-    LogInfo("notification id : " << notiData->m_id);
-    LogInfo("notification iconURL : " << notiData->m_iconURL);
-    LogInfo("notification title : " << notiData->m_title);
-    LogInfo("notification body : " << notiData->m_body);
-
-    showWebNotification(notiData);
-    ewk_notification_showed(This->m_ewkContext, ewk_notification_id_get(noti));
 }
 
 void ViewLogic::notificationCancelCallback(
-    void* /*data*/,
-    Evas_Object* /*obj*/,
-    void* /*eventInfo*/)
+    void* data,
+    Evas_Object* obj,
+    void* eventInfo)
 {
-    LogDebug("notificationCancelCallback called");
+    Assert(eventInfo);
+    uint64_t ewkNotiId = *static_cast<uint64_t*>(eventInfo);
+
+    Assert(data);
+    ViewLogic* This = static_cast<ViewLogic*>(data);
+    Ewk_Notification* ewkNotification =
+        static_cast<Ewk_Notification*>(
+            This->m_webNotificationSupport->hide(ewkNotiId));
+    if (ewkNotification) {
+        Assert(obj);
+        Eina_List* list = NULL;
+        list = eina_list_append(list, ewkNotification);
+        ewk_view_notification_closed(obj, list);
+        eina_list_free(list);
+    }
 }
 
 void ViewLogic::notificationPermissionRequestCallback(
@@ -1384,17 +1375,9 @@ void ViewLogic::notificationPermissionRequestCallback(
     LogDebug("notificationPermissionRequestCallback called");
     Assert(data);
     ViewLogic* This = static_cast<ViewLogic*>(data);
-    if (This->m_model->WebNotificationUsage.Get() == WrtDB::SETTINGS_TYPE_OFF) {
-        Ewk_Notification_Permission_Request* request =
-            static_cast<Ewk_Notification_Permission_Request*>(eventInfo);
-        ewk_notification_permission_request_set(
-            request,
-            EINA_FALSE);
-        return;
-    }
 
     Assert(eventInfo);
-    ViewModule::WebNotification::webNotificationPermissionRequest(
+    ViewModule::WebNotificationPermissionSupport::permissionRequest(
         This->m_currentEwkView,
         This->m_securityOriginSupport->getSecurityOriginDAO(),
         eventInfo);
@@ -1455,32 +1438,40 @@ Eina_Bool ViewLogic::orientationLockCallback(
 // Fullscreen API callbacks
 void ViewLogic::enterFullscreenCallback(
     void* data,
-    Evas_Object* /*obj*/,
-    void* /*eventInfo*/)
+    Evas_Object* obj,
+    void* eventInfo)
 {
-    LogInfo("enterFullscreenCallback called");
+    LogDebug("enterFullscreenCallback called");
     Assert(data);
     ViewLogic* This = static_cast<ViewLogic*>(data);
     ViewLogicMessageSupport::setViewmodes(
         This->m_ewkContext,
         "fullscreen");
-    if (!This->m_cbs->toggleFullscreen.empty()) {
-        This->m_cbs->toggleFullscreen(true);
+
+    if (eventInfo) {
+        This->m_isFullscreenByPlatform =
+            *static_cast<Eina_Bool*>(eventInfo) == EINA_TRUE;
+    }
+    if (!This->m_cbs->enterFullscreen.empty()) {
+        This->m_cbs->enterFullscreen(obj);
     }
 }
+
 void ViewLogic::exitFullscreenCallback(
     void* data,
-    Evas_Object* /*obj*/,
+    Evas_Object* obj,
     void* /*eventInfo*/)
 {
-    LogInfo("exitFullscreenCallback called");
+    LogDebug("exitFullscreenCallback called");
     Assert(data);
     ViewLogic* This = static_cast<ViewLogic*>(data);
     ViewLogicMessageSupport::setViewmodes(
         This->m_ewkContext,
         Message::ToInjectedBundle::SET_VIEWMODES_MSGBODY_EXIT);
-    if (!This->m_cbs->toggleFullscreen.empty()) {
-        This->m_cbs->toggleFullscreen(false);
+
+    This->m_isFullscreenByPlatform = false;
+    if (!This->m_cbs->exitFullscreen.empty()) {
+        This->m_cbs->exitFullscreen(obj);
     }
 }
 
@@ -1960,40 +1951,53 @@ void ViewLogic::didRunJavaScriptCallback(
     const char* result,
     void* /*userData*/)
 {
-    LogInfo("didRunJavaScriptCallback called");
-    LogInfo("result = " << result);
+    LogDebug("didRunJavaScriptCallback called");
+    LogDebug("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<intptr_t>(eventInfo));
 
-    LogInfo("Key = [" << keyEvent->keyname << "]");
-    if (!strcmp(keyEvent->keyname, KEY_BACK)) {
-        if (This->m_model->SettingList.Get().getHWkeyEvent() ==
-            HWkeyEvent_Enable)
-        {
-            DispatchEventSupport::dispatchHwKeyEvent(obj, "back");
+    LogDebug("Key = [" << keyType << "]");
+
+    std::string keyName;
+    if (keyType == EA_CALLBACK_BACK) {
+        Assert(obj);
+#if 0 // FIXME!!!! ewk_view_text_selection_clear has not landed yet
+        // Call fullscreen exit API
+        // In case of fullscreen is entered by platform(default video tag),
+        // automatically exit fullscreen when backkey is selected
+        if (This->m_isFullscreenByPlatform) {
+            ewk_view_fullscreen_exit(obj);
+            return;
         }
-        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");
+
+        // Call text selection clear API
+        // In case of current state is selection mode,
+        // application doesn't need to handle back key
+        if (EINA_TRUE == ewk_view_text_selection_clear(obj)) {
+            return;
         }
-        This->m_cbs->hwkey("menu");
+#endif
+        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)
@@ -2006,8 +2010,8 @@ Eina_Bool ViewLogic::windowCloseIdlerCallback(void* data)
 
 Eina_Bool ViewLogic::exceededDatabaseQuotaCallback(Evas_Object* obj,
                                                    Ewk_Security_Origin* origin,
-                                                   const char* /*databaseName*/,
-                                                   unsigned long long expectedQuota,
+                                                   const char* ,
+                                                   unsigned long long ,
                                                    void* data)
 {
     LogDebug("exceededDatabaseQuotaCallback called");
@@ -2025,14 +2029,13 @@ Eina_Bool ViewLogic::exceededDatabaseQuotaCallback(Evas_Object* obj,
         This->m_securityOriginSupport->getSecurityOriginDAO(),
         obj,
         origin,
-        expectedQuota,
         ewk_view_exceeded_database_quota_reply);
     return EINA_TRUE;
 }
 
 Eina_Bool ViewLogic::exceededIndexedDatabaseQuotaCallback(Evas_Object* obj,
                                                           Ewk_Security_Origin* origin,
-                                                          long long expectedQuota,
+                                                          long long ,
                                                           void* data)
 {
     LogDebug("exceededIndexedDatabaseQuotaCallback called");
@@ -2050,14 +2053,13 @@ Eina_Bool ViewLogic::exceededIndexedDatabaseQuotaCallback(Evas_Object* obj,
         This->m_securityOriginSupport->getSecurityOriginDAO(),
         obj,
         origin,
-        expectedQuota,
         ewk_view_exceeded_indexed_database_quota_reply);
     return EINA_TRUE;
 }
 
 Eina_Bool ViewLogic::exceededLocalFileSystemQuotaCallback(Evas_Object* obj,
                                                           Ewk_Security_Origin* origin,
-                                                          long long expectedQuota,
+                                                          long long ,
                                                           void* data)
 {
     LogDebug("exceededLocalFileSystemQuotaCallback called");
@@ -2076,7 +2078,6 @@ Eina_Bool ViewLogic::exceededLocalFileSystemQuotaCallback(Evas_Object* obj,
         This->m_securityOriginSupport->getSecurityOriginDAO(),
         obj,
         origin,
-        expectedQuota,
         ewk_view_exceeded_local_file_system_quota_reply);
     return EINA_TRUE;
 }
@@ -2124,14 +2125,19 @@ void ViewLogic::viewFrameRenderedCallback(
     Evas_Object* /*obj*/,
     void* /*eventInfo*/)
 {
-    //LogInfo("enter");
+    static bool logEnable = (getenv("WRT_FRAME_RENDERED_LOG_ENABLE") != NULL);
+
+    if (logEnable)
+    {
+        LogDebug("enter");
+    }
 }
 
 void ViewLogic::mediacontrolRotateHorizontal(void* data,
                                              Evas_Object* obj,
                                              void* /*eventInfo*/)
 {
-    LogInfo("mediacontrolRotateHorizontal called");
+    LogDebug("mediacontrolRotateHorizontal called");
     Assert(data);
     Assert(obj);
     ViewLogic* This = static_cast<ViewLogic*>(data);
@@ -2148,7 +2154,7 @@ void ViewLogic::mediacontrolRotateVertical(void* data,
                                            Evas_Object* obj,
                                            void* /*eventInfo*/)
 {
-    LogInfo("mediacontrolRotateVertical called");
+    LogDebug("mediacontrolRotateVertical called");
     Assert(data);
     Assert(obj);
     ViewLogic* This = static_cast<ViewLogic*>(data);
@@ -2165,7 +2171,7 @@ void ViewLogic::mediacontrolRotateExit(void* data,
                                        Evas_Object* obj,
                                        void* /*eventInfo*/)
 {
-    LogInfo("mediacontrolRotateExit called");
+    LogDebug("mediacontrolRotateExit called");
     Assert(data);
     Assert(obj);
     ViewLogic* This = static_cast<ViewLogic*>(data);
@@ -2207,7 +2213,7 @@ void ViewLogic::mediacontrolRotateExit(void* data,
 
 Eina_Bool ViewLogic::orientationThresholdTimerCallback(void* data)
 {
-    LogInfo("orientationThresholdTimerCallback");
+    LogDebug("orientationThresholdTimerCallback");
     ViewLogic* This = static_cast<ViewLogic*>(data);
 
     if (This->m_deferredRotateAngle ==
@@ -2263,9 +2269,29 @@ Eina_Bool ViewLogic::orientationThresholdTimerCallback(void* data)
     return ECORE_CALLBACK_CANCEL;
 }
 
+void ViewLogic::popupReplyWaitStart(void* data,
+                                    Evas_Object* /*obj*/,
+                                    void* /*eventInfo*/)
+{
+    LogDebug("called");
+    Assert(data);
+    ViewLogic* This = static_cast<ViewLogic*>(data);
+    This->m_isPopupReplyWait = true;
+}
+
+void ViewLogic::popupReplyWaitFinish(void* data,
+                                     Evas_Object* /*obj*/,
+                                     void* /*eventInfo*/)
+{
+    LogDebug("called");
+    Assert(data);
+    ViewLogic* This = static_cast<ViewLogic*>(data);
+    This->m_isPopupReplyWait = false;
+}
+
 void ViewLogic::requestUrlBlocked(const std::string& blockedUrl)
 {
-    LogInfo("enter");
+    LogDebug("enter");
 
     // block this page and open it in browser
     LogDebug("Request was blocked : " << blockedUrl);
@@ -2305,10 +2331,6 @@ void ViewLogic::windowClose()
         // get latest ewkView
         m_currentEwkView = m_ewkViewList.back();
 
-        // resume ewkView
-        /* In case we support many pages in parallel
-         * then view is not suspended*/
-        //resumeEwkView(m_currentEwkView);
         setEwkViewVisible(m_currentEwkView);
 
         // show ewkView