From 4a43d248f2a4752e894b373180f3c429859bbe78 Mon Sep 17 00:00:00 2001 From: Seongjun Yim Date: Tue, 23 Jul 2013 16:52:02 +0900 Subject: [PATCH] change callback functions type with static method Change-Id: I33116f1a698204a24ad13178018b751dd6f23d3c Signed-off-by: Seongjun Yim --- src/controls/FWebCtrl_WebImpl.cpp | 5422 +++++++++++++++++------------------ src/controls/inc/FWebCtrl_WebImpl.h | 117 +- 2 files changed, 2708 insertions(+), 2831 deletions(-) diff --git a/src/controls/FWebCtrl_WebImpl.cpp b/src/controls/FWebCtrl_WebImpl.cpp index c308c2a..37fcb23 100755 --- a/src/controls/FWebCtrl_WebImpl.cpp +++ b/src/controls/FWebCtrl_WebImpl.cpp @@ -152,3965 +152,3776 @@ static const int LANDSCAPE_KEYPAD_HEIGHT = 316; static const int DEFAULT_LIST_ITEM_COUNT = 4; -Eina_Bool -AddHttpHeaderData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData) -{ - 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; -} - - -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) +class _JsBridgeHashCodeProvider + : public Tizen::Base::Collection::IHashCodeProviderT< Tizen::Base::String > { - delete[] reinterpret_cast(pData); -} - +public: + _JsBridgeHashCodeProvider(){} + virtual ~_JsBridgeHashCodeProvider(void) {} -LoadingErrorType -ConvertErrorCode(int error) -{ - LoadingErrorType errorCode = WEB_ERROR_UNKNOWN; - switch (error) + int GetHashCode(const Tizen::Base::String& obj) const { - 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 obj.GetHashCode(); } - return errorCode; -} - - -result -FireLoadingErrorOccurredEvent(_WebImpl* pImpl, int code, const char* pDescription) -{ - 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(); - - 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) +//Comparer implementation +class _JsBridgeComparer + : public Tizen::Base::Collection::IComparerT< Tizen::Base::String > { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - Ewk_Certificate_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Certificate_Policy_Decision* >(pEventInfo); - SysAssertf(pImpl && pPolicy, "Failed to request"); +public: + _JsBridgeComparer(){} + virtual ~_JsBridgeComparer(void) {} - _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore())); - switch (pImpl->GetSetting().GetCertificateErrorHandlingMode()) - { - case WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM: + result Compare(const Tizen::Base::String& obj1, const Tizen::Base::String& obj2, int& cmp) const { - if (pImpl->IsCertificateRequested()) - { - 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()) + if (obj1 == obj2) { - 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)); + cmp = 0; } else { - 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()); - } - - if (pImpl) - { - pImpl->SetCertificateRequested(true); + cmp = 1; } - 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); - - ewk_view_resume(pWebCore->GetWebNativeNode()); -} - - -void -OnHttpAuthenticationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) -{ - _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(); + return E_SUCCESS; } -} - -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; -} +}; -Eina_Bool -OnDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, const char* database_name, unsigned long long expectedQuota, void* pUserData) +_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) { - _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; + __textSearch.__searchAll = false; + __textSearch.__searchForward = true; + __textSearch.__caseSensitive = false; + __textSearch.__pending = 0; + __textSearch.__currentIndex = 1; + __textSearch.__totalCount = -1; + __textSearch.__text = L""; } -Eina_Bool OnLocalFileSystemQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData) +_WebImpl::~_WebImpl() { - _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 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)); - - 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)); - - return EINA_TRUE; + ClearCertificateDb(); } -void -OnGeolocationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) +_WebImpl* +_WebImpl::CreateWebImplN(Web* pControl, const Rectangle& bounds) { - _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 (pImpl->GetSetting().IsGeolocationEnabled()) - { - result r = E_SUCCESS; - - std::unique_ptr pEnum; - - 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 r = E_SUCCESS; - r = db.Construct(geolocationPath, "r", null); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + 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)); - 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)); + _Web* pCore = _Web::CreateWebN(); + SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - int permission = 0; - r = pEnum->GetIntAt(0, permission); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore); - SysLog(NID_WEB_CTRL, "The current value of permission is %d", permission); + r = CheckConstruction(pCore, pImpl); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); - ewk_geolocation_permission_request_set(pPermissionRequest, static_cast < Eina_Bool >(permission)); - } - else - { - ewk_geolocation_permission_request_suspend(pPermissionRequest); + r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation()); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_GEOLOCATION, pPermissionRequest); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - } + r = pImpl->Construct(); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - return; - } + return pImpl; CATCH: - ewk_geolocation_permission_request_set(pPermissionRequest, EINA_FALSE); + delete pImpl; + + return null; } -void -OnGetUserMediaPermissionRequsted(void* pUserData, Evas_Object* pView, void* pEventInfo) +_WebImpl* +_WebImpl::CreateWebImplN(Web* pControl, const FloatRectangle& bounds) { - _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"); - - result r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_USERMEDIA, pEventInfo); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - return; + result r = E_SUCCESS; -CATCH: - ewk_user_media_permission_request_set(pPermissionRequest, EINA_FALSE); -} + 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)); + _Web* pCore = _Web::CreateWebN(); + SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); -void -OnNotificationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) -{ - result r = E_SUCCESS; - _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); + _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore); - Ewk_Notification_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Notification_Permission_Request* >(pEventInfo); - SysAssertf(pImpl && pPermissionRequest, "Failed to request"); + r = CheckConstruction(pCore, pImpl); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); - ewk_notification_permission_request_suspend(pPermissionRequest); + r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation()); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_NOTIFICATION, pPermissionRequest); + r = pImpl->Construct(); SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - return; + + return pImpl; CATCH: - ewk_notification_permission_request_set(pPermissionRequest, EINA_FALSE); + delete pImpl; + + return null; } -void -OnNotificationShow(void* pUserData, Evas_Object* pView, void* pEventInfo) +result +_WebImpl::Construct(void) { - _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) + r = __mutex.Create(); + 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 = __textSearch.__searchQueue.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 = __webNotificationList.Construct(); + 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 = InitJsBridgeList(); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - pNotificationWindow->SetText(String(text)); - pNotificationWindow->LaunchNotification(); - pImpl->SetWebNotification(pNotificationWindow.release()); + r = InitWebEvent(); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - ewk_notification_showed(pContext, notificationId); -} + _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance(); + SysTryReturn(NID_WEB_CTRL, pManagerImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + pManagerImpl->SetDownloadListener(this); -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"); + __pWebCore = dynamic_cast< _Web* >(&(GetCore())); + SysTryReturnResult(NID_WEB_CTRL, __pWebCore, E_SYSTEM, "A system error has been occurred. Failed to get web control"); - //ToDo : Where is ewk API for cancel operation? + return E_SUCCESS; } -void -OnProtocolHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) +result +_WebImpl::InitializeSetting(void) { 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)); -} + WebSetting* pWebSetting = __pWebCore->GetSetting(); + _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(pWebSetting); + SetCookieEnabled(pWebSettingImpl->IsCookieEnabled()); + SetPrivateBrowsingEnabled(pWebSettingImpl->IsPrivateBrowsingEnabled()); -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"); + __defaultUserAgent = pWebSettingImpl->GetUserAgent(); - 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); - } -} + r = SetSetting(*pWebSetting); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); -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"); + SetEventListenerCallback(); - r = pImpl->UnregistrationHandler(pHandlerData, false); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + return E_SUCCESS; } -void -OnContentHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) +bool +_WebImpl::IsLayoutable(void) const { - 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)); + return true; } -void -OnIsContentHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo) +result +_WebImpl::InitWebEvent(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"); + __pWebEvent = std::unique_ptr<_WebEvent>(new (std::nothrow) _WebEvent()); + SysTryReturnResult(NID_WEB_CTRL, __pWebEvent.get(), E_OUT_OF_MEMORY, "Memory allocation failed."); - 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); - } + return __pWebEvent->Construct(*this); +} + + +_WebEvent* +_WebImpl::GetWebEvent(void) const +{ + return __pWebEvent.get(); } -void -OnContentHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) +Eina_Hash* +_WebImpl::ConvertToSlpHeaderN(const HttpHeader& header) const { - 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"); + Eina_Hash* pHttpHeader = null; - r = pImpl->UnregistrationHandler(pHandlerData, true); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); -} + 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(); + 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())); -void -OnFullScreenEntered(void* pUserData, Evas_Object* pView, void* pEventInfo) -{ - _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); - SysAssertf(pImpl, "Failed to request"); + std::unique_ptr pKey(_StringConverter::CopyToCharArrayN(*pFieldName)); + SysTryCatch(NID_WEB_CTRL, pKey.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - SysLog(NID_WEB_CTRL, "Enter."); -} + 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; + String* pFieldValue = dynamic_cast< String* >(pFieldValueEnum->GetCurrent()); + SysTryCatch(NID_WEB_CTRL, pFieldValue, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); -void -OnFullScreenExited(void* pUserData, Evas_Object* pView, void* pEventInfo) -{ - _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); - SysAssertf(pImpl, "Failed to request"); + 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; + +CATCH: + eina_hash_free(pHttpHeader); - SysLog(NID_WEB_CTRL, "Exit."); + return null; } -void -OnVibrationRequested(uint64_t duration, void* pUserData) +result +_WebImpl::LoadUrl(const String& url) const { - result r = E_SUCCESS; + std::unique_ptr pUrl(_StringConverter::CopyToCharArrayN(url)); + SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); - SysAssertf(pImpl, "Failed to request"); + ewk_view_url_set(__pWebCore->GetWebNativeNode(), pUrl.get()); - r = pImpl->VibrationRequested(duration); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + return E_SUCCESS; } -void -OnVibrationCanceled(void* pUserData) +result +_WebImpl::LoadUrl(const String& url, const HttpHeader& header) { - _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); - SysAssertf(pImpl, "Failed to request"); + std::unique_ptr pUrl(_StringConverter::CopyToCharArrayN(url)); + SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header); - pImpl->VibrationCanceled(); + ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_GET, pHttpHeader, null); + + eina_hash_free(pHttpHeader); + + return E_SUCCESS; } -void -OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) +result +_WebImpl::LoadUrlWithPostRequest(const String& url, const HttpHeader& header, const ByteBuffer& body) const { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo); - SysAssertf(pImpl && pPolicy, "Failed to request"); + std::unique_ptr pUrl(_StringConverter::CopyToCharArrayN(url)); + SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - String url(ewk_policy_decision_url_get(pPolicy)); - SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls", url.GetPointer()); + Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header); - if (url == L"about:blank") - { - ewk_policy_decision_use(pPolicy); - return; - } + ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_POST, pHttpHeader, reinterpret_cast< const char* >(body.GetPointer())); - if (pImpl->GetLoadingListener() && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy)) - && !pImpl->IsRedirectRequested()) - { - pImpl->SetCertificateRequested(false); + eina_hash_free(pHttpHeader); - if (pImpl->GetTextSearchListener()) - { - pImpl->DisableAsyncSearch(); - } - - WebNavigationType navigationType = WEB_NAVIGATION_OTHER; - Ewk_Policy_Navigation_Type ewkNavigationType = ewk_policy_decision_navigation_type_get(pPolicy); + return 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: - navigationType = WEB_NAVIGATION_OTHER; - break; - default: - SysAssert(false); - } - if (pImpl->GetLoadingListener()->OnLoadingRequested(url, navigationType)) - { - ewk_policy_decision_ignore(pPolicy); +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."); - return; - } - } + 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())); - String currentUrl(pImpl->GetUrl()); - String redirectUrl(pImpl->GetProtocolFromUri(url, currentUrl)); - if (redirectUrl != L"") - { - pImpl->LoadUrl(redirectUrl); - ewk_policy_decision_ignore(pPolicy); + ewk_view_contents_set(__pWebCore->GetWebNativeNode(), reinterpret_cast< const char* >(content.GetPointer()), content.GetLimit(), pMime.get(), pEncoding.get(), pUrl.get()); - return; - } - - Uri uri; - uri.SetUri(url); + return E_SUCCESS; +} - String uriScheme(uri.GetScheme()); - SysLog(NID_WEB_CTRL, "The current value of scheme is %ls", uriScheme.GetPointer()); - if ((uriScheme != L"http") && (uriScheme != L"https") && (uriScheme != L"file")) - { - ewk_policy_decision_ignore(pPolicy); +void +_WebImpl::Pause(void) +{ + ewk_view_suspend(__pWebCore->GetWebNativeNode()); +} - if (uriScheme == L"") - { - return; - } - result r = E_SUCCESS; +void +_WebImpl::Resume(void) +{ + ewk_view_resume(__pWebCore->GetWebNativeNode()); +} - 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; - } +bool +_WebImpl::CanGoBack(void) const +{ + return static_cast< bool >(ewk_view_back_possible(__pWebCore->GetWebNativeNode())); +} - ewk_policy_decision_use(pPolicy); + +bool +_WebImpl::CanGoForward(void) const +{ + return static_cast< bool >(ewk_view_forward_possible(__pWebCore->GetWebNativeNode())); } void -OnLoadingStarted(void* pUserData, Evas_Object* pView, void* pEventInfo) +_WebImpl::GoBack(void) const { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pImpl, "Failed to request"); - - if (pImpl->GetLoadingListener()) - { - result r = E_SUCCESS; + ewk_view_back(__pWebCore->GetWebNativeNode()); +} - 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 = pImpl->GetWebEvent()->FireAsync(*pEventArg.get()); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - pEventArg.release(); - } +void +_WebImpl::GoForward(void) const +{ + ewk_view_forward(__pWebCore->GetWebNativeNode()); } -void -OnPageTitleReceived(void* pUserData, Evas_Object* pView, void* pEventInfo) +Tizen::Base::String +_WebImpl::GetUrl(void) const { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - char* pTitle = reinterpret_cast< char* >(pEventInfo); - SysAssertf(pImpl, "Failed to request"); + 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 +{ + ewk_view_reload(__pWebCore->GetWebNativeNode()); } -void -OnEstimatedProgress(void* pUserData, Evas_Object* pView, void* pEventInfo) +String* +_WebImpl::EvaluateJavascriptN(const String& scriptCode) { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - double* pProgress = reinterpret_cast< double* >(pEventInfo); - SysAssertf(pImpl, "Failed to request"); + Evas_Object* pView = __pWebCore->GetWebNativeNode(); + if (!pView) + { + return null; + } + + std::unique_ptr pScript(_StringConverter::CopyToCharArrayN(scriptCode)); + SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - SysLog(NID_WEB_CTRL, "The current value of progress is %lf", *pProgress); + 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)); - if (pImpl->GetLoadingListener()) - { - result r = E_SUCCESS; + ewk_view_script_execute(pView, pScript.get(), OnScriptExecuted, pPresenter.get()); - 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)); + 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)); - r = pEventArg->SetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS, *pProgressPercentage.get()); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - pProgressPercentage.release(); + pPresenter->WaitAsyncProcess(*pResult.get()); - r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get()); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - pEventArg.release(); - } + return pResult.release(); } -void -OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo) +result +_WebImpl::SetZoomLevel(float level) { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo); - SysAssertf(pImpl && pPolicy, "Failed to request"); + 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); - result r = E_SUCCESS; + ewk_view_scale_set(__pWebCore->GetWebNativeNode(), static_cast< double >(level), 0, 0); - _SystemResource* pSysResource = _SystemResource::GetInstance(); - SysAssertf(pSysResource != null, "Failed to get _SystemResource instance"); + return E_SUCCESS; +} - 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); - ILoadingListener* pLoadingListener = pImpl->GetLoadingListener(); +float +_WebImpl::GetZoomLevel(void) const +{ + return static_cast< float >(ewk_view_scale_get(__pWebCore->GetWebNativeNode())); +} - String url(ewk_policy_decision_url_get(pPolicy)); - if (pLoadingListener && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy))) +const PageNavigationList* +_WebImpl::GetBackForwardListN(void) const +{ + Evas_Object* pView = __pWebCore->GetWebNativeNode(); + if (!pView) { - const Eina_Hash* pHeader = ewk_policy_decision_response_headers_get(pPolicy); + return null; + } - DecisionPolicy policy; - HttpHeader httpHeader; + result r = E_SUCCESS; - if (code >= REDIRECTION_HEADER_GROUP && code < REDIRECTION_HEADER_GROUP + 100) - { - pImpl->SetRedirectRequested(true); - mime = L""; - } + _PageNavigationListImpl* pNavigationListImpl = null; + _HistoryItemImpl* pHistoryItemImpl = null; - eina_hash_foreach(pHeader, AddHttpHeaderData, &httpHeader); - SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + std::unique_ptr pNavigationList; + std::unique_ptr pHistoryList; - policy = pLoadingListener->OnWebDataReceived(mime, httpHeader); - pImpl->SetPolicyDecision(policy); - } + int backCount = 0; + int forwardCount = 0; - 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); + String url(L""); + String title(L""); - return; - } + 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)); - if (pImpl->IsMimeSupported(mime) || mime == L"") - { - break; - } - - else - { - 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)); - String operationId(L"http://tizen.org/appcontrol/operation/view"); + 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)); - 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)); + pNavigationListImpl = _PageNavigationListImpl::GetInstance(pNavigationList.get()); + SysTryCatch(NID_WEB_CTRL, pNavigationListImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - r = pSelectBox->Construct(false, L"Select application", 1, null, url); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + 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)); - 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)); - } + r = pHistoryList->Construct(); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - return; - } - break; - } - case WEB_DECISION_DOWNLOAD: + 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); + + for (int i = -backCount; i < forwardCount + 1; i++) { - ewk_policy_decision_ignore(pPolicy); + 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)); - _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)); + pHistoryItemImpl = _HistoryItemImpl::GetInstance(pHistoryItem.get()); + SysTryCatch(NID_WEB_CTRL, pHistoryItemImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - Ewk_Context* pContext = ewk_view_context_get(pView); - SysAssertf(pContext, "Failed to get webkit instance."); + 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)); - pDownloadHandler->StartDownload(pUrl); + 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()); - return; - } - case WEB_DECISION_IGNORE: - { - ewk_policy_decision_ignore(pPolicy); + pHistoryItemImpl->SetHistoryItem(url, title); - return; - } - default: - { - SysAssert(false); - } + r = pHistoryList->Add(*pHistoryItem.get()); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + pHistoryItem.release(); } - ewk_policy_decision_use(pPolicy); + pNavigationListImpl->SetPageNavigationList(pHistoryList.release(), backCount); - return; + ewk_history_free(pEwkHistoryList); + + return pNavigationList.release(); CATCH: - ewk_policy_decision_ignore(pPolicy); + ewk_history_free(pEwkHistoryList); + + return null; } -void -OnProgressCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo) +bool +_WebImpl::SearchText(const String& text, bool searchForward) { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pImpl, "Failed to request"); - - if (pImpl->IsRedirectRequested()) + Evas_Object* pView = __pWebCore->GetWebNativeNode(); + if (!pView) { - pImpl->SetRedirectRequested(false); + return false; } - if (pImpl->IsLoadingErrorOccurred()) + 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) { - pImpl->SetLoadingErrorOccurred(false); - evas_object_smart_callback_call(pView, "load,finished", NULL); + condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS); } + + 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); } -void -OnLoadingErrorOccurred(void* pUserData, Evas_Object* pView, void* pEventInfo) +result +_WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive) { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - Ewk_Error* pErrorData = reinterpret_cast< Ewk_Error* >(pEventInfo); - SysAssertf(pImpl && pErrorData, "Failed to request"); + Evas_Object* pView = __pWebCore->GetWebNativeNode(); + if (!pView) + { + return E_SUCCESS; + } - int code = ewk_error_code_get(pErrorData); - const char* pDescription = ewk_error_description_get(pErrorData); + result r = E_SUCCESS; - SysLog(NID_WEB_CTRL, "The current value of code is %d, description is %s", code, pDescription); + Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT; - switch (code) + if (!caseSensitive) { - case EWK_ERROR_CODE_FRAMELOADINTERRUPTEDBYPOLICYCHANGE: - pImpl->SetLoadingErrorOccurred(true); - break; + condition = static_cast (condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE); + } - case EWK_ERROR_CODE_PLUGINWILLHANDLELOAD: - evas_object_smart_callback_call(pView, "load,finished", NULL); - break; + 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_NETWORK_STATUS_CANCELLED: - pImpl->SetLoadingErrorOccurred(true); - evas_object_smart_callback_call(pView, "load,stop", NULL); - break; + return E_SUCCESS; +} - default: - pImpl->SetLoadingErrorOccurred(true); - if (pImpl->GetLoadingListener()) - { - result r = E_SUCCESS; - r = FireLoadingErrorOccurredEvent(pImpl, code, pDescription); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - } - break; +result +_WebImpl::SearchNextAsync(bool searchForward) +{ + Evas_Object* pView = __pWebCore->GetWebNativeNode(); + if (!pView) + { + return 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."); -void -OnLoadingCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo) -{ - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pImpl, "Failed to request"); + result r = E_SUCCESS; - if (pImpl->GetLoadingListener()) - { - result r = E_SUCCESS; + Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT; - 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)); + if (!__textSearch.__caseSensitive) + { + condition = static_cast (condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE); + } - r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get()); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - pEventArg.release(); + if (!searchForward) + { + condition = static_cast (condition | EWK_FIND_OPTIONS_BACKWARDS); } + r = SynchronizeSearch(SEARCH_NEXT_ASYNC, pView, condition, __textSearch.__text, searchForward); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; } -void -OnLoadingCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo) +result +_WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text, bool searchForward, bool caseSensitive, _WebPresenter* pWebPresenter) { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pImpl, "Failed to request"); + MutexGuard lock(__mutex); - if (pImpl->GetLoadingListener()) + std::unique_ptr pText(_StringConverter::CopyToCharArrayN(text)); + SysTryReturn(NID_WEB_CTRL, pText.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + switch (type) { - result r = E_SUCCESS; + case SEARCH_SYNC: + if (__textSearch.__searchAll) + { + DisableAsyncSearch(); - 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(pWebPresenter); - 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); + } + else + { + __textSearch.__searchQueue.Enqueue(pWebPresenter); -} + ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH); + } + break; + case SEARCH_ALL_ASYNC: + __textSearch.__searchAll = true; + __textSearch.__text = text; + __textSearch.__searchForward = true; + __textSearch.__caseSensitive = caseSensitive; + __textSearch.__totalCount = -1; + __textSearch.__currentIndex = 1; -void -OnFaviconReceived(void* pUserData, Evas_Object* pView, void* pEventInfo) -{ - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pImpl, "Failed to request"); + __textSearch.__searchQueue.Enqueue(this); + __textSearch.__searchQueue.Enqueue(this); - if (pImpl->GetLoadingListener()) - { - result r = E_SUCCESS; + ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH); + 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)); + case SEARCH_NEXT_ASYNC: + __textSearch.__searchForward = searchForward; - r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get()); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - pEventArg.release(); + CalculateAsyncSearchOrdinal(); + + __textSearch.__searchQueue.Enqueue(this); + + ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH); + break; + + default: + SysAssert(false); } + return E_SUCCESS; } void -OnDidStartDownloadCallback(const char* pUrl, void* pUserData) +_WebImpl::SetAsyncSearchResult(int 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); + __textSearch.__totalCount = totalCount; } -result -FireWebPageShowRequestedEvent(_WebImpl* pImpl, int event) +_WebPresenter* +_WebImpl::GetSearchPresenter(void) { - result r = E_SUCCESS; + MutexGuard lock(__mutex); - std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event)); - SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed."); + return dynamic_cast< _WebPresenter* >(__textSearch.__searchQueue.Dequeue()); +} - r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get()); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - pEventArg.release(); - return E_SUCCESS; + int + _WebImpl::GetPendingAsyncSearchCount(void) const +{ + return __textSearch.__searchQueue.GetCount(); } void -OnWebPageShowRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) +_WebImpl::CalculateAsyncSearchOrdinal(void) { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pImpl, "Failed to request"); - - if (pImpl->GetUiEventListener()) + if (__textSearch.__searchForward) { - 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)); + __textSearch.__currentIndex++; } - if (pImpl->GetUiEventListenerF()) + else { - result r = E_SUCCESS; - - r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + __textSearch.__currentIndex--; } } -void -OnWebWindowCreateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) + int + _WebImpl::GetAsyncSearchOrdinal(void) const { - _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(pUserData); - Evas_Object** pChildView = reinterpret_cast< Evas_Object** >(pEventInfo); - SysAssertf(pParentImpl && pChildView, "Failed to request"); - - IWebUiEventListener* pUserUiListener = pParentImpl->GetUiEventListener(); - IWebUiEventListenerF* pUserUiListenerF = pParentImpl->GetUiEventListenerF(); - if (pUserUiListener) - { - Web* pWeb = 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)); + return __textSearch.__currentIndex; +} - *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode(); - evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl); - } - } - if (pUserUiListenerF) - { - Web* pWeb = 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)); - *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode(); - evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl); - } - } + void + _WebImpl::DisableAsyncSearch(void) +{ + __textSearch.__searchAll = false; } result -FireWebWindowClosedRequestedEvent(_WebImpl* pImpl, int event) +_WebImpl::SetSetting(const WebSetting& setting) { - result r = E_SUCCESS; + if (__pWebCore->GetWebNativeNode()) + { + 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<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event)); - SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed."); + std::unique_ptr pEncoding(_StringConverter::CopyToCharArrayN(setting.GetDefaultTextEncoding())); + SysTryReturn(NID_WEB_CTRL, pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get()); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - pEventArg.release(); + ewk_settings_default_encoding_set(pSettings, pEncoding.get()); - return E_SUCCESS; -} + 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; -void -OnWebWindowClosedRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) -{ - _WebImpl* pChildImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pChildImpl, "Failed to request"); + default: + SysAssert(false); + } - _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, PARENT_WEB_CTRL)); - if (pParentImpl == null) - { - return; - } + 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); + } - if (pParentImpl->GetUiEventListener()) - { - result r = E_SUCCESS; + ewk_settings_font_default_size_set(pSettings, static_cast< Eina_Bool >(setting.GetFontSize())); - 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; + ewk_settings_javascript_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsJavascriptEnabled())); - r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - } -} + ewk_settings_loads_images_automatically_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoImageLoadEnabled())); + if (__defaultUserAgent != setting.GetUserAgent()) + { + std::unique_ptr pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent())); + SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); -result -FireWebPreventDefaultTriggeredEvent(_WebImpl* pImpl, int event, bool trigger) -{ - result r = E_SUCCESS; + ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get()); + } - 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." ); + ewk_settings_auto_fitting_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFittingEnabled())); - r = pEventArg->SetEventInfo(_WebUiEventArg::PREVENT_DEFAULT, *pPreventTrigger.get()); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - pPreventTrigger.release(); + ewk_settings_scripts_window_open_set(pSettings, static_cast< Eina_Bool >(setting.IsJavaScriptPopupEnabled())); - r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get()); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - pEventArg.release(); + 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())); + } + + _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting()); + + 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()); return E_SUCCESS; } -void -OnWebPreventDefaultTriggered(void* pUserData, Evas_Object* pView, void* pEventInfo) +WebSetting +_WebImpl::GetSetting(void) const +{ + return *__pWebCore->GetSetting(); +} + + +const HitElementResult* +_WebImpl::GetElementByPointN(const Point& point) const { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - Eina_Bool* pTrigger = reinterpret_cast< Eina_Bool* >(pEventInfo); - SysAssertf(pImpl && pTrigger, "Failed to request"); + return GetElementByPointN(_CoordinateSystemUtils::ConvertToFloat(point)); +} - if (pImpl->GetUiEventListener()) - { - 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->GetUiEventListenerF()) +const HitElementResult* +_WebImpl::GetElementByPointN(const FloatPoint& point) const +{ + Evas_Object* pView = __pWebCore->GetWebNativeNode(); + if (!pView) { - 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)); + return null; } -} + 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; - 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."); + _HitElementResultImpl* pHitElementResultImpl = null; - pImpl->GetBlockRange(*startPoint.get(), *endPoint.get()); + std::unique_ptr pHitElementResult; + std::unique_ptr pImage; + std::unique_ptr pAttributeMap; - 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."); + Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(point))); - r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get()); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - startPoint.release(); + 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)); - r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get()); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - endPoint.release(); + 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)); - r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get()); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - pEventArg.release(); - } + SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls, tag is %ls, value is %ls", url.GetPointer(), tagName.GetPointer(), nodeValue.GetPointer()); - return E_SUCCESS; -} + 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())); -result -FireWebPageBlockSelectedEventF(_WebImpl* pImpl) -{ - result r = E_SUCCESS; + if (context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE) + { + ByteBuffer buf; + Image image; + ImageFormat format; - std::unique_ptr startPoint(new (std::nothrow) FloatPoint()); - std::unique_ptr endPoint(new (std::nothrow) FloatPoint()); + 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); - SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed."); + r = buf.Construct(imageLength); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - pImpl->GetBlockRange(*startPoint.get(), *endPoint.get()); + r = buf.SetArray(reinterpret_cast< byte* >(pImageBuffer), 0, imageLength); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - 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."); + buf.Rewind(); - r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get()); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - startPoint.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; + } - r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get()); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - endPoint.release(); + r = image.Construct(); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get()); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - pEventArg.release(); + pImage = std::unique_ptr(image.DecodeN(buf, format, BITMAP_PIXEL_FORMAT_RGB565)); + SysTryCatch(NID_WEB_CTRL, pImage.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); } - return E_SUCCESS; -} - - -void -OnWebPageBlockSelected(void* pUserData, Evas_Object* pView, void* pEventInfo) -{ - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pImpl, "Failed to request"); - - if (pImpl->GetUiEventListener()) + 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)); - r = FireWebPageBlockSelectedEvent(pImpl); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - } - if (pImpl->GetUiEventListenerF()) - { - result r = E_SUCCESS; + r = pAttributeMap->Construct(eina_hash_population(pAttrHash)); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - r = FireWebPageBlockSelectedEventF(pImpl); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + 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); -Eina_Bool -OnSelectUploadFile(Evas_Object* pView, Eina_Bool multipleFile, Eina_List* pAcceptTypes, const char* pCapture, void* pUserData) -{ - std::unique_ptr<_MediaSelectionListener> pMediaListener(new (std::nothrow) _MediaSelectionListener()); - SysTryReturn(NID_WEB_CTRL, pMediaListener.get(), EINA_TRUE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + ewk_hit_test_free(pEwkHitTest); - pMediaListener->Construct(pView); + return pHitElementResult.release(); - HashMap extraData; - result r = extraData.Construct(); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_TRUE, r, "[%s] Propagating.", GetErrorMessage(r)); +CATCH: + ewk_hit_test_free(pEwkHitTest); - String isMultipleSelection(L"single"); - String mode(L"selectionType"); - String type(L"type"); - String fileType = L"*/*"; - String operationId = L"http://tizen.org/appcontrol/operation/pick"; + return null; +} - if (multipleFile) + +bool +_WebImpl::IsLoading(void) const +{ + double percent = ewk_view_load_progress_get(__pWebCore->GetWebNativeNode()); + + if (Double::Compare(percent, 0.0) > 0 && Double::Compare(percent, 1.0) < 0) { - isMultipleSelection.Append(L"multiple"); + return true; } - - if (eina_list_count(pAcceptTypes) == 1) + else { - 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); - } - } + return false; } +} - r = _AppControlImpl::FindAndStart(operationId, null, &fileType, null, &extraData, pMediaListener.get()); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - pMediaListener.release(); +String +_WebImpl::GetTextFromBlock(void) const +{ + return ewk_view_text_selection_text_get(__pWebCore->GetWebNativeNode()); +} - return EINA_TRUE; -CATCH: - ewk_view_open_panel_reply(pView, null, EINA_FALSE); - return EINA_TRUE; +bool +_WebImpl::IsPrivateBrowsingEnabled(void) const +{ + if (__pWebCore->GetWebNativeNode() == null) + { + return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsPrivateBrowsingEnabled(); + } + + Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode()); + SysAssertf(pSettings, "Failed to get webkit instance."); + + return static_cast< bool >(ewk_settings_private_browsing_enabled_get(pSettings)); } void -OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo) +_WebImpl::SetPrivateBrowsingEnabled(bool enable) { - _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); - - 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)); + if (__pWebCore->GetWebNativeNode() == null) + { + _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetPrivateBrowsingEnabled(enable); + return; + } - r = pEventArg->Construct(pJsonText); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode()); + SysAssertf(pSettings, "Failed to get webkit instance."); - r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get()); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - pEventArg.release(); + ewk_settings_private_browsing_enabled_set(pSettings, static_cast< Eina_Bool >(enable)); } void -OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo) +_WebImpl::ClearHistory(void) { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - Eina_Rectangle* pEinaRect = reinterpret_cast< Eina_Rectangle* >(pEventInfo); - SysAssertf(pImpl && pEinaRect, "Failed to request"); - - if (pImpl->IsVisible() == false) - { - evas_object_focus_set(pView, EINA_FALSE); - } + ewk_view_back_forward_list_clear(__pWebCore->GetWebNativeNode()); +} - if (pImpl->GetSetting().GetInputStyle() == INPUT_STYLE_OVERLAY) - { - _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer(); - SysAssertf(pXformer, "Failed to get CoordinateTransformer"); - Rectangle rect(pEinaRect->x, pEinaRect->y, pEinaRect->w, pEinaRect->h); +void +_WebImpl::ClearCache(void) +{ + Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode()); - if (rect.height == 0) - { - return; - } + ewk_context_cache_clear(pContext); +} - _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl)); - if (pFormImpl) - { - pFormImpl->DeflateClientRectHeight(pXformer->TransformVertical(rect.height)); - if (pFormImpl->HasFooter()) - { - pFormImpl->GetCore().SetKeypadShowState(true); - pFormImpl->Draw(); - } - } +void +_WebImpl::ClearCookie(void) +{ + Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode()); + Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(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)); - } + ewk_cookie_manager_cookies_clear(pCookieManager); } void -OnWebKeypadOpened(void* pUserData, Evas_Object* pView, void* pEventInfo) +_WebImpl::ClearFormData(void) { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pImpl, "Failed to request"); + Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode()); - if (pImpl->GetWebKeypadEventListener()) - { - pImpl->GetWebKeypadEventListener()->OnWebKeypadOpened(*static_cast< Web* >(&pImpl->GetPublic())); - } + ewk_context_form_candidate_data_clear(pContext); } void -OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo) +_WebImpl::ClearLoginFormData(void) { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pImpl, "Failed to request"); + Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode()); - _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl)); - if (pFormImpl) - { - pFormImpl->DeflateClientRectHeight(0); + ewk_context_form_password_data_clear(pContext); +} - if (pFormImpl->HasFooter()) - { - pFormImpl->GetCore().SetKeypadShowState(false); - pFormImpl->Draw(); - } - } - if (pImpl->GetWebKeypadEventListener()) +bool +_WebImpl::IsCookieEnabled(void) const +{ + if (__pWebCore->GetWebNativeNode() == null) { - pImpl->GetWebKeypadEventListener()->OnWebKeypadClosed(*dynamic_cast< Web* >(&pImpl->GetPublic())); + return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsCookieEnabled(); } - pImpl->SetKeypadVisibleState(false); -} - + 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."); -void -OnWindowObjectFocusGained(void* pUserData, Evas_Object* pWin, void* pEvent_info) -{ - _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)); - 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"); + ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, pPresenter.get()); - evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE); + bool result = false; + pPresenter->WaitAsyncProcess(result); - pImpl->SetKeypadVisibleState(true); - } + return result; } void -OnWebNativeNodeFocusGained(void* pUserData, Evas* pCanvas, Evas_Object* pView, void* pEventInfo) +_WebImpl::SetCookieEnabled(bool enable) { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pImpl, "Failed to request"); + if (__pWebCore->GetWebNativeNode() == null) + { + _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetCookiEnabled(enable); + + return; + } + + 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 (pImpl->IsKeypadOpened() == true) + if (enable) { - pImpl->SetKeypadOpened(false); + 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); + } +} -Eina_Bool -OnColorPickerProviderRequested(Ewk_View_Smart_Data* pSmartData, int red, int green, int blue, int alpha) +result +_WebImpl::SavePageAsPdf(const String& filePath, const Dimension* pSize) const { - 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; - if (pWebImpl->GetColorpicker()) - { - return EINA_FALSE; - } + std::unique_ptr pFilePath(_StringConverter::CopyToCharArrayN(filePath)); + SysTryReturn(NID_WEB_CTRL, pFilePath.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - Color color; + String dirPath; + String fileExtension = File::GetFileExtension(filePath); + int pathLength = filePath.GetLength(); + int index = 0; - r = pWebImpl->ShowColorPicker(red, green, blue, alpha, color); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r)); + SysTryReturnResult(NID_WEB_CTRL, fileExtension.Equals("pdf", false), E_INVALID_ARG, "Invalid argument(s) is used. File extension is not pdf."); - byte r1, g1, b1, a1; - color.GetColorComponents(r1, g1, b1, a1); - ewk_view_color_picker_color_set(pSmartData->self, r1, g1, b1, a1); + 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."); - return EINA_TRUE; -} + 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."); + 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."); -Eina_Bool -OnColorPickerProviderDismissed(Ewk_View_Smart_Data* pSmartData) -{ - SysAssertf(pSmartData, "invalid smartdata"); + ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), pSize->width, pSize->height, pFilePath.get()); + } + else + { + Evas_Coord contentsWidth; + Evas_Coord contentsHeight; - _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); - SysAssertf(pWebImpl, "Failed to get Impl"); + ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &contentsWidth, &contentsHeight); + ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), contentsWidth, contentsHeight, pFilePath.get()); + } - return pWebImpl->HideColorPicker(); + return E_SUCCESS; } -Eina_Bool -OnDatePickerProviderRequested(Ewk_View_Smart_Data* pSmartData, Ewk_Input_Type inputType, const char* inputValue) +bool +_WebImpl::IsMimeSupported(const String& mime) 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; + std::unique_ptr pMime(_StringConverter::CopyToCharArrayN(mime)); + SysTryReturn(NID_WEB_CTRL, pMime.get(), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - if (pWebImpl->GetDatepicker()) - { - ewk_view_focused_input_element_value_set(pSmartData->self, inputValue); + return static_cast< bool >(ewk_frame_can_show_mime_type(ewk_view_main_frame_get(__pWebCore->GetWebNativeNode()), pMime.get())); +} - return EINA_FALSE; - } - String dateStr; +void +_WebImpl::SetLoadingListener(ILoadingListener* pLoadingListener) +{ + __pUserLoadingListener = const_cast< ILoadingListener* >(pLoadingListener); +} - 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())); +void +_WebImpl::SetWebUiEventListener(IWebUiEventListener* pUiEventListener) +{ + __pUserUiListener = pUiEventListener; +} - ewk_view_focused_input_element_value_set(pSmartData->self, pDateStr.get()); - return EINA_TRUE; +void +_WebImpl::SetWebUiEventListenerF(IWebUiEventListenerF* pUiEventListener) +{ + __pUserUiListenerF = pUiEventListener; } -Eina_Bool -OnSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex) +void +_WebImpl::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener) { - SysAssertf(pSmartData, "Failed to request"); + __pUserKeypadEventListener = pKeypadEventListener; +} - _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); - SysAssertf(pWebImpl, "Failed to get Impl"); - result r = pWebImpl->ShowSelectBoxPopup(false, L"", pItems, pSmartData->self, selectedIndex); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); +void +_WebImpl::SetDownloadListener(IWebDownloadListener* pDownLoadListener) +{ + if (__pWebDownloadHandler.get() == null) + { + __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)); + } - return EINA_TRUE; + __pWebDownloadHandler->SetDownloadListener(pDownLoadListener); + __pWebDownloadHandler->SetWebEvent(__pWebEvent.get()); } -Eina_Bool -OnMultiSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* pItems) +void +_WebImpl::SetTextSearchListener(ITextSearchListener* 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"); + __pTextSearchListener = pTextSearchListener; +} - result r = pWebImpl->ShowSelectBoxPopup(true, L"", pItems, pSmartData->self, 0); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); - return EINA_TRUE; +void +_WebImpl::SetScrollEnabled(bool enable) +{ + _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetScrollEnabled(enable); } -Eina_Bool -OnSelectBoxClosed(Ewk_View_Smart_Data* pSmartData) +bool +_WebImpl::IsScrollEnabled(void) const { - SysAssertf(pSmartData, "invalid smartdata"); + return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled(); +} - _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)); +result +_WebImpl::InitJsBridgeList(void) +{ + result r = E_SUCCESS; - return EINA_TRUE; -} + __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."); -Eina_Bool -OnSelectBoxUpdateRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, Eina_List* pItems, int selectedIndex) -{ - SysAssertf(pSmartData, "invalid smartdata"); + std::unique_ptr > pJsBridgeList(new (std::nothrow) HashMapT< String, IJavaScriptBridge* >); + SysTryReturnResult(NID_WEB_CTRL, pJsBridgeList.get(), E_OUT_OF_MEMORY, "Memory Allocation failed."); - _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); - SysAssertf(pWebImpl, "Failed to get Impl"); + r = pJsBridgeList->Construct(0, 0, *__pJsProvider.get(), *__pJsComparer.get()); + 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)); + __pJsBridgeList = std::move(pJsBridgeList); - return EINA_TRUE; + return E_SUCCESS; } -Eina_Bool -OnFormDataCandidateShow(Ewk_View_Smart_Data *pSmartData, int x, int y, int w, int h) +result +_WebImpl::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge) { - 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"); + IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge); + String key(pJsBridge->GetName()); - 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)); + r = __pJsBridgeList->Add(key, pJsBridge); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - return EINA_TRUE; + return E_SUCCESS; } -Eina_Bool -OnFormDataCandidateHide(Ewk_View_Smart_Data *pSmartData) +result +_WebImpl::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge) { - 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"); + IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge); + String key(pJsBridge->GetName()); - if (pWebImpl->IsFormDataWindowVisible()) - { - pWebImpl->HideFormDataWindow(); - } + r = __pJsBridgeList->Remove(key); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - return EINA_TRUE; + return E_SUCCESS; } -Eina_Bool -OnFormDataCandidateUpdate(Ewk_View_Smart_Data *pSmartData, Eina_List *pDataList) +IJavaScriptBridge* +_WebImpl::FindJsInterface(const IJsonValue* pValue) const { - 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"); + IJsonValue* pJsonValue = null; + IJavaScriptBridge* pJsBridge = null; - pWebImpl->SetFormDataList(pDataList); + String key(L"name"); - return EINA_TRUE; -} + 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)); -Eina_Bool -OnFormDataCandidateIsShowing(Ewk_View_Smart_Data *pSmartData) -{ - SysAssertf(pSmartData, "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* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); - SysAssertf(pWebImpl, "Failed to get Impl"); + r = __pJsBridgeList->GetValue(static_cast< String >(*pBridgeName), pJsBridge); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); - if (pWebImpl->IsFormDataWindowVisible()) - { - return EINA_TRUE; - } - else - { - return EINA_FALSE; - } + return pJsBridge; } -void -OnCookiesPolicyGot(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *pError, void *pUserData) +ILoadingListener* +_WebImpl::GetLoadingListener(void) const { - _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData); - SysAssertf(pPresenter && !pError, "Failed to request"); - - bool ret = EINA_TRUE; - - switch (policy) - { - case EWK_COOKIE_ACCEPT_POLICY_ALWAYS: - //fall through - case EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY: - ret = EINA_TRUE; - break; + return __pUserLoadingListener; +} - case EWK_COOKIE_ACCEPT_POLICY_NEVER: - //fall through - ret = EINA_FALSE; - break; - default: - SysAssert(false); - } +IWebUiEventListener* +_WebImpl::GetUiEventListener(void) const +{ + return __pUserUiListener; +} - SysLog(NID_WEB_CTRL, "The current value of policy is %d", ret); - pPresenter->EndAsyncProcess(ret); +IWebUiEventListenerF* +_WebImpl::GetUiEventListenerF(void) const +{ + return __pUserUiListenerF; } -void -OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData) +IWebKeypadEventListener* +_WebImpl::GetWebKeypadEventListener(void) const { - _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData); - SysAssertf(pPresenter, "Failed to request"); + return __pUserKeypadEventListener; +} - 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); - } +ITextSearchListener* +_WebImpl::GetTextSearchListener(void) const +{ + return __pTextSearchListener; } void -OnTextFound(void* pUserData, Evas_Object* pView, void* pEventInfo) +_WebImpl::SetEventListenerCallback(void) const { - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pImpl, "Failed to request"); + Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode(); + if (pWebNativeNode) + { + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas"); - int* pTotalCount = reinterpret_cast< int* >(pEventInfo); - SysLog(NID_WEB_CTRL, "The current value of totalCount is %d", *pTotalCount); + Evas_Object* pWinObject = pEcoreEvas->GetWindowObject(); + SysAssertf(pWinObject, "Failed to get Ui window evas object"); - _WebPresenter* pWebPresenter = pImpl->GetSearchPresenter(); + Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode); + SysAssertf(pSmartData, "Failed to request"); - if (pWebPresenter) - { - pWebPresenter->EndAsyncProcess(*pTotalCount); - } - else - { - if (pImpl->GetTextSearchListener()) - { - result r = E_SUCCESS; + Ewk_View_Smart_Class *pSmart = const_cast(pSmartData->api); + SysAssertf(pSmart, "Failed to request"); - int ordinal = 0; + pSmart->popup_menu_show = OnSelectBoxRequested; + pSmart->multiple_popup_menu_show = OnMultiSelectBoxRequested; + pSmart->popup_menu_hide = OnSelectBoxClosed; + pSmart->popup_menu_update = OnSelectBoxUpdateRequested; - if (*pTotalCount > 0) - { - ordinal = pImpl->GetAsyncSearchOrdinal(); - pImpl->SetAsyncSearchResult(*pTotalCount); - } + pSmart->input_picker_show = OnDatePickerProviderRequested; + pSmart->input_picker_color_request = OnColorPickerProviderRequested; + pSmart->input_picker_color_dismiss = OnColorPickerProviderDismissed; - if (pImpl->GetPendingAsyncSearchCount() > 0) - { - return; - } + pSmart->formdata_candidate_show = OnFormDataCandidateShow; + pSmart->formdata_candidate_hide = OnFormDataCandidateHide; + pSmart->formdata_candidate_update_data = OnFormDataCandidateUpdate; + pSmart->formdata_candidate_is_showing = OnFormDataCandidateIsShowing; - 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_data_set(pWebNativeNode, WEB_CTRL, this); - r = pEventArg->SetEventInfo(_TextSearchEventArg::TOTAL_COUNT, *pCount.get()); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - pCount.release(); + // 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); - r = pEventArg->SetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL, *pOrdinal.get()); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - pOrdinal.release(); + 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); - 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, "requestToNative,json", OnHandleJavaScriptRequest, this); + evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, this); -class _JsBridgeHashCodeProvider - : public Tizen::Base::Collection::IHashCodeProviderT< Tizen::Base::String > -{ -public: - _JsBridgeHashCodeProvider(){} - virtual ~_JsBridgeHashCodeProvider(void) {} + 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); - int GetHashCode(const Tizen::Base::String& obj) const - { - return obj.GetHashCode(); - } + 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)); + evas_object_smart_callback_add(pWebNativeNode, "policy,response,decide", OnWebDataReceived, this); -//Comparer implementation -class _JsBridgeComparer - : public Tizen::Base::Collection::IComparerT< Tizen::Base::String > -{ -public: - _JsBridgeComparer(){} - virtual ~_JsBridgeComparer(void) {} + 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 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, "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); - return E_SUCCESS; - } + 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); -}; + evas_object_smart_callback_add(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered, this); + evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this); + evas_object_smart_callback_add(pWebNativeNode, "text,selected", OnWebPageBlockSelected, 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""; -} + 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)); + 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)); -_WebImpl::~_WebImpl() -{ - ClearCertificateDb(); + evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this); + } } -_WebImpl* -_WebImpl::CreateWebImplN(Web* pControl, const Rectangle& bounds) +void +_WebImpl::RemoveEventListenerCallback(void) const { - result r = E_SUCCESS; + Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode(); + if (pWebNativeNode) + { + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas"); - 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* pWinObject = pEcoreEvas->GetWindowObject(); + SysAssertf(pWinObject, "Failed to get Ui window evas object"); - _Web* pCore = _Web::CreateWebN(); - SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + evas_object_smart_callback_del(pWebNativeNode, "create,window", OnWebWindowCreateRequested); + evas_object_smart_callback_del(pWebNativeNode, "close,window", OnWebWindowClosedRequested); - _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore); + 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); - r = CheckConstruction(pCore, pImpl); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest); - 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_full(pWinObject, "focus,in", OnWindowObjectFocusGained, this); - r = pImpl->Construct(); - 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); - return pImpl; + evas_object_smart_callback_del(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested); + evas_object_smart_callback_del(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled); -CATCH: - delete pImpl; + evas_object_smart_callback_del(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested); - return null; -} + 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); + evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived); -_WebImpl* -_WebImpl::CreateWebImplN(Web* pControl, const FloatRectangle& bounds) -{ - result r = E_SUCCESS; + 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); - 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, "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); - _Web* pCore = _Web::CreateWebN(); - SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + 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); - _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore); + evas_object_smart_callback_del(pWebNativeNode, "text,found", OnTextFound); - r = CheckConstruction(pCore, pImpl); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered); + evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived); - 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, "text,selected", OnWebPageBlockSelected); - r = pImpl->Construct(); - 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); - return pImpl; + 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); -CATCH: - delete 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); - return null; + evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained); + } } -result -_WebImpl::Construct(void) +void +_WebImpl::ClearCertificateDb(void) { result r = E_SUCCESS; - r = __mutex.Create(); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME); + String table(CERTIFICATE_TABLE_NAME); + _DatabaseImpl db; - r = __textSearch.__searchQueue.Construct(); - 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 = __webNotificationList.Construct(); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + db.BeginTransaction(); - r = InitJsBridgeList(); - 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 = InitWebEvent(); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + db.CommitTransaction(); - _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance(); - SysTryReturn(NID_WEB_CTRL, pManagerImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + return; - pManagerImpl->SetDownloadListener(this); +CATCH: + db.RollbackTransaction(); +} - __pWebCore = dynamic_cast< _Web* >(&(GetCore())); - SysTryReturnResult(NID_WEB_CTRL, __pWebCore, E_SYSTEM, "A system error has been occurred. Failed to get web control"); - return E_SUCCESS; +result +_WebImpl::SetBlockSelectionPosition(const Point& startPoint) +{ + return SetBlockSelectionPosition(_CoordinateSystemUtils::ConvertToFloat(startPoint)); } result -_WebImpl::InitializeSetting(void) +_WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint) { - result r = E_SUCCESS; + 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))); - WebSetting* pWebSetting = __pWebCore->GetSetting(); - _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(pWebSetting); + 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); - SetCookieEnabled(pWebSettingImpl->IsCookieEnabled()); - SetPrivateBrowsingEnabled(pWebSettingImpl->IsPrivateBrowsingEnabled()); + 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."); - __defaultUserAgent = pWebSettingImpl->GetUserAgent(); + String tagName(ewk_hit_test_tag_name_get(pEwkHitTest)); - r = SetSetting(*pWebSetting); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + 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); + } + } + } + } - SetEventListenerCallback(); + SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up."); + + evas_object_smart_callback_call(pView, "text,selected", NULL); return E_SUCCESS; } -bool -_WebImpl::IsLayoutable(void) const +void +_WebImpl::ReleaseBlock(void) { - return true; + ewk_view_text_selection_range_clear(__pWebCore->GetWebNativeNode()); } -result -_WebImpl::InitWebEvent(void) +void +_WebImpl::GetBlockRange(Point& startPoint, Point& endPoint) const { - __pWebEvent = std::unique_ptr<_WebEvent>(new (std::nothrow) _WebEvent()); - SysTryReturnResult(NID_WEB_CTRL, __pWebEvent.get(), E_OUT_OF_MEMORY, "Memory allocation failed."); + FloatPoint tempStartPoint; + FloatPoint tempEndPoint; - return __pWebEvent->Construct(*this); + GetBlockRange(tempStartPoint, tempEndPoint); + + startPoint = _CoordinateSystemUtils::ConvertToInteger(tempStartPoint); + endPoint = _CoordinateSystemUtils::ConvertToInteger(tempEndPoint); } -_WebEvent* -_WebImpl::GetWebEvent(void) const +void +_WebImpl::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const { - return __pWebEvent.get(); + 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); + } } -Eina_Hash* -_WebImpl::ConvertToSlpHeaderN(const HttpHeader& header) const +Bitmap* +_WebImpl::GetFaviconN(void) const { - Eina_Hash* pHttpHeader = null; + result r = E_SUCCESS; - 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(); + 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); - 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())); + Evas_Object* pFavicon = ewk_context_icon_database_icon_object_add(pContext, pUrl, pEvas); + if (!pFavicon) + { + return null; + } - std::unique_ptr pKey(_StringConverter::CopyToCharArrayN(*pFieldName)); - SysTryCatch(NID_WEB_CTRL, pKey.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + Tizen::Graphics::BufferInfo bufferInfo; - 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; + r = _Utility::GetPixelBufferFromEvasObject(pFavicon, bufferInfo); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); - String* pFieldValue = dynamic_cast< String* >(pFieldValueEnum->GetCurrent()); - SysTryCatch(NID_WEB_CTRL, pFieldValue, , 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 pValue(_StringConverter::CopyToCharArrayN(*pFieldValue)); - SysTryCatch(NID_WEB_CTRL, pValue.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + 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)); - ret = eina_hash_add(pHttpHeader, pKey.get(), pValue.release()); - SysTryCatch(NID_WEB_CTRL, ret == EINA_TRUE, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - } - } - } - return pHttpHeader; + r = pImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); -CATCH: - eina_hash_free(pHttpHeader); + return pImage.release(); - return null; } -result -_WebImpl::LoadUrl(const String& url) const +void +_WebImpl::ScrollBy(const Tizen::Graphics::Point& diff) { - std::unique_ptr pUrl(_StringConverter::CopyToCharArrayN(url)); - SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + ewk_view_scroll_by(__pWebCore->GetWebNativeNode(), diff.x, diff.y); +} - ewk_view_url_set(__pWebCore->GetWebNativeNode(), pUrl.get()); - return E_SUCCESS; +void +_WebImpl::ScrollTo(const Tizen::Graphics::Point& dest) +{ + ewk_view_scroll_set(__pWebCore->GetWebNativeNode(), dest.x, dest.y); } -result -_WebImpl::LoadUrl(const String& url, const HttpHeader& header) +Point +_WebImpl::GetScrollPosition(void) const { - 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_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_GET, pHttpHeader, null); + Point position; - eina_hash_free(pHttpHeader); + ewk_view_scroll_pos_get(__pWebCore->GetWebNativeNode(), &position.x, &position.y); - return E_SUCCESS; + return position; } -result -_WebImpl::LoadUrlWithPostRequest(const String& url, const HttpHeader& header, const ByteBuffer& body) const +Dimension +_WebImpl::GetPageSize(void) const { - std::unique_ptr pUrl(_StringConverter::CopyToCharArrayN(url)); - SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - - Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header); + Evas_Coord width = 0; + Evas_Coord height = 0; - ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_POST, pHttpHeader, reinterpret_cast< const char* >(body.GetPointer())); + ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &width, &height); - eina_hash_free(pHttpHeader); + Dimension size(static_cast< int >(width), static_cast< int >(height)); - return E_SUCCESS; + return size; } result -_WebImpl::LoadData(const String& baseUrl, const ByteBuffer& content, const String& mime, const String& encoding) const +_WebImpl::AddHttpHeaderField(const String& name, const String& value) { - SysTryReturnResult(NID_WEB_CTRL, content.GetLimit() > 0, E_INVALID_ARG, "The content buffer is empty."); + SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing."); - 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())); + std::unique_ptr pName(_StringConverter::CopyToCharArrayN(name)); + SysTryReturn(NID_WEB_CTRL, pName.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - ewk_view_contents_set(__pWebCore->GetWebNativeNode(), reinterpret_cast< const char* >(content.GetPointer()), content.GetLimit(), pMime.get(), pEncoding.get(), pUrl.get()); + std::unique_ptr pValue(_StringConverter::CopyToCharArrayN(value)); + + ewk_view_custom_header_add(__pWebCore->GetWebNativeNode(), pName.get(), pValue.get()); return E_SUCCESS; } -void -_WebImpl::Pause(void) +result +_WebImpl::RemoveHttpHeaderField(const String& name) { - ewk_view_suspend(__pWebCore->GetWebNativeNode()); -} + 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())); -void -_WebImpl::Resume(void) -{ - ewk_view_resume(__pWebCore->GetWebNativeNode()); + ewk_view_custom_header_remove(__pWebCore->GetWebNativeNode(), pName.get()); + + return E_SUCCESS; } result -_WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List* pItems, Evas_Object* pWebView, int selectedIndex) +_WebImpl::SetFullScreenKeypad(void) { - __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)); + std::unique_ptr pKeypad(new (std::nothrow) Keypad()); + SysTryReturnResult(NID_WEB_CTRL, pKeypad.get(), E_OUT_OF_MEMORY, "Memory allocation failed."); - r = pSelectBox->UpdateList(pItems, selectedIndex, false, false); + r = pKeypad->Construct(KEYPAD_STYLE_NORMAL, 100); 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."); - - return __pSelectBox->UpdateList(pItems, selectedIndex, true, isGroupedList); -} + 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)); -result -_WebImpl::ClearSelectBoxPopup(void) -{ - SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist."); + r = pKeypad->Show(); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - __pSelectBox.reset(); + pKeypad->AddTextEventListener(*this); + + __pKeypad = std::move(pKeypad); return E_SUCCESS; } -_InputPickerPopup* -_WebImpl::GetDatepicker(void) +void +_WebImpl::RemoveFullScreenKeypad(void) { - _InputPickerPopup* pInputPicker =null; - if (__pDatePicker) - { - pInputPicker = __pDatePicker.get(); - } - return pInputPicker; -} - + __pKeypad->RemoveTextEventListener(*this); -_InputPickerPopup* -_WebImpl::GetColorpicker(void) -{ - _InputPickerPopup* pInputPicker =null; - if (__pColorPicker) - { - pInputPicker = __pColorPicker.get(); - } - return pInputPicker; + __pKeypad.reset(); } bool -_WebImpl::CanGoBack(void) const +_WebImpl::IsKeypadVisible(void) const { - return static_cast< bool >(ewk_view_back_possible(__pWebCore->GetWebNativeNode())); + return __isKeypadVisible; } -bool -_WebImpl::CanGoForward(void) const +Rectangle +_WebImpl::GetPreviousKeypadBounds(void) const { - return static_cast< bool >(ewk_view_forward_possible(__pWebCore->GetWebNativeNode())); + return __previousKeypadBounds; } void -_WebImpl::GoBack(void) const +_WebImpl::OnTextValueChangeCanceled(const Control& source) { - ewk_view_back(__pWebCore->GetWebNativeNode()); + RemoveFullScreenKeypad(); } void -_WebImpl::GoForward(void) const +_WebImpl::OnTextValueChanged(const Control& source) { - ewk_view_forward(__pWebCore->GetWebNativeNode()); -} + std::unique_ptr pText(_StringConverter::CopyToCharArrayN(__pKeypad->GetText())); + ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get()); -Tizen::Base::String -_WebImpl::GetUrl(void) const -{ - return ewk_view_url_get(__pWebCore->GetWebNativeNode()); + RemoveFullScreenKeypad(); } -Tizen::Base::String -_WebImpl::GetTitle(void) const +Eina_Bool +_WebImpl::AddHttpHeaderData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData) { - return ewk_view_title_get(__pWebCore->GetWebNativeNode()); + 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; } -void -_WebImpl::StopLoading(void) const +Eina_Bool +_WebImpl::AddHttpAttributeData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData) { - ewk_view_stop(__pWebCore->GetWebNativeNode()); + 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 -_WebImpl::Reload(void) const +_WebImpl::FreeCharArray(void* pData) { - ewk_view_reload(__pWebCore->GetWebNativeNode()); + delete[] reinterpret_cast(pData); } -String* -_WebImpl::EvaluateJavascriptN(const String& scriptCode) +LoadingErrorType +_WebImpl::ConvertErrorCode(int error) { - Evas_Object* pView = __pWebCore->GetWebNativeNode(); - if (!pView) + LoadingErrorType errorCode = WEB_ERROR_UNKNOWN; + + switch (error) { - 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_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; - 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_BAD_REQUEST: + //fall through + case EWK_ERROR_NETWORK_STATUS_REQUEST_URI_TOO_LONG: + errorCode = WEB_BAD_URL; + break; - ewk_view_script_execute(pView, pScript.get(), OnScriptExecuted, pPresenter.get()); + case EWK_ERROR_NETWORK_STATUS_FORBIDDEN: + errorCode = WEB_FILE_ACCESS_FAILED; + 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)); + case EWK_ERROR_NETWORK_STATUS_REQUEST_TIMEOUT: + errorCode = WEB_REQUEST_TIMEOUT; + break; - pPresenter->WaitAsyncProcess(*pResult.get()); + case EWK_ERROR_NETWORK_STATUS_UNSUPPORTED_MEDIA_TYPE: + errorCode = WEB_MIME_NOT_SUPPORTED; + break; - return pResult.release(); + 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; } result -_WebImpl::SetZoomLevel(float level) +_WebImpl::FireLoadingErrorOccurredEvent(_WebImpl* pImpl, int code, const char* pDescription) { - 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); + result r = E_SUCCESS; - ewk_view_scale_set(__pWebCore->GetWebNativeNode(), static_cast< double >(level), 0, 0); + 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(); + + r = pImpl->GetWebEvent()->FireAsync(*pEventArg); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + pEventArg.release(); return E_SUCCESS; } -float -_WebImpl::GetZoomLevel(void) const +Eina_Bool +_WebImpl::OnScriptAlertRequested(Evas_Object* pView, const char* pMessage, void* pUserData) { - return static_cast< float >(ewk_view_scale_get(__pWebCore->GetWebNativeNode())); + 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; } -const PageNavigationList* -_WebImpl::GetBackForwardListN(void) const +Eina_Bool +_WebImpl::OnScriptConfirmRequested(Evas_Object* pView, const char* pMessage, void* pUserData) { - Evas_Object* pView = __pWebCore->GetWebNativeNode(); - if (!pView) - { - return null; - } + 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 +_WebImpl::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); - _PageNavigationListImpl* pNavigationListImpl = null; - _HistoryItemImpl* pHistoryItemImpl = null; + String msg(pMessage); + String defVal(pDefaultValue); - std::unique_ptr pNavigationList; - std::unique_ptr pHistoryList; + r = pImpl->ShowPromptPopup(msg, defVal); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - int backCount = 0; - int forwardCount = 0; + return EINA_TRUE; - String url(L""); - String title(L""); +CATCH: + ewk_view_javascript_prompt_reply(pView, null); - 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)); + return EINA_FALSE; +} - 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)); - 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)); +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"); - pNavigationListImpl = _PageNavigationListImpl::GetInstance(pNavigationList.get()); - SysTryCatch(NID_WEB_CTRL, pNavigationListImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + 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; - 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)); + result r = E_SUCCESS; - r = pHistoryList->Construct(); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + std::unique_ptr pEnum; - 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); + String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME); + String table(CERTIFICATE_TABLE_NAME); + _DatabaseImpl db; - 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)); + String pem(ewk_certificate_policy_decision_certificate_pem_get(pPolicy)); - pHistoryItemImpl = _HistoryItemImpl::GetInstance(pHistoryItem.get()); - SysTryCatch(NID_WEB_CTRL, pHistoryItemImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + r = db.Construct(certificatePath, "r", null); + 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)); + 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)); - 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()); + int allow = 0; + r = pEnum->GetIntAt(0, allow); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - pHistoryItemImpl->SetHistoryItem(url, title); + SysLog(NID_WEB_CTRL, "The current value of allow is %d", allow); - r = pHistoryList->Add(*pHistoryItem.get()); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - pHistoryItem.release(); - } + 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())); - pNavigationListImpl->SetPageNavigationList(pHistoryList.release(), backCount); + r = pImpl->ShowCertificateConfirmPopup(CERTIFICATE_POPUP_MODE_USER_CONFIRM, pPolicy); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - ewk_history_free(pEwkHistoryList); + ewk_view_resume(pWebCore->GetWebNativeNode()); + } - return pNavigationList.release(); + 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); + } + + return; CATCH: - ewk_history_free(pEwkHistoryList); + ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE); + pImpl->__isCertificateConfirmed = false; - return null; + _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore())); + ewk_view_resume(pWebCore->GetWebNativeNode()); } -bool -_WebImpl::SearchText(const String& text, bool searchForward) +void +_WebImpl::OnHttpAuthenticationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) { - Evas_Object* pView = __pWebCore->GetWebNativeNode(); - if (!pView) - { - return false; - } + _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; - Ewk_Find_Options condition = static_cast< Ewk_Find_Options >(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE); + r = pImpl->HttpAuthenticationRequested(pChallenge); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + return; - if (!searchForward) +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"); + + if (pImpl->__pUserLoadingListener) { - condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS); + 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(); } +} - 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)); +Eina_Bool +_WebImpl::OnApplicationCachePermissionRequested(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, void* pUserData) +{ + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl , "Failed to request"); - r = SynchronizeSearch(SEARCH_SYNC, pView, condition, text, searchForward, false, pPresenter.get()); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); + 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)); - int result = 0; - pPresenter->WaitAsyncProcess(result); + r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_APP_CACHE, pView, msg); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); - return static_cast < bool >(result); + return EINA_TRUE; } -result -_WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive) +Eina_Bool +_WebImpl::OnIndexedDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData) { - Evas_Object* pView = __pWebCore->GetWebNativeNode(); - if (!pView) - { - return E_SUCCESS; - } - - result r = E_SUCCESS; - - Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT; + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl , "Failed to request"); - if (!caseSensitive) - { - condition = static_cast (condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE); - } + 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 = SynchronizeSearch(SEARCH_ALL_ASYNC, pView, condition, text, true, caseSensitive); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, 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 E_SUCCESS; + return EINA_TRUE; } -result -_WebImpl::SearchNextAsync(bool searchForward) +Eina_Bool +_WebImpl::OnDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, const char* database_name, unsigned long long expectedQuota, void* pUserData) { - Evas_Object* pView = __pWebCore->GetWebNativeNode(); - if (!pView) - { - return E_SUCCESS; - } + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl , "Failed to request"); - 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."); + 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)); - result r = E_SUCCESS; + r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_DB_QUOTA_EXCEDED, pView, msg); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); - Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT; + return EINA_TRUE; +} - if (!__textSearch.__caseSensitive) - { - condition = static_cast (condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE); - } - if (!searchForward) - { - condition = static_cast (condition | EWK_FIND_OPTIONS_BACKWARDS); - } +Eina_Bool +_WebImpl::OnLocalFileSystemQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData) +{ + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl , "Failed to request"); - r = SynchronizeSearch(SEARCH_NEXT_ASYNC, pView, condition, __textSearch.__text, searchForward); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, 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)); - return E_SUCCESS; + 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)); + + return EINA_TRUE; } -result -_WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text, bool searchForward, bool caseSensitive, _WebPresenter* pWebPresenter) +void +_WebImpl::OnGeolocationPermissionRequested(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())); - - switch (type) - { - case SEARCH_SYNC: - if (__textSearch.__searchAll) - { - DisableAsyncSearch(); + _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); + Ewk_Geolocation_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Geolocation_Permission_Request* >(pEventInfo); + SysAssertf(pImpl && pPermissionRequest, "Failed to request"); - __textSearch.__searchQueue.Enqueue(this); - __textSearch.__searchQueue.Enqueue(pWebPresenter); + if (pImpl->GetSetting().IsGeolocationEnabled()) + { + result r = E_SUCCESS; - 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); + std::unique_ptr pEnum; - ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH); - } - break; + String geolocationPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME); + String table(GEOLOCATION_TABLE_NAME); + _DatabaseImpl db; - case SEARCH_ALL_ASYNC: - __textSearch.__searchAll = true; - __textSearch.__text = text; - __textSearch.__searchForward = true; - __textSearch.__caseSensitive = caseSensitive; - __textSearch.__totalCount = -1; - __textSearch.__currentIndex = 1; + const Ewk_Security_Origin* pSecurityOrigin = ewk_geolocation_permission_request_origin_get(pPermissionRequest); + String origin = _Utility::CreateOrigin(pSecurityOrigin); - __textSearch.__searchQueue.Enqueue(this); - __textSearch.__searchQueue.Enqueue(this); + r = db.Construct(geolocationPath, "r", null); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH); - ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH); - break; + 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)); - case SEARCH_NEXT_ASYNC: - __textSearch.__searchForward = searchForward; + int permission = 0; + r = pEnum->GetIntAt(0, permission); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - CalculateAsyncSearchOrdinal(); + SysLog(NID_WEB_CTRL, "The current value of permission is %d", permission); - __textSearch.__searchQueue.Enqueue(this); + ewk_geolocation_permission_request_set(pPermissionRequest, static_cast < Eina_Bool >(permission)); + } + else + { + ewk_geolocation_permission_request_suspend(pPermissionRequest); - ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH); - break; + r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_GEOLOCATION, pPermissionRequest); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } - default: - SysAssert(false); + return; } - return E_SUCCESS; +CATCH: + ewk_geolocation_permission_request_set(pPermissionRequest, EINA_FALSE); } void -_WebImpl::SetAsyncSearchResult(int totalCount) +_WebImpl::OnGetUserMediaPermissionRequsted(void* pUserData, Evas_Object* pView, void* pEventInfo) { - __textSearch.__totalCount = totalCount; + _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"); + + result r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_USERMEDIA, pEventInfo); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + return; + +CATCH: + ewk_user_media_permission_request_set(pPermissionRequest, EINA_FALSE); } -_WebPresenter* -_WebImpl::GetSearchPresenter(void) +void +_WebImpl::OnNotificationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) { - MutexGuard lock(__mutex); + result r = E_SUCCESS; + _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); - return dynamic_cast< _WebPresenter* >(__textSearch.__searchQueue.Dequeue()); -} + Ewk_Notification_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Notification_Permission_Request* >(pEventInfo); + SysAssertf(pImpl && pPermissionRequest, "Failed to request"); + + ewk_notification_permission_request_suspend(pPermissionRequest); + r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_NOTIFICATION, pPermissionRequest); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + return; - int - _WebImpl::GetPendingAsyncSearchCount(void) const -{ - return __textSearch.__searchQueue.GetCount(); +CATCH: + ewk_notification_permission_request_set(pPermissionRequest, EINA_FALSE); } void -_WebImpl::CalculateAsyncSearchOrdinal(void) +_WebImpl::OnNotificationShow(void* pUserData, Evas_Object* pView, void* pEventInfo) { - if (__textSearch.__searchForward) - { - __textSearch.__currentIndex++; - } - else - { - __textSearch.__currentIndex--; - } -} + _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); - int - _WebImpl::GetAsyncSearchOrdinal(void) const -{ - return __textSearch.__currentIndex; -} + //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)); - void - _WebImpl::DisableAsyncSearch(void) -{ - __textSearch.__searchAll = false; + 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); } -result -_WebImpl::SetSetting(const WebSetting& setting) +void +_WebImpl::OnNotificationCancel(void* pUserData, Evas_Object* pView, void* pEventInfo) { - if (__pWebCore->GetWebNativeNode()) - { - 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())); + _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); + uint64_t* pNotificationID = reinterpret_cast< uint64_t* >(pEventInfo); + SysAssertf(pImpl && pNotificationID, "Failed to request"); - ewk_settings_default_encoding_set(pSettings, pEncoding.get()); + //ToDo : Where is ewk API for cancel operation? +} - 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; +void +_WebImpl::OnProtocolHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) +{ + result r = E_SUCCESS; + _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); + SysAssertf(pImpl, "Failed to request"); - default: - SysAssert(false); - } + r = pImpl->ShowUserConfirmPopup(USER_PROTOCOL_HANDLER, pEventInfo); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} - 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())); +void +_WebImpl::OnIsProtocolHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo) +{ + int checkHandler = 0; + _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); + Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo); + SysAssertf(pImpl && pHandlerData, "Failed to request"); - ewk_settings_javascript_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsJavascriptEnabled())); + 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); + } +} - ewk_settings_loads_images_automatically_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoImageLoadEnabled())); +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"); - if (__defaultUserAgent != setting.GetUserAgent()) - { - std::unique_ptr pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent())); - SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + r = pImpl->UnregistrationHandler(pHandlerData, false); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} - ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get()); - } - ewk_settings_auto_fitting_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFittingEnabled())); +void +_WebImpl::OnContentHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) +{ + 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)); +} - 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 +_WebImpl::OnIsContentHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo) +{ + int checkHandler = 0; + _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); + Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo); + SysAssertf(pImpl && pHandlerData, "Failed to request"); - ewk_settings_autofill_password_form_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoLoginFormFillEnabled())); + 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); } +} - _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting()); - 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()); +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"); - return E_SUCCESS; + r = pImpl->UnregistrationHandler(pHandlerData, true); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); } -WebSetting -_WebImpl::GetSetting(void) const +void +_WebImpl::OnFullScreenEntered(void* pUserData, Evas_Object* pView, void* pEventInfo) { - return *__pWebCore->GetSetting(); + _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); + SysAssertf(pImpl, "Failed to request"); } -const HitElementResult* -_WebImpl::GetElementByPointN(const Point& point) const +void +_WebImpl::OnFullScreenExited(void* pUserData, Evas_Object* pView, void* pEventInfo) { - return GetElementByPointN(_CoordinateSystemUtils::ConvertToFloat(point)); + _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); + SysAssertf(pImpl, "Failed to request"); } -const HitElementResult* -_WebImpl::GetElementByPointN(const FloatPoint& point) const +void +_WebImpl::OnVibrationRequested(uint64_t duration, void* pUserData) { - Evas_Object* pView = __pWebCore->GetWebNativeNode(); - if (!pView) - { - return null; - } - - 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 r = E_SUCCESS; - _HitElementResultImpl* pHitElementResultImpl = null; + _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); + SysAssertf(pImpl, "Failed to request"); - std::unique_ptr pHitElementResult; - std::unique_ptr pImage; - std::unique_ptr pAttributeMap; + r = pImpl->VibrationRequested(duration); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} - 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)); +void +_WebImpl::OnVibrationCanceled(void* pUserData) +{ + _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); + SysAssertf(pImpl, "Failed to request"); - 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)); + pImpl->VibrationCanceled(); +} - 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)); +void +_WebImpl::OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) +{ + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo); + SysAssertf(pImpl && pPolicy, "Failed to request"); - pHitElementResultImpl = _HitElementResultImpl::GetInstance(pHitElementResult.get()); - SysTryCatch(NID_WEB_CTRL, pHitElementResultImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + String url(ewk_policy_decision_url_get(pPolicy)); + SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls", url.GetPointer()); - if (context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE) + if (url == L"about:blank") { - 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); - - r = buf.Construct(imageLength); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - - r = buf.SetArray(reinterpret_cast< byte* >(pImageBuffer), 0, imageLength); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + ewk_policy_decision_use(pPolicy); + return; + } - buf.Rewind(); + if (pImpl->__pUserLoadingListener && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy)) + && !pImpl->__isRedirectRequested) + { + pImpl->__isCertificateRequested = false; -// 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) + if (pImpl->__pTextSearchListener) { - 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; + pImpl->__textSearch.__searchAll = false;; } - else + + Ewk_Policy_Navigation_Type ewkNavigationType = ewk_policy_decision_navigation_type_get(pPolicy); + WebNavigationType navigationType = WEB_NAVIGATION_OTHER; + + switch (ewkNavigationType) { - SysLogException(NID_WEB_CTRL, E_UNSUPPORTED_FORMAT, "[%s] The %s format is not supported", GetErrorMessage(E_UNSUPPORTED_FORMAT), pExtension); - goto CATCH; + 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); } - r = image.Construct(); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + if (pImpl->__pUserLoadingListener->OnLoadingRequested(url, navigationType)) + { + ewk_policy_decision_ignore(pPolicy); - pImage = std::unique_ptr(image.DecodeN(buf, format, BITMAP_PIXEL_FORMAT_RGB565)); - SysTryCatch(NID_WEB_CTRL, pImage.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + return; + } } - if (pAttrHash) + String currentUrl(pImpl->GetUrl()); + String redirectUrl(pImpl->GetProtocolFromUri(url, currentUrl)); + if (redirectUrl != L"") { - 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)); - - r = pAttributeMap->Construct(eina_hash_population(pAttrHash)); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - - 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); - - return pHitElementResult.release(); - -CATCH: - ewk_hit_test_free(pEwkHitTest); - - return null; -} - - -bool -_WebImpl::IsLoading(void) const -{ - double percent = ewk_view_load_progress_get(__pWebCore->GetWebNativeNode()); + pImpl->LoadUrl(redirectUrl); + ewk_policy_decision_ignore(pPolicy); - if (Double::Compare(percent, 0.0) > 0 && Double::Compare(percent, 1.0) < 0) - { - return true; - } - else - { - return false; + return; } -} - - -String -_WebImpl::GetTextFromBlock(void) const -{ - return ewk_view_text_selection_text_get(__pWebCore->GetWebNativeNode()); -} + + Uri uri; + uri.SetUri(url); + String uriScheme(uri.GetScheme()); + SysLog(NID_WEB_CTRL, "The current value of scheme is %ls", uriScheme.GetPointer()); -bool -_WebImpl::IsPrivateBrowsingEnabled(void) const -{ - if (__pWebCore->GetWebNativeNode() == null) + if ((uriScheme != L"http") && (uriScheme != L"https") && (uriScheme != L"file")) { - return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsPrivateBrowsingEnabled(); - } + ewk_policy_decision_ignore(pPolicy); - Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode()); - SysAssertf(pSettings, "Failed to get webkit instance."); + if (uriScheme == L"") + { + return; + } - return static_cast< bool >(ewk_settings_private_browsing_enabled_get(pSettings)); -} + result r = 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"); + r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null); + } + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); -void -_WebImpl::SetPrivateBrowsingEnabled(bool enable) -{ - if (__pWebCore->GetWebNativeNode() == null) - { - _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetPrivateBrowsingEnabled(enable); return; } - Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode()); - SysAssertf(pSettings, "Failed to get webkit instance."); - - ewk_settings_private_browsing_enabled_set(pSettings, static_cast< Eina_Bool >(enable)); + ewk_policy_decision_use(pPolicy); } void -_WebImpl::ClearHistory(void) +_WebImpl::OnLoadingStarted(void* pUserData, Evas_Object* pView, void* pEventInfo) { - ewk_view_back_forward_list_clear(__pWebCore->GetWebNativeNode()); -} + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl, "Failed to request"); + if (pImpl->__pUserLoadingListener) + { + result r = E_SUCCESS; -void -_WebImpl::ClearCache(void) -{ - Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode()); + 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)); - ewk_context_cache_clear(pContext); + r = pImpl->__pWebEvent->FireAsync(*pEventArg.get()); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + pEventArg.release(); + } } void -_WebImpl::ClearCookie(void) +_WebImpl::OnPageTitleReceived(void* pUserData, Evas_Object* pView, void* pEventInfo) { - Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode()); - Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext); + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + char* pTitle = reinterpret_cast< char* >(pEventInfo); + SysAssertf(pImpl, "Failed to request"); - ewk_cookie_manager_cookies_clear(pCookieManager); -} + SysLog(NID_WEB_CTRL, "The current value of title is %s", pTitle); + if (pImpl->__pUserLoadingListener) + { + result r = E_SUCCESS; -void -_WebImpl::ClearFormData(void) -{ - Ewk_Context* pContext = ewk_view_context_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)); - ewk_context_form_candidate_data_clear(pContext); + r = pEventArg->SetEventInfo(_LoadingEventArg::PAGE_TITLE, *pPageTitle.get()); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + pPageTitle.release(); + + r = pImpl->__pWebEvent->FireAsync(*pEventArg.get()); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + pEventArg.release(); + } } void -_WebImpl::ClearLoginFormData(void) +_WebImpl::OnEstimatedProgress(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); + double* pProgress = reinterpret_cast< double* >(pEventInfo); + SysAssertf(pImpl, "Failed to request"); + SysLog(NID_WEB_CTRL, "The current value of progress is %lf", *pProgress); -bool -_WebImpl::IsCookieEnabled(void) const -{ - if (__pWebCore->GetWebNativeNode() == null) + if (pImpl->__pUserLoadingListener) { - return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsCookieEnabled(); - } - - 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)); + result r = E_SUCCESS; - ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, pPresenter.get()); + 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)); - bool result = false; - pPresenter->WaitAsyncProcess(result); + r = pEventArg->SetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS, *pProgressPercentage.get()); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + pProgressPercentage.release(); - return result; + r = pImpl->__pWebEvent->FireAsync(*pEventArg.get()); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + pEventArg.release(); + } } void -_WebImpl::SetCookieEnabled(bool enable) +_WebImpl::OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo) { - if (__pWebCore->GetWebNativeNode() == null) - { - _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetCookiEnabled(enable); + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo); + SysAssertf(pImpl && pPolicy, "Failed to request"); - return; - } + result r = E_SUCCESS; - 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."); + _SystemResource* pSysResource = _SystemResource::GetInstance(); + SysAssertf(pSysResource != null, "Failed to get _SystemResource instance"); - if (enable) - { - ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS); - } - else + 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))) { - ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER); - ewk_cookie_manager_cookies_clear(pCookieManager); + const Eina_Hash* pHeader = ewk_policy_decision_response_headers_get(pPolicy); + + DecisionPolicy policy; + HttpHeader httpHeader; + + if (code >= REDIRECTION_HEADER_GROUP && code < REDIRECTION_HEADER_GROUP + 100) + { + pImpl->__isRedirectRequested = true; + mime = L""; + } + + 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; } -} + 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); -result -_WebImpl::SavePageAsPdf(const String& filePath, const Dimension* pSize) const -{ - result r = E_SUCCESS; + return; + } - std::unique_ptr pFilePath(_StringConverter::CopyToCharArrayN(filePath)); - SysTryReturn(NID_WEB_CTRL, pFilePath.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + if (pImpl->IsMimeSupported(mime) || mime == L"") + { + break; + } + + else + { + ewk_policy_decision_ignore(pPolicy); - String dirPath; - String fileExtension = File::GetFileExtension(filePath); - int pathLength = filePath.GetLength(); - int index = 0; + String operationId(L"http://tizen.org/appcontrol/operation/view"); - SysTryReturnResult(NID_WEB_CTRL, fileExtension.Equals("pdf", false), E_INVALID_ARG, "Invalid argument(s) is used. File extension is not pdf."); + 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 = 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."); + r = pSelectBox->Construct(false, L"Select application", 1, null, url); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - 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."); + 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)); + } - if (pSize) + return; + } + break; + } + case WEB_DECISION_DOWNLOAD: { - 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_policy_decision_ignore(pPolicy); - ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), pSize->width, pSize->height, pFilePath.get()); + 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* pContext = ewk_view_context_get(pView); + SysAssertf(pContext, "Failed to get webkit instance."); + + pImpl->__pWebDownloadHandler.get()->StartDownload(url); + + return; } - else + case WEB_DECISION_IGNORE: { - Evas_Coord contentsWidth; - Evas_Coord contentsHeight; + ewk_policy_decision_ignore(pPolicy); - ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &contentsWidth, &contentsHeight); - ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), contentsWidth, contentsHeight, pFilePath.get()); + return; + } + default: + { + SysAssert(false); + } } - return E_SUCCESS; -} - + ewk_policy_decision_use(pPolicy); -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; - return static_cast< bool >(ewk_frame_can_show_mime_type(ewk_view_main_frame_get(__pWebCore->GetWebNativeNode()), pMime.get())); +CATCH: + ewk_policy_decision_ignore(pPolicy); } void -_WebImpl::SetLoadingListener(ILoadingListener* pLoadingListener) +_WebImpl::OnProgressCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo) { - __pUserLoadingListener = const_cast< ILoadingListener* >(pLoadingListener); + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl, "Failed to request"); + + if (pImpl->__isRedirectRequested) + { + pImpl->__isRedirectRequested = false; + } + + if (pImpl->__isLoadingErrorOccurred) + { + pImpl->__isLoadingErrorOccurred = false; + evas_object_smart_callback_call(pView, "load,finished", NULL); + } } void -_WebImpl::SetWebUiEventListener(IWebUiEventListener* pUiEventListener) +_WebImpl::OnLoadingErrorOccurred(void* pUserData, Evas_Object* pView, void* pEventInfo) { - __pUserUiListener = pUiEventListener; + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + Ewk_Error* pErrorData = reinterpret_cast< Ewk_Error* >(pEventInfo); + SysAssertf(pImpl && pErrorData, "Failed to request"); + + int code = ewk_error_code_get(pErrorData); + const char* pDescription = ewk_error_description_get(pErrorData); + + SysLog(NID_WEB_CTRL, "The current value of code is %d, description is %s", code, pDescription); + + switch (code) + { + case EWK_ERROR_CODE_FRAMELOADINTERRUPTEDBYPOLICYCHANGE: + pImpl->__isLoadingErrorOccurred = true; + break; + + case EWK_ERROR_CODE_PLUGINWILLHANDLELOAD: + evas_object_smart_callback_call(pView, "load,finished", NULL); + break; + + case EWK_ERROR_NETWORK_STATUS_CANCELLED: + pImpl->__isLoadingErrorOccurred = true; + evas_object_smart_callback_call(pView, "load,stop", NULL); + break; + + default: + pImpl->__isLoadingErrorOccurred = true; + if (pImpl->__pUserLoadingListener) + { + result r = E_SUCCESS; + + r = FireLoadingErrorOccurredEvent(pImpl, code, pDescription); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + break; + } } void -_WebImpl::SetWebUiEventListenerF(IWebUiEventListenerF* pUiEventListener) +_WebImpl::OnLoadingCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo) { - __pUserUiListenerF = pUiEventListener; -} + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl, "Failed to request"); + if (pImpl->__pUserLoadingListener) + { + result r = 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(); + } -void -_WebImpl::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener) -{ - __pUserKeypadEventListener = pKeypadEventListener; } void -_WebImpl::SetDownloadListener(IWebDownloadListener* pDownLoadListener) +_WebImpl::OnLoadingCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo) { - if (__pWebDownloadHandler.get() == null) + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl, "Failed to request"); + + if (pImpl->__pUserLoadingListener) { - __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)); + 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)); + + r = pImpl->__pWebEvent->FireAsync(*pEventArg.get()); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + pEventArg.release(); } - __pWebDownloadHandler->SetDownloadListener(pDownLoadListener); - __pWebDownloadHandler->SetWebEvent(__pWebEvent.get()); } void -_WebImpl::SetTextSearchListener(ITextSearchListener* pTextSearchListener) +_WebImpl::OnFaviconReceived(void* pUserData, Evas_Object* pView, void* pEventInfo) { - __pTextSearchListener = pTextSearchListener; -} + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl, "Failed to request"); + + if (pImpl->__pUserLoadingListener) + { + result r = E_SUCCESS; + 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)); + + r = pImpl->__pWebEvent->FireAsync(*pEventArg.get()); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + pEventArg.release(); + } -void -_WebImpl::SetScrollEnabled(bool enable) -{ - _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetScrollEnabled(enable); } -bool -_WebImpl::IsScrollEnabled(void) const +void +_WebImpl::OnDidStartDownloadCallback(const char* pUrl, void* pUserData) { - return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled(); + _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); } result -_WebImpl::InitJsBridgeList(void) +_WebImpl::FireWebPageShowRequestedEvent(_WebImpl* pImpl, int event) { result r = E_SUCCESS; - __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."); - - std::unique_ptr > pJsBridgeList(new (std::nothrow) HashMapT< String, IJavaScriptBridge* >); - SysTryReturnResult(NID_WEB_CTRL, pJsBridgeList.get(), E_OUT_OF_MEMORY, "Memory Allocation failed."); + std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event)); + SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed."); - r = pJsBridgeList->Construct(0, 0, *__pJsProvider.get(), *__pJsComparer.get()); + r = pImpl->__pWebEvent->FireAsync(*pEventArg.get()); SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - - __pJsBridgeList = std::move(pJsBridgeList); + pEventArg.release(); return E_SUCCESS; } -result -_WebImpl::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge) +void +_WebImpl::OnWebPageShowRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) { - result r = E_SUCCESS; + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl, "Failed to request"); - IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge); - String key(pJsBridge->GetName()); + if (pImpl->__pUserUiListener) + { + 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); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + if (pImpl->__pUserUiListenerF) + { + result r = E_SUCCESS; - return E_SUCCESS; + r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } } -result -_WebImpl::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge) +void +_WebImpl::OnWebWindowCreateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) { - result r = E_SUCCESS; + _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(pUserData); + Evas_Object** pChildView = reinterpret_cast< Evas_Object** >(pEventInfo); + SysAssertf(pParentImpl && pChildView, "Failed to request"); - IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge); - String key(pJsBridge->GetName()); + 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)); - 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); + } + } + 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)); - return E_SUCCESS; + *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode(); + evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl); + } + } } -IJavaScriptBridge* -_WebImpl::FindJsInterface(const IJsonValue* pValue) const +result +_WebImpl::FireWebWindowClosedRequestedEvent(_WebImpl* pImpl, int event) { result r = E_SUCCESS; - IJsonValue* pJsonValue = null; - IJavaScriptBridge* pJsBridge = null; - - String key(L"name"); - - 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)); - - 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)); + std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event)); + SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed."); - r = __pJsBridgeList->GetValue(static_cast< String >(*pBridgeName), pJsBridge); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + r = pImpl->__pWebEvent->FireAsync(*pEventArg.get()); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + pEventArg.release(); - return pJsBridge; + return E_SUCCESS; } -ILoadingListener* -_WebImpl::GetLoadingListener(void) const +void +_WebImpl::OnWebWindowClosedRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) { - return __pUserLoadingListener; -} + _WebImpl* pChildImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pChildImpl, "Failed to request"); + _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, PARENT_WEB_CTRL)); + if (pParentImpl == null) + { + return; + } -IWebUiEventListener* -_WebImpl::GetUiEventListener(void) const -{ - return __pUserUiListener; -} + if (pParentImpl->__pUserUiListener) + { + result r = E_SUCCESS; + 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; -IWebUiEventListenerF* -_WebImpl::GetUiEventListenerF(void) const -{ - return __pUserUiListenerF; + r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } } -IWebKeypadEventListener* -_WebImpl::GetWebKeypadEventListener(void) const +result +_WebImpl::FireWebPreventDefaultTriggeredEvent(_WebImpl* pImpl, int event, bool trigger) { - return __pUserKeypadEventListener; -} + 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." ); -ITextSearchListener* -_WebImpl::GetTextSearchListener(void) const -{ - return __pTextSearchListener; + 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->__pWebEvent->FireAsync(*pEventArg.get()); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + pEventArg.release(); + + return E_SUCCESS; } void -_WebImpl::SetEventListenerCallback(void) const +_WebImpl::OnWebPreventDefaultTriggered(void* pUserData, Evas_Object* pView, void* pEventInfo) { - Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode(); - if (pWebNativeNode) - { - _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); - SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas"); - - 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; + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + Eina_Bool* pTrigger = reinterpret_cast< Eina_Bool* >(pEventInfo); + SysAssertf(pImpl && pTrigger, "Failed to request"); - pSmart->formdata_candidate_show = OnFormDataCandidateShow; - pSmart->formdata_candidate_hide = OnFormDataCandidateHide; - pSmart->formdata_candidate_update_data = OnFormDataCandidateUpdate; - pSmart->formdata_candidate_is_showing = OnFormDataCandidateIsShowing; + if (pImpl->__pUserUiListener) + { + result r = E_SUCCESS; - evas_object_data_set(pWebNativeNode, WEB_CTRL, this); + 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) + { + result r = E_SUCCESS; - // 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); + 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_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); - evas_object_smart_callback_add(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest, this); +result +_WebImpl::FireWebPageBlockSelectedEvent(_WebImpl* pImpl) +{ + result r = E_SUCCESS; - evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, 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(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); + pImpl->GetBlockRange(*startPoint.get(), *endPoint.get()); - evas_object_smart_callback_add(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested, this); - evas_object_smart_callback_add(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled, 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, "geolocation,permission,request", OnGeolocationPermissionRequested, 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_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 = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get()); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + endPoint.release(); - evas_object_smart_callback_add(pWebNativeNode, "policy,response,decide", OnWebDataReceived, 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, "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); + return E_SUCCESS; +} - 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); - 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); +result +_WebImpl::FireWebPageBlockSelectedEventF(_WebImpl* pImpl) +{ + result r = E_SUCCESS; - 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); + std::unique_ptr startPoint(new (std::nothrow) FloatPoint()); + std::unique_ptr endPoint(new (std::nothrow) FloatPoint()); - evas_object_smart_callback_add(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered, this); - evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this); + SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed."); - evas_object_smart_callback_add(pWebNativeNode, "text,selected", OnWebPageBlockSelected, this); + pImpl->GetBlockRange(*startPoint.get(), *endPoint.get()); - evas_object_smart_callback_add(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered, this); - evas_object_smart_callback_add(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited, 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."); - 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_START, *startPoint.get()); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + startPoint.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 = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get()); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + endPoint.release(); - evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this); + r = pImpl->__pWebEvent->FireAsync(*pEventArg.get()); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + pEventArg.release(); } + + return E_SUCCESS; } void -_WebImpl::RemoveEventListenerCallback(void) const +_WebImpl::OnWebPageBlockSelected(void* pUserData, Evas_Object* pView, void* pEventInfo) { - Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode(); - if (pWebNativeNode) - { - _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); - SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas"); - - Evas_Object* pWinObject = pEcoreEvas->GetWindowObject(); - SysAssertf(pWinObject, "Failed to get Ui window evas object"); - - 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); - - evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest); - - evas_object_smart_callback_del_full(pWinObject, "focus,in", OnWindowObjectFocusGained, this); + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl, "Failed to request"); - 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); + if (pImpl->__pUserUiListener) + { + result r = E_SUCCESS; - evas_object_smart_callback_del(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested); - evas_object_smart_callback_del(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled); + r = FireWebPageBlockSelectedEvent(pImpl); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + if (pImpl->__pUserUiListenerF) + { + result r = E_SUCCESS; - evas_object_smart_callback_del(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested); + r = FireWebPageBlockSelectedEventF(pImpl); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } +} - 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); - evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived); +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, "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->Construct(pView); - 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); + 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, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested); - evas_object_smart_callback_del(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered); - evas_object_smart_callback_del(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested); + 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, "text,found", OnTextFound); + if (multipleFile) + { + isMultipleSelection.Append(L"multiple"); + } - evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered); - evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived); + if (eina_list_count(pAcceptTypes) == 1) + { + String item((char*)eina_list_nth(pAcceptTypes, 0)); + String captureString(pCapture); - evas_object_smart_callback_del(pWebNativeNode, "text,selected", OnWebPageBlockSelected); + 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, "fullscreen,enterfullscreen", OnFullScreenEntered); - evas_object_smart_callback_del(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited); + r = _AppControlImpl::FindAndStart(operationId, null, &fileType, null, &extraData, pMediaListener.get()); + 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); + pMediaListener.release(); - 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); + return EINA_TRUE; - evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained); - } +CATCH: + ewk_view_open_panel_reply(pView, null, EINA_FALSE); + return EINA_TRUE; } void -_WebImpl::ClearCertificateDb(void) +_WebImpl::OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo) { - 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 = db.Construct(certificatePath, "r+", null); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + char* pJsonText = reinterpret_cast< char* >(pEventInfo); + SysAssertf(pImpl && pJsonText, "Failed to request"); - db.BeginTransaction(); + result r = E_SUCCESS; - r = db.ExecuteSql(L"Delete From " + table, true); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + SysLog(NID_WEB_CTRL, "The current value of jsontext is %s", pJsonText); - db.CommitTransaction(); + 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)); - return; + r = pEventArg->Construct(pJsonText); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); -CATCH: - db.RollbackTransaction(); + r = pImpl->__pWebEvent->FireAsync(*pEventArg.get()); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + pEventArg.release(); } -result -_WebImpl::SetBlockSelectionPosition(const Point& startPoint) +void +_WebImpl::OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo) { - return SetBlockSelectionPosition(_CoordinateSystemUtils::ConvertToFloat(startPoint)); -} + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + Eina_Rectangle* pEinaRect = reinterpret_cast< Eina_Rectangle* >(pEventInfo); + SysAssertf(pImpl && pEinaRect, "Failed to request"); + if (pImpl->IsVisible() == false) + { + evas_object_focus_set(pView, EINA_FALSE); + } -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) + if (pImpl->GetSetting().GetInputStyle() == INPUT_STYLE_OVERLAY) { - Point absPoint( _CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(startPoint))); + _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer(); + SysAssertf(pXformer, "Failed to get CoordinateTransformer"); - Eina_Bool ret = pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y); - if (ret) + Rectangle rect(pEinaRect->x, pEinaRect->y, pEinaRect->w, pEinaRect->h); + + if (rect.height == 0) { - pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y); + return; + } - 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."); + _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl)); + if (pFormImpl) + { + pFormImpl->DeflateClientRectHeight(pXformer->TransformVertical(rect.height)); - String tagName(ewk_hit_test_tag_name_get(pEwkHitTest)); + if (pFormImpl->HasFooter()) + { + pFormImpl->GetCore().SetKeypadShowState(true); + pFormImpl->Draw(); + } + } - if (tagName.Equals(L"INPUT", false) || tagName.Equals(L"TEXTAREA", false)) + if (pImpl->__pUserKeypadEventListener) + { + if (pImpl->__isKeypadVisible) { - ewk_view_command_execute(pView, "SelectWord", 0); + if ((pImpl->__previousKeypadBounds.width == rect.width) && (pImpl->__previousKeypadBounds.height != rect.height)) + { + pImpl->__pUserKeypadEventListener->OnWebKeypadBoundsChanged(*dynamic_cast< Web* >(&pImpl->GetPublic())); + } } 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); - } + pImpl->__pUserKeypadEventListener->OnWebKeypadWillOpen(*dynamic_cast< Web* >(&pImpl->GetPublic())); } } + 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."); - - evas_object_smart_callback_call(pView, "text,selected", NULL); - - return E_SUCCESS; } void -_WebImpl::ReleaseBlock(void) +_WebImpl::OnWebKeypadOpened(void* pUserData, Evas_Object* pView, void* pEventInfo) { - ewk_view_text_selection_range_clear(__pWebCore->GetWebNativeNode()); + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl, "Failed to request"); + + if (pImpl->__pUserKeypadEventListener) + { + pImpl->__pUserKeypadEventListener->OnWebKeypadOpened(*static_cast< Web* >(&pImpl->GetPublic())); + } } void -_WebImpl::GetBlockRange(Point& startPoint, Point& endPoint) const +_WebImpl::OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo) { - FloatPoint tempStartPoint; - FloatPoint tempEndPoint; + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl, "Failed to request"); - GetBlockRange(tempStartPoint, tempEndPoint); + _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl)); + if (pFormImpl) + { + pFormImpl->DeflateClientRectHeight(0); - startPoint = _CoordinateSystemUtils::ConvertToInteger(tempStartPoint); - endPoint = _CoordinateSystemUtils::ConvertToInteger(tempEndPoint); + if (pFormImpl->HasFooter()) + { + pFormImpl->GetCore().SetKeypadShowState(false); + pFormImpl->Draw(); + } + } + + if (pImpl->__pUserKeypadEventListener) + { + pImpl->__pUserKeypadEventListener->OnWebKeypadClosed(*dynamic_cast< Web* >(&pImpl->GetPublic())); + } + + pImpl->__isKeypadVisible = false; } void -_WebImpl::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const +_WebImpl::OnWindowObjectFocusGained(void* pUserData, Evas_Object* pWin, void* pEvent_info) { - Eina_Rectangle leftHandle; - Eina_Rectangle rightHandle; - - EINA_RECTANGLE_SET(&leftHandle, 0, 0, 0, 0); - EINA_RECTANGLE_SET(&rightHandle, 0, 0, 0, 0); + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl, "Failed to request"); - ewk_view_text_selection_range_get(__pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle); + if (pImpl->__isKeypadOpened && pImpl->IsVisible() && pImpl->IsFocused()) + { + _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore())); + SysAssertf(pWebCore, "Failed to get Web core object"); - 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); + evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE); - if ((endPoint.x != 0.0f) && (endPoint.y != 0.0f)) - { - startPoint = __pWebCore->GetRelativeCoordinate(startPoint); - endPoint = __pWebCore->GetRelativeCoordinate(endPoint); + pImpl->__isKeypadVisible = true; } } -Bitmap* -_WebImpl::GetFaviconN(void) const +void +_WebImpl::OnWebNativeNodeFocusGained(void* pUserData, Evas* pCanvas, Evas_Object* pView, void* pEventInfo) { - 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); + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl, "Failed to request"); - Evas_Object* pFavicon = ewk_context_icon_database_icon_object_add(pContext, pUrl, pEvas); - if (!pFavicon) + if (pImpl->__isKeypadOpened) { - return null; + pImpl->__isKeypadOpened = false; } +} - Tizen::Graphics::BufferInfo bufferInfo; - - r = _Utility::GetPixelBufferFromEvasObject(pFavicon, bufferInfo); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); - - 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 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 = pImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); +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"); - return pImage.release(); + result r = E_SUCCESS; -} + if (pWebImpl->__pColorPicker.get()) + { + return EINA_FALSE; + } + Color color; -void -_WebImpl::ScrollBy(const Tizen::Graphics::Point& diff) -{ - ewk_view_scroll_by(__pWebCore->GetWebNativeNode(), diff.x, diff.y); -} + 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::ScrollTo(const Tizen::Graphics::Point& dest) -{ - ewk_view_scroll_set(__pWebCore->GetWebNativeNode(), dest.x, dest.y); + return EINA_TRUE; } -Point -_WebImpl::GetScrollPosition(void) const +Eina_Bool +_WebImpl::OnColorPickerProviderDismissed(Ewk_View_Smart_Data* pSmartData) { - Point position; + SysAssertf(pSmartData, "invalid smartdata"); - ewk_view_scroll_pos_get(__pWebCore->GetWebNativeNode(), &position.x, &position.y); + _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); + SysAssertf(pWebImpl, "Failed to get Impl"); - return position; + return pWebImpl->HideColorPicker(); } -Dimension -_WebImpl::GetPageSize(void) const +Eina_Bool +_WebImpl::OnDatePickerProviderRequested(Ewk_View_Smart_Data* pSmartData, Ewk_Input_Type inputType, const char* inputValue) { - Evas_Coord width = 0; - Evas_Coord height = 0; - - ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &width, &height); + SysAssertf(pSmartData, "Failed to request"); + _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); + SysAssertf(pWebImpl, "Failed to get Impl"); - Dimension size(static_cast< int >(width), static_cast< int >(height)); + result r = E_SUCCESS; - return size; -} + if (pWebImpl->__pDatePicker.get()) + { + ewk_view_focused_input_element_value_set(pSmartData->self, inputValue); + return EINA_FALSE; + } -result -_WebImpl::AddHttpHeaderField(const String& name, const String& value) -{ - SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing."); + String dateStr; - std::unique_ptr pName(_StringConverter::CopyToCharArrayN(name)); - SysTryReturn(NID_WEB_CTRL, pName.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + 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 pValue(_StringConverter::CopyToCharArrayN(value)); + std::unique_ptr pDateStr(_StringConverter::CopyToCharArrayN(dateStr)); + SysTryReturn(NID_WEB_CTRL, pDateStr.get(), EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - ewk_view_custom_header_add(__pWebCore->GetWebNativeNode(), pName.get(), pValue.get()); + ewk_view_focused_input_element_value_set(pSmartData->self, pDateStr.get()); - return E_SUCCESS; + return EINA_TRUE; } -result -_WebImpl::RemoveHttpHeaderField(const String& name) +Eina_Bool +_WebImpl::OnSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex) { - SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing."); + SysAssertf(pSmartData, "Failed to request"); - std::unique_ptr pName(_StringConverter::CopyToCharArrayN(name)); - SysTryReturn(NID_WEB_CTRL, pName.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); + SysAssertf(pWebImpl, "Failed to get Impl"); - ewk_view_custom_header_remove(__pWebCore->GetWebNativeNode(), pName.get()); + 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 E_SUCCESS; + return EINA_TRUE; } -void -_WebImpl::SetLoadingErrorOccurred(bool arg) +Eina_Bool +_WebImpl::OnMultiSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* pItems) { - __isLoadingErrorOccurred = 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"); -bool -_WebImpl::IsLoadingErrorOccurred(void) const -{ - return __isLoadingErrorOccurred; + result r = pWebImpl->ShowSelectBoxPopup(true, L"", pItems, pSmartData->self, 0); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); + + return EINA_TRUE; } -void -_WebImpl::SetRedirectRequested(bool arg) +Eina_Bool +_WebImpl::OnSelectBoxClosed(Ewk_View_Smart_Data* pSmartData) { - __isRedirectRequested = arg; -} + 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 = pWebImpl->ClearSelectBoxPopup(); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); -bool -_WebImpl::IsRedirectRequested(void) const -{ - return __isRedirectRequested; + return EINA_TRUE; } -void -_WebImpl::SetPolicyDecision(DecisionPolicy policy) +Eina_Bool +_WebImpl::OnSelectBoxUpdateRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, Eina_List* pItems, int selectedIndex) { - __policy = policy; -} + SysAssertf(pSmartData, "invalid smartdata"); + _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); + SysAssertf(pWebImpl, "Failed to get Impl"); -DecisionPolicy -_WebImpl::GetPolicyDecision(void) const -{ - return __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; } -void -_WebImpl::SetCertificateRequested(bool arg) +Eina_Bool +_WebImpl::OnFormDataCandidateShow(Ewk_View_Smart_Data *pSmartData, int x, int y, int w, int h) { - __isCertificateRequested = 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"); -bool -_WebImpl::IsCertificateRequested(void) const -{ - return __isCertificateRequested; + 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; } -void -_WebImpl::SetCertificateConfirmed(bool arg) +Eina_Bool +_WebImpl::OnFormDataCandidateHide(Ewk_View_Smart_Data *pSmartData) { - __isCertificateConfirmed = 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"); -bool -_WebImpl::IsCertificateConfirmed(void) const -{ - return __isCertificateConfirmed; + if (pWebImpl->__isFormDataVisible) + { + pWebImpl->HideFormDataWindow(); + } + + return EINA_TRUE; } -result -_WebImpl::SetFullScreenKeypad(void) +Eina_Bool +_WebImpl::OnFormDataCandidateUpdate(Ewk_View_Smart_Data *pSmartData, Eina_List *pDataList) { - 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."); + SysAssertf(pSmartData, "Failed to request"); - r = pKeypad->Construct(KEYPAD_STYLE_NORMAL, 100); - 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"); - String text(ewk_view_focused_input_element_value_get(__pWebCore->GetWebNativeNode())); - pKeypad->SetText(text); + pWebImpl->SetFormDataList(pDataList); - r = pKeypad->SetShowState(true); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + return EINA_TRUE; +} - r = pKeypad->Show(); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - pKeypad->AddTextEventListener(*this); +Eina_Bool +_WebImpl::OnFormDataCandidateIsShowing(Ewk_View_Smart_Data *pSmartData) +{ + SysAssertf(pSmartData, "Failed to request"); - __pKeypad = std::move(pKeypad); + _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); + SysAssertf(pWebImpl, "Failed to get Impl"); - return E_SUCCESS; + if (pWebImpl->__isFormDataVisible) + { + return EINA_TRUE; + } + else + { + return EINA_FALSE; + } } void -_WebImpl::RemoveFullScreenKeypad(void) +_WebImpl::OnCookiesPolicyGot(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *pError, void *pUserData) { - __pKeypad->RemoveTextEventListener(*this); - - __pKeypad.reset(); -} + _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData); + SysAssertf(pPresenter && !pError, "Failed to request"); + bool ret = EINA_TRUE; -bool -_WebImpl::IsFooterVisible(void) const -{ - return __isFooterVisible; -} + 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; -void -_WebImpl::SetFooterVisibleState(bool isFooterVisible) -{ - __isFooterVisible = isFooterVisible; -} + default: + SysAssert(false); + } + SysLog(NID_WEB_CTRL, "The current value of policy is %d", ret); -bool -_WebImpl::IsKeypadVisible(void) const -{ - return __isKeypadVisible; + pPresenter->EndAsyncProcess(ret); } void -_WebImpl::SetKeypadVisibleState(bool isKeypadVisible) +_WebImpl::OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData) { - __isKeypadVisible = isKeypadVisible; -} + _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData); + SysAssertf(pPresenter, "Failed to request"); + String result(pResult); + SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer()); -bool -_WebImpl::IsKeypadOpened(void) const -{ - return __isKeypadOpened; + _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); + } } -void -_WebImpl::SetKeypadOpened(bool isKeypadOpened) + +void +_WebImpl::OnTextFound(void* pUserData, Evas_Object* pView, void* pEventInfo) { - __isKeypadOpened = isKeypadOpened; -} + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl, "Failed to request"); + int* pTotalCount = reinterpret_cast< int* >(pEventInfo); + SysLog(NID_WEB_CTRL, "The current value of totalCount is %d", *pTotalCount); -Rectangle -_WebImpl::GetPreviousKeypadBounds(void) const -{ - return __keypadBounds; -} + _WebPresenter* pWebPresenter = pImpl->GetSearchPresenter(); + if (pWebPresenter) + { + pWebPresenter->EndAsyncProcess(*pTotalCount); + } + else + { + if (pImpl->__pTextSearchListener) + { + result r = E_SUCCESS; -void -_WebImpl::SetPreviousKeypadBounds(Rectangle& bounds) -{ - __keypadBounds = bounds; -} + int ordinal = 0; + if (*pTotalCount > 0) + { + ordinal = pImpl->GetAsyncSearchOrdinal(); + pImpl->SetAsyncSearchResult(*pTotalCount); + } -void -_WebImpl::OnTextValueChangeCanceled(const Control& source) -{ - RemoveFullScreenKeypad(); -} + if (pImpl->GetPendingAsyncSearchCount() > 0) + { + return; + } + 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)); -void -_WebImpl::OnTextValueChanged(const Control& source) -{ - std::unique_ptr pText(_StringConverter::CopyToCharArrayN(__pKeypad->GetText())); + r = pEventArg->SetEventInfo(_TextSearchEventArg::TOTAL_COUNT, *pCount.get()); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + pCount.release(); - ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get()); + r = pEventArg->SetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL, *pOrdinal.get()); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + pOrdinal.release(); - RemoveFullScreenKeypad(); + r = pImpl->__pWebEvent->FireAsync(*pEventArg.get()); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + pEventArg.release(); + } + } } + result _WebImpl::OnHandleJavaScriptRequestByEventArg(const IEventArg& arg) { @@ -4504,6 +4315,52 @@ _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; @@ -4814,11 +4671,10 @@ _WebImpl::OnFocusGained(const _ControlImpl& source) bool _WebImpl::OnFocusLost(const _ControlImpl& source) { - if(IsKeypadVisible() == true) + if(__isKeypadVisible) { - SetKeypadOpened(true); - - SetKeypadVisibleState(false); + __isKeypadOpened = true; + __isKeypadVisible = false; } Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode()); @@ -4990,22 +4846,6 @@ _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) { @@ -5039,6 +4879,15 @@ CATCH: } +Eina_Bool +_WebImpl::HideColorPicker(void) +{ + __pColorPicker.reset(); + + return EINA_TRUE; +} + + result _WebImpl::ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue, String& dateStr) { @@ -5325,13 +5174,6 @@ _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 267719f..0ae9043 100755 --- a/src/controls/inc/FWebCtrl_WebImpl.h +++ b/src/controls/inc/FWebCtrl_WebImpl.h @@ -314,44 +314,15 @@ public: void RemoveFullScreenKeypad(void); - void SetCurrentEvent(Tizen::Base::Runtime::IEventArg* arg); - - void SetLoadingErrorOccurred(bool arg); - - bool IsLoadingErrorOccurred(void) const; - - void SetRedirectRequested(bool arg); + bool IsKeypadVisible(void) const; - bool IsRedirectRequested(void) const; + Tizen::Graphics::Rectangle GetPreviousKeypadBounds(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); @@ -369,15 +340,8 @@ 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); @@ -417,8 +381,6 @@ 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); @@ -438,6 +400,79 @@ 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); @@ -460,7 +495,7 @@ private: bool __isCertificateRequested; bool __isCertificateConfirmed; bool __isFormDataVisible; - Tizen::Graphics::Rectangle __keypadBounds; + Tizen::Graphics::Rectangle __previousKeypadBounds; _Web* __pWebCore; -- 2.7.4