alert popup change to modal less - async
authorBINDUCHAITANYA TUMMALA <bc.tummala@samsung.com>
Fri, 26 Apr 2013 08:50:25 +0000 (14:20 +0530)
committerBINDUCHAITANYA TUMMALA <bc.tummala@samsung.com>
Fri, 26 Apr 2013 08:50:25 +0000 (14:20 +0530)
Change-Id: I8f732a3d8514c365e25bcc7a140a42056bd26b35
Signed-off-by: BINDUCHAITANYA TUMMALA <bc.tummala@samsung.com>
src/controls/FWebCtrl_UserConfirmPopup.cpp
src/controls/FWebCtrl_UserConfirmPopup.h
src/controls/FWebCtrl_WebImpl.cpp
src/controls/FWebCtrl_WebImpl.h

index fe9140c..a7b2135 100755 (executable)
@@ -70,11 +70,11 @@ _UserConfirmPopup::~_UserConfirmPopup(void)
 
 
 result
-_UserConfirmPopup::Construct(_UserConfirmMode userConfirmMode, void* pEventInfo, bool sync)
+_UserConfirmPopup::Construct(_UserConfirmMode userConfirmMode, void* pEventInfo, bool sync, String msg)
 {
        result r = E_SUCCESS;
        SysTryReturnResult(NID_WEB_CTRL, pEventInfo, E_INVALID_ARG, "Invalid argument(s) is used. pPolicy is null.");
-       SysTryReturnResult(NID_WEB_CTRL, userConfirmMode >= USER_CONFIRM_USERMEDIA && userConfirmMode <= USER_CONFIRM_NOTIFICATION, E_INVALID_ARG,
+       SysTryReturnResult(NID_WEB_CTRL, userConfirmMode >= USER_CONFIRM_USERMEDIA && userConfirmMode <= USER_SCRIPT_ALERT, E_INVALID_ARG,
                                        "Invalid userConfirmMode is used. [%d]", userConfirmMode);
 
        _WebPopupData* pPopupData = _WebPopup::GetPopupData();
@@ -84,16 +84,27 @@ _UserConfirmPopup::Construct(_UserConfirmMode userConfirmMode, void* pEventInfo,
        __userConfirmMode = userConfirmMode;
        __sync = sync;
 
+       bool hasTitle = true;
        int popupMaxHeight = 2*pPopupData->labelDim.height + 2*pPopupData->btnDim.height + 6*pPopupData->sideMargin;
+
        if (__userConfirmMode == USER_CONFIRM_GEOLOCATION)
        {
                popupMaxHeight +=  pPopupData->checkDim.height;
        }
 
-       r = _WebPopup::Construct(true, Dimension(pPopupData->popupDim.width, popupMaxHeight));
+       if (__userConfirmMode == USER_SCRIPT_ALERT)
+       {
+               popupMaxHeight -=  pPopupData->labelDim.height;
+               hasTitle = false;
+       }
+
+       r = _WebPopup::Construct(hasTitle, Dimension(pPopupData->popupDim.width, popupMaxHeight));
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
-       SetTitleText("Security Warning");
+       if (userConfirmMode != USER_SCRIPT_ALERT)
+       {
+               SetTitleText("Security Warning");
+       }
 
        Rectangle rect(0, 0, 0, 0);
 
@@ -104,7 +115,15 @@ _UserConfirmPopup::Construct(_UserConfirmMode userConfirmMode, void* pEventInfo,
        std::unique_ptr<Label> pLabel(new (std::nothrow) Label());
        SysTryReturnResult(NID_WEB_CTRL, pLabel.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
 
-       String message = GetMessageFromPolicy();
+       String message = L"";
+       if (userConfirmMode == USER_SCRIPT_ALERT)
+       {
+               message = msg;
+       }
+       else
+       {
+               message = GetMessageFromPolicy();
+       }
        r = pLabel->Construct(rect, message);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
@@ -138,14 +157,22 @@ _UserConfirmPopup::Construct(_UserConfirmMode userConfirmMode, void* pEventInfo,
        ArrayList idList;
        r = idList.Construct();
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
-       idList.Add(*(new Integer(ID_BUTTON_USER_ALLOW)));
-       idList.Add(*(new Integer(ID_BUTTON_USER_CANCEL)));
 
        ArrayList titleList;
        r = titleList.Construct();
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
-       titleList.Add(*(new String(L"Allow")));
-       titleList.Add(*(new String(L"Cancel")));
+
+       idList.Add(*(new Integer(ID_BUTTON_USER_ALLOW)));
+       if (userConfirmMode == USER_SCRIPT_ALERT)
+       {
+               titleList.Add(*(new String(L"OK")));
+       }
+       else
+       {
+               idList.Add(*(new Integer(ID_BUTTON_USER_CANCEL)));
+               titleList.Add(*(new String(L"Allow")));
+               titleList.Add(*(new String(L"Cancel")));
+       }
 
        r = CreateAndAddButtons(idList, titleList, pButtonPanel);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
@@ -296,6 +323,12 @@ CATCH:
                ewk_notification_permission_request_set(pPermissionRequest, allow);
                break;
        }
+       case USER_SCRIPT_ALERT:
+       {
+               Evas_Object* pView = reinterpret_cast< Evas_Object* >(__pUserPolicyData);
+               ewk_view_javascript_alert_reply(pView);
+               break;
+       }
        default:
                SysAssert(false);
        }
index 22b2852..b090c3c 100755 (executable)
@@ -49,7 +49,8 @@ enum _UserConfirmMode
        USER_CONTENT_HANDLER,
        USER_PROTOCOL_HANDLER,
        USER_CONFIRM_GEOLOCATION,
-       USER_CONFIRM_NOTIFICATION
+       USER_CONFIRM_NOTIFICATION,
+       USER_SCRIPT_ALERT
 };
 
 class _UserConfirmPopup
@@ -67,7 +68,7 @@ public:
         */
        virtual ~_UserConfirmPopup(void);
 
-       result Construct(_UserConfirmMode userConfirmMode, void* pEventInfo, bool sync = false);
+       result Construct(_UserConfirmMode userConfirmMode, void* pEventInfo, bool sync = false, Tizen::Base::String msg = L"");
 
        virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
 
index 00f106b..611a5a0 100755 (executable)
@@ -337,23 +337,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;
-
-       messageBox.SetOwner(&pImpl->GetPublic());
-
-       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;
 }
 
@@ -4364,14 +4356,14 @@ 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);
index ee9a88b..61a1981 100755 (executable)
@@ -336,7 +336,7 @@ public:
        result ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk_Certificate_Policy_Decision *pPolicy);
 
        result ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy);
-       result ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy);
+       result ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy, Tizen::Base::String msg = L"");
 
        Tizen::Ui::Controls::_Form* GetParentFormCore(Tizen::Ui::_Control* pControlCore);