apply before confirm popup
authorSeongjun Yim <se201.yim@samsung.com>
Mon, 14 Oct 2013 08:29:23 +0000 (17:29 +0900)
committerSeongjun Yim <se201.yim@samsung.com>
Mon, 14 Oct 2013 08:29:23 +0000 (17:29 +0900)
Change-Id: Ie6c7d1da51bbfbe0ce5d7925b51e01fc917a92b0
Signed-off-by: Seongjun Yim <se201.yim@samsung.com>
src/controls/FWebCtrl_SelectBox.cpp
src/controls/FWebCtrl_UserConfirmPopup.cpp
src/controls/FWebCtrl_WebImpl.cpp
src/controls/inc/FWebCtrl_UserConfirmPopup.h
src/controls/inc/FWebCtrl_WebImpl.h

index 7f38319..a129b40 100755 (executable)
@@ -190,7 +190,7 @@ _SelectBox::Construct(Tizen::Web::Controls::_WebImpl* pImpl, bool isMultiSelect,
        _WebPopupData* pPopupData = _WebPopup::GetPopupData();
        SysTryReturn(NID_WEB_CTRL, pPopupData, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
 
-       listMaxHeihgt = listCount * listItemHeight + pPopupData->panelHeight;
+       listMaxHeihgt = listCount * listItemHeight;
 
        rect.height = listMaxHeihgt;
        rect.width = pPopupData->popupDim.width;
@@ -224,37 +224,32 @@ _SelectBox::Construct(Tizen::Web::Controls::_WebImpl* pImpl, bool isMultiSelect,
 
        __pListView = pListView.release();
 
-       Panel* pButtonPanel = CreateAndAddPanel();
-       SysTryReturn(NID_WEB_CTRL, pButtonPanel, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
+       if (__multiSelection)
+       {
+               Panel* pButtonPanel = CreateAndAddPanel();
+               SysTryReturn(NID_WEB_CTRL, pButtonPanel, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
 
-       _SystemResource* pSysResource = _SystemResource::GetInstance();
-       SysAssertf(pSysResource != null, "Failed to get _SystemResource instance");
+               _SystemResource* pSysResource = _SystemResource::GetInstance();
+               SysAssertf(pSysResource != null, "Failed to get _SystemResource instance");
 
-       ArrayList idList;
-       r = idList.Construct();
-       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+               ArrayList idList;
+               r = idList.Construct();
+               SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
-       idList.Add(*(new Integer(ID_BUTTON_CANCEL)));
-       if (__multiSelection)
-       {
                idList.Add(*(new Integer(ID_BUTTON_SELECTION)));
-       }
 
-       ArrayList titleList;
-       r = titleList.Construct();
-       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+               ArrayList titleList;
+               r = titleList.Construct();
+               SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
-       titleList.Add(*(new String(pSysResource->GetString(_RESOURCE_DOMAIN_ID_OSP, "IDS_TPLATFORM_BUTTON_CANCEL_ABB"))));
-       if (__multiSelection)
-       {
                titleList.Add(*(new String(pSysResource->GetString(_RESOURCE_DOMAIN_ID_OSP, "IDS_TPLATFORM_BUTTON_OK"))));
 
                __pToggledArray = eina_inarray_new(sizeof(int), 0);
                SysTryReturnResult(NID_WEB_CTRL, __pToggledArray, E_OUT_OF_MEMORY, "Memory Allocation failed.");
-       }
 
-       r = CreateAndAddButtons(idList, titleList, pButtonPanel);
-       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+               r = CreateAndAddButtons(idList, titleList, pButtonPanel);
+               SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
 
        SetPropagatedKeyEventListener(this);
        
index 9c99b70..c73961e 100755 (executable)
@@ -259,6 +259,13 @@ _UserConfirmPopup::Construct(_UserConfirmMode userConfirmMode, void* pEventInfo,
                idList.Add(*(new Integer(ID_BUTTON_USER_ALLOW)));
                titleList.Add(*(new String(pSysResource->GetString(_RESOURCE_DOMAIN_ID_OSP, "IDS_TPLATFORM_BUTTON_OK"))));
        }
+       else if (userConfirmMode == USER_BEFORE_UNLOAD_CONFIRM)
+       {
+               idList.Add(*(new Integer(ID_BUTTON_USER_CANCEL)));
+               idList.Add(*(new Integer(ID_BUTTON_USER_ALLOW)));
+               titleList.Add(*(new String(L"Leave")));
+               titleList.Add(*(new String(L"Stay")));
+       }
        else
        {
                idList.Add(*(new Integer(ID_BUTTON_USER_CANCEL)));
@@ -338,6 +345,11 @@ _UserConfirmPopup::OnActionPerformed(const Control& source, int actionId)
                        __pImpl->SendUserEvent(ID_USER_SCRIPT_CONFIRM_CLOSE, null);
                        break;
                }
+               case USER_BEFORE_UNLOAD_CONFIRM:
+               {
+                       __pImpl->SendUserEvent(ID_USER_BEFORE_UNLOAD_CONFIRM_CLOSE, null);
+                       break;
+               }
                default:
                        SysAssert(false);
                }
@@ -458,6 +470,12 @@ CATCH:
                ewk_view_javascript_confirm_reply(pView, allow);
                break;
        }
+       case USER_BEFORE_UNLOAD_CONFIRM:
+       {
+               Evas_Object* pView = reinterpret_cast< Evas_Object* >(__pUserPolicyData);
+               ewk_view_before_unload_confirm_panel_reply(pView, !allow);
+               break;
+       }
        case USER_CONFIRM_APP_CACHE:
        {
                Evas_Object *pObj = reinterpret_cast< Evas_Object* >(__pUserPolicyData);
@@ -631,6 +649,11 @@ _UserConfirmPopup::OnKeyReleased(Control& source, const KeyEventInfo& keyEventIn
                        __pImpl->SendUserEvent(ID_USER_SCRIPT_CONFIRM_CLOSE, null);
                        break;
                }
+               case USER_BEFORE_UNLOAD_CONFIRM:
+               {
+                       __pImpl->SendUserEvent(ID_USER_BEFORE_UNLOAD_CONFIRM_CLOSE, null);
+                       break;
+               }
                case USER_PROTOCOL_HANDLER:
                case USER_CONTENT_HANDLER:
                case USER_CONFIRM_APP_CACHE:
index 0e4e6f4..c184152 100755 (executable)
@@ -148,7 +148,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;
+static const int DEFAULT_LIST_ITEM_COUNT = 5;
 
 
 Eina_Bool
@@ -380,6 +380,25 @@ CATCH:
 }
 
 
+Eina_Bool
+_WebImpl::OnBeforeUnloadConfirmRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
+{
+       _WebImpl* pWebImpl = reinterpret_cast< _WebImpl* >(pUserData);
+       SysAssertf(pWebImpl, "Failed to request");
+       result r = E_SUCCESS;
+
+       String msg(pMessage);
+
+       r = pWebImpl->ShowUserConfirmPopupAsync(USER_BEFORE_UNLOAD_CONFIRM, pView, msg);
+       SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       return EINA_TRUE;
+
+CATCH:
+       ewk_view_javascript_confirm_reply(pView, EINA_FALSE);
+       return EINA_TRUE;
+}
+
+
 void
 OnCertificateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
 {
@@ -1112,7 +1131,6 @@ OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
                if (code >= REDIRECTION_HEADER_GROUP && code < REDIRECTION_HEADER_GROUP + 100)
                {
                        pImpl->SetRedirectRequested(true);
-                       mime = L"";
                }
 
                ILoadingListener* pLoadingListener = pImpl->GetLoadingListener();
@@ -1133,7 +1151,7 @@ OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
                                        SysSecureLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", key.GetPointer(), value.GetPointer());
 
                                        r = httpHeader.AddField(key, value);
-                                       SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                                       SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, eina_iterator_free(iterator), r, "[%s] Propagating.", GetErrorMessage(r));
                                }
 
                                eina_iterator_free(iterator);
@@ -2209,6 +2227,7 @@ _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
        , __pNotificationConfirmPopup(null)
        , __pScriptAlertConfirmPopup(null)
        , __pScriptConfirmPopup(null)
+       , __pBeforeUnloadConfirmPopup(null)
        , __pAppCacheConfirmPopup(null)
        , __pDbQuotaConfirmPopup(null)
        , __pLocalFsQuotaConfirmPopup(null)
@@ -2519,7 +2538,14 @@ _WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List*
        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(this, isMultiSelect, title, DEFAULT_LIST_ITEM_COUNT, pWebView);
+       if (isMultiSelect)
+       {
+               r = pSelectBox->Construct(this, isMultiSelect, title, DEFAULT_LIST_ITEM_COUNT - 1, pWebView);
+       }
+       else
+       {
+               r = pSelectBox->Construct(this, 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);
@@ -3609,6 +3635,7 @@ _WebImpl::SetEventListenerCallback(void) const
                ewk_view_javascript_alert_callback_set(pWebNativeNode, OnScriptAlertRequested, const_cast< _WebImpl* >(this));
                ewk_view_javascript_prompt_callback_set(pWebNativeNode, OnScriptPromptRequested, const_cast< _WebImpl* >(this));
                ewk_view_javascript_confirm_callback_set(pWebNativeNode, OnScriptConfirmRequested, const_cast< _WebImpl* >(this));
+               ewk_view_before_unload_confirm_panel_callback_set(pWebNativeNode, OnBeforeUnloadConfirmRequested, const_cast< _WebImpl* >(this));
 
                evas_object_smart_callback_add(pWebNativeNode, "policy,response,decide", OnWebDataReceived, this);
 
@@ -3698,6 +3725,7 @@ _WebImpl::RemoveEventListenerCallback(void) const
                ewk_view_javascript_alert_callback_set(pWebNativeNode, null, null);
                ewk_view_javascript_prompt_callback_set(pWebNativeNode, null, null);
                ewk_view_javascript_confirm_callback_set(pWebNativeNode, null, null);
+               ewk_view_before_unload_confirm_panel_callback_set(pWebNativeNode, null, null);
 
                evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived);
 
@@ -4808,6 +4836,17 @@ _WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPol
 
                break;
        }
+       case USER_BEFORE_UNLOAD_CONFIRM:
+       {
+               __pBeforeUnloadConfirmPopup.reset();
+
+               __pBeforeUnloadConfirmPopup = std::move(pUserConfirmPopup);
+
+               r = __pBeforeUnloadConfirmPopup->ShowPopup();
+               SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pBeforeUnloadConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
+
+               break;
+       }
        default:
                break;
        }
@@ -4904,7 +4943,7 @@ _WebImpl::OnPreAttachedToMainTree(void)
                r = InitializeSetting();
                SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
-               SettingInfo::AddSettingEventListener(*this);
+               _SettingInfoImpl::AddSettingEventListener(*this);
 
                _WebManager* pWebManager = _WebManager::GetInstance();
                pWebManager->AddWeb(reinterpret_cast< int >(this));
@@ -5060,6 +5099,11 @@ _WebImpl::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::ILi
        case ID_USER_SCRIPT_CONFIRM_CLOSE:
                __pScriptConfirmPopup.reset();
                break;
+
+       case ID_USER_BEFORE_UNLOAD_CONFIRM_CLOSE:
+               __pBeforeUnloadConfirmPopup.reset();
+               break;
+
        case ID_USER_SCRIPT_SELECTBOX_CLOSE:
                __pSelectBox.reset();
                break;
index 72352a5..bb13523 100755 (executable)
@@ -53,6 +53,7 @@ enum _UserConfirmMode
        USER_CONFIRM_NOTIFICATION,
        USER_SCRIPT_ALERT,
        USER_SCRIPT_CONFIRM,
+       USER_BEFORE_UNLOAD_CONFIRM,
        USER_CONFIRM_APP_CACHE,
        USER_CONFIRM_DB_QUOTA_EXCEDED,
        USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED,
index f90a77a..64ef767 100755 (executable)
@@ -138,6 +138,7 @@ enum _WebPopupCloseId
        ID_USER_CONFIRM_NOTIFICATION_CLOSE,
        ID_USER_SCRIPT_ALERT_CLOSE,
        ID_USER_SCRIPT_CONFIRM_CLOSE,
+       ID_USER_BEFORE_UNLOAD_CONFIRM_CLOSE,
        ID_USER_SCRIPT_SELECTBOX_CLOSE
 };
 
@@ -452,6 +453,7 @@ private:
 
        virtual void OnSettingChanged(Tizen::Base::String& key);
 
+       static Eina_Bool OnBeforeUnloadConfirmRequested(Evas_Object* pView, const char* pMessage, void* pUserData);
 private:
        bool __isFooterVisible;
        bool __isKeypadVisible;
@@ -492,6 +494,7 @@ private:
        std::unique_ptr<_UserConfirmPopup> __pNotificationConfirmPopup;
        std::unique_ptr<_UserConfirmPopup> __pScriptAlertConfirmPopup;
        std::unique_ptr<_UserConfirmPopup> __pScriptConfirmPopup;
+       std::unique_ptr<_UserConfirmPopup> __pBeforeUnloadConfirmPopup;
        std::unique_ptr<_UserConfirmPopup> __pAppCacheConfirmPopup;
        std::unique_ptr<_UserConfirmPopup> __pDbQuotaConfirmPopup;
        std::unique_ptr<_UserConfirmPopup> __pLocalFsQuotaConfirmPopup;