* @file FWebCtrl_UserConfirmPopup.cpp
* @brief The file contains the definition of _UserConfirmPopup class.
*/
+#include <FAppApp.h>
#include <FBaseColArrayList.h>
#include <FBaseSysLog.h>
#include <FBaseUtilUri.h>
#include <FGrpDimension.h>
#include <FGrpRectangle.h>
+#include <FIoDbEnumerator.h>
+#include <FIoDbStatement.h>
#include <FSecCertX509Certificate.h>
#include <FUiCtrlButton.h>
#include <FUiCtrlLabel.h>
#include <FUiCtrlPanel.h>
#include <FUiLayout.h>
#include <FUiVerticalBoxLayout.h>
+#include <FIo_DatabaseImpl.h>
#include <FUi_ControlManager.h>
#include <FUi_ResourceManager.h>
-#include "FWebCtrl_CertificatePopup.h"
+#include "FWebCtrl_EflWebkit.h"
#include "FWebCtrl_UserConfirmPopup.h"
#include "FWebCtrl_Utility.h"
_UserConfirmPopup::_UserConfirmPopup(void)
: __pUserPolicyData(null)
- , __userConfirmMode(USER_CONFIRM_CERTIFICATE)
- , __confirm(false)
- , __sync(true)
+ , __userConfirmMode(USER_CONFIRM_USERMEDIA)
+ , __sync(false)
+ , __pCheckButton(null)
{
}
{
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_CERTIFICATE && userConfirmMode <= USER_CONFIRM_USERMEDIA, E_INVALID_ARG,
- "Invalid userConfirmMode is used. [%d]", userConfirmMode);
+ SysTryReturnResult(NID_WEB_CTRL, userConfirmMode >= USER_CONFIRM_USERMEDIA && userConfirmMode <= USER_CONFIRM_GEOLOCATION, E_INVALID_ARG,
+ "Invalid userConfirmMode is used. [%d]", userConfirmMode);
_WebPopupData* pPopupData = _WebPopup::GetPopupData();
SysTryReturn(NID_WEB_CTRL, pPopupData, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
__userConfirmMode = userConfirmMode;
__sync = sync;
- int popupMaxHeight = 0;
- popupMaxHeight = 2*pPopupData->labelDim.height + 2*pPopupData->btnDim.height + 6*pPopupData->sideMargin;
+ 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));
SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
Label* pInfoLabel = pLabel.release();
+ //checkbutton
+ if (__userConfirmMode == USER_CONFIRM_GEOLOCATION)
+ {
+ rect.y = 0;
+ rect.height = pPopupData->checkDim.height;
+
+ std::unique_ptr<CheckButton> pCheckButton (new (std::nothrow) CheckButton());
+ SysTryReturnResult(NID_WEB_CTRL, pCheckButton.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
+
+ r = pCheckButton->Construct(Rectangle(0, 0, rect.width, rect.height), CHECK_BUTTON_STYLE_MARK, BACKGROUND_STYLE_DEFAULT, false, L"Remember Preference");
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ r = AddControl(*pCheckButton);
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ __pCheckButton = pCheckButton.release();
+ }
Panel* pButtonPanel = CreateAndAddPanel();
SysTryReturn(NID_WEB_CTRL, pButtonPanel, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
r = idList.Construct();
SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
idList.Add(*(new Integer(ID_BUTTON_USER_ALLOW)));
- if (__userConfirmMode == USER_CONFIRM_CERTIFICATE)
- {
- idList.Add(*(new Integer(ID_BUTTON_USER_CERT_VIEW)));
- }
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")));
- if (__userConfirmMode == USER_CONFIRM_CERTIFICATE)
- {
- titleList.Add(*(new String(L"View")));
- }
titleList.Add(*(new String(L"Cancel")));
r = CreateAndAddButtons(idList, titleList, pButtonPanel);
SysTryReturn(NID_WEB_CTRL, pLayout.get(), r = GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
pLayout->SetHorizontalFitPolicy(*pInfoLabel, FIT_POLICY_PARENT);
+ if (__userConfirmMode == USER_CONFIRM_GEOLOCATION)
+ {
+ pLayout->SetHorizontalFitPolicy(*__pCheckButton, FIT_POLICY_PARENT);
+ }
pLayout->SetHorizontalFitPolicy(*pButtonPanel, FIT_POLICY_PARENT);
pLayout->SetHorizontalAlignment(*pInfoLabel, LAYOUT_HORIZONTAL_ALIGN_CENTER);
+ if (__userConfirmMode == USER_CONFIRM_GEOLOCATION)
+ {
+ pLayout->SetHorizontalAlignment(*__pCheckButton, LAYOUT_HORIZONTAL_ALIGN_CENTER);
+ }
pLayout->SetHorizontalAlignment(*pButtonPanel, LAYOUT_HORIZONTAL_ALIGN_CENTER);
pLayout->SetSpacing(*pButtonPanel, 2*pPopupData->sideMargin);
HandleUserAction(EINA_TRUE);
break;
- case ID_BUTTON_USER_CERT_VIEW:
- r = ShowCertificatePopup();
- SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
- return;
-
case ID_BUTTON_USER_CANCEL:
HandleUserAction(EINA_FALSE);
break;
SysLogException(NID_WEB_CTRL, r, "[%s] Propagating.", GetErrorMessage(r));
}
- if (!sync)
+ if (!__sync)
{
delete this;
}
}
-bool
-_UserConfirmPopup::GetConfirmResult() const
-{
- return __confirm;
-}
-
-
String
_UserConfirmPopup::GetMessageFromPolicy(void)
{
switch(__userConfirmMode)
{
- case USER_CONFIRM_CERTIFICATE:
+ case USER_CONFIRM_USERMEDIA:
{
- Ewk_Certificate_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Certificate_Policy_Decision* >(__pUserPolicyData);
- message = L"There are problems with the security certificate of this site.\n";
- message.Append(ewk_certificate_policy_decision_url_get(pPolicy));
+ message = L"Do you want to allow acccess to media?\n";
break;
}
- case USER_CONFIRM_USERMEDIA:
+ case USER_PROTOCOL_HANDLER:
{
- message = L"Do you want to allow acccess to media?\n";
+ Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(__pUserPolicyData);
+ SysAssertf(pHandlerData, "Failed to request");
+
+ String target(ewk_custom_handlers_data_target_get(pHandlerData));
+ String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
+
+ message = baseUri + String(L" is asking to register ") + target + String(L" protocol handler.");
+ break;
+ }
+ case USER_CONTENT_HANDLER:
+ {
+ Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(__pUserPolicyData);
+ SysAssertf(pHandlerData, "Failed to request");
+
+ String target(ewk_custom_handlers_data_target_get(pHandlerData));
+ String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
+
+ message = String(baseUri) + String(L" is asking to register ") + String(target) + String(L" content handler.");
+ break;
+ }
+ case USER_CONFIRM_GEOLOCATION:
+ {
+ Ewk_Geolocation_Permission_Request* pGeoLocPermReq = reinterpret_cast< Ewk_Geolocation_Permission_Request* >(__pUserPolicyData);
+ const Ewk_Security_Origin* pSecurityOrigin = ewk_geolocation_permission_request_origin_get(pGeoLocPermReq);
+
+ message = _Utility::CreateOrigin(pSecurityOrigin);
+ message.Append("Requests your Location");
break;
}
default:
{
switch (__userConfirmMode)
{
- case USER_CONFIRM_CERTIFICATE:
- {
- Ewk_Certificate_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Certificate_Policy_Decision* >(__pUserPolicyData);
- ewk_certificate_policy_decision_allowed_set(pPolicy, allow);
- break;
- }
case USER_CONFIRM_USERMEDIA:
{
Ewk_User_Media_Permission_Request* pPolicy = reinterpret_cast< Ewk_User_Media_Permission_Request* >(__pUserPolicyData);
ewk_user_media_permission_request_set(pPolicy, allow);
break;
}
+ case USER_PROTOCOL_HANDLER:
+ {
+ RegisterHandler(false, allow);
+ break;
+ }
+ case USER_CONTENT_HANDLER:
+ {
+ RegisterHandler(true, allow);
+ break;
+ }
+ case USER_CONFIRM_GEOLOCATION:
+ {
+ Ewk_Geolocation_Permission_Request* pPolicy = reinterpret_cast< Ewk_Geolocation_Permission_Request* >(__pUserPolicyData);
+ if (__pCheckButton->IsSelected())
+ {
+ result r = AddGeolocationDb(pPolicy, static_cast < bool >(allow));
+ SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+ }
+CATCH:
+ ewk_geolocation_permission_request_set(pPolicy, allow);
+ break;
+ }
default:
SysAssert(false);
}
-
- __confirm = static_cast< bool >(allow);
}
result
-_UserConfirmPopup::ShowCertificatePopup(void)
+_UserConfirmPopup::AddGeolocationDb(Ewk_Geolocation_Permission_Request* pPolicy, bool enable)
{
- //get Certificate information
- Ewk_Certificate_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Certificate_Policy_Decision* >(__pUserPolicyData);
- SysTryReturnResult(NID_WEB_CTRL, pPolicy, E_SYSTEM, "Certificate policy is not set.");
+ _DatabaseImpl db;
+ String geolocationPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
+ String table(GEOLOCATION_TABLE_NAME);
- std::unique_ptr<_CertificatePopup> pCertificatePopup(new (std::nothrow) _CertificatePopup());
- SysTryReturnResult(NID_WEB_CTRL, pCertificatePopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
+ const Ewk_Security_Origin* pSecurityOrigin = ewk_geolocation_permission_request_origin_get(pPolicy);
+ String origin = _Utility::CreateOrigin(pSecurityOrigin);
- result r = pCertificatePopup->Construct(pPolicy);
+ result r = db.Construct(geolocationPath, "r+", null);
SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
- r = pCertificatePopup->ShowPopup();
- SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+ std::unique_ptr<DbStatement> pStmt(db.CreateStatementN(L"Insert Into " + table + L" (origin, permission) Values (?, ?)"));
+ SysTryReturn(NID_WEB_CTRL, pStmt.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+ SysLog(NID_WEB_CTRL, "The current value of stmt is %u, host is %ls", pStmt.get(), origin.GetPointer());
+
+ pStmt->BindString(0, origin);
+ pStmt->BindInt(1, static_cast < int >(enable));
+
+ db.BeginTransaction();
+
+ std::unique_ptr<DbEnumerator> pEnum(db.ExecuteStatementN(*pStmt));
+
+ db.CommitTransaction();
- pCertificatePopup.release();
return E_SUCCESS;
}
+void
+_UserConfirmPopup::RegisterHandler(bool checkHandler, Eina_Bool allow)
+{
+ _DatabaseImpl db;
+ String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
+ String table;
+ int checkId = 0;
+
+ if(checkHandler == true)
+ {
+ table = CUSTOM_CONTENT_TABLE_NAME;
+ }
+ else
+ {
+ table = CUSTOM_PROTOCOL_TABLE_NAME;
+ }
+ Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(__pUserPolicyData);
+ SysAssertf(pHandlerData, "Failed to request");
+
+ String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
+ String uri = ewk_custom_handlers_data_url_get(pHandlerData);
+ String target = ewk_custom_handlers_data_target_get(pHandlerData);
+
+ result r = db.Construct(handlerPath, "r+", null);
+ SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select id From " + table + L" Where baseUrl = '" + baseUri + L"' AND url = '" + uri + L"' AND mime = '" + target + L"'"));
+
+ if(pEnum.get())
+ {
+ pEnum->MoveNext();
+ pEnum->GetIntAt(0, checkId);
+
+ std::unique_ptr<DbStatement> pUpdateStmt(db.CreateStatementN(L"Update " + table + L" Set allow = (?) Where id = (?)"));
+ SysTryReturnVoidResult(NID_WEB_CTRL, pUpdateStmt.get(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+ pUpdateStmt->BindInt(0, static_cast < int >(allow));
+ pUpdateStmt->BindInt(1, checkId);
+
+ db.BeginTransaction();
+
+ std::unique_ptr<DbEnumerator> pEnum(db.ExecuteStatementN(*pUpdateStmt));
+
+ db.CommitTransaction();
+
+ }
+ else
+ {
+ std::unique_ptr<DbStatement> pStmt(db.CreateStatementN(L"Insert Into " + table + L" (baseUrl, url, mime, allow) Values (?, ?, ?, ?)"));
+ SysTryReturnVoidResult(NID_WEB_CTRL, pStmt.get(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+ pStmt->BindString(0, baseUri);
+ pStmt->BindString(1, uri);
+ pStmt->BindString(2, target);
+ pStmt->BindInt(3, static_cast < int >(allow));
+
+ db.BeginTransaction();
+
+ std::unique_ptr<DbEnumerator> pRegisterEnum(db.ExecuteStatementN(*pStmt));
+
+ db.CommitTransaction();
+ }
+}
}}} // Tizen::Web::Controls