Jira fix once error
[framework/osp/web.git] / src / controls / FWebCtrl_WebImpl.cpp
index 59682ff..d2e075c 100755 (executable)
@@ -87,7 +87,7 @@
 #include <FUiAnim_EflNode.h>
 #include <FUiAnim_VisualElement.h>
 #include <FUiCtrl_FooterImpl.h>
-#include <FUiCtrl_Form.h>
+#include <FUiCtrl_FormImpl.h>
 #include "FWeb_HistoryItemImpl.h"
 #include "FWebCtrl_AppControlListener.h"
 #include "FWebCtrl_AuthConfirmPopup.h"
 #include "FWebCtrl_WebEvent.h"
 #include "FWebCtrl_WebEventArg.h"
 #include "FWebCtrl_WebImpl.h"
+#include "FWebCtrl_WebManager.h"
 #include "FWebCtrl_WebPresenter.h"
 #include "FWebCtrl_WebSettingImpl.h"
 
@@ -364,26 +365,12 @@ OnScriptConfirmRequested(Evas_Object* pView, const char* pMessage, void* pUserDa
        _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
        String msg(pMessage);
 
-       MessageBox messageBox;
-       r = messageBox.Construct(L"", msg, MSGBOX_STYLE_OKCANCEL);
-       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));
-
-       if (modalResult == MSGBOX_RESULT_OK)
-       {
-               ewk_view_javascript_confirm_reply(pView, EINA_TRUE);
-       }
-       else
-       {
-               ewk_view_javascript_confirm_reply(pView, EINA_FALSE);
-       }
+       r = pImpl->ShowUserConfirmPopupAsync(USER_SCRIPT_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;
 }
 
@@ -418,6 +405,8 @@ OnCertificateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
        Ewk_Certificate_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Certificate_Policy_Decision* >(pEventInfo);
        SysAssertf(pImpl && pPolicy, "Failed to request");
 
+       _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
+
        switch (pImpl->GetSetting().GetCertificateErrorHandlingMode())
        {
        case WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM:
@@ -460,9 +449,14 @@ OnCertificateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
                {
                        r = pImpl->ShowCertificateConfirmPopup(CERTIFICATE_POPUP_MODE_USER_CONFIRM, pPolicy);
                        SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+                       ewk_view_resume(pWebCore->GetWebNativeNode());
                }
 
-               pImpl->SetCertificateRequested(true);
+               if (pImpl)
+               {
+                       pImpl->SetCertificateRequested(true);
+               }
                break;
        }
        case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CANCEL:
@@ -481,6 +475,8 @@ CATCH:
        ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE);
        pImpl->SetCertificateConfirmed(false);
        pImpl->SetCertificateRequested(true);
+
+       ewk_view_resume(pWebCore->GetWebNativeNode());
 }
 
 
@@ -836,9 +832,16 @@ void
 OnFullScreenEntered(void* pUserData, Evas_Object* pView, void* pEventInfo)
 {
        _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
+       bool* pIsHandleNeeded = reinterpret_cast< bool* >(pEventInfo);
        SysAssertf(pImpl, "Failed to request");
 
-       SysLog(NID_WEB_CTRL, "Enter.");
+       _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
+       SysAssertf(pWebCore, "Failed to get Web core object");
+
+       if (pIsHandleNeeded && *pIsHandleNeeded)
+       {
+               pWebCore->SetFullScreenEntered(true);
+       }
 }
 
 
@@ -848,7 +851,10 @@ OnFullScreenExited(void* pUserData, Evas_Object* pView, void* pEventInfo)
        _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
        SysAssertf(pImpl, "Failed to request");
 
-       SysLog(NID_WEB_CTRL, "Exit.");
+       _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
+       SysAssertf(pWebCore, "Failed to get Web core object");
+
+       pWebCore->SetFullScreenEntered(false);
 }
 
 
@@ -894,6 +900,11 @@ OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
        if (pImpl->GetLoadingListener() && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy))
                && !pImpl->IsRedirectRequested())
        {
+               _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
+               SysAssertf(pWebCore, "Failed to get Web core object");
+
+               pWebCore->SetFullScreenEntered(false);
+
                pImpl->SetCertificateRequested(false);
 
                if (pImpl->GetTextSearchListener())
@@ -976,8 +987,7 @@ OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
                else
                {
                        String operationId(L"http://tizen.org/appcontrol/operation/view");
-                       String mime(ewk_policy_decision_response_mime_get(pPolicy));
-                       r = _AppControlImpl::FindAndStart(operationId, &url, &mime, null, null, null);
+                       r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
                }
                SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
 
@@ -1128,8 +1138,6 @@ OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
                {
                        ewk_policy_decision_ignore(pPolicy);
 
-                       _SelectBox selectBox;
-                       int selectedIndex = 0;
                        String operationId(L"http://tizen.org/appcontrol/operation/view");
 
                        r = _AppControlImpl::FindAndStart(operationId, &url, &mime, null, null, null);
@@ -1137,24 +1145,15 @@ OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
        
                        if (r == E_OBJ_NOT_FOUND)
                        {
-                               r = selectBox.Construct(false, L"Select application", 1); //+1 for Downloader
-                               SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+                               _SelectBox* pSelectBox = new (std::nothrow) _SelectBox;
+                               SysTryReturnVoidResult(NID_WEB_CTRL, pSelectBox, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
-                               selectBox.AddListItem(pSysResource->GetString(_RESOURCE_DOMAIN_ID_OSP, "IDS_BR_BODY_DOWNLOAD"), _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
-                               r = selectBox.ShowAndWait(selectedIndex);
+                               r = pSelectBox->Construct(false, L"Select application", 1, null, url);
                                SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
 
-                               if (selectedIndex == 0) //download
-                               {
-                                       RequestId reqId = 0;
-                                       DownloadRequest request(pUrl);
-
-                                       _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
-                                       SysTryReturnVoidResult(NID_WEB_CTRL, pManagerImpl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
-
-                                       r = pManagerImpl->Start(request, reqId);
-                                       SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
-                               }
+                               pSelectBox->AddListItem(pSysResource->GetString(_RESOURCE_DOMAIN_ID_OSP, "IDS_BR_BODY_DOWNLOAD"), _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
+                               r = pSelectBox->ShowPopup();
+                               SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
                        }
 
                        return;
@@ -1585,135 +1584,6 @@ 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);
-
-       SysLog(NID_WEB_CTRL, "Enter.");
-}
-
-
-Eina_Bool
-OnSelectUploadFile(Evas_Object* pView, Eina_Bool multipleFile, Eina_List* pAcceptTypes, const char* pCapture, void* pUserData)
-{
-       std::unique_ptr<_MediaSelectionListener> pMediaListener(new (std::nothrow) _MediaSelectionListener());
-       SysTryReturn(NID_WEB_CTRL, pMediaListener.get(), EINA_TRUE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
-
-       pMediaListener->Construct(pView);
-
-       HashMap extraData;
-       result r = extraData.Construct();
-       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_TRUE, r, "[%s] Propagating.", GetErrorMessage(r));
-
-       String isMultipleSelection(L"single");
-       String mode(L"selectionType");
-       String type(L"type");
-       String fileType = L"*/*";
-       String operationId = L"http://tizen.org/appcontrol/operation/pick";
-
-       if (multipleFile)
-       {
-               isMultipleSelection.Append(L"multiple");
-       }
-
-       if (eina_list_count(pAcceptTypes) == 1)
-       {
-               String item((char*)eina_list_nth(pAcceptTypes, 0));
-               String captureString(pCapture);
-
-               if (item.StartsWith("image/",0))
-               {
-                       if (captureString == L"camera")
-                       {
-                               fileType = L"image/jpg";
-                               operationId = L"http://tizen.org/appcontrol/operation/create_content";
-                               String typeKey = L"http://tizen.org/appcontrol/data/camera/allow_switch";
-                               String typeVal = L"false";
-                               extraData.Add(&typeKey, &typeVal);
-                       }
-                       else
-                       {
-                               fileType = L"image/*";
-                               String selectKey = L"http://tizen.org/appcontrol/data/selection_mode";
-                               extraData.Add(&selectKey, &isMultipleSelection);
-                       }
-               }
-               else if (item.StartsWith("audio/",0))
-               {
-                       fileType = L"audio/*";
-                       //TO DO: as microphone is not supported yet. suggest to throw an exception
-                       //if (captureString == L"microphone")
-                       //{
-                               //operationId = L"http://tizen.org/appcontrol/operation/create_content";
-                       //}
-                       //else
-                       //{
-                               String selectKey = L"http://tizen.org/appcontrol/data/selection_mode";
-                               extraData.Add(&selectKey, &isMultipleSelection);
-                       //}
-               }
-               else if (item.StartsWith("video/",0))
-               {
-                       if (captureString == L"camcorder")
-                       {
-                               fileType = L"video/3gpp";
-                               operationId = L"http://tizen.org/appcontrol/operation/create_content";
-                               String typeKey = L"http://tizen.org/appcontrol/data/camera/allow_switch";
-                               String typeVal = L"false";
-                               extraData.Add(&typeKey, &typeVal);
-                       }
-                       else
-                       {
-                               fileType = L"video/*";
-                               String selectKey = L"http://tizen.org/appcontrol/data/selection_mode";
-                               extraData.Add(&selectKey, &isMultipleSelection);
-                       }
-               }
-       }
-
-       r = _AppControlImpl::FindAndStart(operationId, null, &fileType, null, &extraData, pMediaListener.get());
-       SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-
-       pMediaListener.release();
-
-       return EINA_TRUE;
-
-CATCH:
-       ewk_view_open_panel_reply(pView, null, EINA_FALSE);
-       return EINA_TRUE;
-}
-
-
-void
 OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo)
 {
        _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
@@ -1743,6 +1613,11 @@ OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo)
        Eina_Rectangle* pEinaRect = reinterpret_cast< Eina_Rectangle* >(pEventInfo);
        SysAssertf(pImpl && pEinaRect, "Failed to request");
 
+       if (pImpl->IsVisible() == false)
+       {
+               evas_object_focus_set(pView, EINA_FALSE);
+       }
+
        if (pImpl->GetSetting().GetInputStyle() == INPUT_STYLE_OVERLAY)
        {
                _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
@@ -1755,15 +1630,15 @@ OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo)
                        return;
                }
 
-               _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
-               if (pFormCore)
+               _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl));
+               if (pFormImpl)
                {
-                       pFormCore->DeflateClientRectHeight(pXformer->TransformVertical(rect.height));
+                       pFormImpl->DeflateClientRectHeight(pXformer->TransformVertical(rect.height));
 
-                       if (pFormCore->HasFooter())
+                       if (pFormImpl->HasFooter())
                        {
-                               pFormCore->SetKeypadShowState(true);
-                               pFormCore->Draw();
+                               pFormImpl->GetCore().SetKeypadShowState(true);
+                               pFormImpl->Draw();
                        }                       
                }
 
@@ -1811,15 +1686,15 @@ OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo)
        _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
        SysAssertf(pImpl, "Failed to request");
 
-       _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
-       if (pFormCore)
+       _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl));
+       if (pFormImpl)
        {
-               pFormCore->DeflateClientRectHeight(0);
+               pFormImpl->DeflateClientRectHeight(0);
 
-               if (pFormCore->HasFooter())
+               if (pFormImpl->HasFooter())
                {
-                       pFormCore->SetKeypadShowState(false);
-                       pFormCore->Draw();
+                       pFormImpl->GetCore().SetKeypadShowState(false);
+                       pFormImpl->Draw();
                }
        }
 
@@ -1838,15 +1713,15 @@ OnWindowObjectFocusGained(void* pUserData, Evas_Object* pWin, void* pEvent_info)
        _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
        SysAssertf(pImpl, "Failed to request");
 
-       if (pImpl->IsKeypadOpened() == true && pImpl->IsVisible() == true)
+       if (pImpl->IsKeypadOpened() == true && pImpl->IsVisible() == true && pImpl->IsFocused() == true)
        {
                _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
                SysAssertf(pWebCore, "Failed to get Web core object");
 
                evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE);
-       }
 
-       pImpl->SetKeypadOpened(false);
+               pImpl->SetKeypadVisibleState(true);
+       }
 }
 
 
@@ -1859,8 +1734,6 @@ OnWebNativeNodeFocusGained(void* pUserData, Evas* pCanvas, Evas_Object* pView, v
        if (pImpl->IsKeypadOpened() == true)
        {
                pImpl->SetKeypadOpened(false);
-
-               pImpl->SetFocused();
        }
 } 
 
@@ -2101,7 +1974,8 @@ OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData)
        SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer());
 
        _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, WEB_CTRL));
-       if (pImpl && pImpl->IsPresenterAlived(pPresenter))
+       _WebManager* pWebManager = _WebManager::GetInstance();
+       if (pWebManager->IsValidCallback(reinterpret_cast< int >(pImpl), reinterpret_cast< int >(pPresenter)))
        {
                pPresenter->EndAsyncProcess(result);
        }
@@ -2214,7 +2088,6 @@ _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
        , __isRedirectRequested(false)
        , __isCertificateRequested(false)
        , __isCertificateConfirmed(false)
-       , __isOrientationChanged(false)
        , __isFormDataVisible(false)
        , __keypadBounds(0, 0, 0, 0)
        , __pWebCore(null)
@@ -2237,6 +2110,7 @@ _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
        , __pGeolocationConfirmPopup(null)
        , __pNotificationConfirmPopup(null)
        , __pScriptAlertConfirmPopup(null)
+       , __pScriptConfirmPopup(null)
        , __pAppCacheConfirmPopup(null)
        , __pDbQuotaConfirmPopup(null)
        , __pLocalFsQuotaConfirmPopup(null)
@@ -2251,6 +2125,7 @@ _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
        , __policy(WEB_DECISION_CONTINUE)
        , __defaultUserAgent(L"")
        , __pFormDataList(null)
+       , __popupClosed(false)
 {
        __textSearch.__searchAll = false;
        __textSearch.__searchForward = true;
@@ -2267,7 +2142,11 @@ _WebImpl::~_WebImpl()
        _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
        pManagerImpl->SetDownloadListener(null);
 
+       _WebManager* pWebManager = _WebManager::GetInstance();
+       pWebManager->RemoveWeb(reinterpret_cast< int >(this));
+
        RemoveEventListenerCallback();
+
        ClearCertificateDb();
 }
 
@@ -2345,9 +2224,6 @@ _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 = __webNotificationList.Construct();
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
@@ -2557,8 +2433,6 @@ _WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List*
 
        __pSelectBox = std::move(pSelectBox);
 
-       __pSelectBox->SetOwner(&GetPublic());
-
        return __pSelectBox->ShowPopup();
 }
 
@@ -2579,6 +2453,8 @@ _WebImpl::ClearSelectBoxPopup(void)
 
        __pSelectBox.reset();
 
+       Resume();
+
        return E_SUCCESS;
 }
 
@@ -2672,35 +2548,20 @@ _WebImpl::EvaluateJavascriptN(const String& scriptCode)
                return null;
        }
        
-       result r = E_SUCCESS;
-
        std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(scriptCode));
        SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
 
-       std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter());
+       std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
        SysTryReturn(NID_WEB_CTRL, pPresenter.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
-       r = __callbackList.Add(pPresenter.get());
-       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
-
        ewk_view_script_execute(pView, pScript.get(), OnScriptExecuted, pPresenter.get());
 
-       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();
-}
+       String* pResult = new (std::nothrow) String(L"");
+       SysTryReturn(NID_WEB_CTRL, pResult, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
+       pPresenter->WaitAsyncProcess(*pResult);
 
-bool
-_WebImpl::IsPresenterAlived(_WebPresenter* pPresenter) const
-{
-       return __callbackList.Contains(*pPresenter);
+       return pResult;
 }
 
 
@@ -2820,14 +2681,14 @@ _WebImpl::SearchText(const String& text, bool searchForward)
            condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS);
        }
 
-       _WebPresenter presenter;
-       presenter.InitAsyncProcess();
+       std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
+       SysTryReturn(NID_WEB_CTRL, pPresenter.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
-       r = SynchronizeSearch(SEARCH_SYNC, pView, condition, text, searchForward, false, &presenter);
-       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       r = SynchronizeSearch(SEARCH_SYNC, pView, condition, text, searchForward, false, pPresenter.get());
+       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
 
        int result = 0;
-       presenter.WaitAsyncProcess(result);
+       pPresenter->WaitAsyncProcess(result);
 
        return static_cast < bool >(result);
 }
@@ -2900,6 +2761,10 @@ _WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Optio
        std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(text));
        SysTryReturn(NID_WEB_CTRL, pText.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
 
+       Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
+       SysAssertf(pSettings, "Failed to get webkit instance.");
+       ewk_settings_clear_text_selection_automatically_set(pSettings, true);
+
        switch (type)
        {
        case SEARCH_SYNC:
@@ -3322,13 +3187,13 @@ _WebImpl::IsCookieEnabled(void) const
        Ewk_Cookie_Manager* pCookieManager =  ewk_context_cookie_manager_get(pContext);
        SysAssertf(pCookieManager, "Failed to get webkit instance.");
 
-       _WebPresenter presenter;
-       presenter.InitAsyncProcess();
+       std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
+       SysTryReturn(NID_WEB_CTRL, pPresenter.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
-       ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, &presenter);
+       ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, pPresenter.get());
 
        bool result = false;
-       presenter.WaitAsyncProcess(result);
+       pPresenter->WaitAsyncProcess(result);
 
        return result;
 }
@@ -3676,12 +3541,10 @@ _WebImpl::SetEventListenerCallback(void) const
                evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this);
 
                evas_object_smart_callback_add(pWebNativeNode, "text,selected", OnWebPageBlockSelected, this);
-               evas_object_smart_callback_add(pWebNativeNode, "frame,rendered", OnWebPageBlockSelectedByOrientation, this);
 
                evas_object_smart_callback_add(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered, this);
                evas_object_smart_callback_add(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited, 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));
@@ -3734,9 +3597,9 @@ _WebImpl::RemoveEventListenerCallback(void) const
 
                evas_object_smart_callback_del(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested);
 
-               ewk_view_javascript_alert_callback_set(null, null, null);
-               ewk_view_javascript_prompt_callback_set(null, null, null);
-               ewk_view_javascript_confirm_callback_set(null, null, null);
+               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);
 
                evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived);
 
@@ -3761,12 +3624,10 @@ _WebImpl::RemoveEventListenerCallback(void) const
                evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived);
 
                evas_object_smart_callback_del(pWebNativeNode, "text,selected", OnWebPageBlockSelected);
-               evas_object_smart_callback_del(pWebNativeNode, "frame,rendered", OnWebPageBlockSelectedByOrientation);
 
                evas_object_smart_callback_del(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered);
                evas_object_smart_callback_del(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited);
 
-               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);
@@ -3823,6 +3684,10 @@ _WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint)
        {
                Point absPoint( _CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(startPoint)));
 
+               Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
+               SysAssertf(pSettings, "Failed to get webkit instance.");
+               ewk_settings_clear_text_selection_automatically_set(pSettings, true);
+
                Eina_Bool ret = pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y);
                if (ret)
                {
@@ -3979,7 +3844,7 @@ _WebImpl::GetPageSize(void) const
 
 
 result
-_WebImpl::AddCustomHeader(const String& name, const String& value)
+_WebImpl::AddHttpHeaderField(const String& name, const String& value)
 {
        SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing.");
 
@@ -3995,7 +3860,7 @@ _WebImpl::AddCustomHeader(const String& name, const String& value)
 
 
 result
-_WebImpl::RemoveCustomHeader(const String& name)
+_WebImpl::RemoveHttpHeaderField(const String& name)
 {
        SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing.");
 
@@ -4078,20 +3943,6 @@ _WebImpl::IsCertificateConfirmed(void) const
 }
 
 
-void
-_WebImpl::SetOrientationChanged(bool arg)
-{
-       __isOrientationChanged = arg;
-}
-
-
-bool
-_WebImpl::IsOrientationChanged(void) const
-{
-       return __isOrientationChanged;
-}
-
-
 result
 _WebImpl::SetFullScreenKeypad(void)
 {
@@ -4609,13 +4460,14 @@ _WebImpl::ShowAuthenticationPopup(const String& host, const String& realm, Authe
 
        int modalResult = 0;
 
-       __pAuthPopup->SetOwner(&GetPublic());
-       
        r = __pAuthPopup->ShowAndWait(modalResult);
        SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
 
 CATCH:
-       __pAuthPopup.reset();
+       if (__pAuthPopup)
+       {
+               __pAuthPopup.reset();
+       }
 
        return r;
 }
@@ -4636,18 +4488,19 @@ _WebImpl::ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk
 
        int modalResult = 0;
 
-       __pCertConfirmPopup->SetOwner(&GetPublic());
-       
        r = __pCertConfirmPopup->ShowAndWait(modalResult);
        SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
 
-       if (userConfirmMode == CERTIFICATE_POPUP_MODE_USER_CONFIRM)
+       if (__pCertConfirmPopup.get() && userConfirmMode == CERTIFICATE_POPUP_MODE_USER_CONFIRM)
        {
                __isCertificateConfirmed = __pCertConfirmPopup->GetConfirmResult();
        }
 
 CATCH:
-       __pCertConfirmPopup.reset();
+       if (__pCertConfirmPopup.get())
+       {
+               __pCertConfirmPopup.reset();
+       }
 
        return r;
 }
@@ -4661,13 +4514,11 @@ _WebImpl::ShowPromptPopup(String msg, String defVal)
        std::unique_ptr< _PromptPopup > pPromptPopup(new (std::nothrow) _PromptPopup());
        SysTryReturnResult(NID_WEB_CTRL, pPromptPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
 
-       r = pPromptPopup->Construct(msg, defVal, __pWebCore->GetWebNativeNode());
+       r = pPromptPopup->Construct(msg, defVal, __pWebCore->GetWebNativeNode(), this);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
        __pPromptPopup = std::move(pPromptPopup);
 
-       __pPromptPopup->SetOwner(&GetPublic());
-
        r = __pPromptPopup->ShowPopup();
        SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
 
@@ -4689,73 +4540,89 @@ _WebImpl::ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy,
        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, msg);
+       r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, this, true, msg);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
-       pUserConfirmPopup->SetOwner(&GetPublic());
-
        int modalResult = 0;
 
        switch(userConfirmMode)
        {
        case USER_CONTENT_HANDLER:
        {
-               __pContentHandlerConfirmPopup.reset();
-
                __pContentHandlerConfirmPopup = std::move(pUserConfirmPopup);
 
                r = __pContentHandlerConfirmPopup->ShowAndWait(modalResult);
                SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pContentHandlerConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
+
+               __pContentHandlerConfirmPopup.reset();
+
+               ewk_view_resume(__pWebCore->GetWebNativeNode());
+
                break;
        }
        case USER_PROTOCOL_HANDLER:
        {
-               __pProtocolHandlerConfirmPopup.reset();
-
                __pProtocolHandlerConfirmPopup = std::move(pUserConfirmPopup);
 
                r = __pProtocolHandlerConfirmPopup->ShowAndWait(modalResult);
                SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pProtocolHandlerConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
+
+               __pProtocolHandlerConfirmPopup.reset();
+
+               ewk_view_resume(__pWebCore->GetWebNativeNode());
+
                break;
        }
        case USER_CONFIRM_APP_CACHE:
        {
-               __pAppCacheConfirmPopup.reset();
-
                __pAppCacheConfirmPopup = std::move(pUserConfirmPopup);
 
                r = __pAppCacheConfirmPopup->ShowAndWait(modalResult);
                SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pAppCacheConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
+
+               __pAppCacheConfirmPopup.reset();
+
+               ewk_view_resume(__pWebCore->GetWebNativeNode());
+
                break;
        }
        case USER_CONFIRM_DB_QUOTA_EXCEDED:
        {
-               __pDbQuotaConfirmPopup.reset();
-
                __pDbQuotaConfirmPopup = std::move(pUserConfirmPopup);
 
                r = __pDbQuotaConfirmPopup->ShowAndWait(modalResult);
                SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pDbQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
+
+               __pDbQuotaConfirmPopup.reset();
+
+               ewk_view_resume(__pWebCore->GetWebNativeNode());
+
                break;
        }
        case USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED:
        {
-               __pLocalFsQuotaConfirmPopup.reset();
-
                __pLocalFsQuotaConfirmPopup = std::move(pUserConfirmPopup);
 
                r = __pLocalFsQuotaConfirmPopup->ShowAndWait(modalResult);
                SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pLocalFsQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
+
+               __pLocalFsQuotaConfirmPopup.reset();
+
+               ewk_view_resume(__pWebCore->GetWebNativeNode());
+
                break;
        }
        case USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED:
        {
-               __pIndexedDbQuotaConfirmPopup.reset();
-
                __pIndexedDbQuotaConfirmPopup = std::move(pUserConfirmPopup);
 
                r = __pIndexedDbQuotaConfirmPopup->ShowAndWait(modalResult);
                SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pIndexedDbQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
+
+               __pIndexedDbQuotaConfirmPopup.reset();
+
+               ewk_view_resume(__pWebCore->GetWebNativeNode());
+
                break;
        }
        default:
@@ -4774,15 +4641,13 @@ _WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPol
        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, msg);
+       r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, this, false, msg);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
-       pUserConfirmPopup->SetOwner(&GetPublic());
-
        switch(userConfirmMode)
        {
        case USER_CONFIRM_USERMEDIA:
-    {
+       {
         __pUserMediaConfirmPopup.reset();
 
                __pUserMediaConfirmPopup = std::move(pUserConfirmPopup);
@@ -4829,6 +4694,19 @@ _WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPol
                __pScriptAlertConfirmPopup.release();
                break;
        }
+       case USER_SCRIPT_CONFIRM:
+       {
+               __pScriptConfirmPopup.reset();
+
+               __pScriptConfirmPopup = std::move(pUserConfirmPopup);
+
+               r = __pScriptConfirmPopup->ShowPopup();
+               SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pScriptConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
+
+               __pScriptConfirmPopup.release();
+
+               break;
+       }
        default:
                break;
        }
@@ -4840,31 +4718,35 @@ CATCH:
 }
 
 
-_Form*
-_WebImpl::GetParentFormCore(_Control* pControlCore)
+_FormImpl*
+_WebImpl::GetParentFormImpl(_ControlImpl* pControlImpl)
 {
        String parentName;
-       _Form* pFormCore = null;
+       _FormImpl* pFormImpl = null;
 
-       _Control* pParentControlCore = dynamic_cast< _Control* >(pControlCore->GetParent());
-       if (!pParentControlCore)
+       _ControlImpl* pParentControlImpl = dynamic_cast< _ControlImpl* >(pControlImpl->GetParent());
+       if (!pParentControlImpl)
        {
                return null;
        }
 
-       pFormCore = dynamic_cast< _Form* >(pParentControlCore);
-       if (pFormCore)
+       pFormImpl = dynamic_cast< _FormImpl* >(pParentControlImpl);
+       if (pFormImpl)
        {
-               return pFormCore;
+               return pFormImpl;
        }
 
-       return GetParentFormCore(pParentControlCore);
+       return GetParentFormImpl(pParentControlImpl);
 }
 
 
 bool 
 _WebImpl::OnFocusGained(const _ControlImpl& source)
 {
+       Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
+       SysAssertf(pSettings, "Failed to get webkit instance.");
+       ewk_settings_clear_text_selection_automatically_set(pSettings, true);
+
        return false;
 }
 
@@ -4879,6 +4761,10 @@ _WebImpl::OnFocusLost(const _ControlImpl& source)
                SetKeypadVisibleState(false);
        }
 
+       Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
+       SysAssertf(pSettings, "Failed to get webkit instance.");
+       ewk_settings_clear_text_selection_automatically_set(pSettings, false);
+
        evas_object_focus_set(__pWebCore->GetWebNativeNode(), EINA_FALSE);
 
        return false;
@@ -4902,13 +4788,44 @@ _WebImpl::OnPreAttachedToMainTree(void)
 {
        result r = E_SUCCESS;
 
-       r = __pWebCore->InitializeWebNativeNode();
-       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       if (IsVisible() == true)
+       {
+               _WebManager* pWebManager = _WebManager::GetInstance();
+               pWebManager->SetActiveWeb(this);
+       }
 
-       r = InitializeSetting();
+       r = _ContainerImpl::OnPreAttachedToMainTree();
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
-       r = _ContainerImpl::OnPreAttachedToMainTree();
+       if (!HasValidNativeNode())
+       {
+               r = __pWebCore->InitializeWebNativeNode();
+               SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               _ControlManager* pControlManager = _ControlManager::GetInstance();
+               SysTryReturnResult(NID_WEB_CTRL, pControlManager, E_SYSTEM, "Failed to get the ControlManager instance.");
+               OnChangeLayout(pControlManager->GetScreenRotation());
+
+               r = InitializeSetting();
+               SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               _WebManager* pWebManager = _WebManager::GetInstance();
+               pWebManager->AddWeb(reinterpret_cast< int >(this));
+       }
+
+       return E_SUCCESS;
+}
+
+
+result
+_WebImpl::OnDetachingFromMainTree(void)
+{
+       result r = E_SUCCESS;
+
+       _WebManager* pWebManager = _WebManager::GetInstance();
+       pWebManager->RemoveActiveWeb(this);
+
+       r = _ContainerImpl::OnDetachingFromMainTree();
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
        return E_SUCCESS;
@@ -4916,12 +4833,36 @@ _WebImpl::OnPreAttachedToMainTree(void)
 
 
 void
+_WebImpl::OnChangeLayout(_ControlRotation rotation)
+{
+       int degree = 0;
+
+       switch (rotation)
+       {
+               case _CONTROL_ROTATION_0:
+                       degree =  0;
+                       break;
+               case _CONTROL_ROTATION_90:
+                       degree =  90;
+                       break;
+               case _CONTROL_ROTATION_180:
+                       degree =  180;
+                       break;
+               case _CONTROL_ROTATION_270:
+                       degree =  -90;
+                       break;
+               default:
+                       SysAssert(false);
+       }
+       ewk_view_orientation_send(__pWebCore->GetWebNativeNode(), degree);
+}
+
+
+void
 _WebImpl::OnChangeLayout(_ControlOrientation orientation)
 {
        _ContainerImpl::OnChangeLayout(orientation);
 
-       __isOrientationChanged = true;
-
        if (__pColorPicker.get())
        {
                __pColorPicker->ChangeLayout(orientation);
@@ -4943,12 +4884,15 @@ _WebImpl::OnChangeLayout(_ControlOrientation orientation)
 void
 _WebImpl::OnAncestorVisibleStateChanged(const _Control& control)
 {
+       _WebManager* pWebManager = _WebManager::GetInstance();
        if (IsVisible() == true)
        {
+               pWebManager->SetActiveWeb(this);
                ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_VISIBLE, false);
        }
        else
        {
+               pWebManager->RemoveActiveWeb(this);
                ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_HIDDEN, false);
        }
 }
@@ -4979,9 +4923,14 @@ _WebImpl::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::ILi
        case ID_USER_SCRIPT_ALERT_CLOSE:
                __pScriptAlertConfirmPopup.reset();
                break;
+       case ID_USER_SCRIPT_CONFIRM_CLOSE:
+               __pScriptConfirmPopup.reset();
+               break;
        default:
                break;
        }
+
+       Resume();
 }
 
 
@@ -4997,6 +4946,8 @@ _WebImpl::HideColorPicker(void)
 {
        __pColorPicker.reset();
 
+       Resume();
+
        return EINA_TRUE;
 }
 
@@ -5019,12 +4970,17 @@ _WebImpl::ShowColorPicker(int red, int green, int blue, int alpha, Color& color)
        r = __pColorPicker->ShowPopup();
        SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
 
-       color = __pColorPicker->GetColor();
-
-       return E_SUCCESS;
+       if (__pColorPicker)
+       {
+               color = __pColorPicker->GetColor();
+       }
 
 CATCH:
-       __pColorPicker.reset();
+       if (__pColorPicker)
+       {
+               __pColorPicker.reset();
+               Resume();
+       }
 
        return r;
 }
@@ -5046,10 +5002,17 @@ _WebImpl::ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue, Strin
        r = __pDatePicker->ShowPopup();
        SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
 
-       dateStr = __pDatePicker->GetDate();
+       if (__pDatePicker)
+       {
+               dateStr = __pDatePicker->GetDate();
+       }
 
 CATCH:
-       __pDatePicker.reset();
+       if (__pDatePicker)
+       {
+               __pDatePicker.reset();
+               Resume();
+       }
 
        return r;
 }