adding new popups for indexeddb, app cache and FS access request
[framework/osp/web.git] / src / controls / FWebCtrl_WebImpl.cpp
index a3d5ff4..f9ae898 100755 (executable)
@@ -72,6 +72,7 @@
 #include <FBase_StringConverter.h>
 #include <FCnt_DownloadManagerImpl.h>
 #include <FGrp_CoordinateSystem.h>
+#include <FGrp_Screen.h>
 #include <FIo_DatabaseImpl.h>
 #include <FIo_NormalFile.h>
 #include <FSys_VibratorImpl.h>
@@ -144,6 +145,7 @@ static const int MAX_TEXT_MATCH = pow(2, 31) - 1;
 
 static const int PORTRAIT_KEYPAD_HEIGHT = 444;
 static const int LANDSCAPE_KEYPAD_HEIGHT = 316;
+static const int DEFAULT_LIST_ITEM_COUNT = 4;
 
 
 Eina_Bool
@@ -337,20 +339,15 @@ OnScriptAlertRequested(Evas_Object* pView, const char* pMessage, void* pUserData
 {
        SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
 
-       result r = E_SUCCESS;
-
+       _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
        String msg(pMessage);
 
-       MessageBox messageBox;
-       r = messageBox.Construct(L"", msg, MSGBOX_STYLE_OK);
-       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
-
-       int modalResult = 0;
-       r = messageBox.ShowAndWait(modalResult);
-       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
+       result r = pImpl->ShowUserConfirmPopupAsync(USER_SCRIPT_ALERT, pView, msg);
+       SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       return EINA_TRUE;
 
+CATCH:
        ewk_view_javascript_alert_reply(pView);
-
        return EINA_TRUE;
 }
 
@@ -361,7 +358,7 @@ OnScriptConfirmRequested(Evas_Object* pView, const char* pMessage, void* pUserDa
        SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
 
        result r = E_SUCCESS;
-
+       _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
        String msg(pMessage);
 
        MessageBox messageBox;
@@ -369,6 +366,9 @@ OnScriptConfirmRequested(Evas_Object* pView, const char* pMessage, void* pUserDa
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
 
        int modalResult = 0;
+
+       messageBox.SetOwner(&pImpl->GetPublic());
+
        r = messageBox.ShowAndWait(modalResult);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
 
@@ -391,32 +391,29 @@ OnScriptPromptRequested(Evas_Object* pView, const char* pMessage, const char* pD
        SysLog(NID_WEB_CTRL, "The current value of message is %s, defaulValue is %s", pMessage, pDefaultValue);
 
        result r = E_SUCCESS;
-
+       _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
        String msg(pMessage);
        String defVal(pDefaultValue);
 
-       int modalResult = -1;
-       Eina_Bool returnValue = EINA_TRUE;
-       _PromptPopup pPromptPopup;
+       std::unique_ptr< _PromptPopup > pPromptPopup(new (std::nothrow) _PromptPopup());
+       SysTryCatch(NID_WEB_CTRL, pPromptPopup.get(), , E_OUT_OF_MEMORY, "Memory allocation failed.");
 
-       r = pPromptPopup.Construct(msg, defVal);
-       SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, returnValue = EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
+       r = pPromptPopup->Construct(msg, defVal, pView);
+       SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
 
-       r = pPromptPopup.ShowAndWait(modalResult);
-       SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, returnValue = EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
+       pPromptPopup->SetOwner(&pImpl->GetPublic());
 
-       if (modalResult == ID_BUTTON_PROMPT_OK)
-       {
-               std::unique_ptr<char[]> pResult(_StringConverter::CopyToCharArrayN(pPromptPopup.GetPromptText()));
-               SysTryCatch(NID_WEB_CTRL, pResult.get(), returnValue = EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       r = pPromptPopup->ShowPopup();
+       SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
 
-               ewk_view_javascript_prompt_reply(pView, pResult.get());
-               return EINA_TRUE;
-       }
+       pPromptPopup.release();
+
+       return EINA_TRUE;
 
 CATCH:
        ewk_view_javascript_prompt_reply(pView, null);
-       return returnValue;
+
+       return EINA_FALSE;
 }
 
 
@@ -496,6 +493,76 @@ OnHttpAuthenticationCanceled(void* pUserData, Evas_Object* pView, void* pEventIn
        }
 }
 
+Eina_Bool
+OnApplicationCachePermissionRequested(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin,  void* pUserData)
+{
+       _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
+       SysAssertf(pImpl , "Failed to request");
+
+       const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
+       String msg;
+       result r = msg.Format(256, L"Allow %s to use offline application cache?", pHostName);
+       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_APP_CACHE, pView, msg);
+       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return EINA_TRUE;
+}
+
+
+Eina_Bool
+OnIndexedDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin,  long long currentQuota, void* pUserData)
+{
+       _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
+       SysAssertf(pImpl , "Failed to request");
+
+       const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
+       String msg;
+       result r = msg.Format(512, L"%s Used %lld of storage. Allow %s to use upto 2GB of indexed db?", pHostName, currentQuota, pHostName);
+       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED, pView, msg);
+       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return EINA_TRUE;
+}
+
+
+Eina_Bool
+OnDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, const char* database_name, unsigned long long expectedQuota, void* pUserData)
+{
+       _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
+       SysAssertf(pImpl , "Failed to request");
+
+       const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
+       String msg;
+       result r = msg.Format(512, L"Allow %s to open  %s use upto %lld  of web database?", pHostName, database_name, expectedQuota);
+       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_DB_QUOTA_EXCEDED, pView, msg);
+       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return EINA_TRUE;
+}
+
+
+Eina_Bool OnLocalFileSystemQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin,  long long currentQuota, void* pUserData)
+{
+       _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
+       SysAssertf(pImpl , "Failed to request");
+
+       const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
+       String msg;
+       result r = msg.Format(512, L"%s Used %lld of storgae. Allow %s to use upto 2GB of file system?", pHostName, currentQuota, pHostName);
+       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED, pView, msg);
+       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return EINA_TRUE;
+}
+
 
 void
 OnGeolocationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
@@ -571,25 +638,18 @@ OnNotificationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEv
 {
        result r = E_SUCCESS;
        _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
+
        Ewk_Notification_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Notification_Permission_Request* >(pEventInfo);
        SysAssertf(pImpl && pPermissionRequest, "Failed to request");
 
-       MessageBox messageBox;
-       r = messageBox.Construct(L"Notification request", L"Do you want to allow notifications from this site ?", MSGBOX_STYLE_OKCANCEL);
-       SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+       ewk_notification_permission_request_suspend(pPermissionRequest);
 
-       int modalResult = 0;
-       r = messageBox.ShowAndWait(modalResult);
-       SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+       r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_NOTIFICATION, pPermissionRequest);
+       SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       return;
 
-       if (modalResult == MSGBOX_RESULT_OK)
-       {
-               ewk_notification_permission_request_set(pPermissionRequest, EINA_TRUE);
-       }
-       else
-       {
-               ewk_notification_permission_request_set(pPermissionRequest, EINA_FALSE);
-       }
+CATCH:
+       ewk_notification_permission_request_set(pPermissionRequest, EINA_FALSE);
 }
 
 
@@ -608,12 +668,12 @@ OnNotificationShow(void* pUserData, Evas_Object* pView, void* pEventInfo)
        //ewk_notification_security_origin_get(pNotification)
 
        const char* text = ewk_notification_body_get(pNotification);
-       SysLog(NID_WEB_CTRL, "The current value of icon path is %s",ewk_notification_icon_url_get(pNotification));
+       SysSecureLog(NID_WEB_CTRL, "The current value of icon path is %s",ewk_notification_icon_url_get(pNotification));
 
        std::unique_ptr<_WebNotification> pNotificationWindow( new (std::nothrow) _WebNotification());
        SysTryReturnVoidResult(NID_WEB_CTRL, pNotificationWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
-       r = pNotificationWindow->Construct(pContext, notificationId);
+       r = pNotificationWindow->Construct(pContext, notificationId, pImpl);
        SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Error propogated.", GetErrorMessage(r));
 
        pNotificationWindow->SetText(String(text));
@@ -766,15 +826,6 @@ OnVibrationCanceled(void* pUserData)
 }
 
 
-Eina_Bool
-OnApplicationCachePermissionRequested(Evas_Object* pView, Ewk_Security_Origin* pOrigin, void* pUserData)
-{
-       ewk_view_application_cache_permission_reply(pView, EINA_TRUE);
-
-       return EINA_TRUE;
-}
-
-
 void
 OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
 {
@@ -783,7 +834,7 @@ OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
        SysAssertf(pImpl && pPolicy, "Failed to request");
 
        String url(ewk_policy_decision_url_get(pPolicy));
-       SysLog(NID_WEB_CTRL, "The current value of url is %ls", url.GetPointer());
+       SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls", url.GetPointer());
 
        if (url == L"about:blank")
        {
@@ -988,7 +1039,7 @@ OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
        const char* pUrl = ewk_policy_decision_url_get(pPolicy);
        int code = ewk_policy_decision_response_status_code_get(pPolicy);
        String mime(ewk_policy_decision_response_mime_get(pPolicy));
-       SysLog(NID_WEB_CTRL, "url : %s, mime : %ls, code : %d", pUrl, mime.GetPointer(), code);
+       SysSecureLog(NID_WEB_CTRL, "url : %s, mime : %ls, code : %d", pUrl, mime.GetPointer(), code);
 
        ILoadingListener* pLoadingListener = pImpl->GetLoadingListener();
 
@@ -1273,7 +1324,7 @@ OnDidStartDownloadCallback(const char* pUrl, void* pUserData)
        _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
        SysAssertf(pUrl && pImpl != null, "Failed to request");
 
-       SysLog(NID_WEB_CTRL, "The current value of url is %s", pUrl);
+       SysSecureLog(NID_WEB_CTRL, "The current value of url is %s", pUrl);
 }
 
 
@@ -1513,8 +1564,7 @@ void
 OnWebPageBlockSelected(void* pUserData, Evas_Object* pView, void* pEventInfo)
 {
        _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
-       Ewk_Text_Style* pStyle = reinterpret_cast< Ewk_Text_Style* >(pEventInfo);
-       SysAssertf(pImpl && pStyle, "Failed to request");
+       SysAssertf(pImpl, "Failed to request");
 
        if (pImpl->GetUiEventListener())
        {
@@ -1533,6 +1583,42 @@ OnWebPageBlockSelected(void* pUserData, Evas_Object* pView, void* pEventInfo)
 }
 
 
+void
+OnWebPageBlockSelectedByOrientation(void* pUserData, Evas_Object* pView, void* pEventInfo)
+{
+       _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
+       SysAssertf(pImpl, "Failed to request");
+
+       if (!pImpl->IsOrientationChanged())
+       {
+               return;
+       }
+
+       pImpl->SetOrientationChanged(false);
+
+       int orientation = 0;
+       _ControlRotation rotation = _ControlManager::GetInstance()->GetOrientationStatus();
+       switch (rotation)
+       {
+               case _CONTROL_ROTATION_0:
+                       orientation =  0;
+                       break;
+               case _CONTROL_ROTATION_90:
+                       orientation =  90;
+                       break;
+               case _CONTROL_ROTATION_180:
+                       orientation =  180;
+                       break;
+               case _CONTROL_ROTATION_270:
+                       orientation =  -90;
+                       break;
+       }
+       ewk_view_orientation_send(pView, orientation);
+
+       OnWebPageBlockSelected(pUserData, pView, pEventInfo);
+}
+
+
 Eina_Bool
 OnSelectUploadFile(Evas_Object* pView, Eina_Bool multipleFile, Eina_List* pAcceptTypes, const char* pCapture, void* pUserData)
 {
@@ -1907,7 +1993,11 @@ OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData)
        String result(pResult);
        SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer());
 
-       pPresenter->EndAsyncProcess(result);
+       _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, WEB_CTRL));
+       if (pImpl && pImpl->IsPresenterAlived(pPresenter))
+       {
+               pPresenter->EndAsyncProcess(result);
+       }
 }
 
 
@@ -2017,6 +2107,7 @@ _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
        , __isRedirectRequested(false)
        , __isCertificateRequested(false)
        , __isCertificateConfirmed(false)
+       , __isOrientationChanged(false)
        , __keypadBounds(0, 0, 0, 0)
        , __pWebCore(null)
        , __pUserLoadingListener(null)
@@ -2039,6 +2130,7 @@ _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
        , __pColorPicker(null)
        , __pVibrator(null)
        , __policy(WEB_DECISION_CONTINUE)
+       , __defaultUserAgent(L"")
 {
        __textSearch.__searchAll = false;
        __textSearch.__searchForward = true;
@@ -2128,6 +2220,9 @@ _WebImpl::Construct(void)
        r = __textSearch.__searchQueue.Construct();
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
+       r = __callbackList.Construct();
+       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
        r = InitJsBridgeList();
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
@@ -2146,15 +2241,18 @@ _WebImpl::InitializeSetting(void)
 {
        result r = E_SUCCESS;
 
-       r = SetSetting(*__pWebCore->GetSetting());
-       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
-
-       _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting());
+       WebSetting* pWebSetting = __pWebCore->GetSetting();
+       _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(pWebSetting);
 
        SetCookieEnabled(pWebSettingImpl->IsCookieEnabled());
        SetPrivateBrowsingEnabled(pWebSettingImpl->IsPrivateBrowsingEnabled());
        SetZoomLevel(pWebSettingImpl->GetZoomLevel());
 
+       __defaultUserAgent = pWebSettingImpl->GetUserAgent();
+
+       r = SetSetting(*pWebSetting);
+       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
        SetEventListenerCallback();
 
        return E_SUCCESS;
@@ -2312,15 +2410,14 @@ _WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List*
 {
        __pSelectBox.reset();
 
-       int itemCount = eina_list_count(pItems);
-       SysTryReturnResult(NID_WEB_CTRL, itemCount > 0, E_SYSTEM, "ItemCount is invalid.");
+       SysTryReturnResult(NID_WEB_CTRL, eina_list_count(pItems) > 0, E_SYSTEM, "ItemCount is invalid.");
 
        result r = E_SUCCESS;
 
        std::unique_ptr<_SelectBox> pSelectBox(new (std::nothrow) _SelectBox());
        SysTryReturnResult(NID_WEB_CTRL, pSelectBox.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
 
-       r = pSelectBox->Construct(isMultiSelect, title, itemCount, pWebView);
+       r = pSelectBox->Construct(isMultiSelect, title, DEFAULT_LIST_ITEM_COUNT, pWebView);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
        r = pSelectBox->UpdateList(pItems, selectedIndex, false, false);
@@ -2328,6 +2425,8 @@ _WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List*
 
        __pSelectBox = std::move(pSelectBox);
 
+       __pSelectBox->SetOwner(&GetPublic());
+
        return __pSelectBox->ShowPopup();
 }
 
@@ -2433,26 +2532,42 @@ _WebImpl::Reload(void) const
 
 
 String*
-_WebImpl::EvaluateJavascriptN(const String& scriptCode) const
+_WebImpl::EvaluateJavascriptN(const String& scriptCode)
 {
-       if (scriptCode.GetLength())
+       if (scriptCode.GetLength() == 0)
        {
-               std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(scriptCode));
-               SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+               return null;
+       }
+       
+       result r = E_SUCCESS;
 
-               _WebPresenter presenter;
-               presenter.InitAsyncProcess();
+       std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(scriptCode));
+       SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
 
-               ewk_view_script_execute(__pWebCore->GetWebNativeNode(), pScript.get(), OnScriptExecuted, &presenter);
+       std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter());
+       SysTryReturn(NID_WEB_CTRL, pPresenter.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
-               Tizen::Base::String* pResult = new (std::nothrow) Tizen::Base::String(L"");
-               SysTryReturn(NID_WEB_CTRL, pResult, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
-               presenter.WaitAsyncProcess(*pResult);
+       r = __callbackList.Add(pPresenter.get());
+       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
-               return pResult;
-       }
+       ewk_view_script_execute(__pWebCore->GetWebNativeNode(), pScript.get(), OnScriptExecuted, pPresenter.get());
 
-       return null;
+       std::unique_ptr<String> pResult(new (std::nothrow) String(L""));
+       SysTryReturn(NID_WEB_CTRL, pResult.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       pPresenter->WaitAsyncProcess(*pResult.get());
+       
+       r = __callbackList.Remove(*pPresenter.get());
+       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+       pPresenter.release();
+       
+       return pResult.release();
+}
+
+
+bool
+_WebImpl::IsPresenterAlived(_WebPresenter* pPresenter) const
+{
+       return __callbackList.Contains(*pPresenter);
 }
 
 
@@ -2526,7 +2641,7 @@ _WebImpl::GetBackForwardListN(void) const
 
                url = ewk_history_item_uri_get(pEwkItem);
                title = ewk_history_item_title_get(pEwkItem);
-               SysLog(NID_WEB_CTRL, "The current value of url is %s, title is %s", url.GetPointer(), title.GetPointer());
+               SysSecureLog(NID_WEB_CTRL, "The current value of url is %s, title is %s", url.GetPointer(), title.GetPointer());
 
                pHistoryItemImpl->SetHistoryItem(url, title);
 
@@ -2776,10 +2891,13 @@ _WebImpl::SetSetting(const WebSetting& setting)
 
                ewk_settings_loads_images_automatically_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoImageLoadEnabled()));
 
-               std::unique_ptr<char[]> pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent()));
-               SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+               if (__defaultUserAgent != setting.GetUserAgent())
+               {
+                       std::unique_ptr<char[]> pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent()));
+                       SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
 
-               ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get());
+                       ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get());
+               }
 
                ewk_settings_auto_fitting_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFittingEnabled()));
 
@@ -2820,6 +2938,15 @@ _WebImpl::GetSetting(void) const
 const HitElementResult*
 _WebImpl::GetElementByPointN(const Point& point) const
 {
+       return GetElementByPointN(_CoordinateSystemUtils::ConvertToFloat(point));
+}
+
+
+const HitElementResult*
+_WebImpl::GetElementByPointN(const FloatPoint& point) const
+{
+       SysTryReturn(NID_WEB_CTRL, Contains(point), null, E_INVALID_ARG, "[%s] The point must be contained in the bounds of a web control.", GetErrorMessage(E_INVALID_ARG));
+
        result r = E_SUCCESS;
 
        _HitElementResultImpl* pHitElementResultImpl = null;
@@ -2828,7 +2955,7 @@ _WebImpl::GetElementByPointN(const Point& point) const
        std::unique_ptr<Bitmap> pImage;
        std::unique_ptr<HashMap, AllElementsDeleter> pAttributeMap;
 
-       Point absPoint(__pWebCore->GetAbsoluteCoordinate(point));
+       Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(point)));
 
        Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(__pWebCore->GetWebNativeNode(), absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
        SysTryReturn(NID_WEB_CTRL, pEwkHitTest, null, E_SYSTEM, "[%s] Failed to get hit test.", GetErrorMessage(E_SYSTEM));
@@ -2839,7 +2966,7 @@ _WebImpl::GetElementByPointN(const Point& point) const
        String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
        String nodeValue(ewk_hit_test_node_value_get(pEwkHitTest));
 
-       SysLog(NID_WEB_CTRL, "The current value of url is %ls, tag is %ls, value is %ls", url.GetPointer(), tagName.GetPointer(), nodeValue.GetPointer());
+       SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls, tag is %ls, value is %ls", url.GetPointer(), tagName.GetPointer(), nodeValue.GetPointer());
 
        pHitElementResult = std::unique_ptr<HitElementResult>(new (std::nothrow) HitElementResult());
        SysTryCatch(NID_WEB_CTRL, pHitElementResult.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
@@ -2922,18 +3049,6 @@ CATCH:
 }
 
 
-const HitElementResult*
-_WebImpl::GetElementByPointN(const FloatPoint& point) const
-{
-       const Point integerPoint(_CoordinateSystemUtils::ConvertToInteger(point));
-
-       std::unique_ptr<const HitElementResult> pHitElementResult(GetElementByPointN(integerPoint));
-       SysTryReturn(NID_WEB_CTRL, pHitElementResult.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
-
-       return pHitElementResult.release();
-}
-
-
 bool
 _WebImpl::IsLoading(void) const
 {
@@ -3397,13 +3512,18 @@ _WebImpl::SetEventListenerCallback(void) const
                evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this);
 
                evas_object_smart_callback_add(pWebNativeNode, "text,style,state", OnWebPageBlockSelected, this);
+               evas_object_smart_callback_add(pWebNativeNode, "frame,rendered", OnWebPageBlockSelectedByOrientation, this);
 
                ewk_view_open_panel_callback_set(pWebNativeNode, OnSelectUploadFile, const_cast< _WebImpl* >(this));
                Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
                SysAssertf(pContext, "Failed to get webkit instance.");
                ewk_context_did_start_download_callback_set(pContext, OnDidStartDownloadCallback, const_cast< _WebImpl* >(this));
                ewk_context_vibration_client_callbacks_set(pContext, OnVibrationRequested, OnVibrationCanceled, const_cast< _WebImpl* >(this));
+
                ewk_view_application_cache_permission_callback_set(pWebNativeNode, OnApplicationCachePermissionRequested, const_cast< _WebImpl* >(this));
+               ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, OnIndexedDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
+               ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, OnDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
+               ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, OnLocalFileSystemQuotaExceeded, const_cast< _WebImpl* >(this));
 
                evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this);
        }
@@ -3474,12 +3594,17 @@ _WebImpl::RemoveEventListenerCallback(void) const
                evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived);
 
                evas_object_smart_callback_del(pWebNativeNode, "text,style,state", OnWebPageBlockSelected);
+               evas_object_smart_callback_del(pWebNativeNode, "frame,rendered", OnWebPageBlockSelectedByOrientation);
 
                ewk_view_open_panel_callback_set(null, null, null);
                Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
                SysAssertf(pContext, "Failed to get webkit instance.");
                ewk_context_vibration_client_callbacks_set(pContext, null, null, null);
+
                ewk_view_application_cache_permission_callback_set(pWebNativeNode, null, null);
+               ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, null, null);
+               ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, null, null);
+               ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, null, null);
 
                evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained);
        }
@@ -3489,12 +3614,19 @@ _WebImpl::RemoveEventListenerCallback(void) const
 result
 _WebImpl::SetBlockSelectionPosition(const Point& startPoint)
 {
+       return SetBlockSelectionPosition(_CoordinateSystemUtils::ConvertToFloat(startPoint));
+}
+
+
+result
+_WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint)
+{
        Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
 
        Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
        SysAssertf(pSmartData, "Failed to request");
 
-       Point absPoint(__pWebCore->GetAbsoluteCoordinate(startPoint));
+       Point absPoint( _CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(startPoint)));
 
        Eina_Bool ret = pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y);
        if (ret)
@@ -3510,6 +3642,15 @@ _WebImpl::SetBlockSelectionPosition(const Point& startPoint)
                {
                        ewk_view_command_execute(pWebNativeNode, "SelectWord", 0);
                }
+               else
+               {
+                       Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
+                       char* pValue = reinterpret_cast< char* >(eina_hash_find(pAttrHash, "contenteditable"));
+                       if(pValue)
+                       {
+                               ewk_view_command_execute(pWebNativeNode, "SelectWord", 0);
+                       }
+               }
        }
 
        SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up.");
@@ -3518,17 +3659,10 @@ _WebImpl::SetBlockSelectionPosition(const Point& startPoint)
 }
 
 
-result
-_WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint)
-{
-       return SetBlockSelectionPosition(_CoordinateSystemUtils::ConvertToInteger(startPoint));
-}
-
-
 void
 _WebImpl::ReleaseBlock(void)
 {
-       ewk_view_command_execute(__pWebCore->GetWebNativeNode(), "Unselect", 0);
+       ewk_view_text_selection_range_clear(__pWebCore->GetWebNativeNode());
 }
 
 
@@ -3709,6 +3843,20 @@ _WebImpl::IsCertificateConfirmed(void) const
 }
 
 
+void
+_WebImpl::SetOrientationChanged(bool arg)
+{
+       __isOrientationChanged = arg;
+}
+
+
+bool
+_WebImpl::IsOrientationChanged(void) const
+{
+       return __isOrientationChanged;
+}
+
+
 result
 _WebImpl::LaunchAppControl(const IEventArg& arg)
 {
@@ -4294,6 +4442,9 @@ _WebImpl::ShowAuthenticationPopup(const String& host, const String& realm, Authe
        __pAuthPopup = std::move(pAuthPopup);
 
        int modalResult = 0;
+
+       __pAuthPopup->SetOwner(&GetPublic());
+       
        r = __pAuthPopup->ShowAndWait(modalResult);
        SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
 
@@ -4318,6 +4469,9 @@ _WebImpl::ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk
        __pCertConfirmPopup = std::move(pCertConfirmPopup);
 
        int modalResult = 0;
+
+       __pCertConfirmPopup->SetOwner(&GetPublic());
+       
        r = __pCertConfirmPopup->ShowAndWait(modalResult);
        SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
 
@@ -4333,19 +4487,22 @@ CATCH:
 }
 
 result
-_WebImpl::ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy)
+_WebImpl::ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
 {
        result r = E_SUCCESS;
 
        std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
        SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
 
-       r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, true);
+       r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, true, msg);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
        __pUserConfirmPopup = std::move(pUserConfirmPopup);
 
        int modalResult = 0;
+
+       __pUserConfirmPopup->SetOwner(&GetPublic());
+       
        r = __pUserConfirmPopup->ShowAndWait(modalResult);
        SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
        
@@ -4356,18 +4513,20 @@ CATCH:
 }
 
 result
-_WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy)
+_WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
 {
        result r = E_SUCCESS;
 
        std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
        SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
 
-       r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, false);
+       r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, false, msg);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
        __pUserConfirmPopup = std::move(pUserConfirmPopup);
 
+       __pUserConfirmPopup->SetOwner(&GetPublic());
+
        r = __pUserConfirmPopup->ShowPopup();
        SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
 
@@ -4440,7 +4599,7 @@ _WebImpl::HasValidNativeNode(void) const
 
 
 result
-_WebImpl::OnAttachedToMainTree(void)
+_WebImpl::OnPreAttachedToMainTree(void)
 {
        result r = E_SUCCESS;
 
@@ -4450,7 +4609,7 @@ _WebImpl::OnAttachedToMainTree(void)
        r = InitializeSetting();
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
-       r = _ContainerImpl::OnAttachedToMainTree();
+       r = _ContainerImpl::OnPreAttachedToMainTree();
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
        return E_SUCCESS;
@@ -4466,6 +4625,8 @@ _WebImpl::OnChangeLayout(_ControlOrientation orientation)
        {
                __pColorPicker->ChangeLayout(orientation);
        }
+
+       __isOrientationChanged = true;
 }
 
 
@@ -4509,7 +4670,7 @@ _WebImpl::ShowColorPicker(int red, int green, int blue, int alpha, Color& color)
 
        Tizen::Graphics::Color colorVal(static_cast< byte >(red), static_cast< byte >(green), static_cast< byte >(blue), static_cast< byte >(alpha));
 
-       r = pColorHadler->Construct(colorVal);
+       r = pColorHadler->Construct(colorVal, this);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
        __pColorPicker = std::move(pColorHadler);
@@ -4536,7 +4697,7 @@ _WebImpl::ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue, Strin
        std::unique_ptr<_InputPickerPopup> pInputPicker(new (std::nothrow) _InputPickerPopup());
        SysTryReturnResult(NID_WEB_CTRL, pInputPicker.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
 
-       r = pInputPicker->Construct(String(inputValue), inputType);
+       r = pInputPicker->Construct(String(inputValue), inputType, this);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
        __pDatePicker = std::move(pInputPicker);
@@ -4588,7 +4749,7 @@ _WebImpl::SearchHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
        String uri(ewk_custom_handlers_data_url_get(pHandlerData));
        String target(ewk_custom_handlers_data_target_get(pHandlerData));
 
-       SysLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
+       SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
        
        result r = db.Construct(handlerPath, "r+", null);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
@@ -4633,7 +4794,7 @@ _WebImpl::UnregistrationHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool che
        String uri(ewk_custom_handlers_data_url_get(pHandlerData));
        String target(ewk_custom_handlers_data_target_get(pHandlerData));
        
-       SysLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
+       SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
        
        result r = db.Construct(handlerPath, "r+", null);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));