X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fcontrols%2FFWebCtrl_UserConfirmPopup.cpp;h=6f73c0382912e411e92df6ec05b59f60d5f5b4da;hb=8969993a70eec139a6e0b9d0b16778ef738ff05b;hp=4b46e0240327dd9ad67cf640e40267a7a4c27b44;hpb=f69dddae6f85dbd5b3e1ce9ebbe68f577b7b4461;p=framework%2Fosp%2Fweb.git diff --git a/src/controls/FWebCtrl_UserConfirmPopup.cpp b/src/controls/FWebCtrl_UserConfirmPopup.cpp index 4b46e02..6f73c03 100755 --- a/src/controls/FWebCtrl_UserConfirmPopup.cpp +++ b/src/controls/FWebCtrl_UserConfirmPopup.cpp @@ -19,11 +19,13 @@ * @file FWebCtrl_UserConfirmPopup.cpp * @brief The file contains the definition of _UserConfirmPopup class. */ +#include #include #include #include #include #include +#include #include #include #include @@ -31,22 +33,30 @@ #include #include #include +#include +#include #include #include +#include +#include #include +#include #include #include -#include "FWebCtrl_EflWebkit.h" +#include "FWebCtrl_WebManager.h" #include "FWebCtrl_UserConfirmPopup.h" #include "FWebCtrl_Utility.h" +#include "FWebCtrl_WebImpl.h" using namespace Tizen::Base; using namespace Tizen::Base::Collection; using namespace Tizen::Base::Utility; using namespace Tizen::Graphics; +using namespace Tizen::Graphics::_Text; using namespace Tizen::Io; using namespace Tizen::Security::Cert; +using namespace Tizen::System; using namespace Tizen::Ui; using namespace Tizen::Ui::Controls; @@ -55,28 +65,41 @@ namespace Tizen { namespace Web { namespace Controls { +static const int TEXT_SIZE_ADJUST = 1; + + _UserConfirmPopup::_UserConfirmPopup(void) : __pUserPolicyData(null) , __userConfirmMode(USER_CONFIRM_USERMEDIA) , __pCheckButton(null) + , __isUserActionNeeded(false) , __sync(false) + , __pImpl(null) { } _UserConfirmPopup::~_UserConfirmPopup(void) { + if (__isUserActionNeeded == true) + { + HandleUserAction(EINA_FALSE); + __isUserActionNeeded = false; + } } result -_UserConfirmPopup::Construct(_UserConfirmMode userConfirmMode, void* pEventInfo, bool sync) +_UserConfirmPopup::Construct(_UserConfirmMode userConfirmMode, void* pEventInfo, Tizen::Web::Controls::_WebImpl* pImpl, 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_GEOLOCATION, E_INVALID_ARG, + SysTryReturnResult(NID_WEB_CTRL, userConfirmMode >= USER_CONFIRM_USERMEDIA && userConfirmMode <= USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED, E_INVALID_ARG, "Invalid userConfirmMode is used. [%d]", userConfirmMode); + _SystemResource* pSysResource = _SystemResource::GetInstance(); + SysAssertf(pSysResource != null, "Failed to get _SystemResource instance"); + _WebPopupData* pPopupData = _WebPopup::GetPopupData(); SysTryReturn(NID_WEB_CTRL, pPopupData, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r)); @@ -84,16 +107,41 @@ _UserConfirmPopup::Construct(_UserConfirmMode userConfirmMode, void* pEventInfo, __userConfirmMode = userConfirmMode; __sync = sync; - int popupMaxHeight = 2*pPopupData->labelDim.height + 2*pPopupData->btnDim.height + 6*pPopupData->sideMargin; + __isUserActionNeeded = true; + + bool hasTitle = true; + int popupMaxHeight = 2*pPopupData->labelDim.height + pPopupData->panelHeight; + + __pImpl = pImpl; + SysAssertf(__pImpl != null, "Failed to get _WebImpl"); + if (__userConfirmMode == USER_CONFIRM_GEOLOCATION) { popupMaxHeight += pPopupData->checkDim.height; } - r = _WebPopup::Construct(true, Dimension(pPopupData->popupDim.width, popupMaxHeight)); + if (__userConfirmMode == USER_SCRIPT_ALERT) + { + 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(pSysResource->GetString(_RESOURCE_DOMAIN_ID_OSP, "IDS_TPLATFORM_HEADER_SECURITY_WARNING_ABB")); + } + + String message = L""; + if (userConfirmMode >= USER_SCRIPT_ALERT && userConfirmMode <= USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED) + { + message = msg; + } + else + { + message = GetMessageFromPolicy(); + } Rectangle rect(0, 0, 0, 0); @@ -101,19 +149,82 @@ _UserConfirmPopup::Construct(_UserConfirmMode userConfirmMode, void* pEventInfo, rect.height = 2*pPopupData->labelDim.height; rect.width = pPopupData->labelDim.width; + //With the font of label and width of label, required height is calculated + // using textobject. TEXT_SIZE_ADJUST is used to increase font size and get bigger height + // as the accurate height is not fitting text in some cases. + Font font; + r = font.Construct(FONT_STYLE_PLAIN, pPopupData->labelFontSize + TEXT_SIZE_ADJUST); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + std::unique_ptr pTextObject(new (std::nothrow) TextObject()); + SysTryReturnResult(NID_WEB_CTRL, pTextObject.get(), E_OUT_OF_MEMORY, "Memory Allocation failed."); + + r = pTextObject->Construct(); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + std::unique_ptr pSimpleText(new (std::nothrow) TextSimple(message.GetPointer(), message.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, &font)); + SysTryReturnResult(NID_WEB_CTRL, pSimpleText.get(), E_OUT_OF_MEMORY, "Memory Allocation failed."); + + r = pTextObject->AppendElement(*pSimpleText); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pSimpleText.release(); + + r = pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pTextObject->SetBounds(rect); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pTextObject->SetFont(&font, 0, message.GetLength()); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pTextObject->Compose(); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + int labelHeight = pTextObject->GetTotalHeight(); + std::unique_ptr