From ff57de05fea9302935a08e4659f848fc4b75cf4a Mon Sep 17 00:00:00 2001 From: Seongjun Yim Date: Wed, 24 Jul 2013 00:57:30 +0000 Subject: [PATCH] Revert "change callback functions type with static method" This reverts commit 4a43d248f2a4752e894b373180f3c429859bbe78 Change-Id: Iede7e6e54cb9f9eeb694aac0e21b755009d78997 --- src/controls/FWebCtrl_WebImpl.cpp | 5412 ++++++++++++++++++----------------- src/controls/inc/FWebCtrl_WebImpl.h | 117 +- 2 files changed, 2826 insertions(+), 2703 deletions(-) diff --git a/src/controls/FWebCtrl_WebImpl.cpp b/src/controls/FWebCtrl_WebImpl.cpp index 37fcb23..c308c2a 100755 --- a/src/controls/FWebCtrl_WebImpl.cpp +++ b/src/controls/FWebCtrl_WebImpl.cpp @@ -152,3776 +152,3965 @@ static const int LANDSCAPE_KEYPAD_HEIGHT = 316; static const int DEFAULT_LIST_ITEM_COUNT = 4; -class _JsBridgeHashCodeProvider - : public Tizen::Base::Collection::IHashCodeProviderT< Tizen::Base::String > +Eina_Bool +AddHttpHeaderData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData) { -public: - _JsBridgeHashCodeProvider(){} - virtual ~_JsBridgeHashCodeProvider(void) {} + result r = E_SUCCESS; + String key(reinterpret_cast< const char* >(pKey)); + String value(reinterpret_cast< char* >(pValue)); - int GetHashCode(const Tizen::Base::String& obj) const + SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", key.GetPointer(), value.GetPointer()); + + r = reinterpret_cast< HttpHeader* >(pUserData)->AddField(key, value); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); + + return EINA_TRUE; +} + + +Eina_Bool +AddHttpAttributeData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData) +{ + result r = E_SUCCESS; + + std::unique_ptr pAttrKey(new (std::nothrow) String(reinterpret_cast< char* >(const_cast< void* >(pKey)))); + std::unique_ptr pAttrValue(new (std::nothrow) String(reinterpret_cast< char* >(pValue))); + SysTryReturn(NID_WEB_CTRL, pAttrKey.get() && pAttrValue.get(), EINA_FALSE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", pAttrKey->GetPointer(), pAttrValue->GetPointer()); + + r = reinterpret_cast< HashMap* >(pUserData)->Add(*pAttrKey, *pAttrValue); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); + pAttrKey.release(); + pAttrValue.release(); + + return EINA_TRUE; +} + + +void +FreeCharArray(void* pData) +{ + delete[] reinterpret_cast(pData); +} + + +LoadingErrorType +ConvertErrorCode(int error) +{ + LoadingErrorType errorCode = WEB_ERROR_UNKNOWN; + + switch (error) { - return obj.GetHashCode(); + case EWK_ERROR_NETWORK_STATUS_CANCELLED: + //fall through + case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE: + //fall through + case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE_PROXY: + //fall through + case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT: + //fall through + case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT_PROXY: + //fall through + case EWK_ERROR_NETWORK_STATUS_IO_ERROR: + //fall through + case EWK_ERROR_NETWORK_STATUS_MALFORMED: + //fall through + case EWK_ERROR_NETWORK_STATUS_TRY_AGAIN: + //fall through + case EWK_ERROR_NETWORK_STATUS_TOO_MANY_REDIRECTS: + //fall through + case EWK_ERROR_NETWORK_STATUS_TLS_FAILED: + //fall through + case EWK_ERROR_NETWORK_STATUS_INTERNAL_SERVER_ERROR: + //fall through + case EWK_ERROR_NETWORK_STATUS_BAD_GATEWAY: + //fall through + case EWK_ERROR_NETWORK_STATUS_SERVICE_UNAVAILABLE: + //fall through + case EWK_ERROR_NETWORK_STATUS_GATEWAY_TIMEOUT: + errorCode = WEB_NO_CONNECTION; + break; + + case EWK_ERROR_NETWORK_STATUS_BAD_REQUEST: + //fall through + case EWK_ERROR_NETWORK_STATUS_REQUEST_URI_TOO_LONG: + errorCode = WEB_BAD_URL; + break; + + case EWK_ERROR_NETWORK_STATUS_FORBIDDEN: + errorCode = WEB_FILE_ACCESS_FAILED; + break; + + case EWK_ERROR_NETWORK_STATUS_REQUEST_TIMEOUT: + errorCode = WEB_REQUEST_TIMEOUT; + break; + + case EWK_ERROR_NETWORK_STATUS_UNSUPPORTED_MEDIA_TYPE: + errorCode = WEB_MIME_NOT_SUPPORTED; + break; + + case EWK_ERROR_NETWORK_STATUS_INSUFFICIENT_STORAGE: + errorCode = WEB_OUT_OF_MEMORY; + break; + + case EWK_ERROR_NETWORK_STATUS_REQUEST_ENTITY_TOO_LARGE: + errorCode = WEB_REQUEST_MAX_EXCEEDED; + break; + + case EWK_ERROR_NETWORK_STATUS_CONTINUE: + //fall through + case EWK_ERROR_NETWORK_STATUS_SWITCHING_PROTOCOLS: + //fall through + case EWK_ERROR_NETWORK_STATUS_PROCESSING: + //fall through + case EWK_ERROR_NETWORK_STATUS_OK: + //fall through + case EWK_ERROR_NETWORK_STATUS_CREATED: + //fall through + case EWK_ERROR_NETWORK_STATUS_ACCEPTED: + //fall through + case EWK_ERROR_NETWORK_STATUS_NON_AUTHORITATIVE: + //fall through + case EWK_ERROR_NETWORK_STATUS_NO_CONTENT: + //fall through + case EWK_ERROR_NETWORK_STATUS_RESET_CONTENT: + //fall through + case EWK_ERROR_NETWORK_STATUS_PARTIAL_CONTENT: + //fall through + case EWK_ERROR_NETWORK_STATUS_MULTI_STATUS: + //fall through + case EWK_ERROR_NETWORK_STATUS_MULTIPLE_CHOICES: + //fall through + case EWK_ERROR_NETWORK_STATUS_MOVED_PERMANENTLY: + //fall through + case EWK_ERROR_NETWORK_STATUS_FOUND: + //fall through + case EWK_ERROR_NETWORK_STATUS_SEE_OTHER: + //fall through + case EWK_ERROR_NETWORK_STATUS_NOT_MODIFIED: + //fall through + case EWK_ERROR_NETWORK_STATUS_USE_PROXY: + //fall through + case EWK_ERROR_NETWORK_STATUS_NOT_APPEARING_IN_THIS_PROTOCOL: + //fall through + case EWK_ERROR_NETWORK_STATUS_TEMPORARY_REDIRECT: + errorCode = WEB_HTTP_RESPONSE; + break; + + case EWK_ERROR_NETWORK_STATUS_SSL_FAILED: + errorCode = WEB_INVALID_CERTIFICATE; + break; + + default: + errorCode = WEB_ERROR_UNKNOWN; + break; } -}; + return errorCode; +} -//Comparer implementation -class _JsBridgeComparer - : public Tizen::Base::Collection::IComparerT< Tizen::Base::String > +result +FireLoadingErrorOccurredEvent(_WebImpl* pImpl, int code, const char* pDescription) { -public: - _JsBridgeComparer(){} - virtual ~_JsBridgeComparer(void) {} + result r = E_SUCCESS; + + std::unique_ptr pErrorCode(new (std::nothrow) Integer(code)); + std::unique_ptr pErrorDescription(new (std::nothrow) String(pDescription)); + std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED)); + SysTryReturnResult(NID_WEB_CTRL, pErrorCode.get() && pErrorDescription.get() && pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed."); + r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_TYPE, *pErrorCode.get()); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + pErrorCode.release(); - result Compare(const Tizen::Base::String& obj1, const Tizen::Base::String& obj2, int& cmp) const + r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_MESSAGE, *pErrorDescription.get()); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + pErrorDescription.release(); + + r = pImpl->GetWebEvent()->FireAsync(*pEventArg); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + pEventArg.release(); + + return E_SUCCESS; +} + + +Eina_Bool +OnScriptAlertRequested(Evas_Object* pView, const char* pMessage, void* pUserData) +{ + SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage); + + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + String msg(pMessage); + + result r = pImpl->ShowUserConfirmPopupAsync(USER_SCRIPT_ALERT, pView, msg); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + return EINA_TRUE; + +CATCH: + ewk_view_javascript_alert_reply(pView); + return EINA_TRUE; +} + + +Eina_Bool +OnScriptConfirmRequested(Evas_Object* pView, const char* pMessage, void* pUserData) +{ + SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage); + + result r = E_SUCCESS; + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + String msg(pMessage); + + r = pImpl->ShowUserConfirmPopup(USER_SCRIPT_CONFIRM, pView, msg); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); + + return EINA_TRUE; +} + + +Eina_Bool +OnScriptPromptRequested(Evas_Object* pView, const char* pMessage, const char* pDefaultValue, void* pUserData) +{ + SysLog(NID_WEB_CTRL, "The current value of message is %s, defaulValue is %s", pMessage, pDefaultValue); + + result r = E_SUCCESS; + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + + String msg(pMessage); + String defVal(pDefaultValue); + + r = pImpl->ShowPromptPopup(msg, defVal); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return EINA_TRUE; + +CATCH: + ewk_view_javascript_prompt_reply(pView, null); + + return EINA_FALSE; +} + + +void +OnCertificateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) +{ + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + 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()) { - if (obj1 == obj2) + case WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM: + { + if (pImpl->IsCertificateRequested()) { - cmp = 0; + ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast< Eina_Bool >(pImpl->IsCertificateConfirmed())); + return; + } + + result r = E_SUCCESS; + + std::unique_ptr pEnum; + + String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME); + String table(CERTIFICATE_TABLE_NAME); + _DatabaseImpl db; + + String pem(ewk_certificate_policy_decision_certificate_pem_get(pPolicy)); + + r = db.Construct(certificatePath, "r", null); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pEnum = std::unique_ptr(db.QueryN(L"Select allow From " + table + L" Where pem = '" + pem + L"'")); + if (pEnum.get()) + { + r = pEnum->MoveNext(); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + int allow = 0; + r = pEnum->GetIntAt(0, allow); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SysLog(NID_WEB_CTRL, "The current value of allow is %d", allow); + + ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast < Eina_Bool >(allow)); + pImpl->SetCertificateConfirmed(static_cast < bool >(allow)); } else { - cmp = 1; + 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()); } - return E_SUCCESS; + if (pImpl) + { + pImpl->SetCertificateRequested(true); + } + break; + } + case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CANCEL: + ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE); + break; + case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE : + ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_TRUE); + break; + default: + SysAssert(false); } -}; + return; +CATCH: + ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE); + pImpl->SetCertificateConfirmed(false); + pImpl->SetCertificateRequested(true); -_WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore) - : _ContainerImpl(pWeb, pCore) - , __isFooterVisible(false) - , __isKeypadVisible(false) - , __isKeypadOpened(false) - , __isLoadingErrorOccurred(false) - , __isRedirectRequested(false) - , __isCertificateRequested(false) - , __isCertificateConfirmed(false) - , __isFormDataVisible(false) - , __previousKeypadBounds(0, 0, 0, 0) - , __pWebCore(null) - , __pUserLoadingListener(null) - , __pUserUiListener(null) - , __pUserUiListenerF(null) - , __pUserKeypadEventListener(null) - , __pTextSearchListener(null) - , __pKeypad(null) - , __pJsBridgeList(null) - , __pJsProvider(null) - , __pJsComparer(null) - , __pWebDownloadHandler(null) - , __pWebEvent(null) - , __pAuthChallenge(null) - , __pAuthPopup(null) - , __pUserMediaConfirmPopup(null) - , __pContentHandlerConfirmPopup(null) - , __pProtocolHandlerConfirmPopup(null) - , __pGeolocationConfirmPopup(null) - , __pNotificationConfirmPopup(null) - , __pScriptAlertConfirmPopup(null) - , __pScriptConfirmPopup(null) - , __pAppCacheConfirmPopup(null) - , __pDbQuotaConfirmPopup(null) - , __pLocalFsQuotaConfirmPopup(null) - , __pIndexedDbQuotaConfirmPopup(null) - , __pPromptPopup(null) - , __pCertConfirmPopup(null) - , __pSelectBox(null) - , __pDatePicker(null) - , __pColorPicker(null) - , __pFormDataWindow(null) - , __pVibrator(null) - , __policy(WEB_DECISION_CONTINUE) - , __defaultUserAgent(L"") - , __pFormDataList(null) - , __popupClosed(false) + ewk_view_resume(pWebCore->GetWebNativeNode()); +} + + +void +OnHttpAuthenticationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) { - __textSearch.__searchAll = false; - __textSearch.__searchForward = true; - __textSearch.__caseSensitive = false; - __textSearch.__pending = 0; - __textSearch.__currentIndex = 1; - __textSearch.__totalCount = -1; - __textSearch.__text = L""; + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + Ewk_Auth_Challenge* pChallenge = reinterpret_cast< Ewk_Auth_Challenge* >(pEventInfo); + SysAssertf(pImpl && pChallenge, "Failed to request"); + + result r = E_SUCCESS; + + r = pImpl->HttpAuthenticationRequested(pChallenge); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + return; + +CATCH: + ewk_auth_challenge_credential_cancel(pChallenge); + evas_object_smart_callback_call(pView, "authentication,canceled", NULL); +} + + +void +OnHttpAuthenticationCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo) +{ + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl , "Failed to request"); + + if (pImpl->GetLoadingListener()) + { + result r = E_SUCCESS; + + std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED)); + SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get()); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + pEventArg.release(); + } +} + +Eina_Bool +OnApplicationCachePermissionRequested(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, void* pUserData) +{ + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl , "Failed to request"); + + const char* pHostName = ewk_security_origin_host_get(pSecOrigin); + String msg; + result r = msg.Format(256, L"Allow %s to use offline application cache?", pHostName); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_APP_CACHE, pView, msg); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); + + return EINA_TRUE; +} + + +Eina_Bool +OnIndexedDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData) +{ + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl , "Failed to request"); + + const char* pHostName = ewk_security_origin_host_get(pSecOrigin); + String msg; + result r = msg.Format(512, L"%s Used %lld of storage. Allow %s to use upto 2GB of indexed db?", pHostName, currentQuota, pHostName); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED, pView, msg); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); + + return EINA_TRUE; } -_WebImpl::~_WebImpl() +Eina_Bool +OnDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, const char* database_name, unsigned long long expectedQuota, void* pUserData) { - ClearCertificateDb(); + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl , "Failed to request"); + + const char* pHostName = ewk_security_origin_host_get(pSecOrigin); + String msg; + result r = msg.Format(512, L"Allow %s to open %s use upto %lld of web database?", pHostName, database_name, expectedQuota); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_DB_QUOTA_EXCEDED, pView, msg); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); + + return EINA_TRUE; } -_WebImpl* -_WebImpl::CreateWebImplN(Web* pControl, const Rectangle& bounds) +Eina_Bool OnLocalFileSystemQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData) { - result r = E_SUCCESS; + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl , "Failed to request"); - r = GET_SIZE_INFO(Web).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + const char* pHostName = ewk_security_origin_host_get(pSecOrigin); + String msg; + result r = msg.Format(512, L"%s Used %lld of storgae. Allow %s to use upto 2GB of file system?", pHostName, currentQuota, pHostName); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); - _Web* pCore = _Web::CreateWebN(); - SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED, pView, msg); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); - _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore); + return EINA_TRUE; +} - r = CheckConstruction(pCore, pImpl); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); - r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation()); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); +void +OnGeolocationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) +{ + _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); + Ewk_Geolocation_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Geolocation_Permission_Request* >(pEventInfo); + SysAssertf(pImpl && pPermissionRequest, "Failed to request"); - r = pImpl->Construct(); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + if (pImpl->GetSetting().IsGeolocationEnabled()) + { + result r = E_SUCCESS; - return pImpl; + std::unique_ptr pEnum; -CATCH: - delete pImpl; + String geolocationPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME); + String table(GEOLOCATION_TABLE_NAME); + _DatabaseImpl db; - return null; + const Ewk_Security_Origin* pSecurityOrigin = ewk_geolocation_permission_request_origin_get(pPermissionRequest); + String origin = _Utility::CreateOrigin(pSecurityOrigin); + + r = db.Construct(geolocationPath, "r", null); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pEnum = std::unique_ptr(db.QueryN(L"Select permission From " + table + L" Where origin = '" + origin + L"'")); + if (pEnum.get()) + { + r = pEnum->MoveNext(); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + int permission = 0; + r = pEnum->GetIntAt(0, permission); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SysLog(NID_WEB_CTRL, "The current value of permission is %d", permission); + + ewk_geolocation_permission_request_set(pPermissionRequest, static_cast < Eina_Bool >(permission)); + } + else + { + ewk_geolocation_permission_request_suspend(pPermissionRequest); + + r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_GEOLOCATION, pPermissionRequest); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return; + } + +CATCH: + ewk_geolocation_permission_request_set(pPermissionRequest, EINA_FALSE); } -_WebImpl* -_WebImpl::CreateWebImplN(Web* pControl, const FloatRectangle& bounds) +void +OnGetUserMediaPermissionRequsted(void* pUserData, Evas_Object* pView, void* pEventInfo) { - result r = E_SUCCESS; + _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); + Ewk_User_Media_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_User_Media_Permission_Request* >(pEventInfo); + SysAssertf(pImpl && pPermissionRequest, "Failed to request"); - r = GET_SIZE_INFO(Web).CheckInitialSizeValidF(FloatDimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + result r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_USERMEDIA, pEventInfo); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + return; - _Web* pCore = _Web::CreateWebN(); - SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); +CATCH: + ewk_user_media_permission_request_set(pPermissionRequest, EINA_FALSE); +} - _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore); - r = CheckConstruction(pCore, pImpl); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); +void +OnNotificationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) +{ + result r = E_SUCCESS; + _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); - r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation()); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + Ewk_Notification_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Notification_Permission_Request* >(pEventInfo); + SysAssertf(pImpl && pPermissionRequest, "Failed to request"); - r = pImpl->Construct(); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + ewk_notification_permission_request_suspend(pPermissionRequest); - return pImpl; + r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_NOTIFICATION, pPermissionRequest); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + return; CATCH: - delete pImpl; - - return null; + ewk_notification_permission_request_set(pPermissionRequest, EINA_FALSE); } -result -_WebImpl::Construct(void) +void +OnNotificationShow(void* pUserData, Evas_Object* pView, void* pEventInfo) { + _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); + Ewk_Notification* pNotification = reinterpret_cast< Ewk_Notification* >(pEventInfo); + SysAssertf(pImpl && pNotification, "Failed to request"); + result r = E_SUCCESS; + Ewk_Context* pContext = ewk_view_context_get(pView); + SysAssertf(pContext, "Failed to get webkit instance."); + uint64_t notificationId = ewk_notification_id_get(pNotification); - r = __mutex.Create(); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + //ewk_notification_security_origin_get(pNotification) - r = __textSearch.__searchQueue.Construct(); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + const char* text = ewk_notification_body_get(pNotification); + SysSecureLog(NID_WEB_CTRL, "The current value of icon path is %s",ewk_notification_icon_url_get(pNotification)); - r = __webNotificationList.Construct(); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + std::unique_ptr<_WebNotification> pNotificationWindow( new (std::nothrow) _WebNotification()); + SysTryReturnVoidResult(NID_WEB_CTRL, pNotificationWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - r = InitJsBridgeList(); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + r = pNotificationWindow->Construct(pContext, notificationId, pImpl); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Error propogated.", GetErrorMessage(r)); - r = InitWebEvent(); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + pNotificationWindow->SetText(String(text)); + pNotificationWindow->LaunchNotification(); + pImpl->SetWebNotification(pNotificationWindow.release()); - _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance(); - SysTryReturn(NID_WEB_CTRL, pManagerImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + ewk_notification_showed(pContext, notificationId); +} - pManagerImpl->SetDownloadListener(this); - __pWebCore = dynamic_cast< _Web* >(&(GetCore())); - SysTryReturnResult(NID_WEB_CTRL, __pWebCore, E_SYSTEM, "A system error has been occurred. Failed to get web control"); +void +OnNotificationCancel(void* pUserData, Evas_Object* pView, void* pEventInfo) +{ + _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); + uint64_t* pNotificationID = reinterpret_cast< uint64_t* >(pEventInfo); + SysAssertf(pImpl && pNotificationID, "Failed to request"); - return E_SUCCESS; + //ToDo : Where is ewk API for cancel operation? } -result -_WebImpl::InitializeSetting(void) +void +OnProtocolHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) { result r = E_SUCCESS; + _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); + SysAssertf(pImpl, "Failed to request"); - WebSetting* pWebSetting = __pWebCore->GetSetting(); - _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(pWebSetting); + r = pImpl->ShowUserConfirmPopup(USER_PROTOCOL_HANDLER, pEventInfo); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} - SetCookieEnabled(pWebSettingImpl->IsCookieEnabled()); - SetPrivateBrowsingEnabled(pWebSettingImpl->IsPrivateBrowsingEnabled()); - __defaultUserAgent = pWebSettingImpl->GetUserAgent(); +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"); - r = SetSetting(*pWebSetting); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + 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); + } +} - SetEventListenerCallback(); +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"); - return E_SUCCESS; + r = pImpl->UnregistrationHandler(pHandlerData, false); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); } -bool -_WebImpl::IsLayoutable(void) const +void +OnContentHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) { - return true; + result r = E_SUCCESS; + _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); + SysAssertf(pImpl, "Failed to request"); + + r = pImpl->ShowUserConfirmPopup(USER_CONTENT_HANDLER, pEventInfo); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); } -result -_WebImpl::InitWebEvent(void) +void +OnIsContentHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo) { - __pWebEvent = std::unique_ptr<_WebEvent>(new (std::nothrow) _WebEvent()); - SysTryReturnResult(NID_WEB_CTRL, __pWebEvent.get(), E_OUT_OF_MEMORY, "Memory allocation failed."); + 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"); - return __pWebEvent->Construct(*this); + 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); + } } -_WebEvent* -_WebImpl::GetWebEvent(void) const +void +OnContentHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) { - return __pWebEvent.get(); + 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)); } -Eina_Hash* -_WebImpl::ConvertToSlpHeaderN(const HttpHeader& header) const +void +OnFullScreenEntered(void* pUserData, Evas_Object* pView, void* pEventInfo) { - Eina_Hash* pHttpHeader = null; - - std::unique_ptr pFieldNameList(header.GetFieldNamesN()); - if (pFieldNameList.get()) - { - pHttpHeader = eina_hash_string_small_new(FreeCharArray); - SysTryReturn(NID_WEB_CTRL, pHttpHeader, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - - int count = pFieldNameList->GetCount(); + _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); + SysAssertf(pImpl, "Failed to request"); - for (int i = 0; i < count; i++) - { - String* pFieldName = dynamic_cast< String* >(pFieldNameList->GetAt(i)); - SysTryCatch(NID_WEB_CTRL, pFieldName, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + SysLog(NID_WEB_CTRL, "Enter."); +} - std::unique_ptr pKey(_StringConverter::CopyToCharArrayN(*pFieldName)); - SysTryCatch(NID_WEB_CTRL, pKey.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - std::unique_ptr pFieldValueEnum(header.GetFieldValuesN(*pFieldName)); - SysTryCatch(NID_WEB_CTRL, pFieldValueEnum.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - - while (pFieldValueEnum->MoveNext() == E_SUCCESS) - { - Eina_Bool ret = false; +void +OnFullScreenExited(void* pUserData, Evas_Object* pView, void* pEventInfo) +{ + _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); + SysAssertf(pImpl, "Failed to request"); - String* pFieldValue = dynamic_cast< String* >(pFieldValueEnum->GetCurrent()); - SysTryCatch(NID_WEB_CTRL, pFieldValue, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + SysLog(NID_WEB_CTRL, "Exit."); +} - std::unique_ptr pValue(_StringConverter::CopyToCharArrayN(*pFieldValue)); - SysTryCatch(NID_WEB_CTRL, pValue.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - ret = eina_hash_add(pHttpHeader, pKey.get(), pValue.release()); - SysTryCatch(NID_WEB_CTRL, ret == EINA_TRUE, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - } - } - } - return pHttpHeader; +void +OnVibrationRequested(uint64_t duration, void* pUserData) +{ + result r = E_SUCCESS; -CATCH: - eina_hash_free(pHttpHeader); + _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); + SysAssertf(pImpl, "Failed to request"); - return null; + r = pImpl->VibrationRequested(duration); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); } -result -_WebImpl::LoadUrl(const String& url) const +void +OnVibrationCanceled(void* pUserData) { - std::unique_ptr pUrl(_StringConverter::CopyToCharArrayN(url)); - SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - - ewk_view_url_set(__pWebCore->GetWebNativeNode(), pUrl.get()); + _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); + SysAssertf(pImpl, "Failed to request"); - return E_SUCCESS; + pImpl->VibrationCanceled(); } -result -_WebImpl::LoadUrl(const String& url, const HttpHeader& header) +void +OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) { - std::unique_ptr pUrl(_StringConverter::CopyToCharArrayN(url)); - SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - - Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header); + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo); + SysAssertf(pImpl && pPolicy, "Failed to request"); - ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_GET, pHttpHeader, null); + String url(ewk_policy_decision_url_get(pPolicy)); + SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls", url.GetPointer()); - eina_hash_free(pHttpHeader); + if (url == L"about:blank") + { + ewk_policy_decision_use(pPolicy); + return; + } - return E_SUCCESS; -} + if (pImpl->GetLoadingListener() && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy)) + && !pImpl->IsRedirectRequested()) + { + pImpl->SetCertificateRequested(false); + if (pImpl->GetTextSearchListener()) + { + pImpl->DisableAsyncSearch(); + } + + WebNavigationType navigationType = WEB_NAVIGATION_OTHER; + Ewk_Policy_Navigation_Type ewkNavigationType = ewk_policy_decision_navigation_type_get(pPolicy); -result -_WebImpl::LoadUrlWithPostRequest(const String& url, const HttpHeader& header, const ByteBuffer& body) const -{ - std::unique_ptr pUrl(_StringConverter::CopyToCharArrayN(url)); - SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + switch (ewkNavigationType) + { + case EWK_POLICY_NAVIGATION_TYPE_LINK_CLICKED: + navigationType = WEB_NAVIGATION_LINK_CLICKED; + break; + case EWK_POLICY_NAVIGATION_TYPE_FORM_SUBMITTED: + navigationType = WEB_NAVIGATION_FORM_SUBMITTED; + break; + case EWK_POLICY_NAVIGATION_TYPE_BACK_FORWARD: + navigationType = WEB_NAVIGATION_BACKFORWARD; + break; + case EWK_POLICY_NAVIGATION_TYPE_RELOAD: + navigationType = WEB_NAVIGATION_RELOAD; + break; + case EWK_POLICY_NAVIGATION_TYPE_FORM_RESUBMITTED: + navigationType = WEB_NAVIGATION_FORM_RESUBMITTED; + break; + case EWK_POLICY_NAVIGATION_TYPE_OTHER: + navigationType = WEB_NAVIGATION_OTHER; + break; + default: + SysAssert(false); + } - Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header); + if (pImpl->GetLoadingListener()->OnLoadingRequested(url, navigationType)) + { + ewk_policy_decision_ignore(pPolicy); - ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_POST, pHttpHeader, reinterpret_cast< const char* >(body.GetPointer())); + return; + } + } - eina_hash_free(pHttpHeader); + String currentUrl(pImpl->GetUrl()); + String redirectUrl(pImpl->GetProtocolFromUri(url, currentUrl)); + if (redirectUrl != L"") + { + pImpl->LoadUrl(redirectUrl); + ewk_policy_decision_ignore(pPolicy); - return E_SUCCESS; -} + return; + } + + Uri uri; + uri.SetUri(url); + String uriScheme(uri.GetScheme()); + SysLog(NID_WEB_CTRL, "The current value of scheme is %ls", uriScheme.GetPointer()); -result -_WebImpl::LoadData(const String& baseUrl, const ByteBuffer& content, const String& mime, const String& encoding) const -{ - SysTryReturnResult(NID_WEB_CTRL, content.GetLimit() > 0, E_INVALID_ARG, "The content buffer is empty."); + if ((uriScheme != L"http") && (uriScheme != L"https") && (uriScheme != L"file")) + { + ewk_policy_decision_ignore(pPolicy); - std::unique_ptr pUrl(_StringConverter::CopyToCharArrayN(baseUrl)); - std::unique_ptr pMime(_StringConverter::CopyToCharArrayN(mime)); - std::unique_ptr pEncoding(_StringConverter::CopyToCharArrayN(encoding)); - SysTryReturn(NID_WEB_CTRL, pUrl.get() && pMime.get() && pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + if (uriScheme == L"") + { + return; + } - ewk_view_contents_set(__pWebCore->GetWebNativeNode(), reinterpret_cast< const char* >(content.GetPointer()), content.GetLimit(), pMime.get(), pEncoding.get(), pUrl.get()); + result r = E_SUCCESS; - return E_SUCCESS; -} + if (uriScheme == L"tel") + { + String operationId(L"http://tizen.org/appcontrol/operation/dial"); + r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null); + } + else if (uriScheme == L"mailto" || uriScheme == L"sms" || uriScheme == L"smsto" || uriScheme == L"mms" || uriScheme == L"mmsto" ) + { + String operationId(L"http://tizen.org/appcontrol/operation/compose"); + r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null); + } + 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); + } + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + return; + } -void -_WebImpl::Pause(void) -{ - ewk_view_suspend(__pWebCore->GetWebNativeNode()); + ewk_policy_decision_use(pPolicy); } void -_WebImpl::Resume(void) -{ - ewk_view_resume(__pWebCore->GetWebNativeNode()); -} - - -bool -_WebImpl::CanGoBack(void) const +OnLoadingStarted(void* pUserData, Evas_Object* pView, void* pEventInfo) { - return static_cast< bool >(ewk_view_back_possible(__pWebCore->GetWebNativeNode())); -} - + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl, "Failed to request"); -bool -_WebImpl::CanGoForward(void) const -{ - return static_cast< bool >(ewk_view_forward_possible(__pWebCore->GetWebNativeNode())); -} + if (pImpl->GetLoadingListener()) + { + result r = E_SUCCESS; + std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_STARTED)); + SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); -void -_WebImpl::GoBack(void) const -{ - ewk_view_back(__pWebCore->GetWebNativeNode()); + r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get()); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + pEventArg.release(); + } } void -_WebImpl::GoForward(void) const +OnPageTitleReceived(void* pUserData, Evas_Object* pView, void* pEventInfo) { - ewk_view_forward(__pWebCore->GetWebNativeNode()); -} - + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + char* pTitle = reinterpret_cast< char* >(pEventInfo); + SysAssertf(pImpl, "Failed to request"); -Tizen::Base::String -_WebImpl::GetUrl(void) const -{ - return ewk_view_url_get(__pWebCore->GetWebNativeNode()); -} + SysLog(NID_WEB_CTRL, "The current value of title is %s", pTitle); + if (pImpl->GetLoadingListener()) + { + result r = E_SUCCESS; -Tizen::Base::String -_WebImpl::GetTitle(void) const -{ - return ewk_view_title_get(__pWebCore->GetWebNativeNode()); -} + std::unique_ptr pPageTitle(new (std::nothrow) String(pTitle)); + std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED)); + SysTryReturnVoidResult(NID_WEB_CTRL, pPageTitle.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + r = pEventArg->SetEventInfo(_LoadingEventArg::PAGE_TITLE, *pPageTitle.get()); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + pPageTitle.release(); -void -_WebImpl::StopLoading(void) const -{ - ewk_view_stop(__pWebCore->GetWebNativeNode()); + r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get()); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + pEventArg.release(); + } } void -_WebImpl::Reload(void) const +OnEstimatedProgress(void* pUserData, Evas_Object* pView, void* pEventInfo) { - ewk_view_reload(__pWebCore->GetWebNativeNode()); -} + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + double* pProgress = reinterpret_cast< double* >(pEventInfo); + SysAssertf(pImpl, "Failed to request"); + SysLog(NID_WEB_CTRL, "The current value of progress is %lf", *pProgress); -String* -_WebImpl::EvaluateJavascriptN(const String& scriptCode) -{ - Evas_Object* pView = __pWebCore->GetWebNativeNode(); - if (!pView) + if (pImpl->GetLoadingListener()) { - return null; - } - - std::unique_ptr 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(this)); - SysTryReturn(NID_WEB_CTRL, pPresenter.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - - ewk_view_script_execute(pView, pScript.get(), OnScriptExecuted, pPresenter.get()); + result r = E_SUCCESS; - std::unique_ptr 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)); + std::unique_ptr pProgressPercentage(new (std::nothrow) Integer(static_cast< int >(*pProgress * 100))); + std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PROGRESS)); + SysTryReturnVoidResult(NID_WEB_CTRL, pProgressPercentage.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - pPresenter->WaitAsyncProcess(*pResult.get()); + r = pEventArg->SetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS, *pProgressPercentage.get()); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + pProgressPercentage.release(); - return pResult.release(); + r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get()); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + pEventArg.release(); + } } -result -_WebImpl::SetZoomLevel(float level) +void +OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo) { - SysTryReturnResult(NID_WEB_CTRL, level >= MIN_ZOOM_LEVEL && level <= MAX_ZOOM_LEVEL, E_OUT_OF_RANGE, "The level(%f) must be between 0.3 and 2.0(%f).", level, level); + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo); + SysAssertf(pImpl && pPolicy, "Failed to request"); - ewk_view_scale_set(__pWebCore->GetWebNativeNode(), static_cast< double >(level), 0, 0); + result r = E_SUCCESS; - return E_SUCCESS; -} + _SystemResource* pSysResource = _SystemResource::GetInstance(); + SysAssertf(pSysResource != null, "Failed to get _SystemResource instance"); + const char* pUrl = ewk_policy_decision_url_get(pPolicy); + int code = ewk_policy_decision_response_status_code_get(pPolicy); + String mime(ewk_policy_decision_response_mime_get(pPolicy)); + SysSecureLog(NID_WEB_CTRL, "url : %s, mime : %ls, code : %d", pUrl, mime.GetPointer(), code); -float -_WebImpl::GetZoomLevel(void) const -{ - return static_cast< float >(ewk_view_scale_get(__pWebCore->GetWebNativeNode())); -} + ILoadingListener* pLoadingListener = pImpl->GetLoadingListener(); + String url(ewk_policy_decision_url_get(pPolicy)); -const PageNavigationList* -_WebImpl::GetBackForwardListN(void) const -{ - Evas_Object* pView = __pWebCore->GetWebNativeNode(); - if (!pView) + if (pLoadingListener && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy))) { - return null; - } - - result r = E_SUCCESS; + const Eina_Hash* pHeader = ewk_policy_decision_response_headers_get(pPolicy); - _PageNavigationListImpl* pNavigationListImpl = null; - _HistoryItemImpl* pHistoryItemImpl = null; + DecisionPolicy policy; + HttpHeader httpHeader; - std::unique_ptr pNavigationList; - std::unique_ptr pHistoryList; + if (code >= REDIRECTION_HEADER_GROUP && code < REDIRECTION_HEADER_GROUP + 100) + { + pImpl->SetRedirectRequested(true); + mime = L""; + } - int backCount = 0; - int forwardCount = 0; + eina_hash_foreach(pHeader, AddHttpHeaderData, &httpHeader); + SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - String url(L""); - String title(L""); + policy = pLoadingListener->OnWebDataReceived(mime, httpHeader); + pImpl->SetPolicyDecision(policy); + } - Ewk_History* pEwkHistoryList = ewk_view_history_get(pView); - SysTryReturn(NID_WEB_CTRL, pEwkHistoryList, null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get full history.", GetErrorMessage(E_SYSTEM)); + switch (pImpl->GetPolicyDecision()) + { + 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); - Ewk_History_Item* pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, 0); - SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_DATA_NOT_FOUND, "[%s] There is no history.", GetErrorMessage(E_DATA_NOT_FOUND)); + return; + } - pNavigationList = std::unique_ptr(new (std::nothrow) PageNavigationList()); - SysTryCatch(NID_WEB_CTRL, pNavigationList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + if (pImpl->IsMimeSupported(mime) || mime == L"") + { + break; + } + + else + { + ewk_policy_decision_ignore(pPolicy); - pNavigationListImpl = _PageNavigationListImpl::GetInstance(pNavigationList.get()); - SysTryCatch(NID_WEB_CTRL, pNavigationListImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + String operationId(L"http://tizen.org/appcontrol/operation/view"); - pHistoryList = std::unique_ptr(new (std::nothrow) ArrayList()); - SysTryCatch(NID_WEB_CTRL, pHistoryList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + r = _AppControlImpl::FindAndStart(operationId, &url, &mime, null, null, null); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS || r == E_OBJ_NOT_FOUND, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (r == E_OBJ_NOT_FOUND) + { + _SelectBox* pSelectBox = new (std::nothrow) _SelectBox; + SysTryReturnVoidResult(NID_WEB_CTRL, pSelectBox, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - r = pHistoryList->Construct(); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + r = pSelectBox->Construct(false, L"Select application", 1, null, url); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - backCount = ewk_history_back_list_length_get(pEwkHistoryList); - forwardCount = ewk_history_forward_list_length_get(pEwkHistoryList); - SysLog(NID_WEB_CTRL, "The current value of backCount is %d, forwardCount is %d", backCount, forwardCount); + 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)); + } - for (int i = -backCount; i < forwardCount + 1; i++) + return; + } + break; + } + case WEB_DECISION_DOWNLOAD: { - std::unique_ptr pHistoryItem(new (std::nothrow) HistoryItem()); - SysTryCatch(NID_WEB_CTRL, pHistoryItem.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - - pHistoryItemImpl = _HistoryItemImpl::GetInstance(pHistoryItem.get()); - SysTryCatch(NID_WEB_CTRL, pHistoryItemImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + ewk_policy_decision_ignore(pPolicy); - pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, i); - SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + _WebDataHandler* pDownloadHandler = pImpl->GetDownloadHandler(); + SysTryReturnVoidResult(NID_WEB_CTRL, pDownloadHandler, E_SYSTEM, "[%s] A system error has been occurred. Failed to get DownloadHandler.", GetErrorMessage(E_SYSTEM)); - url = ewk_history_item_uri_get(pEwkItem); - title = ewk_history_item_title_get(pEwkItem); - SysSecureLog(NID_WEB_CTRL, "The current value of url is %s, title is %s", url.GetPointer(), title.GetPointer()); + Ewk_Context* pContext = ewk_view_context_get(pView); + SysAssertf(pContext, "Failed to get webkit instance."); - pHistoryItemImpl->SetHistoryItem(url, title); + pDownloadHandler->StartDownload(pUrl); - r = pHistoryList->Add(*pHistoryItem.get()); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - pHistoryItem.release(); + return; } + case WEB_DECISION_IGNORE: + { + ewk_policy_decision_ignore(pPolicy); - pNavigationListImpl->SetPageNavigationList(pHistoryList.release(), backCount); + return; + } + default: + { + SysAssert(false); + } + } - ewk_history_free(pEwkHistoryList); + ewk_policy_decision_use(pPolicy); - return pNavigationList.release(); + return; CATCH: - ewk_history_free(pEwkHistoryList); - - return null; + ewk_policy_decision_ignore(pPolicy); } -bool -_WebImpl::SearchText(const String& text, bool searchForward) +void +OnProgressCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo) { - Evas_Object* pView = __pWebCore->GetWebNativeNode(); - if (!pView) + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl, "Failed to request"); + + if (pImpl->IsRedirectRequested()) { - return false; + pImpl->SetRedirectRequested(false); } - result r = E_SUCCESS; - - Ewk_Find_Options condition = static_cast< Ewk_Find_Options >(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE); - - if (!searchForward) + if (pImpl->IsLoadingErrorOccurred()) { - condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS); + pImpl->SetLoadingErrorOccurred(false); + evas_object_smart_callback_call(pView, "load,finished", NULL); } - - 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, pPresenter.get()); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); - - int result = 0; - pPresenter->WaitAsyncProcess(result); - - return static_cast < bool >(result); } -result -_WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive) +void +OnLoadingErrorOccurred(void* pUserData, Evas_Object* pView, void* pEventInfo) { - Evas_Object* pView = __pWebCore->GetWebNativeNode(); - if (!pView) - { - return E_SUCCESS; - } + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + Ewk_Error* pErrorData = reinterpret_cast< Ewk_Error* >(pEventInfo); + SysAssertf(pImpl && pErrorData, "Failed to request"); - result r = E_SUCCESS; + int code = ewk_error_code_get(pErrorData); + const char* pDescription = ewk_error_description_get(pErrorData); - Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT; + SysLog(NID_WEB_CTRL, "The current value of code is %d, description is %s", code, pDescription); - if (!caseSensitive) + switch (code) { - condition = static_cast (condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE); - } - - r = SynchronizeSearch(SEARCH_ALL_ASYNC, pView, condition, text, true, caseSensitive); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + case EWK_ERROR_CODE_FRAMELOADINTERRUPTEDBYPOLICYCHANGE: + pImpl->SetLoadingErrorOccurred(true); + break; - return E_SUCCESS; -} + case EWK_ERROR_CODE_PLUGINWILLHANDLELOAD: + evas_object_smart_callback_call(pView, "load,finished", NULL); + break; + case EWK_ERROR_NETWORK_STATUS_CANCELLED: + pImpl->SetLoadingErrorOccurred(true); + evas_object_smart_callback_call(pView, "load,stop", NULL); + break; -result -_WebImpl::SearchNextAsync(bool searchForward) -{ - Evas_Object* pView = __pWebCore->GetWebNativeNode(); - if (!pView) - { - return E_SUCCESS; - } + default: + pImpl->SetLoadingErrorOccurred(true); + if (pImpl->GetLoadingListener()) + { + result r = E_SUCCESS; - SysTryReturnResult(NID_WEB_CTRL, __textSearch.__searchAll && __textSearch.__totalCount > -1, E_INVALID_OPERATION, "The SearchTextAllAsync() method is not called or completed."); - SysTryReturnResult(NID_WEB_CTRL, (searchForward && __textSearch.__currentIndex < __textSearch.__totalCount) || (!searchForward && __textSearch.__currentIndex > 1) - , E_OBJ_NOT_FOUND, "The Next instance is not available."); + r = FireLoadingErrorOccurredEvent(pImpl, code, pDescription); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + break; + } +} - result r = E_SUCCESS; - Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT; +void +OnLoadingCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo) +{ + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl, "Failed to request"); - if (!__textSearch.__caseSensitive) + if (pImpl->GetLoadingListener()) { - condition = static_cast (condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE); - } + result r = E_SUCCESS; - if (!searchForward) - { - condition = static_cast (condition | EWK_FIND_OPTIONS_BACKWARDS); - } + std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_CANCELED)); + SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - r = SynchronizeSearch(SEARCH_NEXT_ASYNC, pView, condition, __textSearch.__text, searchForward); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get()); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + pEventArg.release(); + } - return E_SUCCESS; } -result -_WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text, bool searchForward, bool caseSensitive, _WebPresenter* pWebPresenter) +void +OnLoadingCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo) { - MutexGuard lock(__mutex); - - std::unique_ptr pText(_StringConverter::CopyToCharArrayN(text)); - SysTryReturn(NID_WEB_CTRL, pText.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl, "Failed to request"); - switch (type) + if (pImpl->GetLoadingListener()) { - case SEARCH_SYNC: - if (__textSearch.__searchAll) - { - DisableAsyncSearch(); - - __textSearch.__searchQueue.Enqueue(this); - __textSearch.__searchQueue.Enqueue(pWebPresenter); - - ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH); - ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH); - } - else - { - __textSearch.__searchQueue.Enqueue(pWebPresenter); - - ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH); - } - break; + result r = E_SUCCESS; - case SEARCH_ALL_ASYNC: - __textSearch.__searchAll = true; - __textSearch.__text = text; - __textSearch.__searchForward = true; - __textSearch.__caseSensitive = caseSensitive; - __textSearch.__totalCount = -1; - __textSearch.__currentIndex = 1; + std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_COMPLETED)); + SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - __textSearch.__searchQueue.Enqueue(this); - __textSearch.__searchQueue.Enqueue(this); + r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get()); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + pEventArg.release(); + } - ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH); - ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH); - break; +} - case SEARCH_NEXT_ASYNC: - __textSearch.__searchForward = searchForward; - CalculateAsyncSearchOrdinal(); +void +OnFaviconReceived(void* pUserData, Evas_Object* pView, void* pEventInfo) +{ + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl, "Failed to request"); - __textSearch.__searchQueue.Enqueue(this); + if (pImpl->GetLoadingListener()) + { + result r = E_SUCCESS; - ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH); - break; + std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED)); + SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - default: - SysAssert(false); + r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get()); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + pEventArg.release(); } - return E_SUCCESS; } void -_WebImpl::SetAsyncSearchResult(int totalCount) +OnDidStartDownloadCallback(const char* pUrl, void* pUserData) { - __textSearch.__totalCount = totalCount; + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pUrl && pImpl != null, "Failed to request"); + + SysSecureLog(NID_WEB_CTRL, "The current value of url is %s", pUrl); } -_WebPresenter* -_WebImpl::GetSearchPresenter(void) +result +FireWebPageShowRequestedEvent(_WebImpl* pImpl, int event) { - MutexGuard lock(__mutex); + result r = E_SUCCESS; - return dynamic_cast< _WebPresenter* >(__textSearch.__searchQueue.Dequeue()); -} + std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event)); + SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed."); + r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get()); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + pEventArg.release(); - int - _WebImpl::GetPendingAsyncSearchCount(void) const -{ - return __textSearch.__searchQueue.GetCount(); + return E_SUCCESS; } void -_WebImpl::CalculateAsyncSearchOrdinal(void) +OnWebPageShowRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) { - if (__textSearch.__searchForward) + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl, "Failed to request"); + + if (pImpl->GetUiEventListener()) { - __textSearch.__currentIndex++; + result r = E_SUCCESS; + + r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); } - else + if (pImpl->GetUiEventListenerF()) { - __textSearch.__currentIndex--; - } -} - + result r = E_SUCCESS; - int - _WebImpl::GetAsyncSearchOrdinal(void) const -{ - return __textSearch.__currentIndex; + r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } } - void - _WebImpl::DisableAsyncSearch(void) +void +OnWebWindowCreateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) { - __textSearch.__searchAll = false; -} - + _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(pUserData); + Evas_Object** pChildView = reinterpret_cast< Evas_Object** >(pEventInfo); + SysAssertf(pParentImpl && pChildView, "Failed to request"); -result -_WebImpl::SetSetting(const WebSetting& setting) -{ - if (__pWebCore->GetWebNativeNode()) + IWebUiEventListener* pUserUiListener = pParentImpl->GetUiEventListener(); + IWebUiEventListenerF* pUserUiListenerF = pParentImpl->GetUiEventListenerF(); + if (pUserUiListener) { - Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode()); - Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode()); - SysAssertf(pContext && pSettings, "Failed to get webkit instance."); - - std::unique_ptr pEncoding(_StringConverter::CopyToCharArrayN(setting.GetDefaultTextEncoding())); - SysTryReturn(NID_WEB_CTRL, pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - - ewk_settings_default_encoding_set(pSettings, pEncoding.get()); - - switch (setting.GetCacheControl()) + Web* pWeb = pUserUiListener->OnWebWindowCreateRequested(); + if (pWeb) { - case WEB_CACHE_VALIDATED: - ewk_context_cache_disabled_set(pContext, EINA_FALSE); - break; - - case WEB_CACHE_IGNORE: - ewk_context_cache_disabled_set(pContext, EINA_TRUE); - break; - - default: - SysAssert(false); - } + _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb); + SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM)); - if (setting.GetInputStyle() == INPUT_STYLE_OVERLAY) - { - ewk_settings_default_keypad_enabled_set(pSettings, EINA_TRUE); + *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode(); + evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl); } - else + } + if (pUserUiListenerF) + { + Web* pWeb = pUserUiListenerF->OnWebWindowCreateRequested(); + if (pWeb) { - ewk_settings_default_keypad_enabled_set(pSettings, EINA_FALSE); - } + _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb); + SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM)); - ewk_settings_font_default_size_set(pSettings, static_cast< Eina_Bool >(setting.GetFontSize())); + *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode(); + evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl); + } + } +} - ewk_settings_javascript_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsJavascriptEnabled())); - ewk_settings_loads_images_automatically_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoImageLoadEnabled())); +result +FireWebWindowClosedRequestedEvent(_WebImpl* pImpl, int event) +{ + result r = E_SUCCESS; - if (__defaultUserAgent != setting.GetUserAgent()) - { - std::unique_ptr pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent())); - SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event)); + SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed."); - ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get()); - } + r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get()); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + pEventArg.release(); - ewk_settings_auto_fitting_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFittingEnabled())); + return E_SUCCESS; +} - ewk_settings_scripts_window_open_set(pSettings, static_cast< Eina_Bool >(setting.IsJavaScriptPopupEnabled())); - ewk_settings_form_candidate_data_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFormDataShowEnabled())); +void +OnWebWindowClosedRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) +{ + _WebImpl* pChildImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pChildImpl, "Failed to request"); - ewk_settings_autofill_password_form_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoLoginFormFillEnabled())); + _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, PARENT_WEB_CTRL)); + if (pParentImpl == null) + { + return; } - _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting()); + if (pParentImpl->GetUiEventListener()) + { + result r = E_SUCCESS; - pWebSettingImpl->SetCertificateErrorHandlingMode(setting.GetCertificateErrorHandlingMode()); - pWebSettingImpl->SetDefaultTextEncoding(setting.GetDefaultTextEncoding()); - pWebSettingImpl->SetCacheControl(setting.GetCacheControl()); - pWebSettingImpl->SetFontSize(setting.GetFontSize()); - pWebSettingImpl->SetJavascriptEnabled(setting.IsJavascriptEnabled()); - pWebSettingImpl->SetAutoImageLoadEnabled(setting.IsAutoImageLoadEnabled()); - pWebSettingImpl->SetInputStyle(setting.GetInputStyle()); - pWebSettingImpl->SetUserAgent(setting.GetUserAgent()); - pWebSettingImpl->SetAutoFittingEnabled(setting.IsAutoFittingEnabled()); - pWebSettingImpl->SetJavaScriptPopupEnabled(setting.IsJavaScriptPopupEnabled()); - pWebSettingImpl->SetGeolocationEnabled(setting.IsGeolocationEnabled()); - pWebSettingImpl->SetAutoFormDataShowEnabled(setting.IsAutoFormDataShowEnabled()); - pWebSettingImpl->SetAutoLoginFormFillEnabled(setting.IsAutoLoginFormFillEnabled()); + r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + if (pParentImpl->GetUiEventListenerF()) + { + result r = E_SUCCESS; - return E_SUCCESS; + r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } } -WebSetting -_WebImpl::GetSetting(void) const -{ - return *__pWebCore->GetSetting(); +result +FireWebPreventDefaultTriggeredEvent(_WebImpl* pImpl, int event, bool trigger) +{ + result r = E_SUCCESS; + + std::unique_ptr pPreventTrigger(new (std::nothrow) Boolean(trigger)); + std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event)); + SysTryReturnResult(NID_WEB_CTRL, pPreventTrigger.get() && pEventArg.get(), E_OUT_OF_MEMORY, " Memory allocation failed." ); + + r = pEventArg->SetEventInfo(_WebUiEventArg::PREVENT_DEFAULT, *pPreventTrigger.get()); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + pPreventTrigger.release(); + + r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get()); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + pEventArg.release(); + + return E_SUCCESS; } -const HitElementResult* -_WebImpl::GetElementByPointN(const Point& point) const +void +OnWebPreventDefaultTriggered(void* pUserData, Evas_Object* pView, void* pEventInfo) { - return GetElementByPointN(_CoordinateSystemUtils::ConvertToFloat(point)); -} + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + Eina_Bool* pTrigger = reinterpret_cast< Eina_Bool* >(pEventInfo); + SysAssertf(pImpl && pTrigger, "Failed to request"); + if (pImpl->GetUiEventListener()) + { + result r = E_SUCCESS; -const HitElementResult* -_WebImpl::GetElementByPointN(const FloatPoint& point) const -{ - Evas_Object* pView = __pWebCore->GetWebNativeNode(); - if (!pView) + r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED, static_cast< bool >(*pTrigger)); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + if (pImpl->GetUiEventListenerF()) { - return null; + result r = E_SUCCESS; + + r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT, static_cast< bool >(*pTrigger)); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); } +} - SysTryReturn(NID_WEB_CTRL, Contains(point), null, E_INVALID_ARG, "[%s] The point must be contained in the bounds of a web control.", GetErrorMessage(E_INVALID_ARG)); +result +FireWebPageBlockSelectedEvent(_WebImpl* pImpl) +{ result r = E_SUCCESS; - _HitElementResultImpl* pHitElementResultImpl = null; - - std::unique_ptr pHitElementResult; - std::unique_ptr pImage; - std::unique_ptr pAttributeMap; - - Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(point))); - - Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL); - SysTryReturn(NID_WEB_CTRL, pEwkHitTest, null, E_SYSTEM, "[%s] Failed to get hit test.", GetErrorMessage(E_SYSTEM)); - - Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest); - Ewk_Hit_Test_Result_Context context = ewk_hit_test_result_context_get(pEwkHitTest); - String url(ewk_hit_test_link_uri_get(pEwkHitTest)); - String tagName(ewk_hit_test_tag_name_get(pEwkHitTest)); - String nodeValue(ewk_hit_test_node_value_get(pEwkHitTest)); - - SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls, tag is %ls, value is %ls", url.GetPointer(), tagName.GetPointer(), nodeValue.GetPointer()); - - pHitElementResult = std::unique_ptr(new (std::nothrow) HitElementResult()); - SysTryCatch(NID_WEB_CTRL, pHitElementResult.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + std::unique_ptr startPoint(new (std::nothrow) Point()); + std::unique_ptr endPoint(new (std::nothrow) Point()); + SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed."); - pHitElementResultImpl = _HitElementResultImpl::GetInstance(pHitElementResult.get()); - SysTryCatch(NID_WEB_CTRL, pHitElementResultImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + pImpl->GetBlockRange(*startPoint.get(), *endPoint.get()); - if (context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE) + if ((endPoint->x != 0) && (endPoint->y != 0)) { - ByteBuffer buf; - Image image; - ImageFormat format; - - int imageLength = ewk_hit_test_image_buffer_length_get(pEwkHitTest); - void* pImageBuffer = ewk_hit_test_image_buffer_get(pEwkHitTest); - const char* pExtension = ewk_hit_test_image_file_name_extension_get(pEwkHitTest); - SysLog(NID_WEB_CTRL, "The current value of imageBuffer is %u, bufferLength is %d, extension is %s", pImageBuffer, imageLength, pExtension); + std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED)); + SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed."); - r = buf.Construct(imageLength); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get()); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + startPoint.release(); - r = buf.SetArray(reinterpret_cast< byte* >(pImageBuffer), 0, imageLength); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get()); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + endPoint.release(); - buf.Rewind(); + r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get()); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + pEventArg.release(); + } -// ToDo : webkit doesn't support types such as IMG_FORMAT_WBMP and IMG_FORMAT_TIFF -// webkit support types such as ico and vp8 additionally - if (strcmp(pExtension, "gif") == 0) - { - format = IMG_FORMAT_GIF; - } - else if (strcmp(pExtension, "jpg") == 0) - { - format = IMG_FORMAT_JPG; - } - else if (strcmp(pExtension, "png") == 0) - { - format = IMG_FORMAT_PNG; - } - else if (strcmp(pExtension, "bmp") == 0) - { - format = IMG_FORMAT_BMP; - } - else - { - SysLogException(NID_WEB_CTRL, E_UNSUPPORTED_FORMAT, "[%s] The %s format is not supported", GetErrorMessage(E_UNSUPPORTED_FORMAT), pExtension); - goto CATCH; - } + return E_SUCCESS; +} - r = image.Construct(); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - pImage = std::unique_ptr(image.DecodeN(buf, format, BITMAP_PIXEL_FORMAT_RGB565)); - SysTryCatch(NID_WEB_CTRL, pImage.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - } +result +FireWebPageBlockSelectedEventF(_WebImpl* pImpl) +{ + result r = E_SUCCESS; - if (pAttrHash) - { - pAttributeMap = std::unique_ptr(new (std::nothrow) HashMap()); - SysTryCatch(NID_WEB_CTRL, pAttributeMap.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + std::unique_ptr startPoint(new (std::nothrow) FloatPoint()); + std::unique_ptr endPoint(new (std::nothrow) FloatPoint()); - r = pAttributeMap->Construct(eina_hash_population(pAttrHash)); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed."); - eina_hash_foreach(pAttrHash, AddHttpAttributeData, pAttributeMap.get()); - SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - } + pImpl->GetBlockRange(*startPoint.get(), *endPoint.get()); - pHitElementResultImpl->SetHitElementResult(pAttributeMap.release(), pImage.release(), tagName, nodeValue, url); + if ((endPoint->x != 0.0f) && (endPoint->y != 0.0f)) + { + std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT)); + SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed."); - ewk_hit_test_free(pEwkHitTest); + r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get()); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + startPoint.release(); - return pHitElementResult.release(); + r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get()); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + endPoint.release(); -CATCH: - ewk_hit_test_free(pEwkHitTest); + r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get()); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + pEventArg.release(); + } - return null; + return E_SUCCESS; } -bool -_WebImpl::IsLoading(void) const +void +OnWebPageBlockSelected(void* pUserData, Evas_Object* pView, void* pEventInfo) { - double percent = ewk_view_load_progress_get(__pWebCore->GetWebNativeNode()); + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl, "Failed to request"); - if (Double::Compare(percent, 0.0) > 0 && Double::Compare(percent, 1.0) < 0) + if (pImpl->GetUiEventListener()) { - return true; + result r = E_SUCCESS; + + r = FireWebPageBlockSelectedEvent(pImpl); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); } - else + if (pImpl->GetUiEventListenerF()) { - return false; + result r = E_SUCCESS; + + r = FireWebPageBlockSelectedEventF(pImpl); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); } } -String -_WebImpl::GetTextFromBlock(void) const +Eina_Bool +OnSelectUploadFile(Evas_Object* pView, Eina_Bool multipleFile, Eina_List* pAcceptTypes, const char* pCapture, void* pUserData) { - return ewk_view_text_selection_text_get(__pWebCore->GetWebNativeNode()); -} + 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); -bool -_WebImpl::IsPrivateBrowsingEnabled(void) const -{ - if (__pWebCore->GetWebNativeNode() == null) + 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) { - return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsPrivateBrowsingEnabled(); + 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); + } + } } - Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode()); - SysAssertf(pSettings, "Failed to get webkit instance."); + 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 static_cast< bool >(ewk_settings_private_browsing_enabled_get(pSettings)); + return EINA_TRUE; + +CATCH: + ewk_view_open_panel_reply(pView, null, EINA_FALSE); + return EINA_TRUE; } void -_WebImpl::SetPrivateBrowsingEnabled(bool enable) +OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo) { - if (__pWebCore->GetWebNativeNode() == null) - { - _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetPrivateBrowsingEnabled(enable); - return; - } + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + char* pJsonText = reinterpret_cast< char* >(pEventInfo); + SysAssertf(pImpl && pJsonText, "Failed to request"); - Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode()); - SysAssertf(pSettings, "Failed to get webkit instance."); + result r = E_SUCCESS; - ewk_settings_private_browsing_enabled_set(pSettings, static_cast< Eina_Bool >(enable)); -} + SysLog(NID_WEB_CTRL, "The current value of jsontext is %s", pJsonText); + std::unique_ptr<_JsBridgeArg> pEventArg(new (std::nothrow) _JsBridgeArg()); + SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); -void -_WebImpl::ClearHistory(void) -{ - ewk_view_back_forward_list_clear(__pWebCore->GetWebNativeNode()); + r = pEventArg->Construct(pJsonText); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get()); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + pEventArg.release(); } void -_WebImpl::ClearCache(void) +OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo) { - Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode()); + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + Eina_Rectangle* pEinaRect = reinterpret_cast< Eina_Rectangle* >(pEventInfo); + SysAssertf(pImpl && pEinaRect, "Failed to request"); - ewk_context_cache_clear(pContext); -} + if (pImpl->IsVisible() == false) + { + evas_object_focus_set(pView, EINA_FALSE); + } + if (pImpl->GetSetting().GetInputStyle() == INPUT_STYLE_OVERLAY) + { + _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer(); + SysAssertf(pXformer, "Failed to get CoordinateTransformer"); -void -_WebImpl::ClearCookie(void) -{ - Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode()); - Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext); + Rectangle rect(pEinaRect->x, pEinaRect->y, pEinaRect->w, pEinaRect->h); - ewk_cookie_manager_cookies_clear(pCookieManager); -} + if (rect.height == 0) + { + return; + } + _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl)); + if (pFormImpl) + { + pFormImpl->DeflateClientRectHeight(pXformer->TransformVertical(rect.height)); -void -_WebImpl::ClearFormData(void) -{ - Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode()); + if (pFormImpl->HasFooter()) + { + pFormImpl->GetCore().SetKeypadShowState(true); + pFormImpl->Draw(); + } + } - ewk_context_form_candidate_data_clear(pContext); + if (pImpl->GetWebKeypadEventListener()) + { + if (pImpl->IsKeypadVisible() == true) + { + if ((pImpl->GetPreviousKeypadBounds().width == rect.width) && (pImpl->GetPreviousKeypadBounds().height != rect.height)) + { + pImpl->GetWebKeypadEventListener()->OnWebKeypadBoundsChanged(*dynamic_cast< Web* >(&pImpl->GetPublic())); + } + } + else + { + pImpl->GetWebKeypadEventListener()->OnWebKeypadWillOpen(*dynamic_cast< Web* >(&pImpl->GetPublic())); + } + } + pImpl->SetKeypadVisibleState(true); + pImpl->SetPreviousKeypadBounds(rect); + } + else + { + result r = pImpl->SetFullScreenKeypad(); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } } void -_WebImpl::ClearLoginFormData(void) +OnWebKeypadOpened(void* pUserData, Evas_Object* pView, void* pEventInfo) { - Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode()); - - ewk_context_form_password_data_clear(pContext); -} - + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl, "Failed to request"); -bool -_WebImpl::IsCookieEnabled(void) const -{ - if (__pWebCore->GetWebNativeNode() == null) + if (pImpl->GetWebKeypadEventListener()) { - return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsCookieEnabled(); + pImpl->GetWebKeypadEventListener()->OnWebKeypadOpened(*static_cast< Web* >(&pImpl->GetPublic())); } - - Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode()); - Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext); - SysAssertf(pCookieManager, "Failed to get webkit instance."); - - 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, pPresenter.get()); - - bool result = false; - pPresenter->WaitAsyncProcess(result); - - return result; } void -_WebImpl::SetCookieEnabled(bool enable) +OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo) { - if (__pWebCore->GetWebNativeNode() == null) + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl, "Failed to request"); + + _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl)); + if (pFormImpl) { - _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetCookiEnabled(enable); + pFormImpl->DeflateClientRectHeight(0); - return; + if (pFormImpl->HasFooter()) + { + pFormImpl->GetCore().SetKeypadShowState(false); + pFormImpl->Draw(); + } } - Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode()); - Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext); - SysAssertf(pCookieManager, "Failed to get webkit instance."); - - if (enable) - { - ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS); - } - else + if (pImpl->GetWebKeypadEventListener()) { - ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER); - ewk_cookie_manager_cookies_clear(pCookieManager); + pImpl->GetWebKeypadEventListener()->OnWebKeypadClosed(*dynamic_cast< Web* >(&pImpl->GetPublic())); } + + pImpl->SetKeypadVisibleState(false); } -result -_WebImpl::SavePageAsPdf(const String& filePath, const Dimension* pSize) const +void +OnWindowObjectFocusGained(void* pUserData, Evas_Object* pWin, void* pEvent_info) { - result r = E_SUCCESS; + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl, "Failed to request"); - std::unique_ptr pFilePath(_StringConverter::CopyToCharArrayN(filePath)); - SysTryReturn(NID_WEB_CTRL, pFilePath.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + 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"); - String dirPath; - String fileExtension = File::GetFileExtension(filePath); - int pathLength = filePath.GetLength(); - int index = 0; + evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE); - SysTryReturnResult(NID_WEB_CTRL, fileExtension.Equals("pdf", false), E_INVALID_ARG, "Invalid argument(s) is used. File extension is not pdf."); + pImpl->SetKeypadVisibleState(true); + } +} - r = filePath.LastIndexOf(L"/", pathLength - 1, index); - SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid."); - r = filePath.SubString(0, index + 1, dirPath); - SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid."); - std::unique_ptr pDirPath(_StringConverter::CopyToCharArrayN(dirPath)); - SysTryReturnResult(NID_WEB_CTRL, access(pDirPath.get(), W_OK) == 0, E_INACCESSIBLE_PATH, "Directory permission is read-only."); +void +OnWebNativeNodeFocusGained(void* pUserData, Evas* pCanvas, Evas_Object* pView, void* pEventInfo) +{ + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl, "Failed to request"); - if (pSize) + if (pImpl->IsKeypadOpened() == true) { - SysTryReturnResult(NID_WEB_CTRL, pSize->width > 0 && pSize->height > 0, E_INVALID_ARG, "Invalid argument(s) is used. Size of pdf file is invalid."); - - ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), pSize->width, pSize->height, pFilePath.get()); + pImpl->SetKeypadOpened(false); } - else - { - Evas_Coord contentsWidth; - Evas_Coord contentsHeight; +} - ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &contentsWidth, &contentsHeight); - ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), contentsWidth, contentsHeight, pFilePath.get()); - } - return E_SUCCESS; -} +Eina_Bool +OnColorPickerProviderRequested(Ewk_View_Smart_Data* pSmartData, int red, int green, int blue, int alpha) +{ + SysAssertf(pSmartData, "invalid smartdata"); + _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); + SysAssertf(pWebImpl, "Failed to get Impl"); + result r = E_SUCCESS; -bool -_WebImpl::IsMimeSupported(const String& mime) const -{ - std::unique_ptr pMime(_StringConverter::CopyToCharArrayN(mime)); - SysTryReturn(NID_WEB_CTRL, pMime.get(), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + if (pWebImpl->GetColorpicker()) + { + return EINA_FALSE; + } - return static_cast< bool >(ewk_frame_can_show_mime_type(ewk_view_main_frame_get(__pWebCore->GetWebNativeNode()), pMime.get())); -} + Color color; + + r = pWebImpl->ShowColorPicker(red, green, blue, alpha, color); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r)); + byte r1, g1, b1, a1; + color.GetColorComponents(r1, g1, b1, a1); + ewk_view_color_picker_color_set(pSmartData->self, r1, g1, b1, a1); -void -_WebImpl::SetLoadingListener(ILoadingListener* pLoadingListener) -{ - __pUserLoadingListener = const_cast< ILoadingListener* >(pLoadingListener); + return EINA_TRUE; } -void -_WebImpl::SetWebUiEventListener(IWebUiEventListener* pUiEventListener) +Eina_Bool +OnColorPickerProviderDismissed(Ewk_View_Smart_Data* pSmartData) { - __pUserUiListener = pUiEventListener; -} + SysAssertf(pSmartData, "invalid smartdata"); + _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); + SysAssertf(pWebImpl, "Failed to get Impl"); -void -_WebImpl::SetWebUiEventListenerF(IWebUiEventListenerF* pUiEventListener) -{ - __pUserUiListenerF = pUiEventListener; + return pWebImpl->HideColorPicker(); } -void -_WebImpl::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener) +Eina_Bool +OnDatePickerProviderRequested(Ewk_View_Smart_Data* pSmartData, Ewk_Input_Type inputType, const char* inputValue) { - __pUserKeypadEventListener = pKeypadEventListener; -} + SysAssertf(pSmartData, "Failed to request"); + _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); + SysAssertf(pWebImpl, "Failed to get Impl"); + result r = E_SUCCESS; -void -_WebImpl::SetDownloadListener(IWebDownloadListener* pDownLoadListener) -{ - if (__pWebDownloadHandler.get() == null) + if (pWebImpl->GetDatepicker()) { - __pWebDownloadHandler = std::unique_ptr<_WebDataHandler>(new (std::nothrow) _WebDataHandler()); - SysTryReturnVoidResult(NID_WEB_CTRL, __pWebDownloadHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + ewk_view_focused_input_element_value_set(pSmartData->self, inputValue); + + return EINA_FALSE; } - __pWebDownloadHandler->SetDownloadListener(pDownLoadListener); - __pWebDownloadHandler->SetWebEvent(__pWebEvent.get()); + String dateStr; + + r = pWebImpl->ShowDatePicker(inputType, inputValue, dateStr); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r)); + + std::unique_ptr pDateStr(_StringConverter::CopyToCharArrayN(dateStr)); + SysTryReturn(NID_WEB_CTRL, pDateStr.get(), EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + ewk_view_focused_input_element_value_set(pSmartData->self, pDateStr.get()); + + return EINA_TRUE; } -void -_WebImpl::SetTextSearchListener(ITextSearchListener* pTextSearchListener) +Eina_Bool +OnSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex) { - __pTextSearchListener = pTextSearchListener; -} + SysAssertf(pSmartData, "Failed to request"); + _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); + SysAssertf(pWebImpl, "Failed to get Impl"); -void -_WebImpl::SetScrollEnabled(bool enable) -{ - _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetScrollEnabled(enable); + result r = pWebImpl->ShowSelectBoxPopup(false, L"", pItems, pSmartData->self, selectedIndex); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); + + return EINA_TRUE; } -bool -_WebImpl::IsScrollEnabled(void) const +Eina_Bool +OnMultiSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* pItems) { - return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled(); -} + SysAssertf(pSmartData, "Failed to request"); + _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); + SysAssertf(pWebImpl, "Failed to get Impl"); -result -_WebImpl::InitJsBridgeList(void) -{ - result r = E_SUCCESS; + result r = pWebImpl->ShowSelectBoxPopup(true, L"", pItems, pSmartData->self, 0); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); - __pJsProvider = std::unique_ptr<_JsBridgeHashCodeProvider>(new (std::nothrow) _JsBridgeHashCodeProvider()); - SysTryReturnResult(NID_WEB_CTRL, __pJsProvider.get(), E_OUT_OF_MEMORY, "Memory Allocation failed."); + return EINA_TRUE; +} - __pJsComparer = std::unique_ptr<_JsBridgeComparer>(new (std::nothrow) _JsBridgeComparer()); - SysTryReturnResult(NID_WEB_CTRL, __pJsComparer.get(), E_OUT_OF_MEMORY, "Memory Allocation failed."); - std::unique_ptr > pJsBridgeList(new (std::nothrow) HashMapT< String, IJavaScriptBridge* >); - SysTryReturnResult(NID_WEB_CTRL, pJsBridgeList.get(), E_OUT_OF_MEMORY, "Memory Allocation failed."); +Eina_Bool +OnSelectBoxClosed(Ewk_View_Smart_Data* pSmartData) +{ + SysAssertf(pSmartData, "invalid smartdata"); - r = pJsBridgeList->Construct(0, 0, *__pJsProvider.get(), *__pJsComparer.get()); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); + SysAssertf(pWebImpl, "Failed to get Impl"); - __pJsBridgeList = std::move(pJsBridgeList); + result r = pWebImpl->ClearSelectBoxPopup(); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); - return E_SUCCESS; + return EINA_TRUE; } -result -_WebImpl::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge) +Eina_Bool +OnSelectBoxUpdateRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, Eina_List* pItems, int selectedIndex) { - result r = E_SUCCESS; + SysAssertf(pSmartData, "invalid smartdata"); - IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge); - String key(pJsBridge->GetName()); + _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); + SysAssertf(pWebImpl, "Failed to get Impl"); - r = __pJsBridgeList->Add(key, pJsBridge); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + result r = pWebImpl->UpdateSelectBoxPopup(pItems, selectedIndex, false); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); - return E_SUCCESS; + return EINA_TRUE; } -result -_WebImpl::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge) +Eina_Bool +OnFormDataCandidateShow(Ewk_View_Smart_Data *pSmartData, int x, int y, int w, int h) { - result r = E_SUCCESS; + SysAssertf(pSmartData, "Failed to request"); - IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge); - String key(pJsBridge->GetName()); + _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); + SysAssertf(pWebImpl, "Failed to get Impl"); - r = __pJsBridgeList->Remove(key); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + Rectangle windowRect(x, y, w, h); + result r = pWebImpl->ShowFormDataWindow(windowRect, pSmartData->self); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); - return E_SUCCESS; + return EINA_TRUE; } -IJavaScriptBridge* -_WebImpl::FindJsInterface(const IJsonValue* pValue) const +Eina_Bool +OnFormDataCandidateHide(Ewk_View_Smart_Data *pSmartData) { - result r = E_SUCCESS; + SysAssertf(pSmartData, "Failed to request"); - IJsonValue* pJsonValue = null; - IJavaScriptBridge* pJsBridge = null; + _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); + SysAssertf(pWebImpl, "Failed to get Impl"); - String key(L"name"); + if (pWebImpl->IsFormDataWindowVisible()) + { + pWebImpl->HideFormDataWindow(); + } - const JsonObject* pJsonObject = dynamic_cast< const JsonObject* >(pValue); - SysTryReturn(NID_WEB_CTRL, pJsonObject, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. Json text must be Json Object type." , GetErrorMessage(E_INVALID_ARG)); + return EINA_TRUE; +} - r = pJsonObject->GetValue(&key, pJsonValue); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS && pJsonValue, null, r, "[%s] Propagating.", GetErrorMessage(r)); - JsonString* pBridgeName = dynamic_cast< JsonString* >(pJsonValue); - SysTryReturn(NID_WEB_CTRL, pBridgeName, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. name key is missing." , GetErrorMessage(E_INVALID_ARG)); +Eina_Bool +OnFormDataCandidateUpdate(Ewk_View_Smart_Data *pSmartData, Eina_List *pDataList) +{ + SysAssertf(pSmartData, "Failed to request"); - r = __pJsBridgeList->GetValue(static_cast< String >(*pBridgeName), pJsBridge); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); + SysAssertf(pWebImpl, "Failed to get Impl"); - return pJsBridge; + pWebImpl->SetFormDataList(pDataList); + + return EINA_TRUE; } -ILoadingListener* -_WebImpl::GetLoadingListener(void) const +Eina_Bool +OnFormDataCandidateIsShowing(Ewk_View_Smart_Data *pSmartData) { - return __pUserLoadingListener; -} + SysAssertf(pSmartData, "Failed to request"); + _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); + SysAssertf(pWebImpl, "Failed to get Impl"); -IWebUiEventListener* -_WebImpl::GetUiEventListener(void) const -{ - return __pUserUiListener; + if (pWebImpl->IsFormDataWindowVisible()) + { + return EINA_TRUE; + } + else + { + return EINA_FALSE; + } } -IWebUiEventListenerF* -_WebImpl::GetUiEventListenerF(void) const +void +OnCookiesPolicyGot(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *pError, void *pUserData) { - return __pUserUiListenerF; -} + _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData); + SysAssertf(pPresenter && !pError, "Failed to request"); + bool ret = EINA_TRUE; -IWebKeypadEventListener* -_WebImpl::GetWebKeypadEventListener(void) const -{ - return __pUserKeypadEventListener; -} + switch (policy) + { + case EWK_COOKIE_ACCEPT_POLICY_ALWAYS: + //fall through + case EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY: + ret = EINA_TRUE; + break; + + case EWK_COOKIE_ACCEPT_POLICY_NEVER: + //fall through + ret = EINA_FALSE; + break; + default: + SysAssert(false); + } -ITextSearchListener* -_WebImpl::GetTextSearchListener(void) const -{ - return __pTextSearchListener; + SysLog(NID_WEB_CTRL, "The current value of policy is %d", ret); + + pPresenter->EndAsyncProcess(ret); } void -_WebImpl::SetEventListenerCallback(void) const +OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData) { - Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode(); - if (pWebNativeNode) + _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData); + SysAssertf(pPresenter, "Failed to request"); + + String result(pResult); + SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer()); + + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, WEB_CTRL)); + _WebManager* pWebManager = _WebManager::GetInstance(); + if (pWebManager->IsValidCallback(reinterpret_cast< int >(pImpl), reinterpret_cast< int >(pPresenter))) { - _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); - SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas"); + pPresenter->EndAsyncProcess(result); + } +} - Evas_Object* pWinObject = pEcoreEvas->GetWindowObject(); - SysAssertf(pWinObject, "Failed to get Ui window evas object"); - Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode); - SysAssertf(pSmartData, "Failed to request"); +void +OnTextFound(void* pUserData, Evas_Object* pView, void* pEventInfo) +{ + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl, "Failed to request"); - Ewk_View_Smart_Class *pSmart = const_cast(pSmartData->api); - SysAssertf(pSmart, "Failed to request"); + int* pTotalCount = reinterpret_cast< int* >(pEventInfo); + SysLog(NID_WEB_CTRL, "The current value of totalCount is %d", *pTotalCount); - pSmart->popup_menu_show = OnSelectBoxRequested; - pSmart->multiple_popup_menu_show = OnMultiSelectBoxRequested; - pSmart->popup_menu_hide = OnSelectBoxClosed; - pSmart->popup_menu_update = OnSelectBoxUpdateRequested; + _WebPresenter* pWebPresenter = pImpl->GetSearchPresenter(); - pSmart->input_picker_show = OnDatePickerProviderRequested; - pSmart->input_picker_color_request = OnColorPickerProviderRequested; - pSmart->input_picker_color_dismiss = OnColorPickerProviderDismissed; + if (pWebPresenter) + { + pWebPresenter->EndAsyncProcess(*pTotalCount); + } + else + { + if (pImpl->GetTextSearchListener()) + { + result r = E_SUCCESS; - pSmart->formdata_candidate_show = OnFormDataCandidateShow; - pSmart->formdata_candidate_hide = OnFormDataCandidateHide; - pSmart->formdata_candidate_update_data = OnFormDataCandidateUpdate; - pSmart->formdata_candidate_is_showing = OnFormDataCandidateIsShowing; + int ordinal = 0; - evas_object_data_set(pWebNativeNode, WEB_CTRL, this); + if (*pTotalCount > 0) + { + ordinal = pImpl->GetAsyncSearchOrdinal(); + pImpl->SetAsyncSearchResult(*pTotalCount); + } - // add loading event callbacks for ILoadingListener - evas_object_smart_callback_add(pWebNativeNode, "create,window", OnWebWindowCreateRequested, this); - evas_object_smart_callback_add(pWebNativeNode, "close,window", OnWebWindowClosedRequested, this); + if (pImpl->GetPendingAsyncSearchCount() > 0) + { + return; + } - evas_object_smart_callback_add(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested, this); - evas_object_smart_callback_add(pWebNativeNode, "load,started", OnLoadingStarted, this); - evas_object_smart_callback_add(pWebNativeNode, "load,finished", OnLoadingCompleted, this); - evas_object_smart_callback_add(pWebNativeNode, "load,progress", OnEstimatedProgress, this); - evas_object_smart_callback_add(pWebNativeNode, "load,progress,finished", OnProgressCompleted, this); - evas_object_smart_callback_add(pWebNativeNode, "load,stop", OnLoadingCanceled, this); - evas_object_smart_callback_add(pWebNativeNode, "load,error", OnLoadingErrorOccurred, this); - evas_object_smart_callback_add(pWebNativeNode, "title,changed", OnPageTitleReceived, this); + std::unique_ptr pCount(new (std::nothrow) Integer(*pTotalCount)); + std::unique_ptr pOrdinal(new (std::nothrow) Integer(ordinal)); + std::unique_ptr<_TextSearchEventArg> pEventArg(new (std::nothrow) _TextSearchEventArg(WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND)); + SysTryReturnVoidResult(NID_WEB_CTRL, pCount.get() && pOrdinal.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - evas_object_smart_callback_add(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest, this); + r = pEventArg->SetEventInfo(_TextSearchEventArg::TOTAL_COUNT, *pCount.get()); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + pCount.release(); - evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, this); + r = pEventArg->SetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL, *pOrdinal.get()); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + pOrdinal.release(); + + r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get()); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + pEventArg.release(); + } + } +} - evas_object_smart_callback_add(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged, this); - evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened, this); - evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed, this); - evas_object_smart_callback_add(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested, this); - evas_object_smart_callback_add(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled, this); +class _JsBridgeHashCodeProvider + : public Tizen::Base::Collection::IHashCodeProviderT< Tizen::Base::String > +{ +public: + _JsBridgeHashCodeProvider(){} + virtual ~_JsBridgeHashCodeProvider(void) {} - evas_object_smart_callback_add(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested, this); - ewk_view_javascript_alert_callback_set(pWebNativeNode, OnScriptAlertRequested, const_cast< _WebImpl* >(this)); - ewk_view_javascript_prompt_callback_set(pWebNativeNode, OnScriptPromptRequested, const_cast< _WebImpl* >(this)); - ewk_view_javascript_confirm_callback_set(pWebNativeNode, OnScriptConfirmRequested, const_cast< _WebImpl* >(this)); + int GetHashCode(const Tizen::Base::String& obj) const + { + return obj.GetHashCode(); + } - evas_object_smart_callback_add(pWebNativeNode, "policy,response,decide", OnWebDataReceived, this); +}; - evas_object_smart_callback_add(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested, this); - evas_object_smart_callback_add(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested, this); - evas_object_smart_callback_add(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted, this); - evas_object_smart_callback_add(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested, this); - evas_object_smart_callback_add(pWebNativeNode, "notification,show", OnNotificationShow, this); - evas_object_smart_callback_add(pWebNativeNode, "notification,cancel", OnNotificationCancel, this); +//Comparer implementation +class _JsBridgeComparer + : public Tizen::Base::Collection::IComparerT< Tizen::Base::String > +{ +public: + _JsBridgeComparer(){} + virtual ~_JsBridgeComparer(void) {} - evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested, this); - evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered, this); - evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested, this); - evas_object_smart_callback_add(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested, this); - evas_object_smart_callback_add(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered, this); - evas_object_smart_callback_add(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested, this); - evas_object_smart_callback_add(pWebNativeNode, "text,found", OnTextFound, this); + result Compare(const Tizen::Base::String& obj1, const Tizen::Base::String& obj2, int& cmp) const + { + if (obj1 == obj2) + { + cmp = 0; + } + else + { + cmp = 1; + } - evas_object_smart_callback_add(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered, this); - evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this); + return E_SUCCESS; + } - evas_object_smart_callback_add(pWebNativeNode, "text,selected", OnWebPageBlockSelected, 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)); - ewk_context_vibration_client_callbacks_set(pContext, OnVibrationRequested, OnVibrationCanceled, const_cast< _WebImpl* >(this)); +_WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore) + : _ContainerImpl(pWeb, pCore) + , __isFooterVisible(false) + , __isKeypadVisible(false) + , __isKeypadOpened(false) + , __isLoadingErrorOccurred(false) + , __isRedirectRequested(false) + , __isCertificateRequested(false) + , __isCertificateConfirmed(false) + , __isFormDataVisible(false) + , __keypadBounds(0, 0, 0, 0) + , __pWebCore(null) + , __pUserLoadingListener(null) + , __pUserUiListener(null) + , __pUserUiListenerF(null) + , __pUserKeypadEventListener(null) + , __pTextSearchListener(null) + , __pKeypad(null) + , __pJsBridgeList(null) + , __pJsProvider(null) + , __pJsComparer(null) + , __pWebDownloadHandler(null) + , __pWebEvent(null) + , __pAuthChallenge(null) + , __pAuthPopup(null) + , __pUserMediaConfirmPopup(null) + , __pContentHandlerConfirmPopup(null) + , __pProtocolHandlerConfirmPopup(null) + , __pGeolocationConfirmPopup(null) + , __pNotificationConfirmPopup(null) + , __pScriptAlertConfirmPopup(null) + , __pScriptConfirmPopup(null) + , __pAppCacheConfirmPopup(null) + , __pDbQuotaConfirmPopup(null) + , __pLocalFsQuotaConfirmPopup(null) + , __pIndexedDbQuotaConfirmPopup(null) + , __pPromptPopup(null) + , __pCertConfirmPopup(null) + , __pSelectBox(null) + , __pDatePicker(null) + , __pColorPicker(null) + , __pFormDataWindow(null) + , __pVibrator(null) + , __policy(WEB_DECISION_CONTINUE) + , __defaultUserAgent(L"") + , __pFormDataList(null) + , __popupClosed(false) +{ + __textSearch.__searchAll = false; + __textSearch.__searchForward = true; + __textSearch.__caseSensitive = false; + __textSearch.__pending = 0; + __textSearch.__currentIndex = 1; + __textSearch.__totalCount = -1; + __textSearch.__text = L""; +} - ewk_view_application_cache_permission_callback_set(pWebNativeNode, OnApplicationCachePermissionRequested, const_cast< _WebImpl* >(this)); - ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, OnIndexedDatabaseQuotaExceeded, const_cast< _WebImpl* >(this)); - ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, OnDatabaseQuotaExceeded, const_cast< _WebImpl* >(this)); - ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, OnLocalFileSystemQuotaExceeded, const_cast< _WebImpl* >(this)); - evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this); - } +_WebImpl::~_WebImpl() +{ + ClearCertificateDb(); } -void -_WebImpl::RemoveEventListenerCallback(void) const +_WebImpl* +_WebImpl::CreateWebImplN(Web* pControl, const Rectangle& bounds) { - Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode(); - if (pWebNativeNode) - { - _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); - SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas"); + result r = E_SUCCESS; - Evas_Object* pWinObject = pEcoreEvas->GetWindowObject(); - SysAssertf(pWinObject, "Failed to get Ui window evas object"); + r = GET_SIZE_INFO(Web).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); - evas_object_smart_callback_del(pWebNativeNode, "create,window", OnWebWindowCreateRequested); - evas_object_smart_callback_del(pWebNativeNode, "close,window", OnWebWindowClosedRequested); + _Web* pCore = _Web::CreateWebN(); + SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - evas_object_smart_callback_del(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested); - evas_object_smart_callback_del(pWebNativeNode, "load,started", OnLoadingStarted); - evas_object_smart_callback_del(pWebNativeNode, "load,finished", OnLoadingCompleted); - evas_object_smart_callback_del(pWebNativeNode, "load,progress", OnEstimatedProgress); - evas_object_smart_callback_del(pWebNativeNode, "load,progress,finished", OnProgressCompleted); - evas_object_smart_callback_del(pWebNativeNode, "load,stop", OnLoadingCanceled); - evas_object_smart_callback_del(pWebNativeNode, "load,error", OnLoadingErrorOccurred); - evas_object_smart_callback_del(pWebNativeNode, "title,changed", OnPageTitleReceived); + _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore); - evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest); + r = CheckConstruction(pCore, pImpl); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); - evas_object_smart_callback_del_full(pWinObject, "focus,in", OnWindowObjectFocusGained, this); + r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation()); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - evas_object_smart_callback_del(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged); - evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened); - evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed); + r = pImpl->Construct(); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - evas_object_smart_callback_del(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested); - evas_object_smart_callback_del(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled); + return pImpl; - evas_object_smart_callback_del(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested); +CATCH: + delete pImpl; - 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); + return null; +} - evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived); - evas_object_smart_callback_del(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested); - evas_object_smart_callback_del(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested); - evas_object_smart_callback_del(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted); +_WebImpl* +_WebImpl::CreateWebImplN(Web* pControl, const FloatRectangle& bounds) +{ + result r = E_SUCCESS; - evas_object_smart_callback_del(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested); - evas_object_smart_callback_del(pWebNativeNode, "notification,show", OnNotificationShow); - evas_object_smart_callback_del(pWebNativeNode, "notification,cancel", OnNotificationCancel); - evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested); - evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered); - evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested); + r = GET_SIZE_INFO(Web).CheckInitialSizeValidF(FloatDimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); - evas_object_smart_callback_del(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested); - evas_object_smart_callback_del(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered); - evas_object_smart_callback_del(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested); + _Web* pCore = _Web::CreateWebN(); + SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - evas_object_smart_callback_del(pWebNativeNode, "text,found", OnTextFound); + _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore); - evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered); - evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived); + r = CheckConstruction(pCore, pImpl); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); - evas_object_smart_callback_del(pWebNativeNode, "text,selected", OnWebPageBlockSelected); + r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation()); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - evas_object_smart_callback_del(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered); - evas_object_smart_callback_del(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited); + r = pImpl->Construct(); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - 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); + return pImpl; - ewk_view_application_cache_permission_callback_set(pWebNativeNode, null, null); - ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, null, null); - ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, null, null); - ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, null, null); +CATCH: + delete pImpl; - evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained); - } + return null; } -void -_WebImpl::ClearCertificateDb(void) +result +_WebImpl::Construct(void) { result r = E_SUCCESS; - String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME); - String table(CERTIFICATE_TABLE_NAME); - _DatabaseImpl db; + r = __mutex.Create(); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - r = db.Construct(certificatePath, "r+", null); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + r = __textSearch.__searchQueue.Construct(); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - db.BeginTransaction(); + r = __webNotificationList.Construct(); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - r = db.ExecuteSql(L"Delete From " + table, true); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + r = InitJsBridgeList(); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - db.CommitTransaction(); + r = InitWebEvent(); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - return; + _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance(); + SysTryReturn(NID_WEB_CTRL, pManagerImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); -CATCH: - db.RollbackTransaction(); -} + pManagerImpl->SetDownloadListener(this); + __pWebCore = dynamic_cast< _Web* >(&(GetCore())); + SysTryReturnResult(NID_WEB_CTRL, __pWebCore, E_SYSTEM, "A system error has been occurred. Failed to get web control"); -result -_WebImpl::SetBlockSelectionPosition(const Point& startPoint) -{ - return SetBlockSelectionPosition(_CoordinateSystemUtils::ConvertToFloat(startPoint)); + return E_SUCCESS; } result -_WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint) +_WebImpl::InitializeSetting(void) { - Evas_Object* pView = __pWebCore->GetWebNativeNode(); - Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pView); - if (pSmartData && pSmartData->api) - { - Point absPoint( _CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(startPoint))); - - Eina_Bool ret = pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y); - if (ret) - { - pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y); + result r = E_SUCCESS; - Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL); - SysTryReturnResult(NID_WEB_CTRL, pEwkHitTest, E_SYSTEM, "Failed to get hit test."); + WebSetting* pWebSetting = __pWebCore->GetSetting(); + _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(pWebSetting); - String tagName(ewk_hit_test_tag_name_get(pEwkHitTest)); + SetCookieEnabled(pWebSettingImpl->IsCookieEnabled()); + SetPrivateBrowsingEnabled(pWebSettingImpl->IsPrivateBrowsingEnabled()); - if (tagName.Equals(L"INPUT", false) || tagName.Equals(L"TEXTAREA", false)) - { - ewk_view_command_execute(pView, "SelectWord", 0); - } - else - { - Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest); - char* pValue = reinterpret_cast< char* >(eina_hash_find(pAttrHash, "contenteditable")); - if(pValue) - { - ewk_view_command_execute(pView, "SelectWord", 0); - } - } - } - } + __defaultUserAgent = pWebSettingImpl->GetUserAgent(); - SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up."); + r = SetSetting(*pWebSetting); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - evas_object_smart_callback_call(pView, "text,selected", NULL); + SetEventListenerCallback(); return E_SUCCESS; } -void -_WebImpl::ReleaseBlock(void) +bool +_WebImpl::IsLayoutable(void) const { - ewk_view_text_selection_range_clear(__pWebCore->GetWebNativeNode()); + return true; } -void -_WebImpl::GetBlockRange(Point& startPoint, Point& endPoint) const +result +_WebImpl::InitWebEvent(void) { - FloatPoint tempStartPoint; - FloatPoint tempEndPoint; - - GetBlockRange(tempStartPoint, tempEndPoint); + __pWebEvent = std::unique_ptr<_WebEvent>(new (std::nothrow) _WebEvent()); + SysTryReturnResult(NID_WEB_CTRL, __pWebEvent.get(), E_OUT_OF_MEMORY, "Memory allocation failed."); - startPoint = _CoordinateSystemUtils::ConvertToInteger(tempStartPoint); - endPoint = _CoordinateSystemUtils::ConvertToInteger(tempEndPoint); + return __pWebEvent->Construct(*this); } -void -_WebImpl::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const +_WebEvent* +_WebImpl::GetWebEvent(void) const { - Eina_Rectangle leftHandle; - Eina_Rectangle rightHandle; - - EINA_RECTANGLE_SET(&leftHandle, 0, 0, 0, 0); - EINA_RECTANGLE_SET(&rightHandle, 0, 0, 0, 0); - - ewk_view_text_selection_range_get(__pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle); - - startPoint.x = _CoordinateSystemUtils::ConvertToFloat(leftHandle.x); - startPoint.y = _CoordinateSystemUtils::ConvertToFloat(leftHandle.y); - endPoint.x = _CoordinateSystemUtils::ConvertToFloat(rightHandle.x + rightHandle.w); - endPoint.y = _CoordinateSystemUtils::ConvertToFloat(rightHandle.y + rightHandle.h); - - if ((endPoint.x != 0.0f) && (endPoint.y != 0.0f)) - { - startPoint = __pWebCore->GetRelativeCoordinate(startPoint); - endPoint = __pWebCore->GetRelativeCoordinate(endPoint); - } + return __pWebEvent.get(); } -Bitmap* -_WebImpl::GetFaviconN(void) const +Eina_Hash* +_WebImpl::ConvertToSlpHeaderN(const HttpHeader& header) const { - result r = E_SUCCESS; - - Evas_Object* pView = __pWebCore->GetWebNativeNode(); - Ewk_Context* pContext = ewk_view_context_get(pView); - const char* pUrl = ewk_view_url_get(pView); - Evas* pEvas = evas_object_evas_get(pView); + Eina_Hash* pHttpHeader = null; - Evas_Object* pFavicon = ewk_context_icon_database_icon_object_add(pContext, pUrl, pEvas); - if (!pFavicon) + std::unique_ptr pFieldNameList(header.GetFieldNamesN()); + if (pFieldNameList.get()) { - return null; - } + pHttpHeader = eina_hash_string_small_new(FreeCharArray); + SysTryReturn(NID_WEB_CTRL, pHttpHeader, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + int count = pFieldNameList->GetCount(); - Tizen::Graphics::BufferInfo bufferInfo; + for (int i = 0; i < count; i++) + { + String* pFieldName = dynamic_cast< String* >(pFieldNameList->GetAt(i)); + SysTryCatch(NID_WEB_CTRL, pFieldName, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - r = _Utility::GetPixelBufferFromEvasObject(pFavicon, bufferInfo); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + std::unique_ptr pKey(_StringConverter::CopyToCharArrayN(*pFieldName)); + SysTryCatch(NID_WEB_CTRL, pKey.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - const Dimension dimension(bufferInfo.width, bufferInfo.height); - Tizen::Base::ByteBuffer byteBuffer; - - r = byteBuffer.Construct((byte*)bufferInfo.pPixels, 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 ); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + std::unique_ptr pFieldValueEnum(header.GetFieldValuesN(*pFieldName)); + SysTryCatch(NID_WEB_CTRL, pFieldValueEnum.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + while (pFieldValueEnum->MoveNext() == E_SUCCESS) + { + Eina_Bool ret = false; - std::unique_ptr pImage(new (std::nothrow) Bitmap()); - SysTryReturn(NID_WEB_CTRL, pImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + String* pFieldValue = dynamic_cast< String* >(pFieldValueEnum->GetCurrent()); + SysTryCatch(NID_WEB_CTRL, pFieldValue, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - r = pImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + std::unique_ptr pValue(_StringConverter::CopyToCharArrayN(*pFieldValue)); + SysTryCatch(NID_WEB_CTRL, pValue.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - return pImage.release(); + ret = eina_hash_add(pHttpHeader, pKey.get(), pValue.release()); + SysTryCatch(NID_WEB_CTRL, ret == EINA_TRUE, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + } + } + } + return pHttpHeader; + +CATCH: + eina_hash_free(pHttpHeader); + return null; } -void -_WebImpl::ScrollBy(const Tizen::Graphics::Point& diff) +result +_WebImpl::LoadUrl(const String& url) const { - ewk_view_scroll_by(__pWebCore->GetWebNativeNode(), diff.x, diff.y); -} + std::unique_ptr pUrl(_StringConverter::CopyToCharArrayN(url)); + SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + ewk_view_url_set(__pWebCore->GetWebNativeNode(), pUrl.get()); -void -_WebImpl::ScrollTo(const Tizen::Graphics::Point& dest) -{ - ewk_view_scroll_set(__pWebCore->GetWebNativeNode(), dest.x, dest.y); + return E_SUCCESS; } -Point -_WebImpl::GetScrollPosition(void) const +result +_WebImpl::LoadUrl(const String& url, const HttpHeader& header) { - Point position; + std::unique_ptr pUrl(_StringConverter::CopyToCharArrayN(url)); + SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header); - ewk_view_scroll_pos_get(__pWebCore->GetWebNativeNode(), &position.x, &position.y); + ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_GET, pHttpHeader, null); - return position; + eina_hash_free(pHttpHeader); + + return E_SUCCESS; } -Dimension -_WebImpl::GetPageSize(void) const +result +_WebImpl::LoadUrlWithPostRequest(const String& url, const HttpHeader& header, const ByteBuffer& body) const { - Evas_Coord width = 0; - Evas_Coord height = 0; + std::unique_ptr pUrl(_StringConverter::CopyToCharArrayN(url)); + SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &width, &height); + Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header); - Dimension size(static_cast< int >(width), static_cast< int >(height)); + ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_POST, pHttpHeader, reinterpret_cast< const char* >(body.GetPointer())); - return size; + eina_hash_free(pHttpHeader); + + return E_SUCCESS; } result -_WebImpl::AddHttpHeaderField(const String& name, const String& value) +_WebImpl::LoadData(const String& baseUrl, const ByteBuffer& content, const String& mime, const String& encoding) const { - SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing."); - - std::unique_ptr pName(_StringConverter::CopyToCharArrayN(name)); - SysTryReturn(NID_WEB_CTRL, pName.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + SysTryReturnResult(NID_WEB_CTRL, content.GetLimit() > 0, E_INVALID_ARG, "The content buffer is empty."); - std::unique_ptr pValue(_StringConverter::CopyToCharArrayN(value)); + std::unique_ptr pUrl(_StringConverter::CopyToCharArrayN(baseUrl)); + std::unique_ptr pMime(_StringConverter::CopyToCharArrayN(mime)); + std::unique_ptr pEncoding(_StringConverter::CopyToCharArrayN(encoding)); + SysTryReturn(NID_WEB_CTRL, pUrl.get() && pMime.get() && pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - ewk_view_custom_header_add(__pWebCore->GetWebNativeNode(), pName.get(), pValue.get()); + ewk_view_contents_set(__pWebCore->GetWebNativeNode(), reinterpret_cast< const char* >(content.GetPointer()), content.GetLimit(), pMime.get(), pEncoding.get(), pUrl.get()); return E_SUCCESS; } -result -_WebImpl::RemoveHttpHeaderField(const String& name) +void +_WebImpl::Pause(void) { - SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing."); - - std::unique_ptr pName(_StringConverter::CopyToCharArrayN(name)); - SysTryReturn(NID_WEB_CTRL, pName.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + ewk_view_suspend(__pWebCore->GetWebNativeNode()); +} - ewk_view_custom_header_remove(__pWebCore->GetWebNativeNode(), pName.get()); - return E_SUCCESS; +void +_WebImpl::Resume(void) +{ + ewk_view_resume(__pWebCore->GetWebNativeNode()); } result -_WebImpl::SetFullScreenKeypad(void) +_WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List* pItems, Evas_Object* pWebView, int selectedIndex) { + __pSelectBox.reset(); + + SysTryReturnResult(NID_WEB_CTRL, eina_list_count(pItems) > 0, E_SYSTEM, "ItemCount is invalid."); + result r = E_SUCCESS; - std::unique_ptr pKeypad(new (std::nothrow) Keypad()); - SysTryReturnResult(NID_WEB_CTRL, pKeypad.get(), E_OUT_OF_MEMORY, "Memory allocation failed."); + std::unique_ptr<_SelectBox> pSelectBox(new (std::nothrow) _SelectBox()); + SysTryReturnResult(NID_WEB_CTRL, pSelectBox.get(), E_OUT_OF_MEMORY, "Memory allocation failed."); - r = pKeypad->Construct(KEYPAD_STYLE_NORMAL, 100); + r = pSelectBox->Construct(isMultiSelect, title, DEFAULT_LIST_ITEM_COUNT, pWebView); SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - String text(ewk_view_focused_input_element_value_get(__pWebCore->GetWebNativeNode())); - pKeypad->SetText(text); + r = pSelectBox->UpdateList(pItems, selectedIndex, false, false); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pSelectBox = std::move(pSelectBox); + + return __pSelectBox->ShowPopup(); +} + + +result +_WebImpl::UpdateSelectBoxPopup(Eina_List* pItems, int selectedIndex, bool isGroupedList) +{ + SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist."); - r = pKeypad->SetShowState(true); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + return __pSelectBox->UpdateList(pItems, selectedIndex, true, isGroupedList); +} - r = pKeypad->Show(); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - pKeypad->AddTextEventListener(*this); +result +_WebImpl::ClearSelectBoxPopup(void) +{ + SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist."); - __pKeypad = std::move(pKeypad); + __pSelectBox.reset(); return E_SUCCESS; } -void -_WebImpl::RemoveFullScreenKeypad(void) +_InputPickerPopup* +_WebImpl::GetDatepicker(void) { - __pKeypad->RemoveTextEventListener(*this); + _InputPickerPopup* pInputPicker =null; + if (__pDatePicker) + { + pInputPicker = __pDatePicker.get(); + } + return pInputPicker; +} - __pKeypad.reset(); + +_InputPickerPopup* +_WebImpl::GetColorpicker(void) +{ + _InputPickerPopup* pInputPicker =null; + if (__pColorPicker) + { + pInputPicker = __pColorPicker.get(); + } + return pInputPicker; } bool -_WebImpl::IsKeypadVisible(void) const +_WebImpl::CanGoBack(void) const { - return __isKeypadVisible; + return static_cast< bool >(ewk_view_back_possible(__pWebCore->GetWebNativeNode())); } -Rectangle -_WebImpl::GetPreviousKeypadBounds(void) const +bool +_WebImpl::CanGoForward(void) const { - return __previousKeypadBounds; + return static_cast< bool >(ewk_view_forward_possible(__pWebCore->GetWebNativeNode())); } void -_WebImpl::OnTextValueChangeCanceled(const Control& source) +_WebImpl::GoBack(void) const { - RemoveFullScreenKeypad(); + ewk_view_back(__pWebCore->GetWebNativeNode()); } void -_WebImpl::OnTextValueChanged(const Control& source) +_WebImpl::GoForward(void) const { - std::unique_ptr pText(_StringConverter::CopyToCharArrayN(__pKeypad->GetText())); - - ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get()); - - RemoveFullScreenKeypad(); + ewk_view_forward(__pWebCore->GetWebNativeNode()); } -Eina_Bool -_WebImpl::AddHttpHeaderData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData) +Tizen::Base::String +_WebImpl::GetUrl(void) const { - result r = E_SUCCESS; - - String key(reinterpret_cast< const char* >(pKey)); - String value(reinterpret_cast< char* >(pValue)); - - SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", key.GetPointer(), value.GetPointer()); - - r = reinterpret_cast< HttpHeader* >(pUserData)->AddField(key, value); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); - - return EINA_TRUE; + return ewk_view_url_get(__pWebCore->GetWebNativeNode()); } -Eina_Bool -_WebImpl::AddHttpAttributeData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData) +Tizen::Base::String +_WebImpl::GetTitle(void) const { - result r = E_SUCCESS; - - std::unique_ptr pAttrKey(new (std::nothrow) String(reinterpret_cast< char* >(const_cast< void* >(pKey)))); - std::unique_ptr pAttrValue(new (std::nothrow) String(reinterpret_cast< char* >(pValue))); - SysTryReturn(NID_WEB_CTRL, pAttrKey.get() && pAttrValue.get(), EINA_FALSE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - - SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", pAttrKey->GetPointer(), pAttrValue->GetPointer()); + return ewk_view_title_get(__pWebCore->GetWebNativeNode()); +} - r = reinterpret_cast< HashMap* >(pUserData)->Add(*pAttrKey, *pAttrValue); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); - pAttrKey.release(); - pAttrValue.release(); - return EINA_TRUE; +void +_WebImpl::StopLoading(void) const +{ + ewk_view_stop(__pWebCore->GetWebNativeNode()); } void -_WebImpl::FreeCharArray(void* pData) +_WebImpl::Reload(void) const { - delete[] reinterpret_cast(pData); + ewk_view_reload(__pWebCore->GetWebNativeNode()); } -LoadingErrorType -_WebImpl::ConvertErrorCode(int error) +String* +_WebImpl::EvaluateJavascriptN(const String& scriptCode) { - LoadingErrorType errorCode = WEB_ERROR_UNKNOWN; - - switch (error) + Evas_Object* pView = __pWebCore->GetWebNativeNode(); + if (!pView) { - case EWK_ERROR_NETWORK_STATUS_CANCELLED: - //fall through - case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE: - //fall through - case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE_PROXY: - //fall through - case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT: - //fall through - case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT_PROXY: - //fall through - case EWK_ERROR_NETWORK_STATUS_IO_ERROR: - //fall through - case EWK_ERROR_NETWORK_STATUS_MALFORMED: - //fall through - case EWK_ERROR_NETWORK_STATUS_TRY_AGAIN: - //fall through - case EWK_ERROR_NETWORK_STATUS_TOO_MANY_REDIRECTS: - //fall through - case EWK_ERROR_NETWORK_STATUS_TLS_FAILED: - //fall through - case EWK_ERROR_NETWORK_STATUS_INTERNAL_SERVER_ERROR: - //fall through - case EWK_ERROR_NETWORK_STATUS_BAD_GATEWAY: - //fall through - case EWK_ERROR_NETWORK_STATUS_SERVICE_UNAVAILABLE: - //fall through - case EWK_ERROR_NETWORK_STATUS_GATEWAY_TIMEOUT: - errorCode = WEB_NO_CONNECTION; - break; - - case EWK_ERROR_NETWORK_STATUS_BAD_REQUEST: - //fall through - case EWK_ERROR_NETWORK_STATUS_REQUEST_URI_TOO_LONG: - errorCode = WEB_BAD_URL; - break; - - case EWK_ERROR_NETWORK_STATUS_FORBIDDEN: - errorCode = WEB_FILE_ACCESS_FAILED; - break; - - case EWK_ERROR_NETWORK_STATUS_REQUEST_TIMEOUT: - errorCode = WEB_REQUEST_TIMEOUT; - break; - - case EWK_ERROR_NETWORK_STATUS_UNSUPPORTED_MEDIA_TYPE: - errorCode = WEB_MIME_NOT_SUPPORTED; - break; - - case EWK_ERROR_NETWORK_STATUS_INSUFFICIENT_STORAGE: - errorCode = WEB_OUT_OF_MEMORY; - break; + return null; + } + + std::unique_ptr pScript(_StringConverter::CopyToCharArrayN(scriptCode)); + SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - case EWK_ERROR_NETWORK_STATUS_REQUEST_ENTITY_TOO_LARGE: - errorCode = WEB_REQUEST_MAX_EXCEEDED; - break; + 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)); - case EWK_ERROR_NETWORK_STATUS_CONTINUE: - //fall through - case EWK_ERROR_NETWORK_STATUS_SWITCHING_PROTOCOLS: - //fall through - case EWK_ERROR_NETWORK_STATUS_PROCESSING: - //fall through - case EWK_ERROR_NETWORK_STATUS_OK: - //fall through - case EWK_ERROR_NETWORK_STATUS_CREATED: - //fall through - case EWK_ERROR_NETWORK_STATUS_ACCEPTED: - //fall through - case EWK_ERROR_NETWORK_STATUS_NON_AUTHORITATIVE: - //fall through - case EWK_ERROR_NETWORK_STATUS_NO_CONTENT: - //fall through - case EWK_ERROR_NETWORK_STATUS_RESET_CONTENT: - //fall through - case EWK_ERROR_NETWORK_STATUS_PARTIAL_CONTENT: - //fall through - case EWK_ERROR_NETWORK_STATUS_MULTI_STATUS: - //fall through - case EWK_ERROR_NETWORK_STATUS_MULTIPLE_CHOICES: - //fall through - case EWK_ERROR_NETWORK_STATUS_MOVED_PERMANENTLY: - //fall through - case EWK_ERROR_NETWORK_STATUS_FOUND: - //fall through - case EWK_ERROR_NETWORK_STATUS_SEE_OTHER: - //fall through - case EWK_ERROR_NETWORK_STATUS_NOT_MODIFIED: - //fall through - case EWK_ERROR_NETWORK_STATUS_USE_PROXY: - //fall through - case EWK_ERROR_NETWORK_STATUS_NOT_APPEARING_IN_THIS_PROTOCOL: - //fall through - case EWK_ERROR_NETWORK_STATUS_TEMPORARY_REDIRECT: - errorCode = WEB_HTTP_RESPONSE; - break; + ewk_view_script_execute(pView, pScript.get(), OnScriptExecuted, pPresenter.get()); - case EWK_ERROR_NETWORK_STATUS_SSL_FAILED: - errorCode = WEB_INVALID_CERTIFICATE; - break; + std::unique_ptr 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)); - default: - errorCode = WEB_ERROR_UNKNOWN; - break; - } + pPresenter->WaitAsyncProcess(*pResult.get()); - return errorCode; + return pResult.release(); } result -_WebImpl::FireLoadingErrorOccurredEvent(_WebImpl* pImpl, int code, const char* pDescription) +_WebImpl::SetZoomLevel(float level) { - result r = E_SUCCESS; - - std::unique_ptr pErrorCode(new (std::nothrow) Integer(code)); - std::unique_ptr pErrorDescription(new (std::nothrow) String(pDescription)); - std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED)); - SysTryReturnResult(NID_WEB_CTRL, pErrorCode.get() && pErrorDescription.get() && pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed."); - - r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_TYPE, *pErrorCode.get()); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - pErrorCode.release(); - - r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_MESSAGE, *pErrorDescription.get()); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - pErrorDescription.release(); + SysTryReturnResult(NID_WEB_CTRL, level >= MIN_ZOOM_LEVEL && level <= MAX_ZOOM_LEVEL, E_OUT_OF_RANGE, "The level(%f) must be between 0.3 and 2.0(%f).", level, level); - r = pImpl->GetWebEvent()->FireAsync(*pEventArg); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - pEventArg.release(); + ewk_view_scale_set(__pWebCore->GetWebNativeNode(), static_cast< double >(level), 0, 0); return E_SUCCESS; } - -Eina_Bool -_WebImpl::OnScriptAlertRequested(Evas_Object* pView, const char* pMessage, void* pUserData) -{ - SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage); - - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - String msg(pMessage); - - result r = pImpl->ShowUserConfirmPopupAsync(USER_SCRIPT_ALERT, pView, msg); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - return EINA_TRUE; - -CATCH: - ewk_view_javascript_alert_reply(pView); - return EINA_TRUE; -} - - -Eina_Bool -_WebImpl::OnScriptConfirmRequested(Evas_Object* pView, const char* pMessage, void* pUserData) -{ - SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage); - - result r = E_SUCCESS; - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - String msg(pMessage); - - r = pImpl->ShowUserConfirmPopup(USER_SCRIPT_CONFIRM, pView, msg); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); - - return EINA_TRUE; + +float +_WebImpl::GetZoomLevel(void) const +{ + return static_cast< float >(ewk_view_scale_get(__pWebCore->GetWebNativeNode())); } -Eina_Bool -_WebImpl::OnScriptPromptRequested(Evas_Object* pView, const char* pMessage, const char* pDefaultValue, void* pUserData) +const PageNavigationList* +_WebImpl::GetBackForwardListN(void) const { - SysLog(NID_WEB_CTRL, "The current value of message is %s, defaulValue is %s", pMessage, pDefaultValue); + Evas_Object* pView = __pWebCore->GetWebNativeNode(); + if (!pView) + { + return null; + } result r = E_SUCCESS; - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - String msg(pMessage); - String defVal(pDefaultValue); - - r = pImpl->ShowPromptPopup(msg, defVal); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + _PageNavigationListImpl* pNavigationListImpl = null; + _HistoryItemImpl* pHistoryItemImpl = null; - return EINA_TRUE; + std::unique_ptr pNavigationList; + std::unique_ptr pHistoryList; -CATCH: - ewk_view_javascript_prompt_reply(pView, null); + int backCount = 0; + int forwardCount = 0; - return EINA_FALSE; -} + String url(L""); + String title(L""); + Ewk_History* pEwkHistoryList = ewk_view_history_get(pView); + SysTryReturn(NID_WEB_CTRL, pEwkHistoryList, null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get full history.", GetErrorMessage(E_SYSTEM)); -void -_WebImpl::OnCertificateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) -{ - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - Ewk_Certificate_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Certificate_Policy_Decision* >(pEventInfo); - SysAssertf(pImpl && pPolicy, "Failed to request"); + Ewk_History_Item* pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, 0); + SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_DATA_NOT_FOUND, "[%s] There is no history.", GetErrorMessage(E_DATA_NOT_FOUND)); - switch (pImpl->GetSetting().GetCertificateErrorHandlingMode()) - { - case WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM: - { - if (pImpl->__isCertificateRequested) - { - ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast< Eina_Bool >(pImpl->__isCertificateConfirmed)); - return; - } - pImpl->__isCertificateRequested = true; + pNavigationList = std::unique_ptr(new (std::nothrow) PageNavigationList()); + SysTryCatch(NID_WEB_CTRL, pNavigationList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - result r = E_SUCCESS; + pNavigationListImpl = _PageNavigationListImpl::GetInstance(pNavigationList.get()); + SysTryCatch(NID_WEB_CTRL, pNavigationListImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - std::unique_ptr pEnum; + pHistoryList = std::unique_ptr(new (std::nothrow) ArrayList()); + SysTryCatch(NID_WEB_CTRL, pHistoryList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME); - String table(CERTIFICATE_TABLE_NAME); - _DatabaseImpl db; + r = pHistoryList->Construct(); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - String pem(ewk_certificate_policy_decision_certificate_pem_get(pPolicy)); + backCount = ewk_history_back_list_length_get(pEwkHistoryList); + forwardCount = ewk_history_forward_list_length_get(pEwkHistoryList); + SysLog(NID_WEB_CTRL, "The current value of backCount is %d, forwardCount is %d", backCount, forwardCount); - r = db.Construct(certificatePath, "r", null); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + for (int i = -backCount; i < forwardCount + 1; i++) + { + std::unique_ptr pHistoryItem(new (std::nothrow) HistoryItem()); + SysTryCatch(NID_WEB_CTRL, pHistoryItem.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - pEnum = std::unique_ptr(db.QueryN(L"Select allow From " + table + L" Where pem = '" + pem + L"'")); - if (pEnum.get()) - { - r = pEnum->MoveNext(); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + pHistoryItemImpl = _HistoryItemImpl::GetInstance(pHistoryItem.get()); + SysTryCatch(NID_WEB_CTRL, pHistoryItemImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - int allow = 0; - r = pEnum->GetIntAt(0, allow); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, i); + SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - SysLog(NID_WEB_CTRL, "The current value of allow is %d", allow); + url = ewk_history_item_uri_get(pEwkItem); + title = ewk_history_item_title_get(pEwkItem); + SysSecureLog(NID_WEB_CTRL, "The current value of url is %s, title is %s", url.GetPointer(), title.GetPointer()); - ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast < Eina_Bool >(allow)); - pImpl->__isCertificateConfirmed = static_cast < bool >(allow); - } - else - { - _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore())); + pHistoryItemImpl->SetHistoryItem(url, title); - r = pImpl->ShowCertificateConfirmPopup(CERTIFICATE_POPUP_MODE_USER_CONFIRM, pPolicy); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + r = pHistoryList->Add(*pHistoryItem.get()); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + pHistoryItem.release(); + } - ewk_view_resume(pWebCore->GetWebNativeNode()); - } + pNavigationListImpl->SetPageNavigationList(pHistoryList.release(), backCount); - if (pImpl) - { - pImpl->__isCertificateRequested = true; - } - break; - } - case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CANCEL: - ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE); - break; - case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE : - ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_TRUE); - break; - default: - SysAssert(false); - } + ewk_history_free(pEwkHistoryList); - return; + return pNavigationList.release(); CATCH: - ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE); - pImpl->__isCertificateConfirmed = false; + ewk_history_free(pEwkHistoryList); - _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore())); - ewk_view_resume(pWebCore->GetWebNativeNode()); + return null; } -void -_WebImpl::OnHttpAuthenticationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) +bool +_WebImpl::SearchText(const String& text, bool searchForward) { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - Ewk_Auth_Challenge* pChallenge = reinterpret_cast< Ewk_Auth_Challenge* >(pEventInfo); - SysAssertf(pImpl && pChallenge, "Failed to request"); + Evas_Object* pView = __pWebCore->GetWebNativeNode(); + if (!pView) + { + return false; + } result r = E_SUCCESS; - r = pImpl->HttpAuthenticationRequested(pChallenge); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - return; - -CATCH: - ewk_auth_challenge_credential_cancel(pChallenge); - evas_object_smart_callback_call(pView, "authentication,canceled", NULL); -} - - -void -_WebImpl::OnHttpAuthenticationCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo) -{ - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pImpl , "Failed to request"); + Ewk_Find_Options condition = static_cast< Ewk_Find_Options >(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE); - if (pImpl->__pUserLoadingListener) + if (!searchForward) { - result r = E_SUCCESS; - - std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED)); - SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - - r = pImpl->__pWebEvent->FireAsync(*pEventArg.get()); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - pEventArg.release(); + condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS); } -} -Eina_Bool -_WebImpl::OnApplicationCachePermissionRequested(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, void* pUserData) -{ - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pImpl , "Failed to request"); + 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)); - const char* pHostName = ewk_security_origin_host_get(pSecOrigin); - String msg; - result r = msg.Format(256, L"Allow %s to use offline application cache?", pHostName); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, 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)); - r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_APP_CACHE, pView, msg); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); + int result = 0; + pPresenter->WaitAsyncProcess(result); - return EINA_TRUE; + return static_cast < bool >(result); } -Eina_Bool -_WebImpl::OnIndexedDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData) +result +_WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive) { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pImpl , "Failed to request"); - - const char* pHostName = ewk_security_origin_host_get(pSecOrigin); - String msg; - result r = msg.Format(512, L"%s Used %lld of storage. Allow %s to use upto 2GB of indexed db?", pHostName, currentQuota, pHostName); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); - - r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED, pView, msg); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); - - return EINA_TRUE; -} + Evas_Object* pView = __pWebCore->GetWebNativeNode(); + if (!pView) + { + return E_SUCCESS; + } + result r = E_SUCCESS; -Eina_Bool -_WebImpl::OnDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, const char* database_name, unsigned long long expectedQuota, void* pUserData) -{ - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pImpl , "Failed to request"); + Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT; - const char* pHostName = ewk_security_origin_host_get(pSecOrigin); - String msg; - result r = msg.Format(512, L"Allow %s to open %s use upto %lld of web database?", pHostName, database_name, expectedQuota); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); + if (!caseSensitive) + { + condition = static_cast (condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE); + } - r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_DB_QUOTA_EXCEDED, pView, msg); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); + r = SynchronizeSearch(SEARCH_ALL_ASYNC, pView, condition, text, true, caseSensitive); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - return EINA_TRUE; + return E_SUCCESS; } -Eina_Bool -_WebImpl::OnLocalFileSystemQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData) +result +_WebImpl::SearchNextAsync(bool searchForward) { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pImpl , "Failed to request"); + Evas_Object* pView = __pWebCore->GetWebNativeNode(); + if (!pView) + { + return E_SUCCESS; + } - const char* pHostName = ewk_security_origin_host_get(pSecOrigin); - String msg; - result r = msg.Format(512, L"%s Used %lld of storgae. Allow %s to use upto 2GB of file system?", pHostName, currentQuota, pHostName); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturnResult(NID_WEB_CTRL, __textSearch.__searchAll && __textSearch.__totalCount > -1, E_INVALID_OPERATION, "The SearchTextAllAsync() method is not called or completed."); + SysTryReturnResult(NID_WEB_CTRL, (searchForward && __textSearch.__currentIndex < __textSearch.__totalCount) || (!searchForward && __textSearch.__currentIndex > 1) + , E_OBJ_NOT_FOUND, "The Next instance is not available."); - r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED, pView, msg); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); + result r = E_SUCCESS; - return EINA_TRUE; -} + Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT; + if (!__textSearch.__caseSensitive) + { + condition = static_cast (condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE); + } -void -_WebImpl::OnGeolocationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) -{ - _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); - Ewk_Geolocation_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Geolocation_Permission_Request* >(pEventInfo); - SysAssertf(pImpl && pPermissionRequest, "Failed to request"); + if (!searchForward) + { + condition = static_cast (condition | EWK_FIND_OPTIONS_BACKWARDS); + } - if (pImpl->GetSetting().IsGeolocationEnabled()) - { - result r = E_SUCCESS; + r = SynchronizeSearch(SEARCH_NEXT_ASYNC, pView, condition, __textSearch.__text, searchForward); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - std::unique_ptr pEnum; + return E_SUCCESS; +} - String geolocationPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME); - String table(GEOLOCATION_TABLE_NAME); - _DatabaseImpl db; - const Ewk_Security_Origin* pSecurityOrigin = ewk_geolocation_permission_request_origin_get(pPermissionRequest); - String origin = _Utility::CreateOrigin(pSecurityOrigin); +result +_WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text, bool searchForward, bool caseSensitive, _WebPresenter* pWebPresenter) +{ + MutexGuard lock(__mutex); - r = db.Construct(geolocationPath, "r", null); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + std::unique_ptr pText(_StringConverter::CopyToCharArrayN(text)); + SysTryReturn(NID_WEB_CTRL, pText.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - pEnum = std::unique_ptr(db.QueryN(L"Select permission From " + table + L" Where origin = '" + origin + L"'")); - if (pEnum.get()) + switch (type) + { + case SEARCH_SYNC: + if (__textSearch.__searchAll) { - r = pEnum->MoveNext(); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - - int permission = 0; - r = pEnum->GetIntAt(0, permission); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + DisableAsyncSearch(); - SysLog(NID_WEB_CTRL, "The current value of permission is %d", permission); + __textSearch.__searchQueue.Enqueue(this); + __textSearch.__searchQueue.Enqueue(pWebPresenter); - ewk_geolocation_permission_request_set(pPermissionRequest, static_cast < Eina_Bool >(permission)); + ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH); + ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH); } else { - ewk_geolocation_permission_request_suspend(pPermissionRequest); + __textSearch.__searchQueue.Enqueue(pWebPresenter); - r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_GEOLOCATION, pPermissionRequest); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH); } + break; - return; - } - -CATCH: - ewk_geolocation_permission_request_set(pPermissionRequest, EINA_FALSE); -} - - -void -_WebImpl::OnGetUserMediaPermissionRequsted(void* pUserData, Evas_Object* pView, void* pEventInfo) -{ - _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); - Ewk_User_Media_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_User_Media_Permission_Request* >(pEventInfo); - SysAssertf(pImpl && pPermissionRequest, "Failed to request"); + case SEARCH_ALL_ASYNC: + __textSearch.__searchAll = true; + __textSearch.__text = text; + __textSearch.__searchForward = true; + __textSearch.__caseSensitive = caseSensitive; + __textSearch.__totalCount = -1; + __textSearch.__currentIndex = 1; - result r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_USERMEDIA, pEventInfo); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - return; + __textSearch.__searchQueue.Enqueue(this); + __textSearch.__searchQueue.Enqueue(this); -CATCH: - ewk_user_media_permission_request_set(pPermissionRequest, EINA_FALSE); -} + ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH); + ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH); + break; + case SEARCH_NEXT_ASYNC: + __textSearch.__searchForward = searchForward; -void -_WebImpl::OnNotificationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) -{ - result r = E_SUCCESS; - _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); + CalculateAsyncSearchOrdinal(); - Ewk_Notification_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Notification_Permission_Request* >(pEventInfo); - SysAssertf(pImpl && pPermissionRequest, "Failed to request"); + __textSearch.__searchQueue.Enqueue(this); - ewk_notification_permission_request_suspend(pPermissionRequest); + ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH); + break; - r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_NOTIFICATION, pPermissionRequest); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - return; + default: + SysAssert(false); + } -CATCH: - ewk_notification_permission_request_set(pPermissionRequest, EINA_FALSE); + return E_SUCCESS; } void -_WebImpl::OnNotificationShow(void* pUserData, Evas_Object* pView, void* pEventInfo) +_WebImpl::SetAsyncSearchResult(int totalCount) { - _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); - Ewk_Notification* pNotification = reinterpret_cast< Ewk_Notification* >(pEventInfo); - SysAssertf(pImpl && pNotification, "Failed to request"); - - result r = E_SUCCESS; - Ewk_Context* pContext = ewk_view_context_get(pView); - SysAssertf(pContext, "Failed to get webkit instance."); - uint64_t notificationId = ewk_notification_id_get(pNotification); - - //ewk_notification_security_origin_get(pNotification) - - const char* text = ewk_notification_body_get(pNotification); - SysSecureLog(NID_WEB_CTRL, "The current value of icon path is %s",ewk_notification_icon_url_get(pNotification)); - - std::unique_ptr<_WebNotification> pNotificationWindow( new (std::nothrow) _WebNotification()); - SysTryReturnVoidResult(NID_WEB_CTRL, pNotificationWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - - r = pNotificationWindow->Construct(pContext, notificationId, pImpl); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Error propogated.", GetErrorMessage(r)); - - pNotificationWindow->SetText(String(text)); - pNotificationWindow->LaunchNotification(); - pImpl->SetWebNotification(pNotificationWindow.release()); - - ewk_notification_showed(pContext, notificationId); + __textSearch.__totalCount = totalCount; } -void -_WebImpl::OnNotificationCancel(void* pUserData, Evas_Object* pView, void* pEventInfo) +_WebPresenter* +_WebImpl::GetSearchPresenter(void) { - _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); - uint64_t* pNotificationID = reinterpret_cast< uint64_t* >(pEventInfo); - SysAssertf(pImpl && pNotificationID, "Failed to request"); + MutexGuard lock(__mutex); - //ToDo : Where is ewk API for cancel operation? + return dynamic_cast< _WebPresenter* >(__textSearch.__searchQueue.Dequeue()); } -void -_WebImpl::OnProtocolHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) + int + _WebImpl::GetPendingAsyncSearchCount(void) const { - result r = E_SUCCESS; - _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); - SysAssertf(pImpl, "Failed to request"); - - r = pImpl->ShowUserConfirmPopup(USER_PROTOCOL_HANDLER, pEventInfo); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + return __textSearch.__searchQueue.GetCount(); } void -_WebImpl::OnIsProtocolHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo) +_WebImpl::CalculateAsyncSearchOrdinal(void) { - 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"); - - checkHandler = pImpl->SearchHandler(pHandlerData, false); - SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - switch (checkHandler) + if (__textSearch.__searchForward) { - 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); + __textSearch.__currentIndex++; + } + else + { + __textSearch.__currentIndex--; } } -void -_WebImpl::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)); + int + _WebImpl::GetAsyncSearchOrdinal(void) const +{ + return __textSearch.__currentIndex; } -void -_WebImpl::OnContentHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) + void + _WebImpl::DisableAsyncSearch(void) { - result r = E_SUCCESS; - _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); - SysAssertf(pImpl, "Failed to request"); - - r = pImpl->ShowUserConfirmPopup(USER_CONTENT_HANDLER, pEventInfo); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + __textSearch.__searchAll = false; } -void -_WebImpl::OnIsContentHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo) +result +_WebImpl::SetSetting(const WebSetting& setting) { - 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"); - - checkHandler = pImpl->SearchHandler(pHandlerData, true); - SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - - switch (checkHandler) + if (__pWebCore->GetWebNativeNode()) { - 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); - } -} + Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode()); + Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode()); + SysAssertf(pContext && pSettings, "Failed to get webkit instance."); + + std::unique_ptr pEncoding(_StringConverter::CopyToCharArrayN(setting.GetDefaultTextEncoding())); + SysTryReturn(NID_WEB_CTRL, pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + ewk_settings_default_encoding_set(pSettings, pEncoding.get()); + + switch (setting.GetCacheControl()) + { + case WEB_CACHE_VALIDATED: + ewk_context_cache_disabled_set(pContext, EINA_FALSE); + break; + + case WEB_CACHE_IGNORE: + ewk_context_cache_disabled_set(pContext, EINA_TRUE); + break; + + default: + SysAssert(false); + } + + if (setting.GetInputStyle() == INPUT_STYLE_OVERLAY) + { + ewk_settings_default_keypad_enabled_set(pSettings, EINA_TRUE); + } + else + { + ewk_settings_default_keypad_enabled_set(pSettings, EINA_FALSE); + } + + ewk_settings_font_default_size_set(pSettings, static_cast< Eina_Bool >(setting.GetFontSize())); + ewk_settings_javascript_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsJavascriptEnabled())); -void -_WebImpl::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"); + ewk_settings_loads_images_automatically_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoImageLoadEnabled())); - r = pImpl->UnregistrationHandler(pHandlerData, true); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); -} + if (__defaultUserAgent != setting.GetUserAgent()) + { + std::unique_ptr pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent())); + SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get()); + } -void -_WebImpl::OnFullScreenEntered(void* pUserData, Evas_Object* pView, void* pEventInfo) -{ - _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); - SysAssertf(pImpl, "Failed to request"); -} + ewk_settings_auto_fitting_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFittingEnabled())); + ewk_settings_scripts_window_open_set(pSettings, static_cast< Eina_Bool >(setting.IsJavaScriptPopupEnabled())); -void -_WebImpl::OnFullScreenExited(void* pUserData, Evas_Object* pView, void* pEventInfo) -{ - _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); - SysAssertf(pImpl, "Failed to request"); -} + ewk_settings_form_candidate_data_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFormDataShowEnabled())); + ewk_settings_autofill_password_form_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoLoginFormFillEnabled())); + } -void -_WebImpl::OnVibrationRequested(uint64_t duration, void* pUserData) -{ - result r = E_SUCCESS; + _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting()); - _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); - SysAssertf(pImpl, "Failed to request"); + pWebSettingImpl->SetCertificateErrorHandlingMode(setting.GetCertificateErrorHandlingMode()); + pWebSettingImpl->SetDefaultTextEncoding(setting.GetDefaultTextEncoding()); + pWebSettingImpl->SetCacheControl(setting.GetCacheControl()); + pWebSettingImpl->SetFontSize(setting.GetFontSize()); + pWebSettingImpl->SetJavascriptEnabled(setting.IsJavascriptEnabled()); + pWebSettingImpl->SetAutoImageLoadEnabled(setting.IsAutoImageLoadEnabled()); + pWebSettingImpl->SetInputStyle(setting.GetInputStyle()); + pWebSettingImpl->SetUserAgent(setting.GetUserAgent()); + pWebSettingImpl->SetAutoFittingEnabled(setting.IsAutoFittingEnabled()); + pWebSettingImpl->SetJavaScriptPopupEnabled(setting.IsJavaScriptPopupEnabled()); + pWebSettingImpl->SetGeolocationEnabled(setting.IsGeolocationEnabled()); + pWebSettingImpl->SetAutoFormDataShowEnabled(setting.IsAutoFormDataShowEnabled()); + pWebSettingImpl->SetAutoLoginFormFillEnabled(setting.IsAutoLoginFormFillEnabled()); - r = pImpl->VibrationRequested(duration); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + return E_SUCCESS; } -void -_WebImpl::OnVibrationCanceled(void* pUserData) +WebSetting +_WebImpl::GetSetting(void) const { - _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); - SysAssertf(pImpl, "Failed to request"); - - pImpl->VibrationCanceled(); + return *__pWebCore->GetSetting(); } -void -_WebImpl::OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) +const HitElementResult* +_WebImpl::GetElementByPointN(const Point& point) const { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo); - SysAssertf(pImpl && pPolicy, "Failed to request"); + return GetElementByPointN(_CoordinateSystemUtils::ConvertToFloat(point)); +} - String url(ewk_policy_decision_url_get(pPolicy)); - SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls", url.GetPointer()); - if (url == L"about:blank") +const HitElementResult* +_WebImpl::GetElementByPointN(const FloatPoint& point) const +{ + Evas_Object* pView = __pWebCore->GetWebNativeNode(); + if (!pView) { - ewk_policy_decision_use(pPolicy); - return; + return null; } - if (pImpl->__pUserLoadingListener && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy)) - && !pImpl->__isRedirectRequested) - { - pImpl->__isCertificateRequested = false; + SysTryReturn(NID_WEB_CTRL, Contains(point), null, E_INVALID_ARG, "[%s] The point must be contained in the bounds of a web control.", GetErrorMessage(E_INVALID_ARG)); - if (pImpl->__pTextSearchListener) - { - pImpl->__textSearch.__searchAll = false;; - } - - Ewk_Policy_Navigation_Type ewkNavigationType = ewk_policy_decision_navigation_type_get(pPolicy); - WebNavigationType navigationType = WEB_NAVIGATION_OTHER; + result r = E_SUCCESS; - switch (ewkNavigationType) - { - case EWK_POLICY_NAVIGATION_TYPE_LINK_CLICKED: - navigationType = WEB_NAVIGATION_LINK_CLICKED; - break; - case EWK_POLICY_NAVIGATION_TYPE_FORM_SUBMITTED: - navigationType = WEB_NAVIGATION_FORM_SUBMITTED; - break; - case EWK_POLICY_NAVIGATION_TYPE_BACK_FORWARD: - navigationType = WEB_NAVIGATION_BACKFORWARD; - break; - case EWK_POLICY_NAVIGATION_TYPE_RELOAD: - navigationType = WEB_NAVIGATION_RELOAD; - break; - case EWK_POLICY_NAVIGATION_TYPE_FORM_RESUBMITTED: - navigationType = WEB_NAVIGATION_FORM_RESUBMITTED; - break; - case EWK_POLICY_NAVIGATION_TYPE_OTHER: - break; - default: - SysAssert(false); - } + _HitElementResultImpl* pHitElementResultImpl = null; - if (pImpl->__pUserLoadingListener->OnLoadingRequested(url, navigationType)) - { - ewk_policy_decision_ignore(pPolicy); + std::unique_ptr pHitElementResult; + std::unique_ptr pImage; + std::unique_ptr pAttributeMap; - return; - } - } + Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(point))); - String currentUrl(pImpl->GetUrl()); - String redirectUrl(pImpl->GetProtocolFromUri(url, currentUrl)); - if (redirectUrl != L"") - { - pImpl->LoadUrl(redirectUrl); - ewk_policy_decision_ignore(pPolicy); + Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL); + SysTryReturn(NID_WEB_CTRL, pEwkHitTest, null, E_SYSTEM, "[%s] Failed to get hit test.", GetErrorMessage(E_SYSTEM)); - return; - } - - Uri uri; - uri.SetUri(url); + Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest); + Ewk_Hit_Test_Result_Context context = ewk_hit_test_result_context_get(pEwkHitTest); + String url(ewk_hit_test_link_uri_get(pEwkHitTest)); + String tagName(ewk_hit_test_tag_name_get(pEwkHitTest)); + String nodeValue(ewk_hit_test_node_value_get(pEwkHitTest)); - String uriScheme(uri.GetScheme()); - SysLog(NID_WEB_CTRL, "The current value of scheme is %ls", uriScheme.GetPointer()); + SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls, tag is %ls, value is %ls", url.GetPointer(), tagName.GetPointer(), nodeValue.GetPointer()); - if ((uriScheme != L"http") && (uriScheme != L"https") && (uriScheme != L"file")) + pHitElementResult = std::unique_ptr(new (std::nothrow) HitElementResult()); + SysTryCatch(NID_WEB_CTRL, pHitElementResult.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + pHitElementResultImpl = _HitElementResultImpl::GetInstance(pHitElementResult.get()); + SysTryCatch(NID_WEB_CTRL, pHitElementResultImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + if (context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE) { - ewk_policy_decision_ignore(pPolicy); + ByteBuffer buf; + Image image; + ImageFormat format; - if (uriScheme == L"") - { - return; - } + int imageLength = ewk_hit_test_image_buffer_length_get(pEwkHitTest); + void* pImageBuffer = ewk_hit_test_image_buffer_get(pEwkHitTest); + const char* pExtension = ewk_hit_test_image_file_name_extension_get(pEwkHitTest); + SysLog(NID_WEB_CTRL, "The current value of imageBuffer is %u, bufferLength is %d, extension is %s", pImageBuffer, imageLength, pExtension); - result r = E_SUCCESS; + r = buf.Construct(imageLength); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - if (uriScheme == L"tel") + r = buf.SetArray(reinterpret_cast< byte* >(pImageBuffer), 0, imageLength); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + buf.Rewind(); + +// ToDo : webkit doesn't support types such as IMG_FORMAT_WBMP and IMG_FORMAT_TIFF +// webkit support types such as ico and vp8 additionally + if (strcmp(pExtension, "gif") == 0) { - String operationId(L"http://tizen.org/appcontrol/operation/dial"); - r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null); + format = IMG_FORMAT_GIF; } - else if (uriScheme == L"mailto" || uriScheme == L"sms" || uriScheme == L"smsto" || uriScheme == L"mms" || uriScheme == L"mmsto" ) + else if (strcmp(pExtension, "jpg") == 0) { - String operationId(L"http://tizen.org/appcontrol/operation/compose"); - r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null); + format = IMG_FORMAT_JPG; + } + else if (strcmp(pExtension, "png") == 0) + { + format = IMG_FORMAT_PNG; + } + else if (strcmp(pExtension, "bmp") == 0) + { + format = IMG_FORMAT_BMP; } else { - String operationId(L"http://tizen.org/appcontrol/operation/view"); - r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null); + SysLogException(NID_WEB_CTRL, E_UNSUPPORTED_FORMAT, "[%s] The %s format is not supported", GetErrorMessage(E_UNSUPPORTED_FORMAT), pExtension); + goto CATCH; } - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - - return; - } - - ewk_policy_decision_use(pPolicy); -} + r = image.Construct(); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); -void -_WebImpl::OnLoadingStarted(void* pUserData, Evas_Object* pView, void* pEventInfo) -{ - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pImpl, "Failed to request"); + pImage = std::unique_ptr(image.DecodeN(buf, format, BITMAP_PIXEL_FORMAT_RGB565)); + SysTryCatch(NID_WEB_CTRL, pImage.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + } - if (pImpl->__pUserLoadingListener) + if (pAttrHash) { - result r = E_SUCCESS; + pAttributeMap = std::unique_ptr(new (std::nothrow) HashMap()); + SysTryCatch(NID_WEB_CTRL, pAttributeMap.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_STARTED)); - SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + r = pAttributeMap->Construct(eina_hash_population(pAttrHash)); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - r = pImpl->__pWebEvent->FireAsync(*pEventArg.get()); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - pEventArg.release(); + eina_hash_foreach(pAttrHash, AddHttpAttributeData, pAttributeMap.get()); + SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); } -} + pHitElementResultImpl->SetHitElementResult(pAttributeMap.release(), pImage.release(), tagName, nodeValue, url); + + ewk_hit_test_free(pEwkHitTest); -void -_WebImpl::OnPageTitleReceived(void* pUserData, Evas_Object* pView, void* pEventInfo) -{ - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - char* pTitle = reinterpret_cast< char* >(pEventInfo); - SysAssertf(pImpl, "Failed to request"); + return pHitElementResult.release(); - SysLog(NID_WEB_CTRL, "The current value of title is %s", pTitle); +CATCH: + ewk_hit_test_free(pEwkHitTest); - if (pImpl->__pUserLoadingListener) - { - result r = E_SUCCESS; + return null; +} - std::unique_ptr pPageTitle(new (std::nothrow) String(pTitle)); - std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED)); - SysTryReturnVoidResult(NID_WEB_CTRL, pPageTitle.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - r = pEventArg->SetEventInfo(_LoadingEventArg::PAGE_TITLE, *pPageTitle.get()); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - pPageTitle.release(); +bool +_WebImpl::IsLoading(void) const +{ + double percent = ewk_view_load_progress_get(__pWebCore->GetWebNativeNode()); - r = pImpl->__pWebEvent->FireAsync(*pEventArg.get()); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - pEventArg.release(); + if (Double::Compare(percent, 0.0) > 0 && Double::Compare(percent, 1.0) < 0) + { + return true; + } + else + { + return false; } } -void -_WebImpl::OnEstimatedProgress(void* pUserData, Evas_Object* pView, void* pEventInfo) +String +_WebImpl::GetTextFromBlock(void) const { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - double* pProgress = reinterpret_cast< double* >(pEventInfo); - SysAssertf(pImpl, "Failed to request"); + return ewk_view_text_selection_text_get(__pWebCore->GetWebNativeNode()); +} - SysLog(NID_WEB_CTRL, "The current value of progress is %lf", *pProgress); - if (pImpl->__pUserLoadingListener) +bool +_WebImpl::IsPrivateBrowsingEnabled(void) const +{ + if (__pWebCore->GetWebNativeNode() == null) { - result r = E_SUCCESS; - - std::unique_ptr pProgressPercentage(new (std::nothrow) Integer(static_cast< int >(*pProgress * 100))); - std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PROGRESS)); - SysTryReturnVoidResult(NID_WEB_CTRL, pProgressPercentage.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsPrivateBrowsingEnabled(); + } - r = pEventArg->SetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS, *pProgressPercentage.get()); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - pProgressPercentage.release(); + Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode()); + SysAssertf(pSettings, "Failed to get webkit instance."); - r = pImpl->__pWebEvent->FireAsync(*pEventArg.get()); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - pEventArg.release(); - } + return static_cast< bool >(ewk_settings_private_browsing_enabled_get(pSettings)); } void -_WebImpl::OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo) +_WebImpl::SetPrivateBrowsingEnabled(bool enable) { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo); - SysAssertf(pImpl && pPolicy, "Failed to request"); - - result r = E_SUCCESS; - - _SystemResource* pSysResource = _SystemResource::GetInstance(); - SysAssertf(pSysResource != null, "Failed to get _SystemResource instance"); - - int code = ewk_policy_decision_response_status_code_get(pPolicy); - String url(ewk_policy_decision_url_get(pPolicy)); - String mime(ewk_policy_decision_response_mime_get(pPolicy)); - SysSecureLog(NID_WEB_CTRL, "code : %d, url : %ls, mime : %ls", code, url.GetPointer(), mime.GetPointer()); - - if (pImpl->__pUserLoadingListener && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy))) + if (__pWebCore->GetWebNativeNode() == null) { - const Eina_Hash* pHeader = ewk_policy_decision_response_headers_get(pPolicy); + _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetPrivateBrowsingEnabled(enable); + return; + } - DecisionPolicy policy; - HttpHeader httpHeader; + Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode()); + SysAssertf(pSettings, "Failed to get webkit instance."); - if (code >= REDIRECTION_HEADER_GROUP && code < REDIRECTION_HEADER_GROUP + 100) - { - pImpl->__isRedirectRequested = true; - mime = L""; - } + ewk_settings_private_browsing_enabled_set(pSettings, static_cast< Eina_Bool >(enable)); +} - eina_hash_foreach(pHeader, AddHttpHeaderData, &httpHeader); - SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - policy = pImpl->__pUserLoadingListener->OnWebDataReceived(mime, httpHeader); - pImpl->__policy = policy; - } +void +_WebImpl::ClearHistory(void) +{ + ewk_view_back_forward_list_clear(__pWebCore->GetWebNativeNode()); +} - switch (pImpl->__policy) - { - 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; - } +void +_WebImpl::ClearCache(void) +{ + Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode()); - if (pImpl->IsMimeSupported(mime) || mime == L"") - { - break; - } - - else - { - ewk_policy_decision_ignore(pPolicy); + ewk_context_cache_clear(pContext); +} - String operationId(L"http://tizen.org/appcontrol/operation/view"); - r = _AppControlImpl::FindAndStart(operationId, &url, &mime, null, null, null); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS || r == E_OBJ_NOT_FOUND, r, "[%s] Propagating.", GetErrorMessage(r)); - - if (r == E_OBJ_NOT_FOUND) - { - _SelectBox* pSelectBox = new (std::nothrow) _SelectBox; - SysTryReturnVoidResult(NID_WEB_CTRL, pSelectBox, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); +void +_WebImpl::ClearCookie(void) +{ + Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode()); + Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext); - r = pSelectBox->Construct(false, L"Select application", 1, null, url); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + ewk_cookie_manager_cookies_clear(pCookieManager); +} - 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; - } - break; - } - case WEB_DECISION_DOWNLOAD: - { - ewk_policy_decision_ignore(pPolicy); +void +_WebImpl::ClearFormData(void) +{ + Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode()); - SysTryReturnVoidResult(NID_WEB_CTRL, pImpl->__pWebDownloadHandler.get(), E_SYSTEM, "[%s] A system error has been occurred. Failed to get DownloadHandler.", GetErrorMessage(E_SYSTEM)); + ewk_context_form_candidate_data_clear(pContext); +} - Ewk_Context* pContext = ewk_view_context_get(pView); - SysAssertf(pContext, "Failed to get webkit instance."); - pImpl->__pWebDownloadHandler.get()->StartDownload(url); +void +_WebImpl::ClearLoginFormData(void) +{ + Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode()); - return; - } - case WEB_DECISION_IGNORE: - { - ewk_policy_decision_ignore(pPolicy); + ewk_context_form_password_data_clear(pContext); +} - return; - } - default: + +bool +_WebImpl::IsCookieEnabled(void) const +{ + if (__pWebCore->GetWebNativeNode() == null) { - SysAssert(false); - } + return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsCookieEnabled(); } - ewk_policy_decision_use(pPolicy); + Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode()); + Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext); + SysAssertf(pCookieManager, "Failed to get webkit instance."); - return; + 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)); -CATCH: - ewk_policy_decision_ignore(pPolicy); + ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, pPresenter.get()); + + bool result = false; + pPresenter->WaitAsyncProcess(result); + + return result; } void -_WebImpl::OnProgressCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo) +_WebImpl::SetCookieEnabled(bool enable) { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pImpl, "Failed to request"); - - if (pImpl->__isRedirectRequested) + if (__pWebCore->GetWebNativeNode() == null) { - pImpl->__isRedirectRequested = false; + _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetCookiEnabled(enable); + + return; } - if (pImpl->__isLoadingErrorOccurred) + Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode()); + Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext); + SysAssertf(pCookieManager, "Failed to get webkit instance."); + + if (enable) { - pImpl->__isLoadingErrorOccurred = false; - evas_object_smart_callback_call(pView, "load,finished", NULL); + ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS); + } + else + { + ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER); + ewk_cookie_manager_cookies_clear(pCookieManager); } } -void -_WebImpl::OnLoadingErrorOccurred(void* pUserData, Evas_Object* pView, void* pEventInfo) +result +_WebImpl::SavePageAsPdf(const String& filePath, const Dimension* pSize) const { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - Ewk_Error* pErrorData = reinterpret_cast< Ewk_Error* >(pEventInfo); - SysAssertf(pImpl && pErrorData, "Failed to request"); + result r = E_SUCCESS; - int code = ewk_error_code_get(pErrorData); - const char* pDescription = ewk_error_description_get(pErrorData); + std::unique_ptr pFilePath(_StringConverter::CopyToCharArrayN(filePath)); + SysTryReturn(NID_WEB_CTRL, pFilePath.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - SysLog(NID_WEB_CTRL, "The current value of code is %d, description is %s", code, pDescription); + String dirPath; + String fileExtension = File::GetFileExtension(filePath); + int pathLength = filePath.GetLength(); + int index = 0; - switch (code) - { - case EWK_ERROR_CODE_FRAMELOADINTERRUPTEDBYPOLICYCHANGE: - pImpl->__isLoadingErrorOccurred = true; - break; + SysTryReturnResult(NID_WEB_CTRL, fileExtension.Equals("pdf", false), E_INVALID_ARG, "Invalid argument(s) is used. File extension is not pdf."); - case EWK_ERROR_CODE_PLUGINWILLHANDLELOAD: - evas_object_smart_callback_call(pView, "load,finished", NULL); - break; + r = filePath.LastIndexOf(L"/", pathLength - 1, index); + SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid."); + r = filePath.SubString(0, index + 1, dirPath); + SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid."); - case EWK_ERROR_NETWORK_STATUS_CANCELLED: - pImpl->__isLoadingErrorOccurred = true; - evas_object_smart_callback_call(pView, "load,stop", NULL); - break; + std::unique_ptr pDirPath(_StringConverter::CopyToCharArrayN(dirPath)); + SysTryReturnResult(NID_WEB_CTRL, access(pDirPath.get(), W_OK) == 0, E_INACCESSIBLE_PATH, "Directory permission is read-only."); - default: - pImpl->__isLoadingErrorOccurred = true; - if (pImpl->__pUserLoadingListener) - { - result r = E_SUCCESS; + if (pSize) + { + SysTryReturnResult(NID_WEB_CTRL, pSize->width > 0 && pSize->height > 0, E_INVALID_ARG, "Invalid argument(s) is used. Size of pdf file is invalid."); - r = FireLoadingErrorOccurredEvent(pImpl, code, pDescription); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - } - break; + ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), pSize->width, pSize->height, pFilePath.get()); } -} - + else + { + Evas_Coord contentsWidth; + Evas_Coord contentsHeight; -void -_WebImpl::OnLoadingCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo) -{ - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pImpl, "Failed to request"); + ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &contentsWidth, &contentsHeight); + ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), contentsWidth, contentsHeight, pFilePath.get()); + } - if (pImpl->__pUserLoadingListener) - { - result r = E_SUCCESS; + return E_SUCCESS; +} - std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_CANCELED)); - SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - r = pImpl->__pWebEvent->FireAsync(*pEventArg.get()); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - pEventArg.release(); - } +bool +_WebImpl::IsMimeSupported(const String& mime) const +{ + std::unique_ptr pMime(_StringConverter::CopyToCharArrayN(mime)); + SysTryReturn(NID_WEB_CTRL, pMime.get(), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + return static_cast< bool >(ewk_frame_can_show_mime_type(ewk_view_main_frame_get(__pWebCore->GetWebNativeNode()), pMime.get())); } void -_WebImpl::OnLoadingCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo) +_WebImpl::SetLoadingListener(ILoadingListener* pLoadingListener) { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pImpl, "Failed to request"); + __pUserLoadingListener = const_cast< ILoadingListener* >(pLoadingListener); +} - if (pImpl->__pUserLoadingListener) - { - result r = E_SUCCESS; - std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_COMPLETED)); - SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); +void +_WebImpl::SetWebUiEventListener(IWebUiEventListener* pUiEventListener) +{ + __pUserUiListener = pUiEventListener; +} - r = pImpl->__pWebEvent->FireAsync(*pEventArg.get()); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - pEventArg.release(); - } +void +_WebImpl::SetWebUiEventListenerF(IWebUiEventListenerF* pUiEventListener) +{ + __pUserUiListenerF = pUiEventListener; } void -_WebImpl::OnFaviconReceived(void* pUserData, Evas_Object* pView, void* pEventInfo) +_WebImpl::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener) { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pImpl, "Failed to request"); + __pUserKeypadEventListener = pKeypadEventListener; +} - if (pImpl->__pUserLoadingListener) + +void +_WebImpl::SetDownloadListener(IWebDownloadListener* pDownLoadListener) +{ + if (__pWebDownloadHandler.get() == null) { - result r = E_SUCCESS; + __pWebDownloadHandler = std::unique_ptr<_WebDataHandler>(new (std::nothrow) _WebDataHandler()); + SysTryReturnVoidResult(NID_WEB_CTRL, __pWebDownloadHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + } - std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED)); - SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + __pWebDownloadHandler->SetDownloadListener(pDownLoadListener); + __pWebDownloadHandler->SetWebEvent(__pWebEvent.get()); +} - r = pImpl->__pWebEvent->FireAsync(*pEventArg.get()); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - pEventArg.release(); - } +void +_WebImpl::SetTextSearchListener(ITextSearchListener* pTextSearchListener) +{ + __pTextSearchListener = pTextSearchListener; } void -_WebImpl::OnDidStartDownloadCallback(const char* pUrl, void* pUserData) +_WebImpl::SetScrollEnabled(bool enable) { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pUrl && pImpl != null, "Failed to request"); + _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetScrollEnabled(enable); +} - SysSecureLog(NID_WEB_CTRL, "The current value of url is %s", pUrl); + +bool +_WebImpl::IsScrollEnabled(void) const +{ + return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled(); } result -_WebImpl::FireWebPageShowRequestedEvent(_WebImpl* pImpl, int event) +_WebImpl::InitJsBridgeList(void) { result r = E_SUCCESS; - std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event)); - SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed."); + __pJsProvider = std::unique_ptr<_JsBridgeHashCodeProvider>(new (std::nothrow) _JsBridgeHashCodeProvider()); + SysTryReturnResult(NID_WEB_CTRL, __pJsProvider.get(), E_OUT_OF_MEMORY, "Memory Allocation failed."); + + __pJsComparer = std::unique_ptr<_JsBridgeComparer>(new (std::nothrow) _JsBridgeComparer()); + SysTryReturnResult(NID_WEB_CTRL, __pJsComparer.get(), E_OUT_OF_MEMORY, "Memory Allocation failed."); - r = pImpl->__pWebEvent->FireAsync(*pEventArg.get()); + std::unique_ptr > pJsBridgeList(new (std::nothrow) HashMapT< String, IJavaScriptBridge* >); + SysTryReturnResult(NID_WEB_CTRL, pJsBridgeList.get(), E_OUT_OF_MEMORY, "Memory Allocation failed."); + + r = pJsBridgeList->Construct(0, 0, *__pJsProvider.get(), *__pJsComparer.get()); SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - pEventArg.release(); + + __pJsBridgeList = std::move(pJsBridgeList); return E_SUCCESS; } -void -_WebImpl::OnWebPageShowRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) +result +_WebImpl::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge) { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pImpl, "Failed to request"); + result r = E_SUCCESS; - if (pImpl->__pUserUiListener) - { - result r = E_SUCCESS; + IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge); + String key(pJsBridge->GetName()); - r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - } - if (pImpl->__pUserUiListenerF) - { - result r = E_SUCCESS; + r = __pJsBridgeList->Add(key, pJsBridge); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - } + return E_SUCCESS; } -void -_WebImpl::OnWebWindowCreateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) +result +_WebImpl::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge) { - _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(pUserData); - Evas_Object** pChildView = reinterpret_cast< Evas_Object** >(pEventInfo); - SysAssertf(pParentImpl && pChildView, "Failed to request"); + result r = E_SUCCESS; - if (pParentImpl->__pUserUiListener) - { - Web* pWeb = pParentImpl->__pUserUiListener->OnWebWindowCreateRequested(); - if (pWeb) - { - _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb); - SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM)); + IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge); + String key(pJsBridge->GetName()); - *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode(); - evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl); - } - } - if (pParentImpl->__pUserUiListenerF) - { - Web* pWeb = pParentImpl->__pUserUiListenerF->OnWebWindowCreateRequested(); - if (pWeb) - { - _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb); - SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM)); + r = __pJsBridgeList->Remove(key); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode(); - evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl); - } - } + return E_SUCCESS; } -result -_WebImpl::FireWebWindowClosedRequestedEvent(_WebImpl* pImpl, int event) +IJavaScriptBridge* +_WebImpl::FindJsInterface(const IJsonValue* pValue) const { result r = E_SUCCESS; - std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event)); - SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed."); + IJsonValue* pJsonValue = null; + IJavaScriptBridge* pJsBridge = null; - r = pImpl->__pWebEvent->FireAsync(*pEventArg.get()); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - pEventArg.release(); + String key(L"name"); - return E_SUCCESS; -} + const JsonObject* pJsonObject = dynamic_cast< const JsonObject* >(pValue); + SysTryReturn(NID_WEB_CTRL, pJsonObject, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. Json text must be Json Object type." , GetErrorMessage(E_INVALID_ARG)); + r = pJsonObject->GetValue(&key, pJsonValue); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS && pJsonValue, null, r, "[%s] Propagating.", GetErrorMessage(r)); -void -_WebImpl::OnWebWindowClosedRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) -{ - _WebImpl* pChildImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pChildImpl, "Failed to request"); + JsonString* pBridgeName = dynamic_cast< JsonString* >(pJsonValue); + SysTryReturn(NID_WEB_CTRL, pBridgeName, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. name key is missing." , GetErrorMessage(E_INVALID_ARG)); - _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, PARENT_WEB_CTRL)); - if (pParentImpl == null) - { - return; - } + r = __pJsBridgeList->GetValue(static_cast< String >(*pBridgeName), pJsBridge); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); - if (pParentImpl->__pUserUiListener) - { - result r = E_SUCCESS; + return pJsBridge; +} - r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - } - if (pParentImpl->__pUserUiListenerF) - { - result r = E_SUCCESS; - r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - } +ILoadingListener* +_WebImpl::GetLoadingListener(void) const +{ + return __pUserLoadingListener; } -result -_WebImpl::FireWebPreventDefaultTriggeredEvent(_WebImpl* pImpl, int event, bool trigger) +IWebUiEventListener* +_WebImpl::GetUiEventListener(void) const { - result r = E_SUCCESS; + return __pUserUiListener; +} - std::unique_ptr pPreventTrigger(new (std::nothrow) Boolean(trigger)); - std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event)); - SysTryReturnResult(NID_WEB_CTRL, pPreventTrigger.get() && pEventArg.get(), E_OUT_OF_MEMORY, " Memory allocation failed." ); - r = pEventArg->SetEventInfo(_WebUiEventArg::PREVENT_DEFAULT, *pPreventTrigger.get()); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - pPreventTrigger.release(); +IWebUiEventListenerF* +_WebImpl::GetUiEventListenerF(void) const +{ + return __pUserUiListenerF; +} - r = pImpl->__pWebEvent->FireAsync(*pEventArg.get()); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - pEventArg.release(); - return E_SUCCESS; +IWebKeypadEventListener* +_WebImpl::GetWebKeypadEventListener(void) const +{ + return __pUserKeypadEventListener; } -void -_WebImpl::OnWebPreventDefaultTriggered(void* pUserData, Evas_Object* pView, void* pEventInfo) +ITextSearchListener* +_WebImpl::GetTextSearchListener(void) const { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - Eina_Bool* pTrigger = reinterpret_cast< Eina_Bool* >(pEventInfo); - SysAssertf(pImpl && pTrigger, "Failed to request"); + return __pTextSearchListener; +} - if (pImpl->__pUserUiListener) - { - result r = E_SUCCESS; - r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED, static_cast< bool >(*pTrigger)); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - } - if (pImpl->__pUserUiListenerF) +void +_WebImpl::SetEventListenerCallback(void) const +{ + Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode(); + if (pWebNativeNode) { - result r = E_SUCCESS; + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas"); - r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT, static_cast< bool >(*pTrigger)); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - } -} + Evas_Object* pWinObject = pEcoreEvas->GetWindowObject(); + SysAssertf(pWinObject, "Failed to get Ui window evas object"); + + Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode); + SysAssertf(pSmartData, "Failed to request"); + + Ewk_View_Smart_Class *pSmart = const_cast(pSmartData->api); + SysAssertf(pSmart, "Failed to request"); + + pSmart->popup_menu_show = OnSelectBoxRequested; + pSmart->multiple_popup_menu_show = OnMultiSelectBoxRequested; + pSmart->popup_menu_hide = OnSelectBoxClosed; + pSmart->popup_menu_update = OnSelectBoxUpdateRequested; + + pSmart->input_picker_show = OnDatePickerProviderRequested; + pSmart->input_picker_color_request = OnColorPickerProviderRequested; + pSmart->input_picker_color_dismiss = OnColorPickerProviderDismissed; + + pSmart->formdata_candidate_show = OnFormDataCandidateShow; + pSmart->formdata_candidate_hide = OnFormDataCandidateHide; + pSmart->formdata_candidate_update_data = OnFormDataCandidateUpdate; + pSmart->formdata_candidate_is_showing = OnFormDataCandidateIsShowing; + + evas_object_data_set(pWebNativeNode, WEB_CTRL, this); + + // add loading event callbacks for ILoadingListener + evas_object_smart_callback_add(pWebNativeNode, "create,window", OnWebWindowCreateRequested, this); + evas_object_smart_callback_add(pWebNativeNode, "close,window", OnWebWindowClosedRequested, this); + evas_object_smart_callback_add(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested, this); + evas_object_smart_callback_add(pWebNativeNode, "load,started", OnLoadingStarted, this); + evas_object_smart_callback_add(pWebNativeNode, "load,finished", OnLoadingCompleted, this); + evas_object_smart_callback_add(pWebNativeNode, "load,progress", OnEstimatedProgress, this); + evas_object_smart_callback_add(pWebNativeNode, "load,progress,finished", OnProgressCompleted, this); + evas_object_smart_callback_add(pWebNativeNode, "load,stop", OnLoadingCanceled, this); + evas_object_smart_callback_add(pWebNativeNode, "load,error", OnLoadingErrorOccurred, this); + evas_object_smart_callback_add(pWebNativeNode, "title,changed", OnPageTitleReceived, this); -result -_WebImpl::FireWebPageBlockSelectedEvent(_WebImpl* pImpl) -{ - result r = E_SUCCESS; + evas_object_smart_callback_add(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest, this); - std::unique_ptr startPoint(new (std::nothrow) Point()); - std::unique_ptr endPoint(new (std::nothrow) Point()); - SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed."); + evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, this); - pImpl->GetBlockRange(*startPoint.get(), *endPoint.get()); + evas_object_smart_callback_add(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged, this); + evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened, this); + evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed, this); - if ((endPoint->x != 0) && (endPoint->y != 0)) - { - std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED)); - SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed."); + evas_object_smart_callback_add(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested, this); + evas_object_smart_callback_add(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled, this); - r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get()); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - startPoint.release(); + evas_object_smart_callback_add(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested, this); - r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get()); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - endPoint.release(); + ewk_view_javascript_alert_callback_set(pWebNativeNode, OnScriptAlertRequested, const_cast< _WebImpl* >(this)); + ewk_view_javascript_prompt_callback_set(pWebNativeNode, OnScriptPromptRequested, const_cast< _WebImpl* >(this)); + ewk_view_javascript_confirm_callback_set(pWebNativeNode, OnScriptConfirmRequested, const_cast< _WebImpl* >(this)); - r = pImpl->__pWebEvent->FireAsync(*pEventArg.get()); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - pEventArg.release(); - } + evas_object_smart_callback_add(pWebNativeNode, "policy,response,decide", OnWebDataReceived, this); - return E_SUCCESS; -} + evas_object_smart_callback_add(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested, this); + evas_object_smart_callback_add(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested, this); + evas_object_smart_callback_add(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted, this); + evas_object_smart_callback_add(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested, this); + evas_object_smart_callback_add(pWebNativeNode, "notification,show", OnNotificationShow, this); + evas_object_smart_callback_add(pWebNativeNode, "notification,cancel", OnNotificationCancel, this); -result -_WebImpl::FireWebPageBlockSelectedEventF(_WebImpl* pImpl) -{ - result r = E_SUCCESS; + evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested, this); + evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered, this); + evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested, this); - std::unique_ptr startPoint(new (std::nothrow) FloatPoint()); - std::unique_ptr endPoint(new (std::nothrow) FloatPoint()); + evas_object_smart_callback_add(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested, this); + evas_object_smart_callback_add(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered, this); + evas_object_smart_callback_add(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested, this); + evas_object_smart_callback_add(pWebNativeNode, "text,found", OnTextFound, this); - SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed."); + evas_object_smart_callback_add(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered, this); + evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this); - pImpl->GetBlockRange(*startPoint.get(), *endPoint.get()); + evas_object_smart_callback_add(pWebNativeNode, "text,selected", OnWebPageBlockSelected, this); - if ((endPoint->x != 0.0f) && (endPoint->y != 0.0f)) - { - std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT)); - SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed."); + evas_object_smart_callback_add(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered, this); + evas_object_smart_callback_add(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited, this); - r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get()); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - startPoint.release(); + 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)); + ewk_context_vibration_client_callbacks_set(pContext, OnVibrationRequested, OnVibrationCanceled, const_cast< _WebImpl* >(this)); - r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get()); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - endPoint.release(); + ewk_view_application_cache_permission_callback_set(pWebNativeNode, OnApplicationCachePermissionRequested, const_cast< _WebImpl* >(this)); + ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, OnIndexedDatabaseQuotaExceeded, const_cast< _WebImpl* >(this)); + ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, OnDatabaseQuotaExceeded, const_cast< _WebImpl* >(this)); + ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, OnLocalFileSystemQuotaExceeded, const_cast< _WebImpl* >(this)); - r = pImpl->__pWebEvent->FireAsync(*pEventArg.get()); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - pEventArg.release(); + evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this); } - - return E_SUCCESS; } void -_WebImpl::OnWebPageBlockSelected(void* pUserData, Evas_Object* pView, void* pEventInfo) +_WebImpl::RemoveEventListenerCallback(void) const { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pImpl, "Failed to request"); - - if (pImpl->__pUserUiListener) + Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode(); + if (pWebNativeNode) { - result r = E_SUCCESS; + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas"); - r = FireWebPageBlockSelectedEvent(pImpl); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - } - if (pImpl->__pUserUiListenerF) - { - result r = E_SUCCESS; + Evas_Object* pWinObject = pEcoreEvas->GetWindowObject(); + SysAssertf(pWinObject, "Failed to get Ui window evas object"); - r = FireWebPageBlockSelectedEventF(pImpl); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - } -} + evas_object_smart_callback_del(pWebNativeNode, "create,window", OnWebWindowCreateRequested); + evas_object_smart_callback_del(pWebNativeNode, "close,window", OnWebWindowClosedRequested); + evas_object_smart_callback_del(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested); + evas_object_smart_callback_del(pWebNativeNode, "load,started", OnLoadingStarted); + evas_object_smart_callback_del(pWebNativeNode, "load,finished", OnLoadingCompleted); + evas_object_smart_callback_del(pWebNativeNode, "load,progress", OnEstimatedProgress); + evas_object_smart_callback_del(pWebNativeNode, "load,progress,finished", OnProgressCompleted); + evas_object_smart_callback_del(pWebNativeNode, "load,stop", OnLoadingCanceled); + evas_object_smart_callback_del(pWebNativeNode, "load,error", OnLoadingErrorOccurred); + evas_object_smart_callback_del(pWebNativeNode, "title,changed", OnPageTitleReceived); -Eina_Bool -_WebImpl::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)); + evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest); - pMediaListener->Construct(pView); + evas_object_smart_callback_del_full(pWinObject, "focus,in", OnWindowObjectFocusGained, this); - HashMap extraData; - result r = extraData.Construct(); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_TRUE, r, "[%s] Propagating.", GetErrorMessage(r)); + evas_object_smart_callback_del(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged); + evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened); + evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed); - String isMultipleSelection(L"single"); - String mode(L"selectionType"); - String type(L"type"); - String fileType = L"*/*"; - String operationId = L"http://tizen.org/appcontrol/operation/pick"; + evas_object_smart_callback_del(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested); + evas_object_smart_callback_del(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled); - if (multipleFile) - { - isMultipleSelection.Append(L"multiple"); - } + evas_object_smart_callback_del(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested); - if (eina_list_count(pAcceptTypes) == 1) - { - String item((char*)eina_list_nth(pAcceptTypes, 0)); - String captureString(pCapture); + 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); - 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); - } - } - } + evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived); - r = _AppControlImpl::FindAndStart(operationId, null, &fileType, null, &extraData, pMediaListener.get()); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + evas_object_smart_callback_del(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested); + evas_object_smart_callback_del(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested); + evas_object_smart_callback_del(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted); - pMediaListener.release(); + evas_object_smart_callback_del(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested); + evas_object_smart_callback_del(pWebNativeNode, "notification,show", OnNotificationShow); + evas_object_smart_callback_del(pWebNativeNode, "notification,cancel", OnNotificationCancel); + evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested); + evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered); + evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested); - return EINA_TRUE; + evas_object_smart_callback_del(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested); + evas_object_smart_callback_del(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered); + evas_object_smart_callback_del(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested); -CATCH: - ewk_view_open_panel_reply(pView, null, EINA_FALSE); - return EINA_TRUE; + evas_object_smart_callback_del(pWebNativeNode, "text,found", OnTextFound); + + evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered); + evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived); + + evas_object_smart_callback_del(pWebNativeNode, "text,selected", OnWebPageBlockSelected); + + 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); + + ewk_view_application_cache_permission_callback_set(pWebNativeNode, null, null); + ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, null, null); + ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, null, null); + ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, null, null); + + evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained); + } } void -_WebImpl::OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo) +_WebImpl::ClearCertificateDb(void) { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - char* pJsonText = reinterpret_cast< char* >(pEventInfo); - SysAssertf(pImpl && pJsonText, "Failed to request"); - result r = E_SUCCESS; - SysLog(NID_WEB_CTRL, "The current value of jsontext is %s", pJsonText); + String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME); + String table(CERTIFICATE_TABLE_NAME); + _DatabaseImpl db; - std::unique_ptr<_JsBridgeArg> pEventArg(new (std::nothrow) _JsBridgeArg()); - SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + r = db.Construct(certificatePath, "r+", null); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + db.BeginTransaction(); + + r = db.ExecuteSql(L"Delete From " + table, true); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + db.CommitTransaction(); - r = pEventArg->Construct(pJsonText); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + return; - r = pImpl->__pWebEvent->FireAsync(*pEventArg.get()); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - pEventArg.release(); +CATCH: + db.RollbackTransaction(); } -void -_WebImpl::OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo) +result +_WebImpl::SetBlockSelectionPosition(const Point& startPoint) { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - Eina_Rectangle* pEinaRect = reinterpret_cast< Eina_Rectangle* >(pEventInfo); - SysAssertf(pImpl && pEinaRect, "Failed to request"); + return SetBlockSelectionPosition(_CoordinateSystemUtils::ConvertToFloat(startPoint)); +} - if (pImpl->IsVisible() == false) - { - evas_object_focus_set(pView, EINA_FALSE); - } - if (pImpl->GetSetting().GetInputStyle() == INPUT_STYLE_OVERLAY) +result +_WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint) +{ + Evas_Object* pView = __pWebCore->GetWebNativeNode(); + Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pView); + if (pSmartData && pSmartData->api) { - _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer(); - SysAssertf(pXformer, "Failed to get CoordinateTransformer"); - - Rectangle rect(pEinaRect->x, pEinaRect->y, pEinaRect->w, pEinaRect->h); + Point absPoint( _CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(startPoint))); - if (rect.height == 0) + Eina_Bool ret = pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y); + if (ret) { - return; - } + pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y); - _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl)); - if (pFormImpl) - { - pFormImpl->DeflateClientRectHeight(pXformer->TransformVertical(rect.height)); + Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL); + SysTryReturnResult(NID_WEB_CTRL, pEwkHitTest, E_SYSTEM, "Failed to get hit test."); - if (pFormImpl->HasFooter()) - { - pFormImpl->GetCore().SetKeypadShowState(true); - pFormImpl->Draw(); - } - } + String tagName(ewk_hit_test_tag_name_get(pEwkHitTest)); - if (pImpl->__pUserKeypadEventListener) - { - if (pImpl->__isKeypadVisible) + if (tagName.Equals(L"INPUT", false) || tagName.Equals(L"TEXTAREA", false)) { - if ((pImpl->__previousKeypadBounds.width == rect.width) && (pImpl->__previousKeypadBounds.height != rect.height)) - { - pImpl->__pUserKeypadEventListener->OnWebKeypadBoundsChanged(*dynamic_cast< Web* >(&pImpl->GetPublic())); - } + ewk_view_command_execute(pView, "SelectWord", 0); } else { - pImpl->__pUserKeypadEventListener->OnWebKeypadWillOpen(*dynamic_cast< Web* >(&pImpl->GetPublic())); + Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest); + char* pValue = reinterpret_cast< char* >(eina_hash_find(pAttrHash, "contenteditable")); + if(pValue) + { + ewk_view_command_execute(pView, "SelectWord", 0); + } } } - pImpl->__isKeypadVisible = true; - pImpl->__previousKeypadBounds = rect; - } - else - { - result r = pImpl->SetFullScreenKeypad(); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); } -} + SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up."); -void -_WebImpl::OnWebKeypadOpened(void* pUserData, Evas_Object* pView, void* pEventInfo) -{ - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pImpl, "Failed to request"); + evas_object_smart_callback_call(pView, "text,selected", NULL); - if (pImpl->__pUserKeypadEventListener) - { - pImpl->__pUserKeypadEventListener->OnWebKeypadOpened(*static_cast< Web* >(&pImpl->GetPublic())); - } + return E_SUCCESS; } void -_WebImpl::OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo) +_WebImpl::ReleaseBlock(void) { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pImpl, "Failed to request"); + ewk_view_text_selection_range_clear(__pWebCore->GetWebNativeNode()); +} - _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl)); - if (pFormImpl) - { - pFormImpl->DeflateClientRectHeight(0); - if (pFormImpl->HasFooter()) - { - pFormImpl->GetCore().SetKeypadShowState(false); - pFormImpl->Draw(); - } - } +void +_WebImpl::GetBlockRange(Point& startPoint, Point& endPoint) const +{ + FloatPoint tempStartPoint; + FloatPoint tempEndPoint; - if (pImpl->__pUserKeypadEventListener) - { - pImpl->__pUserKeypadEventListener->OnWebKeypadClosed(*dynamic_cast< Web* >(&pImpl->GetPublic())); - } + GetBlockRange(tempStartPoint, tempEndPoint); - pImpl->__isKeypadVisible = false; + startPoint = _CoordinateSystemUtils::ConvertToInteger(tempStartPoint); + endPoint = _CoordinateSystemUtils::ConvertToInteger(tempEndPoint); } void -_WebImpl::OnWindowObjectFocusGained(void* pUserData, Evas_Object* pWin, void* pEvent_info) +_WebImpl::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pImpl, "Failed to request"); + Eina_Rectangle leftHandle; + Eina_Rectangle rightHandle; - if (pImpl->__isKeypadOpened && pImpl->IsVisible() && pImpl->IsFocused()) - { - _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore())); - SysAssertf(pWebCore, "Failed to get Web core object"); + EINA_RECTANGLE_SET(&leftHandle, 0, 0, 0, 0); + EINA_RECTANGLE_SET(&rightHandle, 0, 0, 0, 0); - evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE); + ewk_view_text_selection_range_get(__pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle); + + startPoint.x = _CoordinateSystemUtils::ConvertToFloat(leftHandle.x); + startPoint.y = _CoordinateSystemUtils::ConvertToFloat(leftHandle.y); + endPoint.x = _CoordinateSystemUtils::ConvertToFloat(rightHandle.x + rightHandle.w); + endPoint.y = _CoordinateSystemUtils::ConvertToFloat(rightHandle.y + rightHandle.h); - pImpl->__isKeypadVisible = true; + if ((endPoint.x != 0.0f) && (endPoint.y != 0.0f)) + { + startPoint = __pWebCore->GetRelativeCoordinate(startPoint); + endPoint = __pWebCore->GetRelativeCoordinate(endPoint); } } -void -_WebImpl::OnWebNativeNodeFocusGained(void* pUserData, Evas* pCanvas, Evas_Object* pView, void* pEventInfo) +Bitmap* +_WebImpl::GetFaviconN(void) const { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pImpl, "Failed to request"); + result r = E_SUCCESS; - if (pImpl->__isKeypadOpened) + Evas_Object* pView = __pWebCore->GetWebNativeNode(); + Ewk_Context* pContext = ewk_view_context_get(pView); + const char* pUrl = ewk_view_url_get(pView); + Evas* pEvas = evas_object_evas_get(pView); + + Evas_Object* pFavicon = ewk_context_icon_database_icon_object_add(pContext, pUrl, pEvas); + if (!pFavicon) { - pImpl->__isKeypadOpened = false; + return null; } -} - -Eina_Bool -_WebImpl::OnColorPickerProviderRequested(Ewk_View_Smart_Data* pSmartData, int red, int green, int blue, int alpha) -{ - SysAssertf(pSmartData, "invalid smartdata"); - _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); - SysAssertf(pWebImpl, "Failed to get Impl"); + Tizen::Graphics::BufferInfo bufferInfo; - result r = E_SUCCESS; + r = _Utility::GetPixelBufferFromEvasObject(pFavicon, bufferInfo); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); - if (pWebImpl->__pColorPicker.get()) - { - return EINA_FALSE; - } + const Dimension dimension(bufferInfo.width, bufferInfo.height); + Tizen::Base::ByteBuffer byteBuffer; + + r = byteBuffer.Construct((byte*)bufferInfo.pPixels, 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 ); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); - Color color; + std::unique_ptr pImage(new (std::nothrow) Bitmap()); + SysTryReturn(NID_WEB_CTRL, pImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - r = pWebImpl->ShowColorPicker(red, green, blue, alpha, color); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r)); + r = pImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); - byte r1, g1, b1, a1; - color.GetColorComponents(r1, g1, b1, a1); - ewk_view_color_picker_color_set(pSmartData->self, r1, g1, b1, a1); + return pImage.release(); - return EINA_TRUE; } -Eina_Bool -_WebImpl::OnColorPickerProviderDismissed(Ewk_View_Smart_Data* pSmartData) +void +_WebImpl::ScrollBy(const Tizen::Graphics::Point& diff) { - SysAssertf(pSmartData, "invalid smartdata"); + ewk_view_scroll_by(__pWebCore->GetWebNativeNode(), diff.x, diff.y); +} - _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); - SysAssertf(pWebImpl, "Failed to get Impl"); - return pWebImpl->HideColorPicker(); +void +_WebImpl::ScrollTo(const Tizen::Graphics::Point& dest) +{ + ewk_view_scroll_set(__pWebCore->GetWebNativeNode(), dest.x, dest.y); } -Eina_Bool -_WebImpl::OnDatePickerProviderRequested(Ewk_View_Smart_Data* pSmartData, Ewk_Input_Type inputType, const char* inputValue) +Point +_WebImpl::GetScrollPosition(void) const { - SysAssertf(pSmartData, "Failed to request"); - _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); - SysAssertf(pWebImpl, "Failed to get Impl"); - - result r = E_SUCCESS; + Point position; - if (pWebImpl->__pDatePicker.get()) - { - ewk_view_focused_input_element_value_set(pSmartData->self, inputValue); + ewk_view_scroll_pos_get(__pWebCore->GetWebNativeNode(), &position.x, &position.y); - return EINA_FALSE; - } + return position; +} - String dateStr; - r = pWebImpl->ShowDatePicker(inputType, inputValue, dateStr); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r)); +Dimension +_WebImpl::GetPageSize(void) const +{ + Evas_Coord width = 0; + Evas_Coord height = 0; - std::unique_ptr pDateStr(_StringConverter::CopyToCharArrayN(dateStr)); - SysTryReturn(NID_WEB_CTRL, pDateStr.get(), EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &width, &height); - ewk_view_focused_input_element_value_set(pSmartData->self, pDateStr.get()); + Dimension size(static_cast< int >(width), static_cast< int >(height)); - return EINA_TRUE; + return size; } -Eina_Bool -_WebImpl::OnSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex) +result +_WebImpl::AddHttpHeaderField(const String& name, const String& value) { - SysAssertf(pSmartData, "Failed to request"); + SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing."); - _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); - SysAssertf(pWebImpl, "Failed to get Impl"); + std::unique_ptr pName(_StringConverter::CopyToCharArrayN(name)); + SysTryReturn(NID_WEB_CTRL, pName.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - result r = pWebImpl->ShowSelectBoxPopup(false, L"", pItems, pSmartData->self, selectedIndex); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); + std::unique_ptr pValue(_StringConverter::CopyToCharArrayN(value)); - return EINA_TRUE; + ewk_view_custom_header_add(__pWebCore->GetWebNativeNode(), pName.get(), pValue.get()); + + return E_SUCCESS; } -Eina_Bool -_WebImpl::OnMultiSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* pItems) +result +_WebImpl::RemoveHttpHeaderField(const String& name) { - SysAssertf(pSmartData, "Failed to request"); + SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing."); - _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); - SysAssertf(pWebImpl, "Failed to get Impl"); + std::unique_ptr pName(_StringConverter::CopyToCharArrayN(name)); + SysTryReturn(NID_WEB_CTRL, pName.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - result r = pWebImpl->ShowSelectBoxPopup(true, L"", pItems, pSmartData->self, 0); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); + ewk_view_custom_header_remove(__pWebCore->GetWebNativeNode(), pName.get()); - return EINA_TRUE; + return E_SUCCESS; } -Eina_Bool -_WebImpl::OnSelectBoxClosed(Ewk_View_Smart_Data* pSmartData) +void +_WebImpl::SetLoadingErrorOccurred(bool arg) { - SysAssertf(pSmartData, "invalid smartdata"); + __isLoadingErrorOccurred = arg; +} - _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); - SysAssertf(pWebImpl, "Failed to get Impl"); - result r = pWebImpl->ClearSelectBoxPopup(); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); +bool +_WebImpl::IsLoadingErrorOccurred(void) const +{ + return __isLoadingErrorOccurred; +} + + +void +_WebImpl::SetRedirectRequested(bool arg) +{ + __isRedirectRequested = arg; +} + - return EINA_TRUE; +bool +_WebImpl::IsRedirectRequested(void) const +{ + return __isRedirectRequested; } -Eina_Bool -_WebImpl::OnSelectBoxUpdateRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, Eina_List* pItems, int selectedIndex) +void +_WebImpl::SetPolicyDecision(DecisionPolicy policy) { - SysAssertf(pSmartData, "invalid smartdata"); - - _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); - SysAssertf(pWebImpl, "Failed to get Impl"); + __policy = policy; +} - result r = pWebImpl->UpdateSelectBoxPopup(pItems, selectedIndex, false); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); - return EINA_TRUE; +DecisionPolicy +_WebImpl::GetPolicyDecision(void) const +{ + return __policy; } -Eina_Bool -_WebImpl::OnFormDataCandidateShow(Ewk_View_Smart_Data *pSmartData, int x, int y, int w, int h) +void +_WebImpl::SetCertificateRequested(bool arg) { - SysAssertf(pSmartData, "Failed to request"); - - _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); - SysAssertf(pWebImpl, "Failed to get Impl"); + __isCertificateRequested = arg; +} - Rectangle windowRect(x, y, w, h); - result r = pWebImpl->ShowFormDataWindow(windowRect, pSmartData->self); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); - return EINA_TRUE; +bool +_WebImpl::IsCertificateRequested(void) const +{ + return __isCertificateRequested; } -Eina_Bool -_WebImpl::OnFormDataCandidateHide(Ewk_View_Smart_Data *pSmartData) +void +_WebImpl::SetCertificateConfirmed(bool arg) { - SysAssertf(pSmartData, "Failed to request"); - - _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); - SysAssertf(pWebImpl, "Failed to get Impl"); + __isCertificateConfirmed = arg; +} - if (pWebImpl->__isFormDataVisible) - { - pWebImpl->HideFormDataWindow(); - } - return EINA_TRUE; +bool +_WebImpl::IsCertificateConfirmed(void) const +{ + return __isCertificateConfirmed; } -Eina_Bool -_WebImpl::OnFormDataCandidateUpdate(Ewk_View_Smart_Data *pSmartData, Eina_List *pDataList) +result +_WebImpl::SetFullScreenKeypad(void) { - SysAssertf(pSmartData, "Failed to request"); + result r = E_SUCCESS; - _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); - SysAssertf(pWebImpl, "Failed to get Impl"); + std::unique_ptr pKeypad(new (std::nothrow) Keypad()); + SysTryReturnResult(NID_WEB_CTRL, pKeypad.get(), E_OUT_OF_MEMORY, "Memory allocation failed."); - pWebImpl->SetFormDataList(pDataList); + r = pKeypad->Construct(KEYPAD_STYLE_NORMAL, 100); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - return EINA_TRUE; -} + String text(ewk_view_focused_input_element_value_get(__pWebCore->GetWebNativeNode())); + pKeypad->SetText(text); + r = pKeypad->SetShowState(true); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); -Eina_Bool -_WebImpl::OnFormDataCandidateIsShowing(Ewk_View_Smart_Data *pSmartData) -{ - SysAssertf(pSmartData, "Failed to request"); + r = pKeypad->Show(); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); - SysAssertf(pWebImpl, "Failed to get Impl"); + pKeypad->AddTextEventListener(*this); - if (pWebImpl->__isFormDataVisible) - { - return EINA_TRUE; - } - else - { - return EINA_FALSE; - } + __pKeypad = std::move(pKeypad); + + return E_SUCCESS; } void -_WebImpl::OnCookiesPolicyGot(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *pError, void *pUserData) +_WebImpl::RemoveFullScreenKeypad(void) { - _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData); - SysAssertf(pPresenter && !pError, "Failed to request"); + __pKeypad->RemoveTextEventListener(*this); - bool ret = EINA_TRUE; + __pKeypad.reset(); +} - switch (policy) - { - case EWK_COOKIE_ACCEPT_POLICY_ALWAYS: - //fall through - case EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY: - ret = EINA_TRUE; - break; - case EWK_COOKIE_ACCEPT_POLICY_NEVER: - //fall through - ret = EINA_FALSE; - break; +bool +_WebImpl::IsFooterVisible(void) const +{ + return __isFooterVisible; +} - default: - SysAssert(false); - } - SysLog(NID_WEB_CTRL, "The current value of policy is %d", ret); +void +_WebImpl::SetFooterVisibleState(bool isFooterVisible) +{ + __isFooterVisible = isFooterVisible; +} - pPresenter->EndAsyncProcess(ret); + +bool +_WebImpl::IsKeypadVisible(void) const +{ + return __isKeypadVisible; } void -_WebImpl::OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData) +_WebImpl::SetKeypadVisibleState(bool isKeypadVisible) { - _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData); - SysAssertf(pPresenter, "Failed to request"); + __isKeypadVisible = isKeypadVisible; +} - String result(pResult); - SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer()); - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, WEB_CTRL)); - _WebManager* pWebManager = _WebManager::GetInstance(); - if (pWebManager->IsValidCallback(reinterpret_cast< int >(pImpl), reinterpret_cast< int >(pPresenter))) - { - pPresenter->EndAsyncProcess(result); - } +bool +_WebImpl::IsKeypadOpened(void) const +{ + return __isKeypadOpened; } - -void -_WebImpl::OnTextFound(void* pUserData, Evas_Object* pView, void* pEventInfo) +void +_WebImpl::SetKeypadOpened(bool isKeypadOpened) { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pImpl, "Failed to request"); + __isKeypadOpened = isKeypadOpened; +} - int* pTotalCount = reinterpret_cast< int* >(pEventInfo); - SysLog(NID_WEB_CTRL, "The current value of totalCount is %d", *pTotalCount); - _WebPresenter* pWebPresenter = pImpl->GetSearchPresenter(); +Rectangle +_WebImpl::GetPreviousKeypadBounds(void) const +{ + return __keypadBounds; +} - if (pWebPresenter) - { - pWebPresenter->EndAsyncProcess(*pTotalCount); - } - else - { - if (pImpl->__pTextSearchListener) - { - result r = E_SUCCESS; - int ordinal = 0; +void +_WebImpl::SetPreviousKeypadBounds(Rectangle& bounds) +{ + __keypadBounds = bounds; +} - if (*pTotalCount > 0) - { - ordinal = pImpl->GetAsyncSearchOrdinal(); - pImpl->SetAsyncSearchResult(*pTotalCount); - } - if (pImpl->GetPendingAsyncSearchCount() > 0) - { - return; - } +void +_WebImpl::OnTextValueChangeCanceled(const Control& source) +{ + RemoveFullScreenKeypad(); +} - std::unique_ptr pCount(new (std::nothrow) Integer(*pTotalCount)); - std::unique_ptr pOrdinal(new (std::nothrow) Integer(ordinal)); - std::unique_ptr<_TextSearchEventArg> pEventArg(new (std::nothrow) _TextSearchEventArg(WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND)); - SysTryReturnVoidResult(NID_WEB_CTRL, pCount.get() && pOrdinal.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - r = pEventArg->SetEventInfo(_TextSearchEventArg::TOTAL_COUNT, *pCount.get()); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - pCount.release(); +void +_WebImpl::OnTextValueChanged(const Control& source) +{ + std::unique_ptr pText(_StringConverter::CopyToCharArrayN(__pKeypad->GetText())); - r = pEventArg->SetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL, *pOrdinal.get()); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - pOrdinal.release(); + ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get()); - r = pImpl->__pWebEvent->FireAsync(*pEventArg.get()); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - pEventArg.release(); - } - } + RemoveFullScreenKeypad(); } - result _WebImpl::OnHandleJavaScriptRequestByEventArg(const IEventArg& arg) { @@ -4315,52 +4504,6 @@ _WebImpl::HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge) result -_WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List* pItems, Evas_Object* pWebView, int selectedIndex) -{ - __pSelectBox.reset(); - - SysTryReturnResult(NID_WEB_CTRL, eina_list_count(pItems) > 0, E_SYSTEM, "ItemCount is invalid."); - - result r = E_SUCCESS; - - std::unique_ptr<_SelectBox> pSelectBox(new (std::nothrow) _SelectBox()); - SysTryReturnResult(NID_WEB_CTRL, pSelectBox.get(), E_OUT_OF_MEMORY, "Memory allocation failed."); - - r = pSelectBox->Construct(isMultiSelect, title, DEFAULT_LIST_ITEM_COUNT, pWebView); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - - r = pSelectBox->UpdateList(pItems, selectedIndex, false, false); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - - __pSelectBox = std::move(pSelectBox); - - __pSelectBox->SetOwner(&GetPublic()); - - return __pSelectBox->ShowPopup(); -} - - -result -_WebImpl::UpdateSelectBoxPopup(Eina_List* pItems, int selectedIndex, bool isGroupedList) -{ - SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist."); - - return __pSelectBox->UpdateList(pItems, selectedIndex, true, isGroupedList); -} - - -result -_WebImpl::ClearSelectBoxPopup(void) -{ - SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist."); - - __pSelectBox.reset(); - - return E_SUCCESS; -} - - -result _WebImpl::ShowAuthenticationPopup(const String& host, const String& realm, AuthenticationChallenge* pAuthChallenge) { result r = E_SUCCESS; @@ -4671,10 +4814,11 @@ _WebImpl::OnFocusGained(const _ControlImpl& source) bool _WebImpl::OnFocusLost(const _ControlImpl& source) { - if(__isKeypadVisible) + if(IsKeypadVisible() == true) { - __isKeypadOpened = true; - __isKeypadVisible = false; + SetKeypadOpened(true); + + SetKeypadVisibleState(false); } Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode()); @@ -4846,6 +4990,22 @@ _WebImpl::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::ILi } +_WebDataHandler* +_WebImpl::GetDownloadHandler(void) const +{ + return __pWebDownloadHandler.get(); +} + + +Eina_Bool +_WebImpl::HideColorPicker(void) +{ + __pColorPicker.reset(); + + return EINA_TRUE; +} + + result _WebImpl::ShowColorPicker(int red, int green, int blue, int alpha, Color& color) { @@ -4879,15 +5039,6 @@ CATCH: } -Eina_Bool -_WebImpl::HideColorPicker(void) -{ - __pColorPicker.reset(); - - return EINA_TRUE; -} - - result _WebImpl::ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue, String& dateStr) { @@ -5174,6 +5325,13 @@ _WebImpl::SetFormDataList(Eina_List* pFormDataList) } +bool +_WebImpl::IsFormDataWindowVisible(void) const +{ + return __isFormDataVisible; +} + + result _WebImpl::ShowFormDataWindow(const Rectangle& windowRect, Evas_Object* pWebView) { diff --git a/src/controls/inc/FWebCtrl_WebImpl.h b/src/controls/inc/FWebCtrl_WebImpl.h index 0ae9043..267719f 100755 --- a/src/controls/inc/FWebCtrl_WebImpl.h +++ b/src/controls/inc/FWebCtrl_WebImpl.h @@ -314,15 +314,44 @@ public: void RemoveFullScreenKeypad(void); - bool IsKeypadVisible(void) const; + void SetCurrentEvent(Tizen::Base::Runtime::IEventArg* arg); - Tizen::Graphics::Rectangle GetPreviousKeypadBounds(void) const; + void SetLoadingErrorOccurred(bool arg); + + bool IsLoadingErrorOccurred(void) const; + void SetRedirectRequested(bool arg); + + bool IsRedirectRequested(void) const; + + void SetCertificateRequested(bool arg); + bool IsCertificateRequested(void) const; + void SetCertificateConfirmed(bool arg); + bool IsCertificateConfirmed(void) const; void ClearCertificateDb(void); + void SetOrientationChanged(bool arg); + bool IsOrientationChanged(void) const; + result VibrationRequested(uint64_t duration); void VibrationCanceled(void); + bool IsFooterVisible(void) const; + + void SetFooterVisibleState(bool isFooterVisible); + + bool IsKeypadVisible(void) const; + + void SetKeypadVisibleState(bool isKeypadVisible); + + bool IsKeypadOpened(void) const; + + void SetKeypadOpened(bool isKeypadOpened); + + Tizen::Graphics::Rectangle GetPreviousKeypadBounds(void) const; + + void SetPreviousKeypadBounds(Tizen::Graphics::Rectangle& bounds); + result HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge); result ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk_Certificate_Policy_Decision *pPolicy); @@ -340,8 +369,15 @@ public: result ShowColorPicker(int r, int g, int b, int a,Tizen::Graphics::Color& color); Eina_Bool HideColorPicker(void); + _InputPickerPopup* GetColorpicker(void); result ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue,Tizen::Base::String& dateStr); + _InputPickerPopup* GetDatepicker(void); + + + void SetPolicyDecision(DecisionPolicy policy); + + DecisionPolicy GetPolicyDecision(void) const; virtual bool OnFocusGained(const Tizen::Ui::_ControlImpl& source); @@ -381,6 +417,8 @@ public: void SetFormDataList(Eina_List* pFormDataList); + bool IsFormDataWindowVisible(void) const; + result ShowFormDataWindow(const Tizen::Graphics::Rectangle& windowRect, Evas_Object* pWebView); void HideFormDataWindow(bool delWindow = true); @@ -400,79 +438,6 @@ private: Eina_Hash* ConvertToSlpHeaderN(const Tizen::Net::Http::HttpHeader& header) const; - static Eina_Bool AddHttpHeaderData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData); - static Eina_Bool AddHttpAttributeData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData); - static void FreeCharArray(void* pData); - static LoadingErrorType ConvertErrorCode(int error); - static result FireLoadingErrorOccurredEvent(_WebImpl* pImpl, int code, const char* pDescription); - static Eina_Bool OnScriptAlertRequested(Evas_Object* pView, const char* pMessage, void* pUserData); - static Eina_Bool OnScriptConfirmRequested(Evas_Object* pView, const char* pMessage, void* pUserData); - static Eina_Bool OnScriptPromptRequested(Evas_Object* pView, const char* pMessage, const char* pDefaultValue, void* pUserData); - static void OnCertificateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnHttpAuthenticationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnHttpAuthenticationCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo); - static Eina_Bool OnApplicationCachePermissionRequested(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, void* pUserData); - static Eina_Bool OnIndexedDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData); - static Eina_Bool OnDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, const char* database_name, unsigned long long expectedQuota, void* pUserData); - static Eina_Bool OnLocalFileSystemQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData); - static void OnGeolocationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnGetUserMediaPermissionRequsted(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnNotificationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnNotificationShow(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnNotificationCancel(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnProtocolHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnIsProtocolHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnProtocolHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnContentHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnIsContentHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnContentHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnFullScreenEntered(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnFullScreenExited(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnVibrationRequested(uint64_t duration, void* pUserData); - static void OnVibrationCanceled(void* pUserData); - static void OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnLoadingStarted(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnPageTitleReceived(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnEstimatedProgress(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnProgressCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnLoadingErrorOccurred(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnLoadingCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnLoadingCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnFaviconReceived(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnDidStartDownloadCallback(const char* pUrl, void* pUserData); - static result FireWebPageShowRequestedEvent(_WebImpl* pImpl, int event); - static void OnWebPageShowRequested(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnWebWindowCreateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo); - static result FireWebWindowClosedRequestedEvent(_WebImpl* pImpl, int event); - static void OnWebWindowClosedRequested(void* pUserData, Evas_Object* pView, void* pEventInfo); - static result FireWebPreventDefaultTriggeredEvent(_WebImpl* pImpl, int event, bool trigger); - static void OnWebPreventDefaultTriggered(void* pUserData, Evas_Object* pView, void* pEventInfo); - static result FireWebPageBlockSelectedEvent(_WebImpl* pImpl); - static result FireWebPageBlockSelectedEventF(_WebImpl* pImpl); - static void OnWebPageBlockSelected(void* pUserData, Evas_Object* pView, void* pEventInfo); - static Eina_Bool OnSelectUploadFile(Evas_Object* pView, Eina_Bool multipleFile, Eina_List* pAcceptTypes, const char* pCapture, void* pUserData); - static void OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnWebKeypadOpened(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo); - static void OnWindowObjectFocusGained(void* pUserData, Evas_Object* pWin, void* pEvent_info); - static void OnWebNativeNodeFocusGained(void* pUserData, Evas* pCanvas, Evas_Object* pView, void* pEventInfo); - static Eina_Bool OnColorPickerProviderRequested(Ewk_View_Smart_Data* pSmartData, int red, int green, int blue, int alpha); - static Eina_Bool OnColorPickerProviderDismissed(Ewk_View_Smart_Data* pSmartData); - static Eina_Bool OnDatePickerProviderRequested(Ewk_View_Smart_Data* pSmartData, Ewk_Input_Type inputType, const char* inputValue); - static Eina_Bool OnSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex); - static Eina_Bool OnMultiSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* pItems); - static Eina_Bool OnSelectBoxClosed(Ewk_View_Smart_Data* pSmartData); - static Eina_Bool OnSelectBoxUpdateRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, Eina_List* pItems, int selectedIndex); - static Eina_Bool OnFormDataCandidateShow(Ewk_View_Smart_Data *pSmartData, int x, int y, int w, int h); - static Eina_Bool OnFormDataCandidateHide(Ewk_View_Smart_Data *pSmartData); - static Eina_Bool OnFormDataCandidateUpdate(Ewk_View_Smart_Data *pSmartData, Eina_List *pDataList); - static Eina_Bool OnFormDataCandidateIsShowing(Ewk_View_Smart_Data *pSmartData); - static void OnCookiesPolicyGot(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *pError, void *pUserData); - static void OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData); - static void OnTextFound(void* pUserData, Evas_Object* pView, void* pEventInfo); - result OnHandleJavaScriptRequestByEventArg(const Tizen::Base::Runtime::IEventArg& arg); result OnHandleLoadingEvent(const Tizen::Base::Runtime::IEventArg& arg); result OnHandleWebDownloadEvent(const Tizen::Base::Runtime::IEventArg& arg); @@ -495,7 +460,7 @@ private: bool __isCertificateRequested; bool __isCertificateConfirmed; bool __isFormDataVisible; - Tizen::Graphics::Rectangle __previousKeypadBounds; + Tizen::Graphics::Rectangle __keypadBounds; _Web* __pWebCore; -- 2.7.4