Tizen 2.2.1
[framework/osp/web.git] / src / controls / FWebCtrl_AuthConfirmPopup.cpp
index 9b3108b..eeaa139 100755 (executable)
@@ -31,6 +31,7 @@
 #include <FUiKeyEventInfo.h>
 #include <FUiLayout.h>
 #include <FUiVerticalBoxLayout.h>
+#include <FWebCtrlAuthenticationChallenge.h>
 #include <FSys_SystemResource.h>
 #include <FSys_VibratorImpl.h>
 #include <FUi_ControlManager.h>
@@ -57,22 +58,27 @@ static const int EDIT_TEXT_SIZE = 35;
 _AuthConfirmPopup::_AuthConfirmPopup(void)
        : __pIdEditField(null)
        , __pPwdEditField(null)
-       , __pImpl(null)
+       , __pAuthHandler(null)
 {
 }
 
 
 _AuthConfirmPopup::~_AuthConfirmPopup(void)
 {
+       if (IsModalPopup())
+       {
+               __pAuthHandler->Cancel();
+       }
 }
 
 
 // Authentication popup
 result
-_AuthConfirmPopup::Construct(const String& host, const String& realm, _WebImpl* pImpl)
+_AuthConfirmPopup::Construct(const String& host, const String& realm, AuthenticationChallenge* pAuth)
 {
-       __pImpl = pImpl;
-       SysAssertf(__pImpl != null, "Failed to get _WebImpl");
+       SysTryReturnResult(NID_WEB_CTRL, pAuth != null, E_INVALID_ARG, "invalid argument(s) is used. The AuthenticationChallenge is null.");
+
+       __pAuthHandler = pAuth;
 
        _SystemResource* pSysResource = _SystemResource::GetInstance();
        SysAssertf(pSysResource != null, "Failed to get _SystemResource instance");
@@ -143,26 +149,23 @@ _AuthConfirmPopup::Construct(const String& host, const String& realm, _WebImpl*
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
        __pPwdEditField = pPwdEditField.release();
-
        __pIdEditField->SetFocus();
 
        Panel* pButtonPanel = CreateAndAddPanel();
        SysTryReturn(NID_WEB_CTRL, pButtonPanel, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
 
        //Add Buttons
-       ArrayList idList(SingleObjectDeleter);
+       ArrayList idList;
        r = idList.Construct();
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       idList.Add(*(new Integer(ID_BUTTON_AUTH_CANCEL)));
+       idList.Add(*(new Integer(ID_BUTTON_AUTH_PROCESS)));
 
-       idList.Add(new Integer(ID_BUTTON_AUTH_CANCEL));
-       idList.Add(new Integer(ID_BUTTON_AUTH_PROCESS));
-
-
-       ArrayList titleList(SingleObjectDeleter);
+       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")));
-       titleList.Add(new String(pSysResource->GetString(_RESOURCE_DOMAIN_ID_OSP, "IDS_TPLATFORM_BUTTON_CONTINUE_ABB")));
+       titleList.Add(*(new String(pSysResource->GetString(_RESOURCE_DOMAIN_ID_OSP, "IDS_TPLATFORM_BUTTON_CANCEL_ABB"))));
+       titleList.Add(*(new String(pSysResource->GetString(_RESOURCE_DOMAIN_ID_OSP, "IDS_TPLATFORM_BUTTON_CONTINUE_ABB"))));
 
        r = CreateAndAddButtons(idList, titleList, pButtonPanel);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
@@ -191,21 +194,14 @@ _AuthConfirmPopup::OnActionPerformed(const Control& source, int actionId)
        r = HidePopup();
        SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
 
-       ArrayList* pAuthValueList = null;
-
        switch (actionId)
        {
        case ID_BUTTON_AUTH_PROCESS:
-
-               pAuthValueList = new (std::nothrow) ArrayList();
-               pAuthValueList->Construct();
-               pAuthValueList->Add(new String(__pIdEditField->GetText()));
-               pAuthValueList->Add(new String(__pPwdEditField->GetText()));
-               __pImpl->SendUserEvent(ID_AUTHENTICATION_CONFIRM_POPUP_PROCESS, pAuthValueList);
+               __pAuthHandler->Process(__pIdEditField->GetText(), __pPwdEditField->GetText());
                break;
 
        case ID_BUTTON_AUTH_CANCEL:
-               __pImpl->SendUserEvent(ID_AUTHENTICATION_CONFIRM_POPUP_CANCEL, null);
+               __pAuthHandler->Cancel();
                break;
 
        default:
@@ -225,13 +221,12 @@ _AuthConfirmPopup::OnKeyReleased(Control& source, const KeyEventInfo& keyEventIn
        result r = E_SUCCESS;
        if ((keyEventInfo.GetKeyCode() == KEY_ESC || keyEventInfo.GetKeyCode() == KEY_BACK) && source.GetShowState() == true)
        {
+               __pAuthHandler->Cancel();
                r = HidePopup();
                if (IsFailed(r))
                {
                        SysLogException(NID_WEB_CTRL, r, "[%s] Propagating.", GetErrorMessage(r));
                }
-
-               __pImpl->SendUserEvent(ID_AUTHENTICATION_CONFIRM_POPUP_CANCEL, null);
        }
 
        return false;