X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fcontrols%2FFWebCtrl_WebImpl.cpp;h=73f832086b4992298f81bb326e3bd70c200282fc;hb=f8aded97f30a889abadf821203d81c8a391602e1;hp=d37deecd9df28b7a9cfd119ec90d2feeafc69a07;hpb=7c4c849d4ed533656cfa8cbf16434ed8738ff554;p=framework%2Fosp%2Fweb.git diff --git a/src/controls/FWebCtrl_WebImpl.cpp b/src/controls/FWebCtrl_WebImpl.cpp index d37deec..73f8320 100755 --- a/src/controls/FWebCtrl_WebImpl.cpp +++ b/src/controls/FWebCtrl_WebImpl.cpp @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include @@ -70,11 +69,11 @@ #include #include #include -#include #include #include #include #include +#include #include #include #include @@ -85,12 +84,13 @@ #include #include #include -#include +#include #include "FWeb_HistoryItemImpl.h" #include "FWebCtrl_AppControlListener.h" #include "FWebCtrl_AuthConfirmPopup.h" #include "FWebCtrl_AuthenticationChallengeImpl.h" #include "FWebCtrl_EflWebkit.h" +#include "FWebCtrl_FormDataWindow.h" #include "FWebCtrl_GeolocationPermissionManagerImpl.h" #include "FWebCtrl_HitElementResultImpl.h" #include "FWebCtrl_InputPickerPopup.h" @@ -104,6 +104,7 @@ #include "FWebCtrl_WebEvent.h" #include "FWebCtrl_WebEventArg.h" #include "FWebCtrl_WebImpl.h" +#include "FWebCtrl_WebManager.h" #include "FWebCtrl_WebPresenter.h" #include "FWebCtrl_WebSettingImpl.h" @@ -149,23 +150,6 @@ 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; @@ -361,26 +345,12 @@ OnScriptConfirmRequested(Evas_Object* pView, const char* pMessage, void* pUserDa _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); String msg(pMessage); - MessageBox messageBox; - r = messageBox.Construct(L"", msg, MSGBOX_STYLE_OKCANCEL); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); - - int modalResult = 0; - - messageBox.SetOwner(&pImpl->GetPublic()); - - r = messageBox.ShowAndWait(modalResult); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r)); - - if (modalResult == MSGBOX_RESULT_OK) - { - ewk_view_javascript_confirm_reply(pView, EINA_TRUE); - } - else - { - ewk_view_javascript_confirm_reply(pView, EINA_FALSE); - } + r = pImpl->ShowUserConfirmPopupAsync(USER_SCRIPT_CONFIRM, pView, msg); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + return EINA_TRUE; +CATCH: + ewk_view_javascript_confirm_reply(pView, EINA_FALSE); return EINA_TRUE; } @@ -392,22 +362,13 @@ OnScriptPromptRequested(Evas_Object* pView, const char* pMessage, const char* pD result r = E_SUCCESS; _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + String msg(pMessage); String defVal(pDefaultValue); - std::unique_ptr< _PromptPopup > pPromptPopup(new (std::nothrow) _PromptPopup()); - SysTryCatch(NID_WEB_CTRL, pPromptPopup.get(), , E_OUT_OF_MEMORY, "Memory allocation failed."); - - r = pPromptPopup->Construct(msg, defVal, pView); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - - pPromptPopup->SetOwner(&pImpl->GetPublic()); - - r = pPromptPopup->ShowPopup(); + r = pImpl->ShowPromptPopup(msg, defVal); SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - pPromptPopup.release(); - return EINA_TRUE; CATCH: @@ -424,6 +385,8 @@ OnCertificateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) Ewk_Certificate_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Certificate_Policy_Decision* >(pEventInfo); SysAssertf(pImpl && pPolicy, "Failed to request"); + _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore())); + switch (pImpl->GetSetting().GetCertificateErrorHandlingMode()) { case WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM: @@ -436,14 +399,47 @@ OnCertificateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) result r = E_SUCCESS; - r = pImpl->ShowCertificateConfirmPopup(CERTIFICATE_POPUP_MODE_USER_CONFIRM, pPolicy); + 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)); - pImpl->SetCertificateRequested(true); + pEnum = std::unique_ptr(db.QueryN(L"Select allow From " + table + L" Where pem = '" + pem + L"'")); + if (pEnum.get()) + { + r = pEnum->MoveNext(); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + int allow = 0; + r = pEnum->GetIntAt(0, allow); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SysLog(NID_WEB_CTRL, "The current value of allow is %d", allow); + + ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast < Eina_Bool >(allow)); + pImpl->SetCertificateConfirmed(static_cast < bool >(allow)); + } + else + { + 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); + } break; } case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CANCEL: -CATCH: ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE); break; case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE : @@ -452,6 +448,15 @@ CATCH: 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()); } @@ -493,6 +498,76 @@ OnHttpAuthenticationCanceled(void* pUserData, Evas_Object* pView, void* pEventIn } } +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* 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; +} + + +Eina_Bool OnLocalFileSystemQuotaExceeded(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 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; +} + void OnGeolocationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) @@ -608,7 +683,7 @@ OnNotificationShow(void* pUserData, Evas_Object* pView, void* pEventInfo) pNotificationWindow->SetText(String(text)); pNotificationWindow->LaunchNotification(); - pNotificationWindow.release(); + pImpl->SetWebNotification(pNotificationWindow.release()); ewk_notification_showed(pContext, notificationId); } @@ -734,6 +809,58 @@ OnContentHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, voi void +OnFullScreenEntered(void* pUserData, Evas_Object* pView, void* pEventInfo) +{ + _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); + bool* pIsHandleNeeded = reinterpret_cast< bool* >(pEventInfo); + SysAssertf(pImpl, "Failed to request"); + + _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore())); + SysAssertf(pWebCore, "Failed to get Web core object"); + + if (pIsHandleNeeded && *pIsHandleNeeded) + { + pWebCore->SetFullScreenEntered(true); + } +} + + +void +OnFullScreenExited(void* pUserData, Evas_Object* pView, void* pEventInfo) +{ + _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); + SysAssertf(pImpl, "Failed to request"); + + _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore())); + SysAssertf(pWebCore, "Failed to get Web core object"); + + pWebCore->SetFullScreenEntered(false); +} + + +void +OnFocusDownRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) +{ + _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); + SysAssertf(pImpl, "Failed to request"); + + _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore())); + pWebCore->SetFocusEnd(true); +} + + +void +OnFocusUpRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) +{ + _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData); + SysAssertf(pImpl, "Failed to request"); + + _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore())); + pWebCore->SetFocusEnd(true); +} + + +void OnVibrationRequested(uint64_t duration, void* pUserData) { result r = E_SUCCESS; @@ -756,15 +883,6 @@ OnVibrationCanceled(void* pUserData) } -Eina_Bool -OnApplicationCachePermissionRequested(Evas_Object* pView, Ewk_Security_Origin* pOrigin, void* pUserData) -{ - ewk_view_application_cache_permission_reply(pView, EINA_TRUE); - - return EINA_TRUE; -} - - void OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) { @@ -775,64 +893,75 @@ OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) String url(ewk_policy_decision_url_get(pPolicy)); SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls", url.GetPointer()); - if (url == L"about:blank") - { - ewk_policy_decision_use(pPolicy); - return; - } - - if (pImpl->GetLoadingListener() && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy)) + if (ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy)) && !pImpl->IsRedirectRequested()) { + _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore())); + SysAssertf(pWebCore, "Failed to get Web core object"); + + pWebCore->SetFullScreenEntered(false); + pImpl->SetCertificateRequested(false); if (pImpl->GetTextSearchListener()) { pImpl->DisableAsyncSearch(); } - - WebNavigationType navigationType = WEB_NAVIGATION_OTHER; - Ewk_Policy_Navigation_Type ewkNavigationType = ewk_policy_decision_navigation_type_get(pPolicy); - switch (ewkNavigationType) + ILoadingListener* pLoadingListener = pImpl->GetLoadingListener(); + if (pLoadingListener) { - 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); - } + WebNavigationType navigationType = WEB_NAVIGATION_OTHER; + Ewk_Policy_Navigation_Type ewkNavigationType = ewk_policy_decision_navigation_type_get(pPolicy); - if (pImpl->GetLoadingListener()->OnLoadingRequested(url, navigationType)) - { - ewk_policy_decision_ignore(pPolicy); + 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); + } - return; + if (pLoadingListener->OnLoadingRequested(url, navigationType)) + { + ewk_policy_decision_ignore(pPolicy); + + return; + } } } + if (url == L"about:blank") + { + ewk_policy_decision_use(pPolicy); + + return; + } + String currentUrl(pImpl->GetUrl()); String redirectUrl(pImpl->GetProtocolFromUri(url, currentUrl)); if (redirectUrl != L"") { - pImpl->LoadUrl(redirectUrl); ewk_policy_decision_ignore(pPolicy); + pImpl->LoadUrl(redirectUrl); + return; } @@ -840,7 +969,7 @@ OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) uri.SetUri(url); String uriScheme(uri.GetScheme()); - SysLog(NID_WEB_CTRL, "The current value of scheme is %ls", uriScheme.GetPointer()); + SysSecureLog(NID_WEB_CTRL, "The current value of scheme is %ls", uriScheme.GetPointer()); if ((uriScheme != L"http") && (uriScheme != L"https") && (uriScheme != L"file")) { @@ -853,35 +982,22 @@ OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo) result r = E_SUCCESS; - _WebEventType eventType = WEB_EVENT_REQUEST_UNKNOWN; - - if (uriScheme == L"rtsp") - { - eventType = WEB_EVENT_REQUEST_RTSP; - } - else if (uriScheme == L"mailto") + if (uriScheme == L"tel") { - eventType = WEB_EVENT_REQUEST_EMAIL; + String operationId(L"http://tizen.org/appcontrol/operation/dial"); + r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null); } - else if (uriScheme == L"tel") + else if (uriScheme == L"mailto" || uriScheme == L"sms" || uriScheme == L"smsto" || uriScheme == L"mms" || uriScheme == L"mmsto" ) { - eventType = WEB_EVENT_REQUEST_TEL; + String operationId(L"http://tizen.org/appcontrol/operation/compose"); + r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null); } - else if (uriScheme == L"sms" || uriScheme == L"smsto" ) - { - eventType = WEB_EVENT_REQUEST_SMS; - } - else if (uriScheme == L"mms" || uriScheme == L"mmsto" ) + else { - eventType = WEB_EVENT_REQUEST_MMS; + String operationId(L"http://tizen.org/appcontrol/operation/view"); + r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null); } - - std::unique_ptr<_WebEventArg> pEventArg(new _WebEventArg(eventType, url)); - 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; } @@ -975,34 +1091,49 @@ OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo) result r = 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(); - 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 (pLoadingListener && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy))) + if (ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy))) { - 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->SetRedirectRequested(true); mime = L""; } - eina_hash_foreach(pHeader, AddHttpHeaderData, &httpHeader); - SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + ILoadingListener* pLoadingListener = pImpl->GetLoadingListener(); + if (pLoadingListener) + { + HttpHeader httpHeader; + + Eina_Iterator* iterator = eina_hash_iterator_tuple_new(ewk_policy_decision_response_headers_get(pPolicy)); + if (iterator) + { + Eina_Hash_Tuple *tuple = null; + + EINA_ITERATOR_FOREACH(iterator, tuple) + { + String key(reinterpret_cast< const char* >(tuple->key)); + String value(reinterpret_cast< char* >(tuple->data)); + + SysSecureLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", key.GetPointer(), value.GetPointer()); + + r = httpHeader.AddField(key, value); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } - policy = pLoadingListener->OnWebDataReceived(mime, httpHeader); - pImpl->SetPolicyDecision(policy); + eina_iterator_free(iterator); + } + + pImpl->SetPolicyDecision(pLoadingListener->OnWebDataReceived(mime, httpHeader)); + } + else + { + pImpl->SetPolicyDecision(WEB_DECISION_CONTINUE); + } } switch (pImpl->GetPolicyDecision()) @@ -1013,92 +1144,41 @@ OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo) String redirectUrl(pImpl->GetRedirectUri(url, currentUrl, mime)); if (redirectUrl != L"") { - pImpl->LoadUrl(redirectUrl); ewk_policy_decision_ignore(pPolicy); + pImpl->LoadUrl(redirectUrl); + return; } - if (pImpl->IsMimeSupported(mime) || mime == L"") + if (ewk_policy_decision_type_get(pPolicy) == EWK_POLICY_DECISION_USE) { break; } - else { - SysLog(NID_WEB_CTRL, "Launch native app to handle the mime"); - ewk_policy_decision_ignore(pPolicy); - AppControl* pAppControl = null; - _SelectBox selectBox; - int appCount = 0; - int selectedIndex = 0; - - std::unique_ptr pList(_AppManagerImpl::FindAppControlsN(NULL, NULL, &mime, NULL)); + String operationId(L"http://tizen.org/appcontrol/operation/view"); - if (pList.get()) + 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) { - appCount = pList->GetCount(); - } - - r = selectBox.Construct(false, L"", appCount+1); //+1 for Downloader - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - - selectBox.AddListItem(L"Download", _SelectBox::LIST_ITEM_TYPE_NORMAL, false); - for (int i = 0; i < appCount; i++) - { - pAppControl = dynamic_cast< AppControl* >(pList->GetAt(i)); - SysTryReturnVoidResult(NID_WEB_CTRL, pAppControl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - - String text = pAppControl->GetAppName(); - SysLog(NID_WEB_CTRL, "AppName : %S", text.GetPointer()); + String operationId(L"http://tizen.org/appcontrol/operation/download"); - selectBox.AddListItem(text, _SelectBox::LIST_ITEM_TYPE_NORMAL, false); + r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); } - r = selectBox.ShowAndWait(selectedIndex); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - if (selectedIndex == 0) //download - { - RequestId reqId = 0; - DownloadRequest request(pUrl); + return; + } + break; + } - _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance(); - SysTryReturnVoidResult(NID_WEB_CTRL, pManagerImpl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - - r = pManagerImpl->Start(request, reqId); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - } - else if (selectedIndex != -1) // -1 for cancel - { - String path("path"); - String pathVal(pUrl); - - HashMap dataList; - r = dataList.Construct(); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - - r = dataList.Add(path, pathVal); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - - pAppControl = dynamic_cast< AppControl* >(pList->GetAt(selectedIndex)); - SysTryReturnVoidResult(NID_WEB_CTRL, pAppControl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - - _AppControlImpl* pAcImpl = _AppControlImpl::GetInstance(*pAppControl); - SysTryReturnVoidResult(NID_WEB_CTRL, pAcImpl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - - r = pAcImpl->Start(null, null, &dataList, null); - SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); - } - - return; - } - break; - } - case WEB_DECISION_DOWNLOAD: - { - ewk_policy_decision_ignore(pPolicy); + case WEB_DECISION_DOWNLOAD: + { + ewk_policy_decision_ignore(pPolicy); _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)); @@ -1106,16 +1186,18 @@ OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo) Ewk_Context* pContext = ewk_view_context_get(pView); SysAssertf(pContext, "Failed to get webkit instance."); - pDownloadHandler->StartDownload(pUrl); + pDownloadHandler->StartDownload(url); return; } + case WEB_DECISION_IGNORE: { ewk_policy_decision_ignore(pPolicy); return; } + default: { SysAssert(false); @@ -1162,19 +1244,23 @@ OnLoadingErrorOccurred(void* pUserData, Evas_Object* pView, void* pEventInfo) SysLog(NID_WEB_CTRL, "The current value of code is %d, description is %s", code, pDescription); - pImpl->SetLoadingErrorOccurred(true); switch (code) { case EWK_ERROR_CODE_FRAMELOADINTERRUPTEDBYPOLICYCHANGE: - //fall through + pImpl->SetLoadingErrorOccurred(true); + break; + case EWK_ERROR_CODE_PLUGINWILLHANDLELOAD: + evas_object_smart_callback_call(pView, "load,finished", NULL); break; case EWK_ERROR_NETWORK_STATUS_CANCELLED: + pImpl->SetLoadingErrorOccurred(true); evas_object_smart_callback_call(pView, "load,stop", NULL); break; default: + pImpl->SetLoadingErrorOccurred(true); if (pImpl->GetLoadingListener()) { result r = E_SUCCESS; @@ -1476,7 +1562,6 @@ FireWebPageBlockSelectedEventF(_WebImpl* pImpl) SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed."); pImpl->GetBlockRange(*startPoint.get(), *endPoint.get()); - 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)); @@ -1523,112 +1608,6 @@ OnWebPageBlockSelected(void* pUserData, Evas_Object* pView, void* pEventInfo) void -OnWebPageBlockSelectedByOrientation(void* pUserData, Evas_Object* pView, void* pEventInfo) -{ - _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); - SysAssertf(pImpl, "Failed to request"); - - if (!pImpl->IsOrientationChanged()) - { - return; - } - - pImpl->SetOrientationChanged(false); - - int orientation = 0; - _ControlRotation rotation = _ControlManager::GetInstance()->GetOrientationStatus(); - switch (rotation) - { - case _CONTROL_ROTATION_0: - orientation = 0; - break; - case _CONTROL_ROTATION_90: - orientation = 90; - break; - case _CONTROL_ROTATION_180: - orientation = 180; - break; - case _CONTROL_ROTATION_270: - orientation = -90; - break; - } - ewk_view_orientation_send(pView, orientation); - - OnWebPageBlockSelected(pUserData, pView, pEventInfo); -} - - -Eina_Bool -OnSelectUploadFile(Evas_Object* pView, Eina_Bool multipleFile, Eina_List* pAcceptTypes, const char* pCapture, void* pUserData) -{ - String isMultipleSelection(L"single"); - result r = E_SUCCESS; - - HashMap dataList; - String mode(L"selectionType"); - String type(L"type"); - _AppControlImpl* pMediaAppControlImpl = null; - - int itemCount = 0; - String fileType = L"all"; - - if (multipleFile) - { - isMultipleSelection.Append(L"multiple"); - } - - std::unique_ptr pMediaAppControl(_AppManagerImpl::FindAppControlN(L"tizen.filemanager", L"http://tizen.org/appcontrol/operation/pick")); - SysTryReturn(NID_WEB_CTRL, pMediaAppControl.get(), EINA_TRUE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - - std::unique_ptr<_MediaSelectionListener> pMediaListener(new (std::nothrow) _MediaSelectionListener()); - SysTryReturn(NID_WEB_CTRL, pMediaListener.get(), EINA_TRUE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - - pMediaListener->Construct(pView, pMediaAppControl.get()); - - itemCount = eina_list_count(pAcceptTypes); - - if (itemCount == 1) - { - String item((char*)eina_list_nth(pAcceptTypes, 0)); - if (item.StartsWith("image/",0)) - { - fileType = L"image"; - } - else if (item.StartsWith("audio/",0)) - { - fileType = L"audio"; - } - else if (item.StartsWith("video/",0)) - { - fileType = L"video"; - } - } - - r = dataList.Construct(); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - - r = dataList.Add(mode, isMultipleSelection); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - - r = dataList.Add(type, fileType); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - - pMediaAppControlImpl = _AppControlImpl::GetInstance(*pMediaAppControl.get()); - r = pMediaAppControlImpl->Start(null, null, &dataList, pMediaListener.get()); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - - pMediaListener.release(); - pMediaAppControl.release(); - - return EINA_TRUE; - -CATCH: - ewk_view_open_panel_reply(pView, null, EINA_FALSE); - return EINA_TRUE; -} - - -void OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo) { _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); @@ -1670,16 +1649,10 @@ OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo) return; } - _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore())); - if (pFormCore) + _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl)); + if (pFormImpl) { - if (pFormCore->HasFooter() && pFormCore->IsFooterVisible()) - { - pImpl->SetFooterVisibleState(true); - pFormCore->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, false); - } - - pFormCore->DeflateClientRectHeight(pXformer->TransformVertical(rect.height)); + pFormImpl->DeflateClientRectHeight(pXformer->TransformVertical(rect.height)); } if (pImpl->GetWebKeypadEventListener()) @@ -1696,7 +1669,7 @@ OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo) pImpl->GetWebKeypadEventListener()->OnWebKeypadWillOpen(*dynamic_cast< Web* >(&pImpl->GetPublic())); } } - pImpl->SetKeypadVisibleState(true); + pImpl->SetPreviousKeypadBounds(rect); } else @@ -1713,6 +1686,23 @@ OnWebKeypadOpened(void* pUserData, Evas_Object* pView, void* pEventInfo) _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); SysAssertf(pImpl, "Failed to request"); + pImpl->SetKeypadVisibleState(true); + + _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl)); + if (pFormImpl) + { + _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer(); + SysAssertf(pXformer, "Failed to get CoordinateTransformer"); + + pFormImpl->DeflateClientRectHeight(pXformer->TransformVertical(pImpl->GetPreviousKeypadBounds().height)); + + if (pFormImpl->HasFooter()) + { + pFormImpl->GetCore().SetKeypadShowState(true); + pFormImpl->Draw(); + } + } + if (pImpl->GetWebKeypadEventListener()) { pImpl->GetWebKeypadEventListener()->OnWebKeypadOpened(*static_cast< Web* >(&pImpl->GetPublic())); @@ -1726,16 +1716,16 @@ OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo) _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); SysAssertf(pImpl, "Failed to request"); - _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore())); - if (pFormCore) + _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl)); + if (pFormImpl) { - if (pFormCore->HasFooter() && pImpl->IsFooterVisible()) + pFormImpl->DeflateClientRectHeight(0); + + if (pFormImpl->HasFooter()) { - pImpl->SetFooterVisibleState(false); - pFormCore->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true); + pFormImpl->GetCore().SetKeypadShowState(false); + pFormImpl->Draw(); } - - pFormCore->DeflateClientRectHeight(0); } if (pImpl->GetWebKeypadEventListener()) @@ -1748,25 +1738,50 @@ OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo) void -OnWindowObjectFocusGained(void *pUserData, Evas_Object *pWin, void *pEvent_info) +OnWindowObjectFocusLost(void* pUserData, Evas_Object* pWin, void* pEvent_info) { _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); SysAssertf(pImpl, "Failed to request"); - if (pImpl->IsKeypadOpened() == true) + pImpl->SetWinFocusLost(true); +} + + +void +OnWindowObjectFocusGained(void* pUserData, Evas_Object* pWin, void* pEvent_info) +{ + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl, "Failed to request"); + + if (pImpl->IsVisible() == true && pImpl->IsFocused() == true) { _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore())); SysAssertf(pWebCore, "Failed to get Web core object"); - evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE); + if (pImpl->IsWinFocusLost() == true) + { + Ewk_Settings* pSettings = ewk_view_settings_get(pWebCore->GetWebNativeNode()); + SysAssertf(pSettings, "Failed to get settings instance."); - pImpl->SetKeypadOpened(false); + if (ewk_settings_clear_text_selection_automatically_get(pSettings) == EINA_FALSE) + { + ewk_settings_clear_text_selection_automatically_set(pSettings, EINA_TRUE); + + evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE); + } + else if (pImpl->IsKeypadOpened() == true) + { + evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE); + } + } } + + pImpl->SetWinFocusLost(false); } void -OnWebNativeNodeFocusGained(void *pUserData, Evas *pCanvas, Evas_Object* pView, void* pEventInfo) +OnWebNativeNodeFocusGained(void* pUserData, Evas* pCanvas, Evas_Object* pView, void* pEventInfo) { _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); SysAssertf(pImpl, "Failed to request"); @@ -1775,11 +1790,36 @@ OnWebNativeNodeFocusGained(void *pUserData, Evas *pCanvas, Evas_Object* pView, v { pImpl->SetKeypadOpened(false); } +} + + +void +OnWebNativeNodeFocusLost(void* pUserData, Evas* pCanvas, Evas_Object* pView, void* pEventInfo) +{ + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl, "Failed to request"); + + _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore())); + SysAssertf(pWebCore, "Failed to get Web core object"); + + Eina_Rectangle leftHandle; + Eina_Rectangle rightHandle; + + EINA_RECTANGLE_SET(&leftHandle, 0, 0, 0, 0); + EINA_RECTANGLE_SET(&rightHandle, 0, 0, 0, 0); + + if (pImpl->IsWinFocusLost() == true && ewk_view_text_selection_range_get(pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle)) + { + Ewk_Settings* pSettings = ewk_view_settings_get(pWebCore->GetWebNativeNode()); + SysAssertf(pSettings, "Failed to get settings instance."); + + ewk_settings_clear_text_selection_automatically_set(pSettings, EINA_FALSE); + } } Eina_Bool -OnColorPickerProviderRequested(Ewk_View_Smart_Data *pSmartData, int red, int green, int blue, int alpha) +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)); @@ -1806,7 +1846,7 @@ OnColorPickerProviderRequested(Ewk_View_Smart_Data *pSmartData, int red, int gre Eina_Bool -OnColorPickerProviderDismissed(Ewk_View_Smart_Data *pSmartData) +OnColorPickerProviderDismissed(Ewk_View_Smart_Data* pSmartData) { SysAssertf(pSmartData, "invalid smartdata"); @@ -1818,7 +1858,7 @@ OnColorPickerProviderDismissed(Ewk_View_Smart_Data *pSmartData) Eina_Bool -OnDatePickerProviderRequested(Ewk_View_Smart_Data *pSmartData, Ewk_Input_Type inputType, const char* inputValue) +OnDatePickerProviderRequested(Ewk_View_Smart_Data* pSmartData, Ewk_Input_Type inputType, const char* inputValue) { SysAssertf(pSmartData, "Failed to request"); _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); @@ -1848,7 +1888,7 @@ OnDatePickerProviderRequested(Ewk_View_Smart_Data *pSmartData, Ewk_Input_Type in Eina_Bool -OnSelectBoxRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex) +OnSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex) { SysAssertf(pSmartData, "Failed to request"); @@ -1863,7 +1903,22 @@ OnSelectBoxRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_T Eina_Bool -OnSelectBoxClosed(Ewk_View_Smart_Data *pSmartData) +OnMultiSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* pItems) +{ + 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 = 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; +} + + +Eina_Bool +OnSelectBoxClosed(Ewk_View_Smart_Data* pSmartData) { SysAssertf(pSmartData, "invalid smartdata"); @@ -1892,6 +1947,72 @@ OnSelectBoxUpdateRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, } +Eina_Bool +OnFormDataCandidateShow(Ewk_View_Smart_Data *pSmartData, int x, int y, int w, int h) +{ + SysAssertf(pSmartData, "Failed to request"); + + _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); + SysAssertf(pWebImpl, "Failed to get Impl"); + + 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; +} + + +Eina_Bool +OnFormDataCandidateHide(Ewk_View_Smart_Data *pSmartData) +{ + SysAssertf(pSmartData, "Failed to request"); + + _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); + SysAssertf(pWebImpl, "Failed to get Impl"); + + if (pWebImpl->IsFormDataWindowVisible()) + { + pWebImpl->HideFormDataWindow(); + } + + return EINA_TRUE; +} + + +Eina_Bool +OnFormDataCandidateUpdate(Ewk_View_Smart_Data *pSmartData, Eina_List *pDataList) +{ + SysAssertf(pSmartData, "Failed to request"); + + _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); + SysAssertf(pWebImpl, "Failed to get Impl"); + + pWebImpl->SetFormDataList(pDataList); + + return EINA_TRUE; +} + + +Eina_Bool +OnFormDataCandidateIsShowing(Ewk_View_Smart_Data *pSmartData) +{ + SysAssertf(pSmartData, "Failed to request"); + + _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL)); + SysAssertf(pWebImpl, "Failed to get Impl"); + + if (pWebImpl->IsFormDataWindowVisible()) + { + return EINA_TRUE; + } + else + { + return EINA_FALSE; + } +} + + void OnCookiesPolicyGot(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *pError, void *pUserData) { @@ -1933,7 +2054,8 @@ OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData) SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer()); _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, WEB_CTRL)); - if (pImpl && pImpl->IsPresenterAlived(pPresenter)) + _WebManager* pWebManager = _WebManager::GetInstance(); + if (pWebManager->IsValidCallback(reinterpret_cast< int >(pImpl), reinterpret_cast< int >(pPresenter))) { pPresenter->EndAsyncProcess(result); } @@ -2042,11 +2164,12 @@ _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore) , __isFooterVisible(false) , __isKeypadVisible(false) , __isKeypadOpened(false) + , __isWinFocusLost(false) , __isLoadingErrorOccurred(false) , __isRedirectRequested(false) , __isCertificateRequested(false) , __isCertificateConfirmed(false) - , __isOrientationChanged(false) + , __isFormDataVisible(false) , __keypadBounds(0, 0, 0, 0) , __pWebCore(null) , __pUserLoadingListener(null) @@ -2062,14 +2185,28 @@ _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore) , __pWebEvent(null) , __pAuthChallenge(null) , __pAuthPopup(null) - , __pUserConfirmPopup(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; @@ -2083,9 +2220,19 @@ _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore) _WebImpl::~_WebImpl() { + _WebManager* pWebManager = _WebManager::GetInstance(); + SysTryCatch(NID_WEB_CTRL, pWebManager, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + pWebManager->RemoveWeb(reinterpret_cast< int >(this)); + pWebManager->RemoveActiveWeb(this); + +CATCH: RemoveEventListenerCallback(); + + ClearCertificateDb(); } + _WebImpl* _WebImpl::CreateWebImplN(Web* pControl, const Rectangle& bounds) { @@ -2159,7 +2306,7 @@ _WebImpl::Construct(void) r = __textSearch.__searchQueue.Construct(); SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - r = __callbackList.Construct(); + r = __webNotificationList.Construct(); SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); r = InitJsBridgeList(); @@ -2185,7 +2332,6 @@ _WebImpl::InitializeSetting(void) SetCookieEnabled(pWebSettingImpl->IsCookieEnabled()); SetPrivateBrowsingEnabled(pWebSettingImpl->IsPrivateBrowsingEnabled()); - SetZoomLevel(pWebSettingImpl->GetZoomLevel()); __defaultUserAgent = pWebSettingImpl->GetUserAgent(); @@ -2364,8 +2510,6 @@ _WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List* __pSelectBox = std::move(pSelectBox); - __pSelectBox->SetOwner(&GetPublic()); - return __pSelectBox->ShowPopup(); } @@ -2386,6 +2530,8 @@ _WebImpl::ClearSelectBoxPopup(void) __pSelectBox.reset(); + Resume(); + return E_SUCCESS; } @@ -2466,47 +2612,33 @@ _WebImpl::StopLoading(void) const void _WebImpl::Reload(void) const { - ewk_view_reload_bypass_cache(__pWebCore->GetWebNativeNode()); + ewk_view_reload(__pWebCore->GetWebNativeNode()); } String* _WebImpl::EvaluateJavascriptN(const String& scriptCode) { - if (scriptCode.GetLength() == 0) + Evas_Object* pView = __pWebCore->GetWebNativeNode(); + if (!pView) { return null; } - result r = E_SUCCESS; - std::unique_ptr pScript(_StringConverter::CopyToCharArrayN(scriptCode)); SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter()); + 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)); - r = __callbackList.Add(pPresenter.get()); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); - - ewk_view_script_execute(__pWebCore->GetWebNativeNode(), pScript.get(), OnScriptExecuted, pPresenter.get()); + ewk_view_script_execute(pView, pScript.get(), OnScriptExecuted, pPresenter.get()); - 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)); - pPresenter->WaitAsyncProcess(*pResult.get()); - - r = __callbackList.Remove(*pPresenter.get()); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); - pPresenter.release(); - - return pResult.release(); -} + String* pResult = new (std::nothrow) String(L""); + SysTryReturn(NID_WEB_CTRL, pResult, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + pPresenter->WaitAsyncProcess(*pResult); -bool -_WebImpl::IsPresenterAlived(_WebPresenter* pPresenter) const -{ - return __callbackList.Contains(*pPresenter); + return pResult; } @@ -2531,6 +2663,12 @@ _WebImpl::GetZoomLevel(void) const const PageNavigationList* _WebImpl::GetBackForwardListN(void) const { + Evas_Object* pView = __pWebCore->GetWebNativeNode(); + if (!pView) + { + return null; + } + result r = E_SUCCESS; _PageNavigationListImpl* pNavigationListImpl = null; @@ -2545,7 +2683,7 @@ _WebImpl::GetBackForwardListN(void) const String url(L""); String title(L""); - Ewk_History* pEwkHistoryList = ewk_view_history_get(__pWebCore->GetWebNativeNode()); + 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)); Ewk_History_Item* pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, 0); @@ -2605,6 +2743,12 @@ CATCH: bool _WebImpl::SearchText(const String& text, bool searchForward) { + Evas_Object* pView = __pWebCore->GetWebNativeNode(); + if (!pView) + { + return false; + } + result r = E_SUCCESS; Ewk_Find_Options condition = static_cast< Ewk_Find_Options >(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE); @@ -2614,14 +2758,14 @@ _WebImpl::SearchText(const String& text, bool searchForward) condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS); } - _WebPresenter presenter; - presenter.InitAsyncProcess(); + 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, __pWebCore->GetWebNativeNode(), condition, text, searchForward, false, &presenter); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + r = SynchronizeSearch(SEARCH_SYNC, pView, condition, text, searchForward, false, pPresenter.get()); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); int result = 0; - presenter.WaitAsyncProcess(result); + pPresenter->WaitAsyncProcess(result); return static_cast < bool >(result); } @@ -2630,6 +2774,12 @@ _WebImpl::SearchText(const String& text, bool searchForward) result _WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive) { + Evas_Object* pView = __pWebCore->GetWebNativeNode(); + if (!pView) + { + return E_SUCCESS; + } + result r = E_SUCCESS; Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT; @@ -2639,7 +2789,7 @@ _WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive condition = static_cast (condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE); } - r = SynchronizeSearch(SEARCH_ALL_ASYNC, __pWebCore->GetWebNativeNode(), condition, text, true, caseSensitive); + r = SynchronizeSearch(SEARCH_ALL_ASYNC, pView, condition, text, true, caseSensitive); SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); return E_SUCCESS; @@ -2649,6 +2799,12 @@ _WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive 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."); @@ -2657,7 +2813,7 @@ _WebImpl::SearchNextAsync(bool searchForward) Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT; - if (__textSearch.__caseSensitive) + if (!__textSearch.__caseSensitive) { condition = static_cast (condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE); } @@ -2667,7 +2823,7 @@ _WebImpl::SearchNextAsync(bool searchForward) condition = static_cast (condition | EWK_FIND_OPTIONS_BACKWARDS); } - r = SynchronizeSearch(SEARCH_NEXT_ASYNC, __pWebCore->GetWebNativeNode(), condition, __textSearch.__text, searchForward); + 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; @@ -2884,6 +3040,12 @@ _WebImpl::GetElementByPointN(const Point& point) const const HitElementResult* _WebImpl::GetElementByPointN(const FloatPoint& point) const { + 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; @@ -2896,7 +3058,7 @@ _WebImpl::GetElementByPointN(const FloatPoint& point) const Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(point))); - Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(__pWebCore->GetWebNativeNode(), absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL); + Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL); SysTryReturn(NID_WEB_CTRL, pEwkHitTest, null, E_SYSTEM, "[%s] Failed to get hit test.", GetErrorMessage(E_SYSTEM)); Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest); @@ -3053,7 +3215,6 @@ void _WebImpl::ClearCache(void) { Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode()); - SysAssertf(pContext, "Failed to get webkit instance."); ewk_context_cache_clear(pContext); } @@ -3064,7 +3225,6 @@ _WebImpl::ClearCookie(void) { 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."); ewk_cookie_manager_cookies_clear(pCookieManager); } @@ -3074,7 +3234,6 @@ void _WebImpl::ClearFormData(void) { Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode()); - SysAssertf(pContext, "Failed to get webkit instance."); ewk_context_form_candidate_data_clear(pContext); } @@ -3084,7 +3243,6 @@ void _WebImpl::ClearLoginFormData(void) { Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode()); - SysAssertf(pContext, "Failed to get webkit instance."); ewk_context_form_password_data_clear(pContext); } @@ -3102,13 +3260,13 @@ _WebImpl::IsCookieEnabled(void) const Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext); SysAssertf(pCookieManager, "Failed to get webkit instance."); - _WebPresenter presenter; - presenter.InitAsyncProcess(); + std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this)); + SysTryReturn(NID_WEB_CTRL, pPresenter.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, &presenter); + ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, pPresenter.get()); bool result = false; - presenter.WaitAsyncProcess(result); + pPresenter->WaitAsyncProcess(result); return result; } @@ -3388,6 +3546,7 @@ _WebImpl::SetEventListenerCallback(void) const 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; @@ -3395,6 +3554,11 @@ _WebImpl::SetEventListenerCallback(void) const pSmart->input_picker_color_request = OnColorPickerProviderRequested; pSmart->input_picker_color_dismiss = OnColorPickerProviderDismissed; + pSmart->formdata_candidate_show = OnFormDataCandidateShow; + pSmart->formdata_candidate_hide = OnFormDataCandidateHide; + pSmart->formdata_candidate_update_data = OnFormDataCandidateUpdate; + pSmart->formdata_candidate_is_showing = OnFormDataCandidateIsShowing; + evas_object_data_set(pWebNativeNode, WEB_CTRL, this); // add loading event callbacks for ILoadingListener @@ -3414,6 +3578,7 @@ _WebImpl::SetEventListenerCallback(void) const evas_object_smart_callback_add(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest, this); evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, this); + evas_object_smart_callback_add(pWinObject, "focus,out", OnWindowObjectFocusLost, this); evas_object_smart_callback_add(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged, this); evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened, this); @@ -3450,17 +3615,26 @@ _WebImpl::SetEventListenerCallback(void) const 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,style,state", OnWebPageBlockSelected, this); - evas_object_smart_callback_add(pWebNativeNode, "frame,rendered", OnWebPageBlockSelectedByOrientation, this); + evas_object_smart_callback_add(pWebNativeNode, "magnifier,hide", OnWebPageBlockSelected, this); + + evas_object_smart_callback_add(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered, this); + evas_object_smart_callback_add(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited, this); + + evas_object_smart_callback_add(pWebNativeNode, "keyevent,down,not,handled", OnFocusDownRequested, this); + evas_object_smart_callback_add(pWebNativeNode, "keyevent,up,not,handled", OnFocusUpRequested, 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)); evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this); + evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_OUT, OnWebNativeNodeFocusLost, this); } } @@ -3488,10 +3662,12 @@ _WebImpl::RemoveEventListenerCallback(void) const 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, "load,committed", OnLoadingCommitted); evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest); evas_object_smart_callback_del_full(pWinObject, "focus,in", OnWindowObjectFocusGained, this); + evas_object_smart_callback_del_full(pWinObject, "focus,out", OnWindowObjectFocusLost, this); evas_object_smart_callback_del(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged); evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened); @@ -3502,9 +3678,9 @@ _WebImpl::RemoveEventListenerCallback(void) const evas_object_smart_callback_del(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested); - 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); + ewk_view_javascript_alert_callback_set(pWebNativeNode, null, null); + ewk_view_javascript_prompt_callback_set(pWebNativeNode, null, null); + ewk_view_javascript_confirm_callback_set(pWebNativeNode, null, null); evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived); @@ -3528,20 +3704,55 @@ _WebImpl::RemoveEventListenerCallback(void) const evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered); evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived); - evas_object_smart_callback_del(pWebNativeNode, "text,style,state", OnWebPageBlockSelected); - evas_object_smart_callback_del(pWebNativeNode, "frame,rendered", OnWebPageBlockSelectedByOrientation); + evas_object_smart_callback_del(pWebNativeNode, "magnifier,hide", OnWebPageBlockSelected); + + evas_object_smart_callback_del(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered); + evas_object_smart_callback_del(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited); + + evas_object_smart_callback_del(pWebNativeNode, "keyevent,down,not,handled", OnFocusDownRequested); + evas_object_smart_callback_del(pWebNativeNode, "keyevent,up,not,handled", OnFocusUpRequested); - ewk_view_open_panel_callback_set(null, null, null); Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode); SysAssertf(pContext, "Failed to get webkit instance."); ewk_context_vibration_client_callbacks_set(pContext, null, null, null); + ewk_view_application_cache_permission_callback_set(pWebNativeNode, null, null); + ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, null, null); + ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, null, null); + ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, null, null); evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained); + evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_OUT, OnWebNativeNodeFocusLost); } } +void +_WebImpl::ClearCertificateDb(void) +{ + result r = E_SUCCESS; + + String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME); + String table(CERTIFICATE_TABLE_NAME); + _DatabaseImpl db; + + r = db.Construct(certificatePath, "r+", null); + SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + db.BeginTransaction(); + + r = db.ExecuteSql(L"Delete From " + table, true); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + db.CommitTransaction(); + + return; + +CATCH: + db.RollbackTransaction(); +} + + result _WebImpl::SetBlockSelectionPosition(const Point& startPoint) { @@ -3552,35 +3763,32 @@ _WebImpl::SetBlockSelectionPosition(const Point& startPoint) result _WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint) { - Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode(); - - Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode); - SysAssertf(pSmartData, "Failed to request"); + Evas_Object* pWebview = __pWebCore->GetWebNativeNode(); + if (!pWebview) + { + return E_SUCCESS; + } - Point absPoint( _CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(startPoint))); + Ewk_View_Smart_Data* pSmartData = reinterpret_cast< Ewk_View_Smart_Data* >(evas_object_smart_data_get(pWebview)); + SysAssertf(pSmartData && pSmartData->api, "Failed to get webkit instance."); + Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(startPoint))); Eina_Bool ret = pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y); if (ret) { pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y); - Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(__pWebCore->GetWebNativeNode(), absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL); + Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pWebview, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL); SysTryReturnResult(NID_WEB_CTRL, pEwkHitTest, E_SYSTEM, "Failed to get hit test."); String tagName(ewk_hit_test_tag_name_get(pEwkHitTest)); - if (tagName.Equals(L"INPUT", false) || tagName.Equals(L"TEXTAREA", false)) - { - ewk_view_command_execute(pWebNativeNode, "SelectWord", 0); - } - else + Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest); + char* pValue = reinterpret_cast< char* >(eina_hash_find(pAttrHash, "contenteditable")); + if (tagName.Equals(L"INPUT", false) || tagName.Equals(L"TEXTAREA", false) || pValue) { - 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(pWebNativeNode, "SelectWord", 0); - } + ewk_view_command_execute(pWebview, "SelectWord", 0); + evas_object_smart_callback_call(pWebview, "magnifier,hide", NULL); } } @@ -3616,6 +3824,9 @@ _WebImpl::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const Eina_Rectangle leftHandle; Eina_Rectangle rightHandle; + EINA_RECTANGLE_SET(&leftHandle, 0, 0, 0, 0); + EINA_RECTANGLE_SET(&rightHandle, 0, 0, 0, 0); + ewk_view_text_selection_range_get(__pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle); startPoint.x = _CoordinateSystemUtils::ConvertToFloat(leftHandle.x); @@ -3637,18 +3848,9 @@ _WebImpl::GetFaviconN(void) const result r = E_SUCCESS; Evas_Object* pView = __pWebCore->GetWebNativeNode(); - - Evas* pEvas = evas_object_evas_get(pView); Ewk_Context* pContext = ewk_view_context_get(pView); - SysAssertf(pEvas && pContext, "Failed to request"); - const char* pUrl = ewk_view_url_get(pView); - - Tizen::Graphics::BufferInfo bufferInfo; - Tizen::Base::ByteBuffer byteBuffer; - - std::unique_ptr pBitmapImage(new (std::nothrow) Bitmap()); - SysTryReturn(NID_WEB_CTRL, pBitmapImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + Evas* pEvas = evas_object_evas_get(pView); Evas_Object* pFavicon = ewk_context_icon_database_icon_object_add(pContext, pUrl, pEvas); if (!pFavicon) @@ -3656,18 +3858,24 @@ _WebImpl::GetFaviconN(void) const return null; } + 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)); - r = pBitmapImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888); + 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)); - return pBitmapImage.release(); + return pImage.release(); } @@ -3711,6 +3919,36 @@ _WebImpl::GetPageSize(void) const } +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."); + + std::unique_ptr pName(_StringConverter::CopyToCharArrayN(name)); + SysTryReturn(NID_WEB_CTRL, pName.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + std::unique_ptr pValue(_StringConverter::CopyToCharArrayN(value)); + + ewk_view_custom_header_add(__pWebCore->GetWebNativeNode(), pName.get(), pValue.get()); + + return E_SUCCESS; +} + + +result +_WebImpl::RemoveHttpHeaderField(const String& name) +{ + SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing."); + + std::unique_ptr pName(_StringConverter::CopyToCharArrayN(name)); + SysTryReturn(NID_WEB_CTRL, pName.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + ewk_view_custom_header_remove(__pWebCore->GetWebNativeNode(), pName.get()); + + return E_SUCCESS; +} + + void _WebImpl::SetLoadingErrorOccurred(bool arg) { @@ -3767,93 +4005,17 @@ _WebImpl::IsCertificateRequested(void) const } -bool -_WebImpl::IsCertificateConfirmed(void) const -{ - return __isCertificateConfirmed; -} - - void -_WebImpl::SetOrientationChanged(bool arg) +_WebImpl::SetCertificateConfirmed(bool arg) { - __isOrientationChanged = arg; + __isCertificateConfirmed = arg; } bool -_WebImpl::IsOrientationChanged(void) const -{ - return __isOrientationChanged; -} - - -result -_WebImpl::LaunchAppControl(const IEventArg& arg) +_WebImpl::IsCertificateConfirmed(void) const { - result r = E_SUCCESS; - - IEventArg* pArg = const_cast< IEventArg* >(&arg); - _WebEventArg* pWebEventArg = dynamic_cast< _WebEventArg* >(pArg); - SysTryReturnResult(NID_WEB_CTRL, pWebEventArg, E_INVALID_ARG, "Type casting failed. argument must be IEventArg type."); - - String operationId(L""); - String uriPattern(pWebEventArg->GetEventMessage()); - SysLog(NID_WEB_CTRL, "The current value of web event type is %d", pWebEventArg->GetEventType()); - - switch (pWebEventArg->GetEventType()) - { - case WEB_EVENT_REQUEST_RTSP: - { - String ext; - String mimeType; - int uriLength = uriPattern.GetLength(); - int index; - - operationId = L"http://tizen.org/appcontrol/operation/view"; - - r = uriPattern.LastIndexOf(L".", uriLength - 1, index); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - - r = uriPattern.SubString(index + 1, ext); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - - r = _AppControlManager::GetMimeFromExt(ext, mimeType); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - - r = _AppControlImpl::FindAndStart(operationId, &uriPattern, &mimeType, null, null, null); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - - return r; - } - case WEB_EVENT_REQUEST_TEL: - { - operationId = L"http://tizen.org/appcontrol/operation/dial"; - break; - } - case WEB_EVENT_REQUEST_EMAIL: - //fall through - case WEB_EVENT_REQUEST_SMS: - //fall through - case WEB_EVENT_REQUEST_MMS: - { - operationId = L"http://tizen.org/appcontrol/operation/compose"; - break; - } - case WEB_EVENT_REQUEST_UNKNOWN: - { - operationId = L"http://tizen.org/appcontrol/operation/view"; - break; - } - default: - SysAssert(false); - break; - } - - r = _AppControlImpl::FindAndStart(operationId, &uriPattern, null, null, null, null); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - - return r; + return __isCertificateConfirmed; } @@ -3935,6 +4097,20 @@ _WebImpl::SetKeypadOpened(bool isKeypadOpened) } +bool +_WebImpl::IsWinFocusLost(void) const +{ + return __isWinFocusLost; +} + + +void +_WebImpl::SetWinFocusLost(bool isWinFocusLost) +{ + __isWinFocusLost = isWinFocusLost; +} + + Rectangle _WebImpl::GetPreviousKeypadBounds(void) const { @@ -4374,13 +4550,14 @@ _WebImpl::ShowAuthenticationPopup(const String& host, const String& realm, Authe int modalResult = 0; - __pAuthPopup->SetOwner(&GetPublic()); - r = __pAuthPopup->ShowAndWait(modalResult); SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); CATCH: - __pAuthPopup.reset(); + if (__pAuthPopup) + { + __pAuthPopup.reset(); + } return r; } @@ -4401,48 +4578,151 @@ _WebImpl::ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk int modalResult = 0; - __pCertConfirmPopup->SetOwner(&GetPublic()); - r = __pCertConfirmPopup->ShowAndWait(modalResult); SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - if (userConfirmMode == CERTIFICATE_POPUP_MODE_USER_CONFIRM) + if (__pCertConfirmPopup.get() && userConfirmMode == CERTIFICATE_POPUP_MODE_USER_CONFIRM) { __isCertificateConfirmed = __pCertConfirmPopup->GetConfirmResult(); } CATCH: - __pCertConfirmPopup.reset(); + if (__pCertConfirmPopup.get()) + { + __pCertConfirmPopup.reset(); + } return r; } + result -_WebImpl::ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy) +_WebImpl::ShowPromptPopup(String msg, String defVal) { result r = E_SUCCESS; - std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup()); - SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed."); + std::unique_ptr< _PromptPopup > pPromptPopup(new (std::nothrow) _PromptPopup()); + SysTryReturnResult(NID_WEB_CTRL, pPromptPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed."); - r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, true); + r = pPromptPopup->Construct(msg, defVal, __pWebCore->GetWebNativeNode(), this); SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - __pUserConfirmPopup = std::move(pUserConfirmPopup); - - int modalResult = 0; + __pPromptPopup = std::move(pPromptPopup); - __pUserConfirmPopup->SetOwner(&GetPublic()); - - r = __pUserConfirmPopup->ShowAndWait(modalResult); + r = __pPromptPopup->ShowPopup(); SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - + + return E_SUCCESS; + CATCH: - __pUserConfirmPopup.reset(); + __pPromptPopup.reset(); return r; + +} + + +result +_WebImpl::ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy, String msg) +{ + result r = E_SUCCESS; + + std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup()); + SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed."); + + r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, this, true, msg); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + int modalResult = 0; + + switch(userConfirmMode) + { + case USER_CONTENT_HANDLER: + { + __pContentHandlerConfirmPopup = std::move(pUserConfirmPopup); + + r = __pContentHandlerConfirmPopup->ShowAndWait(modalResult); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pContentHandlerConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r)); + + __pContentHandlerConfirmPopup.reset(); + + ewk_view_resume(__pWebCore->GetWebNativeNode()); + + break; + } + case USER_PROTOCOL_HANDLER: + { + __pProtocolHandlerConfirmPopup = std::move(pUserConfirmPopup); + + r = __pProtocolHandlerConfirmPopup->ShowAndWait(modalResult); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pProtocolHandlerConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r)); + + __pProtocolHandlerConfirmPopup.reset(); + + ewk_view_resume(__pWebCore->GetWebNativeNode()); + + break; + } + case USER_CONFIRM_APP_CACHE: + { + __pAppCacheConfirmPopup = std::move(pUserConfirmPopup); + + r = __pAppCacheConfirmPopup->ShowAndWait(modalResult); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pAppCacheConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r)); + + __pAppCacheConfirmPopup.reset(); + + ewk_view_resume(__pWebCore->GetWebNativeNode()); + + break; + } + case USER_CONFIRM_DB_QUOTA_EXCEDED: + { + __pDbQuotaConfirmPopup = std::move(pUserConfirmPopup); + + r = __pDbQuotaConfirmPopup->ShowAndWait(modalResult); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pDbQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r)); + + __pDbQuotaConfirmPopup.reset(); + + ewk_view_resume(__pWebCore->GetWebNativeNode()); + + break; + } + case USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED: + { + __pLocalFsQuotaConfirmPopup = std::move(pUserConfirmPopup); + + r = __pLocalFsQuotaConfirmPopup->ShowAndWait(modalResult); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pLocalFsQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r)); + + __pLocalFsQuotaConfirmPopup.reset(); + + ewk_view_resume(__pWebCore->GetWebNativeNode()); + + break; + } + case USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED: + { + __pIndexedDbQuotaConfirmPopup = std::move(pUserConfirmPopup); + + r = __pIndexedDbQuotaConfirmPopup->ShowAndWait(modalResult); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pIndexedDbQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r)); + + __pIndexedDbQuotaConfirmPopup.reset(); + + ewk_view_resume(__pWebCore->GetWebNativeNode()); + + break; + } + default: + break; + } +CATCH: + return r; } + result _WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy, String msg) { @@ -4451,69 +4731,121 @@ _WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPol std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup()); SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed."); - r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, false, msg); + r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, this, false, msg); SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - __pUserConfirmPopup = std::move(pUserConfirmPopup); + switch(userConfirmMode) + { + case USER_CONFIRM_USERMEDIA: + { + __pUserMediaConfirmPopup.reset(); + + __pUserMediaConfirmPopup = std::move(pUserConfirmPopup); - __pUserConfirmPopup->SetOwner(&GetPublic()); + r = __pUserMediaConfirmPopup->ShowPopup(); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pUserMediaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r)); - r = __pUserConfirmPopup->ShowPopup(); - SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + break; + } + case USER_CONFIRM_GEOLOCATION: + { + __pGeolocationConfirmPopup.reset(); + + __pGeolocationConfirmPopup = std::move(pUserConfirmPopup); - __pUserConfirmPopup.release(); + r = __pGeolocationConfirmPopup->ShowPopup(); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pGeolocationConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r)); + + break; + } + case USER_CONFIRM_NOTIFICATION: + { + __pNotificationConfirmPopup.reset(); + + __pNotificationConfirmPopup = std::move(pUserConfirmPopup); + + r = __pNotificationConfirmPopup->ShowPopup(); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pNotificationConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r)); + + break; + } + case USER_SCRIPT_ALERT: + { + __pScriptAlertConfirmPopup.reset(); + + __pScriptAlertConfirmPopup = std::move(pUserConfirmPopup); + + r = __pScriptAlertConfirmPopup->ShowPopup(); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pScriptAlertConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r)); + + break; + } + case USER_SCRIPT_CONFIRM: + { + __pScriptConfirmPopup.reset(); + + __pScriptConfirmPopup = std::move(pUserConfirmPopup); + + r = __pScriptConfirmPopup->ShowPopup(); + SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pScriptConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r)); + + break; + } + default: + break; + } return E_SUCCESS; CATCH: - __pUserConfirmPopup.reset(); - return r; } -_Form* -_WebImpl::GetParentFormCore(_Control* pControlCore) +_FormImpl* +_WebImpl::GetParentFormImpl(_ControlImpl* pControlImpl) { String parentName; - _Form* pFormCore = null; + _FormImpl* pFormImpl = null; - _Control* pParentControlCore = dynamic_cast< _Control* >(pControlCore->GetParent()); - if (!pParentControlCore) + _ControlImpl* pParentControlImpl = dynamic_cast< _ControlImpl* >(pControlImpl->GetParent()); + if (!pParentControlImpl) { return null; } - pFormCore = dynamic_cast< _Form* >(pParentControlCore); - if (pFormCore) + pFormImpl = dynamic_cast< _FormImpl* >(pParentControlImpl); + if (pFormImpl) { - return pFormCore; + return pFormImpl; } - return GetParentFormCore(pParentControlCore); + return GetParentFormImpl(pParentControlImpl); } bool _WebImpl::OnFocusGained(const _ControlImpl& source) { - return true; + return false; } bool _WebImpl::OnFocusLost(const _ControlImpl& source) { + Evas_Object* pWebview = __pWebCore->GetWebNativeNode(); + if (!pWebview) + { + return false; + } + if(IsKeypadVisible() == true) { SetKeypadOpened(true); - - SetKeypadVisibleState(false); } - evas_object_focus_set(__pWebCore->GetWebNativeNode(), EINA_FALSE); - - return true; + return false; } @@ -4534,13 +4866,44 @@ _WebImpl::OnPreAttachedToMainTree(void) { result r = E_SUCCESS; - r = __pWebCore->InitializeWebNativeNode(); - SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + if (IsVisible() == true) + { + _WebManager* pWebManager = _WebManager::GetInstance(); + pWebManager->SetActiveWeb(this); + } - r = InitializeSetting(); + r = _ContainerImpl::OnPreAttachedToMainTree(); SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - r = _ContainerImpl::OnPreAttachedToMainTree(); + if (!HasValidNativeNode()) + { + r = __pWebCore->InitializeWebNativeNode(); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturnResult(NID_WEB_CTRL, pControlManager, E_SYSTEM, "Failed to get the ControlManager instance."); + OnChangeLayout(pControlManager->GetScreenRotation()); + + r = InitializeSetting(); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _WebManager* pWebManager = _WebManager::GetInstance(); + pWebManager->AddWeb(reinterpret_cast< int >(this)); + } + + return E_SUCCESS; +} + + +result +_WebImpl::OnDetachingFromMainTree(void) +{ + result r = E_SUCCESS; + + _WebManager* pWebManager = _WebManager::GetInstance(); + pWebManager->RemoveActiveWeb(this); + + r = _ContainerImpl::OnDetachingFromMainTree(); SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); return E_SUCCESS; @@ -4548,6 +4911,32 @@ _WebImpl::OnPreAttachedToMainTree(void) void +_WebImpl::OnChangeLayout(_ControlRotation rotation) +{ + int degree = 0; + + switch (rotation) + { + case _CONTROL_ROTATION_0: + degree = 0; + break; + case _CONTROL_ROTATION_90: + degree = 90; + break; + case _CONTROL_ROTATION_180: + degree = 180; + break; + case _CONTROL_ROTATION_270: + degree = -90; + break; + default: + SysAssert(false); + } + ewk_view_orientation_send(__pWebCore->GetWebNativeNode(), degree); +} + + +void _WebImpl::OnChangeLayout(_ControlOrientation orientation) { _ContainerImpl::OnChangeLayout(orientation); @@ -4557,24 +4946,81 @@ _WebImpl::OnChangeLayout(_ControlOrientation orientation) __pColorPicker->ChangeLayout(orientation); } - __isOrientationChanged = true; + HideFormDataWindow(); + + std::unique_ptr< IEnumerator > pEnum(__webNotificationList.GetEnumeratorN()); + _WebNotification* pWebNotification = null; + + while (pEnum->MoveNext() == E_SUCCESS) + { + pWebNotification = static_cast< _WebNotification* >(pEnum->GetCurrent()); + pWebNotification->OnChangeLayout(); + } + + if (IsKeypadVisible()) + { + _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer(); + SysAssertf(pXformer, "Failed to get CoordinateTransformer"); + + _FormImpl* pFormImpl = GetParentFormImpl(dynamic_cast< _ControlImpl* >(this)); + pFormImpl->DeflateClientRectHeight(pXformer->TransformVertical(GetPreviousKeypadBounds().height)); + } } void _WebImpl::OnAncestorVisibleStateChanged(const _Control& control) { + _WebManager* pWebManager = _WebManager::GetInstance(); if (IsVisible() == true) { + pWebManager->SetActiveWeb(this); ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_VISIBLE, false); } else { + pWebManager->RemoveActiveWeb(this); ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_HIDDEN, false); } } +void +_WebImpl::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs) +{ + _ContainerImpl::OnUserEventReceivedN(requestId, pArgs); + + switch (requestId) + { + case ID_CERTIFICATE_CONFIRM_POPUP_CLOSE: + __pCertConfirmPopup.reset(); + break; + case ID_PROMPT_POPUP_CLOSE: + __pPromptPopup.reset(); + break; + case ID_USER_CONFIRM_USERMEDIA_CLOSE: + __pUserMediaConfirmPopup.reset(); + break; + case ID_USER_CONFIRM_GEOLOCATION_CLOSE: + __pGeolocationConfirmPopup.reset(); + break; + case ID_USER_CONFIRM_NOTIFICATION_CLOSE: + __pNotificationConfirmPopup.reset(); + break; + case ID_USER_SCRIPT_ALERT_CLOSE: + __pScriptAlertConfirmPopup.reset(); + break; + case ID_USER_SCRIPT_CONFIRM_CLOSE: + __pScriptConfirmPopup.reset(); + break; + default: + break; + } + + Resume(); +} + + _WebDataHandler* _WebImpl::GetDownloadHandler(void) const { @@ -4587,6 +5033,8 @@ _WebImpl::HideColorPicker(void) { __pColorPicker.reset(); + Resume(); + return EINA_TRUE; } @@ -4609,12 +5057,17 @@ _WebImpl::ShowColorPicker(int red, int green, int blue, int alpha, Color& color) r = __pColorPicker->ShowPopup(); SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - color = __pColorPicker->GetColor(); - - return E_SUCCESS; + if (__pColorPicker) + { + color = __pColorPicker->GetColor(); + } CATCH: - __pColorPicker.reset(); + if (__pColorPicker) + { + __pColorPicker.reset(); + Resume(); + } return r; } @@ -4636,10 +5089,17 @@ _WebImpl::ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue, Strin r = __pDatePicker->ShowPopup(); SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - dateStr = __pDatePicker->GetDate(); + if (__pDatePicker) + { + dateStr = __pDatePicker->GetDate(); + } CATCH: - __pDatePicker.reset(); + if (__pDatePicker) + { + __pDatePicker.reset(); + Resume(); + } return r; } @@ -4893,4 +5353,78 @@ _WebImpl::GetRedirectUri(const Tizen::Base::String& originUri, const Tizen::Base } +void +_WebImpl::SetFormDataList(Eina_List* pFormDataList) +{ + __pFormDataList = pFormDataList; +} + + +bool +_WebImpl::IsFormDataWindowVisible(void) const +{ + return __isFormDataVisible; +} + + +result +_WebImpl::ShowFormDataWindow(const Rectangle& windowRect, Evas_Object* pWebView) +{ + Rectangle rect(_CoordinateSystemUtils::InverseTransform(Rectangle(windowRect.x, windowRect.y + windowRect.height, windowRect.width, windowRect.height))); + + if (__isFormDataVisible) + { + result r = __pFormDataWindow->UpdateList(__pFormDataList, rect); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + __pFormDataWindow.reset(); + + std::unique_ptr<_FormDataWindow> pFormDataWindow( new (std::nothrow) _FormDataWindow()); + SysTryReturnResult(NID_WEB_CTRL, pFormDataWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + result r = pFormDataWindow->Construct(rect, this, pWebView); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pFormDataWindow->UpdateList(__pFormDataList, rect); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pFormDataWindow->LaunchFormDataWindow(); + SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pFormDataWindow = std::move(pFormDataWindow); + __isFormDataVisible = true; + } + + return E_SUCCESS; +} + + +void +_WebImpl::HideFormDataWindow(bool delWindow) +{ + if (delWindow) + { + __pFormDataWindow.reset(); + } + + __isFormDataVisible = false; +} + + +void +_WebImpl::ClearWebNotification(_WebNotification* pWebNotification) +{ + __webNotificationList.Remove(*pWebNotification); +} + + +void +_WebImpl::SetWebNotification(_WebNotification* pWebNotification) +{ + __webNotificationList.Add(pWebNotification); +} + + }}} // Tizen::Web::Controls