_UserConfirmPopup::_UserConfirmPopup(void)
: __pUserPolicyData(null)
, __userConfirmMode(USER_CONFIRM_USERMEDIA)
+ , __sync(false)
, __pCheckButton(null)
{
}
result
-_UserConfirmPopup::Construct(_UserConfirmMode userConfirmMode, void* pEventInfo)
+_UserConfirmPopup::Construct(_UserConfirmMode userConfirmMode, void* pEventInfo, bool sync)
{
result r = E_SUCCESS;
SysTryReturnResult(NID_WEB_CTRL, pEventInfo, E_INVALID_ARG, "Invalid argument(s) is used. pPolicy is null.");
__pUserPolicyData = pEventInfo;
__userConfirmMode = userConfirmMode;
+ __sync = sync;
int popupMaxHeight = 2*pPopupData->labelDim.height + 2*pPopupData->btnDim.height + 6*pPopupData->sideMargin;
if (__userConfirmMode == USER_CONFIRM_GEOLOCATION)
SysLogException(NID_WEB_CTRL, r, "[%s] Propagating.", GetErrorMessage(r));
}
- delete this;
+ if (!__sync)
+ {
+ delete this;
+ }
}
message = L"Do you want to allow acccess to media?\n";
break;
}
+ case USER_PROTOCOL_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 = 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);
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);
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
void
OnProtocolHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
{
+ result r = E_SUCCESS;
_WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
- Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
- SysAssertf(pImpl && pHandlerData, "Failed to request");
+ SysAssertf(pImpl, "Failed to request");
- ewk_custom_handlers_data_target_get(pHandlerData);
- ewk_custom_handlers_data_base_url_get(pHandlerData);
- ewk_custom_handlers_data_url_get(pHandlerData);
- ewk_custom_handlers_data_title_get(pHandlerData);
+ r = pImpl->ShowUserConfirmPopup(USER_PROTOCOL_HANDLER, pEventInfo);
+ SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
}
void
OnIsProtocolHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
{
+ int checkHandler = 0;
_WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
SysAssertf(pImpl && pHandlerData, "Failed to request");
- ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
+ checkHandler = pImpl->SearchHandler(pHandlerData, false);
+ SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+ switch (checkHandler)
+ {
+ case -1:
+ return;
+ case 0:
+ ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
+ break;
+ case 1:
+ ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
+ break;
+ case 2:
+ ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
+ break;
+ default:
+ SysAssert(false);
+ }
}
-
void
OnProtocolHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
{
+ result r = E_SUCCESS;
_WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
SysAssertf(pImpl && pHandlerData, "Failed to request");
+
+ r = pImpl->UnregistrationHandler(pHandlerData, false);
+ SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
}
void
OnContentHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
{
+ result r = E_SUCCESS;
_WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
- Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
- SysAssertf(pImpl && pHandlerData, "Failed to request");
+ SysAssertf(pImpl, "Failed to request");
+
+ r = pImpl->ShowUserConfirmPopup(USER_CONTENT_HANDLER, pEventInfo);
+ SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
}
void
OnIsContentHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
{
+ int checkHandler = 0;
_WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
SysAssertf(pImpl && pHandlerData, "Failed to request");
- ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
+ checkHandler = pImpl->SearchHandler(pHandlerData, true);
+ SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+ switch (checkHandler)
+ {
+ case -1:
+ return;
+ case 0:
+ ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
+ break;
+ case 1:
+ ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
+ break;
+ case 2:
+ ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
+ break;
+ default:
+ SysAssert(false);
+ }
}
-
void
OnContentHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
{
+ result r = E_SUCCESS;
_WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
SysAssertf(pImpl && pHandlerData, "Failed to request");
+
+ r = pImpl->UnregistrationHandler(pHandlerData, true);
+ SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
}
}
}
+ String currentUrl = pImpl->GetUrl();
+
+ String redirectUrl = pImpl->GetProtocolFromUri(url, currentUrl);
+ if (redirectUrl != null)
+ {
+ pImpl->LoadUrl(redirectUrl);
+ ewk_policy_decision_ignore(pPolicy);
+ return;
+ }
+
Uri uri;
uri.SetUri(url);
SysLog(NID_WEB_CTRL, "url : %s, mime : %ls, code : %d", pUrl, mime.GetPointer(), code);
ILoadingListener* pLoadingListener = pImpl->GetLoadingListener();
+
+ String url(ewk_policy_decision_url_get(pPolicy));
+
+
if (pLoadingListener && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy)))
{
const Eina_Hash* pHeader = ewk_policy_decision_response_headers_get(pPolicy);
{
case WEB_DECISION_CONTINUE:
{
+
+ String currentUrl = pImpl->GetUrl();
+ String redirectUrl = pImpl->GetRedirectUri(url, currentUrl, mime);
+ if (redirectUrl != L"")
+ {
+ pImpl->LoadUrl(redirectUrl);
+ ewk_policy_decision_ignore(pPolicy);
+ return;
+ }
if (pImpl->IsMimeSupported(mime) || mime == L"")
{
break;
else
{
- SysLog(NID_WEB_CTRL, "Lauch native app to handle the mime");
+ SysLog(NID_WEB_CTRL, "Launch native app to handle the mime");
ewk_policy_decision_ignore(pPolicy);
return r;
}
+result
+_WebImpl::ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy)
+{
+ result r = E_SUCCESS;
+
+ 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);
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ __pUserConfirmPopup = std::move(pUserConfirmPopup);
+
+ int modalResult = 0;
+ r = __pUserConfirmPopup->ShowAndWait(modalResult);
+ SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+CATCH:
+ __pUserConfirmPopup.reset();
+
+ return r;
+}
result
_WebImpl::ShowUserConfirmPopupAsync(_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);
+ r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, false);
SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
__pUserConfirmPopup = std::move(pUserConfirmPopup);
return dynamic_cast< const _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
}
+int
+_WebImpl::SearchHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
+{
+ int checkReturn = 0;
+ _DatabaseImpl db;
+ String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
+
+ String table;
+ if( checkmime == true)
+ {
+ table = CUSTOM_CONTENT_TABLE_NAME;
+ }
+ else
+ {
+ table = CUSTOM_PROTOCOL_TABLE_NAME;
+ }
+
+ 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));
+
+ SysLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
+
+ result r = db.Construct(handlerPath, "r+", null);
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select allow From " + table + L" Where baseUrl = '" + baseUri + L"' AND url = '" + uri + L"' AND mime = '" + target + L"'"));
+ SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+ if(pEnum.get())
+ {
+ r = pEnum->MoveNext();
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
+ r = pEnum->GetIntAt(0, checkReturn);
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
+ }
+ else
+ {
+ checkReturn = 2;
+ }
+
+ return checkReturn;
+}
+
+result
+_WebImpl::UnregistrationHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
+{
+ int checkId = 0;
+ _DatabaseImpl db;
+ String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
+
+ String table;
+ if( checkmime == true)
+ {
+ table = CUSTOM_CONTENT_TABLE_NAME;
+ }
+ else
+ {
+ table = CUSTOM_PROTOCOL_TABLE_NAME;
+ }
+
+ 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));
+
+ SysLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
+
+ result r = db.Construct(handlerPath, "r+", null);
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, 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"'"));
+ SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+ if(pEnum.get())
+ {
+ r = pEnum->MoveNext();
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+ r = pEnum->GetIntAt(0, checkId);
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ std::unique_ptr<DbStatement> pDeleteStmt(db.CreateStatementN(L"Delete From " + table + L" Where id = (?)"));
+ SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+ r = pDeleteStmt->BindInt(0, checkId);
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ db.BeginTransaction();
+
+ std::unique_ptr<DbEnumerator> pEnum(db.ExecuteStatementN(*pDeleteStmt));
+
+ db.CommitTransaction();
+ }
+
+ return E_SUCCESS;
+}
+
+const Tizen::Base::String
+_WebImpl::GetProtocolFromUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri)
+{
+ SysAssertf(currentUri != null, "Failed to get currenturi");
+
+ result r = E_SUCCESS;
+ String baseUri;
+ _DatabaseImpl db;
+ String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
+ String originReplace(originUri);
+ String table(CUSTOM_PROTOCOL_TABLE_NAME);
+ int found = 0;
+ int foundQuery = 0;
+
+ r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
+
+ r = currentUri.SubString(0, found + 1, baseUri);
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
+
+ r = db.Construct(handlerPath, "r+", null);
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
+
+ std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select mime, url, allow From " + table + L" Where baseUrl = '" + baseUri + "'"));
+ SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, L"", GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
+
+ if(pEnum.get())
+ {
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ String protocol;
+ String queryUrl;
+ int allow;
+ String originScheme;
+
+ r = pEnum->GetStringAt(0, protocol);
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
+
+ r = pEnum->GetStringAt(1, queryUrl);
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
+
+ r = pEnum->GetIntAt(2, allow);
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
+
+ if (allow == 0)
+ {
+ break;
+ }
+
+ String protocolScheme(protocol + L":");
+
+ r = originReplace.SubString(0, protocolScheme.GetLength(), originScheme);
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
+
+ if ((originReplace.GetLength() >= protocolScheme.GetLength()) && originScheme.Equals(protocolScheme, false))
+ {
+ if (queryUrl.IndexOf(L"%s", 0, foundQuery) == E_SUCCESS)
+ {
+ r = originReplace.Replace(originScheme, "");
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
+
+ queryUrl.Replace("%s", originReplace, 0);
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
+
+ return queryUrl;
+ }
+ }
+ }
+ }
+
+ return L"";
+}
+
+
+const Tizen::Base::String
+_WebImpl::GetRedirectUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri, const Tizen::Base::String& mime)
+{
+ SysAssertf(currentUri != null, "Failed to get currenturi");
+
+ result r = E_SUCCESS;
+ String baseUri;
+ String contentUrl;
+ String originUrlStr = originUri;
+ const String replaceStr = L"%s";
+ _DatabaseImpl db;
+ String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
+ String table(CUSTOM_CONTENT_TABLE_NAME);
+ int allow = 0;
+ int found = 0;
+
+ r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
+
+ r = currentUri.SubString(0, found + 1, baseUri);
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
+
+ r = db.Construct(handlerPath, "r+", null);
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
+
+ std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select allow, url From " + table + L" Where baseUrl = '" + baseUri + "' AND mime = '" + mime + L"'"));
+
+ if (pEnum.get())
+ {
+ r = pEnum->MoveNext();
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
+ r = pEnum->GetIntAt(0, allow);
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
+ r = pEnum->GetStringAt(1, contentUrl);
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
+
+ if (allow == 0)
+ {
+ return L"";
+ }
+ else
+ {
+ if (contentUrl != L"")
+ {
+ r = contentUrl.Replace(replaceStr, originUrlStr, 0);
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
+
+ return contentUrl;
+ }
+ }
+ }
+
+ return L"";
+}
}}} // Tizen::Web::Controls