2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FWebCtrl_WebImpl.cpp
20 * @brief The file contains the definition of _WebImpl class.
22 * The file contains the definition of _WebImpl class.
24 #include <Ecore_IMF_Evas.h>
25 #include <Ecore_Evas.h>
26 #include <elm_config.h>
29 #include <ewk_popup_menu_item.h>
30 #include <libsoup/soup-status.h>
32 #include <FAppAppControl.h>
33 #include <FAppIAppControlListener.h>
34 #include <FBaseColAllElementsDeleter.h>
35 #include <FBaseColHashMapT.h>
36 #include <FBaseRtMutex.h>
37 #include <FBaseRtMutexGuard.h>
38 #include <FBaseSysLog.h>
39 #include <FBaseUtilUri.h>
40 #include <FCntDownloadRequest.h>
41 #include <FGrpColor.h>
42 #include <FGrpPoint.h>
43 #include <FGrpRectangle.h>
44 #include <FIoDbEnumerator.h>
45 #include <FIoDbStatement.h>
47 #include <FMediaImage.h>
48 #include <FMediaImageTypes.h>
49 #include <FNetHttpHttpHeader.h>
50 #include <FSysVibrator.h>
51 #include <FUiControl.h>
52 #include <FUiCtrlKeypad.h>
53 #include <FWebCtrlHitElementResult.h>
54 #include <FWebCtrlITextSearchListener.h>
55 #include <FWebCtrlIWebDownloadListener.h>
56 #include <FWebCtrlIWebUiEventListener.h>
57 #include <FWebCtrlIWebUiEventListenerF.h>
58 #include <FWebCtrlIWebKeypadEventListener.h>
59 #include <FWebCtrlIJavaScriptBridge.h>
60 #include <FWebCtrlPageNavigationList.h>
61 #include <FWebCtrlAuthenticationChallenge.h>
62 #include <FWebCtrlWeb.h>
63 #include <FWebCtrlWebSetting.h>
64 #include <FWebHistoryItem.h>
65 #include <FWebJsonJsonObject.h>
66 #include <FWebJsonJsonParser.h>
67 #include <FWebJsonJsonString.h>
68 #include <FApp_AppControlImpl.h>
69 #include <FApp_AppControlManager.h>
70 #include <FApp_AppInfo.h>
71 #include <FApp_AppManagerImpl.h>
72 #include <FBase_StringConverter.h>
73 #include <FCnt_DownloadManagerImpl.h>
74 #include <FCnt_ContentManagerImpl.h>
75 #include <FGrp_CoordinateSystem.h>
76 #include <FGrp_Screen.h>
77 #include <FIo_DatabaseImpl.h>
78 #include <FIo_NormalFile.h>
79 #include <FSys_SystemResource.h>
80 #include <FSys_VibratorImpl.h>
81 #include <FUi_Control.h>
82 #include <FUi_CoordinateSystemUtils.h>
83 #include <FUi_EcoreEvasMgr.h>
84 #include <FUi_EcoreEvas.h>
85 #include <FUi_ResourceSizeInfo.h>
86 #include <FUi_Window.h>
87 #include <FUiAnim_EflNode.h>
88 #include <FUiAnim_VisualElement.h>
89 #include <FUiCtrl_FooterImpl.h>
90 #include <FUiCtrl_FormImpl.h>
91 #include "FWeb_HistoryItemImpl.h"
92 #include "FWebCtrl_AppControlListener.h"
93 #include "FWebCtrl_AuthConfirmPopup.h"
94 #include "FWebCtrl_AuthenticationChallengeImpl.h"
95 #include "FWebCtrl_EflWebkit.h"
96 #include "FWebCtrl_FormDataWindow.h"
97 #include "FWebCtrl_GeolocationPermissionManagerImpl.h"
98 #include "FWebCtrl_HitElementResultImpl.h"
99 #include "FWebCtrl_InputPickerPopup.h"
100 #include "FWebCtrl_WebNotification.h"
101 #include "FWebCtrl_PageNavigationListImpl.h"
102 #include "FWebCtrl_PromptPopup.h"
103 #include "FWebCtrl_SelectBox.h"
104 #include "FWebCtrl_Utility.h"
105 #include "FWebCtrl_Web.h"
106 #include "FWebCtrl_WebDataHandler.h"
107 #include "FWebCtrl_WebEvent.h"
108 #include "FWebCtrl_WebEventArg.h"
109 #include "FWebCtrl_WebImpl.h"
110 #include "FWebCtrl_WebManager.h"
111 #include "FWebCtrl_WebPresenter.h"
112 #include "FWebCtrl_WebSettingImpl.h"
115 using namespace Tizen::App;
116 using namespace Tizen::Base;
117 using namespace Tizen::Base::Collection;
118 using namespace Tizen::Base::Runtime;
119 using namespace Tizen::Base::Utility;
120 using namespace Tizen::Content;
121 using namespace Tizen::Graphics;
122 using namespace Tizen::Io;
123 using namespace Tizen::Media;
124 using namespace Tizen::Net::Http;
125 using namespace Tizen::System;
126 using namespace Tizen::Ui;
127 using namespace Tizen::Ui::Animations;
128 using namespace Tizen::Ui::Controls;
129 using namespace Tizen::Web::Json;
132 namespace Tizen { namespace Web { namespace Controls
136 static const char WEB_CTRL[] = "webcontrol";
137 static const char PARENT_WEB_CTRL[] = "parentwebcontrol";
140 static const float MIN_ZOOM_LEVEL = 0.3;
141 static const float MAX_ZOOM_LEVEL = 2;
144 static const int REDIRECTION_HEADER_GROUP = 300;
147 static const int MAX_TEXT_MATCH = pow(2, 31) - 1;
150 static const int PORTRAIT_KEYPAD_HEIGHT = 444;
151 static const int LANDSCAPE_KEYPAD_HEIGHT = 316;
152 static const int DEFAULT_LIST_ITEM_COUNT = 4;
156 AddHttpHeaderData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData)
158 result r = E_SUCCESS;
160 String key(reinterpret_cast< const char* >(pKey));
161 String value(reinterpret_cast< char* >(pValue));
163 SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", key.GetPointer(), value.GetPointer());
165 r = reinterpret_cast< HttpHeader* >(pUserData)->AddField(key, value);
166 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
173 AddHttpAttributeData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData)
175 result r = E_SUCCESS;
177 std::unique_ptr<String> pAttrKey(new (std::nothrow) String(reinterpret_cast< char* >(const_cast< void* >(pKey))));
178 std::unique_ptr<String> pAttrValue(new (std::nothrow) String(reinterpret_cast< char* >(pValue)));
179 SysTryReturn(NID_WEB_CTRL, pAttrKey.get() && pAttrValue.get(), EINA_FALSE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
181 SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", pAttrKey->GetPointer(), pAttrValue->GetPointer());
183 r = reinterpret_cast< HashMap* >(pUserData)->Add(*pAttrKey, *pAttrValue);
184 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
186 pAttrValue.release();
193 FreeCharArray(void* pData)
195 delete[] reinterpret_cast<char*>(pData);
200 ConvertErrorCode(int error)
202 LoadingErrorType errorCode = WEB_ERROR_UNKNOWN;
206 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
208 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE:
210 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE_PROXY:
212 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT:
214 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT_PROXY:
216 case EWK_ERROR_NETWORK_STATUS_IO_ERROR:
218 case EWK_ERROR_NETWORK_STATUS_MALFORMED:
220 case EWK_ERROR_NETWORK_STATUS_TRY_AGAIN:
222 case EWK_ERROR_NETWORK_STATUS_TOO_MANY_REDIRECTS:
224 case EWK_ERROR_NETWORK_STATUS_TLS_FAILED:
226 case EWK_ERROR_NETWORK_STATUS_INTERNAL_SERVER_ERROR:
228 case EWK_ERROR_NETWORK_STATUS_BAD_GATEWAY:
230 case EWK_ERROR_NETWORK_STATUS_SERVICE_UNAVAILABLE:
232 case EWK_ERROR_NETWORK_STATUS_GATEWAY_TIMEOUT:
233 errorCode = WEB_NO_CONNECTION;
236 case EWK_ERROR_NETWORK_STATUS_BAD_REQUEST:
238 case EWK_ERROR_NETWORK_STATUS_REQUEST_URI_TOO_LONG:
239 errorCode = WEB_BAD_URL;
242 case EWK_ERROR_NETWORK_STATUS_FORBIDDEN:
243 errorCode = WEB_FILE_ACCESS_FAILED;
246 case EWK_ERROR_NETWORK_STATUS_REQUEST_TIMEOUT:
247 errorCode = WEB_REQUEST_TIMEOUT;
250 case EWK_ERROR_NETWORK_STATUS_UNSUPPORTED_MEDIA_TYPE:
251 errorCode = WEB_MIME_NOT_SUPPORTED;
254 case EWK_ERROR_NETWORK_STATUS_INSUFFICIENT_STORAGE:
255 errorCode = WEB_OUT_OF_MEMORY;
258 case EWK_ERROR_NETWORK_STATUS_REQUEST_ENTITY_TOO_LARGE:
259 errorCode = WEB_REQUEST_MAX_EXCEEDED;
262 case EWK_ERROR_NETWORK_STATUS_CONTINUE:
264 case EWK_ERROR_NETWORK_STATUS_SWITCHING_PROTOCOLS:
266 case EWK_ERROR_NETWORK_STATUS_PROCESSING:
268 case EWK_ERROR_NETWORK_STATUS_OK:
270 case EWK_ERROR_NETWORK_STATUS_CREATED:
272 case EWK_ERROR_NETWORK_STATUS_ACCEPTED:
274 case EWK_ERROR_NETWORK_STATUS_NON_AUTHORITATIVE:
276 case EWK_ERROR_NETWORK_STATUS_NO_CONTENT:
278 case EWK_ERROR_NETWORK_STATUS_RESET_CONTENT:
280 case EWK_ERROR_NETWORK_STATUS_PARTIAL_CONTENT:
282 case EWK_ERROR_NETWORK_STATUS_MULTI_STATUS:
284 case EWK_ERROR_NETWORK_STATUS_MULTIPLE_CHOICES:
286 case EWK_ERROR_NETWORK_STATUS_MOVED_PERMANENTLY:
288 case EWK_ERROR_NETWORK_STATUS_FOUND:
290 case EWK_ERROR_NETWORK_STATUS_SEE_OTHER:
292 case EWK_ERROR_NETWORK_STATUS_NOT_MODIFIED:
294 case EWK_ERROR_NETWORK_STATUS_USE_PROXY:
296 case EWK_ERROR_NETWORK_STATUS_NOT_APPEARING_IN_THIS_PROTOCOL:
298 case EWK_ERROR_NETWORK_STATUS_TEMPORARY_REDIRECT:
299 errorCode = WEB_HTTP_RESPONSE;
302 case EWK_ERROR_NETWORK_STATUS_SSL_FAILED:
303 errorCode = WEB_INVALID_CERTIFICATE;
307 errorCode = WEB_ERROR_UNKNOWN;
316 FireLoadingErrorOccurredEvent(_WebImpl* pImpl, int code, const char* pDescription)
318 result r = E_SUCCESS;
320 std::unique_ptr<Integer> pErrorCode(new (std::nothrow) Integer(code));
321 std::unique_ptr<String> pErrorDescription(new (std::nothrow) String(pDescription));
322 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED));
323 SysTryReturnResult(NID_WEB_CTRL, pErrorCode.get() && pErrorDescription.get() && pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
325 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_TYPE, *pErrorCode.get());
326 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
327 pErrorCode.release();
329 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_MESSAGE, *pErrorDescription.get());
330 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
331 pErrorDescription.release();
333 r = pImpl->GetWebEvent()->FireAsync(*pEventArg);
334 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
342 OnScriptAlertRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
344 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
346 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
347 String msg(pMessage);
349 result r = pImpl->ShowUserConfirmPopupAsync(USER_SCRIPT_ALERT, pView, msg);
350 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
354 ewk_view_javascript_alert_reply(pView);
360 OnScriptConfirmRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
362 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
364 result r = E_SUCCESS;
365 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
366 String msg(pMessage);
368 r = pImpl->ShowUserConfirmPopupAsync(USER_SCRIPT_CONFIRM, pView, msg);
369 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
373 ewk_view_javascript_confirm_reply(pView, EINA_FALSE);
379 OnScriptPromptRequested(Evas_Object* pView, const char* pMessage, const char* pDefaultValue, void* pUserData)
381 SysLog(NID_WEB_CTRL, "The current value of message is %s, defaulValue is %s", pMessage, pDefaultValue);
383 result r = E_SUCCESS;
384 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
386 String msg(pMessage);
387 String defVal(pDefaultValue);
389 r = pImpl->ShowPromptPopup(msg, defVal);
390 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
395 ewk_view_javascript_prompt_reply(pView, null);
402 OnCertificateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
404 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
405 Ewk_Certificate_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Certificate_Policy_Decision* >(pEventInfo);
406 SysAssertf(pImpl && pPolicy, "Failed to request");
408 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
410 switch (pImpl->GetSetting().GetCertificateErrorHandlingMode())
412 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM:
414 if (pImpl->IsCertificateRequested())
416 ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast< Eina_Bool >(pImpl->IsCertificateConfirmed()));
420 result r = E_SUCCESS;
422 std::unique_ptr<DbEnumerator> pEnum;
424 String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
425 String table(CERTIFICATE_TABLE_NAME);
428 String pem(ewk_certificate_policy_decision_certificate_pem_get(pPolicy));
430 r = db.Construct(certificatePath, "r", null);
431 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
433 pEnum = std::unique_ptr<DbEnumerator>(db.QueryN(L"Select allow From " + table + L" Where pem = '" + pem + L"'"));
436 r = pEnum->MoveNext();
437 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
440 r = pEnum->GetIntAt(0, allow);
441 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
443 SysLog(NID_WEB_CTRL, "The current value of allow is %d", allow);
445 ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast < Eina_Bool >(allow));
446 pImpl->SetCertificateConfirmed(static_cast < bool >(allow));
450 r = pImpl->ShowCertificateConfirmPopup(CERTIFICATE_POPUP_MODE_USER_CONFIRM, pPolicy);
451 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
453 ewk_view_resume(pWebCore->GetWebNativeNode());
458 pImpl->SetCertificateRequested(true);
462 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CANCEL:
463 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE);
465 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE :
466 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_TRUE);
475 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE);
476 pImpl->SetCertificateConfirmed(false);
477 pImpl->SetCertificateRequested(true);
479 ewk_view_resume(pWebCore->GetWebNativeNode());
484 OnHttpAuthenticationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
486 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
487 Ewk_Auth_Challenge* pChallenge = reinterpret_cast< Ewk_Auth_Challenge* >(pEventInfo);
488 SysAssertf(pImpl && pChallenge, "Failed to request");
490 result r = E_SUCCESS;
492 r = pImpl->HttpAuthenticationRequested(pChallenge);
493 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
497 ewk_auth_challenge_credential_cancel(pChallenge);
498 evas_object_smart_callback_call(pView, "authentication,canceled", NULL);
503 OnHttpAuthenticationCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
505 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
506 SysAssertf(pImpl , "Failed to request");
508 if (pImpl->GetLoadingListener())
510 result r = E_SUCCESS;
512 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED));
513 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
515 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
516 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
522 OnApplicationCachePermissionRequested(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, void* pUserData)
524 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
525 SysAssertf(pImpl , "Failed to request");
527 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
529 result r = msg.Format(256, L"Allow %s to use offline application cache?", pHostName);
530 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
532 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_APP_CACHE, pView, msg);
533 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
540 OnIndexedDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData)
542 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
543 SysAssertf(pImpl , "Failed to request");
545 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
547 result r = msg.Format(512, L"%s Used %lld of storage. Allow %s to use upto 2GB of indexed db?", pHostName, currentQuota, pHostName);
548 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
550 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED, pView, msg);
551 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
558 OnDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, const char* database_name, unsigned long long expectedQuota, void* pUserData)
560 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
561 SysAssertf(pImpl , "Failed to request");
563 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
565 result r = msg.Format(512, L"Allow %s to open %s use upto %lld of web database?", pHostName, database_name, expectedQuota);
566 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
568 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_DB_QUOTA_EXCEDED, pView, msg);
569 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
575 Eina_Bool OnLocalFileSystemQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData)
577 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
578 SysAssertf(pImpl , "Failed to request");
580 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
582 result r = msg.Format(512, L"%s Used %lld of storgae. Allow %s to use upto 2GB of file system?", pHostName, currentQuota, pHostName);
583 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
585 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED, pView, msg);
586 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
593 OnGeolocationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
595 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
596 Ewk_Geolocation_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Geolocation_Permission_Request* >(pEventInfo);
597 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
599 if (pImpl->GetSetting().IsGeolocationEnabled())
601 result r = E_SUCCESS;
603 std::unique_ptr<DbEnumerator> pEnum;
605 String geolocationPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
606 String table(GEOLOCATION_TABLE_NAME);
609 const Ewk_Security_Origin* pSecurityOrigin = ewk_geolocation_permission_request_origin_get(pPermissionRequest);
610 String origin = _Utility::CreateOrigin(pSecurityOrigin);
612 r = db.Construct(geolocationPath, "r", null);
613 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
615 pEnum = std::unique_ptr<DbEnumerator>(db.QueryN(L"Select permission From " + table + L" Where origin = '" + origin + L"'"));
618 r = pEnum->MoveNext();
619 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
622 r = pEnum->GetIntAt(0, permission);
623 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
625 SysLog(NID_WEB_CTRL, "The current value of permission is %d", permission);
627 ewk_geolocation_permission_request_set(pPermissionRequest, static_cast < Eina_Bool >(permission));
631 ewk_geolocation_permission_request_suspend(pPermissionRequest);
633 r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_GEOLOCATION, pPermissionRequest);
634 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
641 ewk_geolocation_permission_request_set(pPermissionRequest, EINA_FALSE);
646 OnGetUserMediaPermissionRequsted(void* pUserData, Evas_Object* pView, void* pEventInfo)
648 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
649 Ewk_User_Media_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_User_Media_Permission_Request* >(pEventInfo);
650 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
652 result r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_USERMEDIA, pEventInfo);
653 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
657 ewk_user_media_permission_request_set(pPermissionRequest, EINA_FALSE);
662 OnNotificationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
664 result r = E_SUCCESS;
665 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
667 Ewk_Notification_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Notification_Permission_Request* >(pEventInfo);
668 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
670 ewk_notification_permission_request_suspend(pPermissionRequest);
672 r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_NOTIFICATION, pPermissionRequest);
673 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
677 ewk_notification_permission_request_set(pPermissionRequest, EINA_FALSE);
682 OnNotificationShow(void* pUserData, Evas_Object* pView, void* pEventInfo)
684 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
685 Ewk_Notification* pNotification = reinterpret_cast< Ewk_Notification* >(pEventInfo);
686 SysAssertf(pImpl && pNotification, "Failed to request");
688 result r = E_SUCCESS;
689 Ewk_Context* pContext = ewk_view_context_get(pView);
690 SysAssertf(pContext, "Failed to get webkit instance.");
691 uint64_t notificationId = ewk_notification_id_get(pNotification);
693 //ewk_notification_security_origin_get(pNotification)
695 const char* text = ewk_notification_body_get(pNotification);
696 SysSecureLog(NID_WEB_CTRL, "The current value of icon path is %s",ewk_notification_icon_url_get(pNotification));
698 std::unique_ptr<_WebNotification> pNotificationWindow( new (std::nothrow) _WebNotification());
699 SysTryReturnVoidResult(NID_WEB_CTRL, pNotificationWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
701 r = pNotificationWindow->Construct(pContext, notificationId, pImpl);
702 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Error propogated.", GetErrorMessage(r));
704 pNotificationWindow->SetText(String(text));
705 pNotificationWindow->LaunchNotification();
706 pImpl->SetWebNotification(pNotificationWindow.release());
708 ewk_notification_showed(pContext, notificationId);
713 OnNotificationCancel(void* pUserData, Evas_Object* pView, void* pEventInfo)
715 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
716 uint64_t* pNotificationID = reinterpret_cast< uint64_t* >(pEventInfo);
717 SysAssertf(pImpl && pNotificationID, "Failed to request");
719 //ToDo : Where is ewk API for cancel operation?
724 OnProtocolHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
726 result r = E_SUCCESS;
727 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
728 SysAssertf(pImpl, "Failed to request");
730 r = pImpl->ShowUserConfirmPopup(USER_PROTOCOL_HANDLER, pEventInfo);
731 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
736 OnIsProtocolHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
738 int checkHandler = 0;
739 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
740 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
741 SysAssertf(pImpl && pHandlerData, "Failed to request");
743 checkHandler = pImpl->SearchHandler(pHandlerData, false);
744 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
745 switch (checkHandler)
750 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
753 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
756 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
764 OnProtocolHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
766 result r = E_SUCCESS;
767 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
768 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
769 SysAssertf(pImpl && pHandlerData, "Failed to request");
771 r = pImpl->UnregistrationHandler(pHandlerData, false);
772 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
777 OnContentHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
779 result r = E_SUCCESS;
780 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
781 SysAssertf(pImpl, "Failed to request");
783 r = pImpl->ShowUserConfirmPopup(USER_CONTENT_HANDLER, pEventInfo);
784 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
789 OnIsContentHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
791 int checkHandler = 0;
792 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
793 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
794 SysAssertf(pImpl && pHandlerData, "Failed to request");
796 checkHandler = pImpl->SearchHandler(pHandlerData, true);
797 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
799 switch (checkHandler)
804 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
807 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
810 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
819 OnContentHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
821 result r = E_SUCCESS;
822 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
823 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
824 SysAssertf(pImpl && pHandlerData, "Failed to request");
826 r = pImpl->UnregistrationHandler(pHandlerData, true);
827 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
832 OnFullScreenEntered(void* pUserData, Evas_Object* pView, void* pEventInfo)
834 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
835 bool* pIsHandleNeeded = reinterpret_cast< bool* >(pEventInfo);
836 SysAssertf(pImpl, "Failed to request");
838 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
839 SysAssertf(pWebCore, "Failed to get Web core object");
841 if (pIsHandleNeeded && *pIsHandleNeeded)
843 pWebCore->SetFullScreenEntered(true);
849 OnFullScreenExited(void* pUserData, Evas_Object* pView, void* pEventInfo)
851 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
852 SysAssertf(pImpl, "Failed to request");
854 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
855 SysAssertf(pWebCore, "Failed to get Web core object");
857 pWebCore->SetFullScreenEntered(false);
862 OnVibrationRequested(uint64_t duration, void* pUserData)
864 result r = E_SUCCESS;
866 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
867 SysAssertf(pImpl, "Failed to request");
869 r = pImpl->VibrationRequested(duration);
870 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
875 OnVibrationCanceled(void* pUserData)
877 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
878 SysAssertf(pImpl, "Failed to request");
880 pImpl->VibrationCanceled();
885 OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
887 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
888 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
889 SysAssertf(pImpl && pPolicy, "Failed to request");
891 String url(ewk_policy_decision_url_get(pPolicy));
892 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls", url.GetPointer());
894 if (url == L"about:blank")
896 ewk_policy_decision_use(pPolicy);
900 if (pImpl->GetLoadingListener() && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy))
901 && !pImpl->IsRedirectRequested())
903 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
904 SysAssertf(pWebCore, "Failed to get Web core object");
906 pWebCore->SetFullScreenEntered(false);
908 pImpl->SetCertificateRequested(false);
910 if (pImpl->GetTextSearchListener())
912 pImpl->DisableAsyncSearch();
915 WebNavigationType navigationType = WEB_NAVIGATION_OTHER;
916 Ewk_Policy_Navigation_Type ewkNavigationType = ewk_policy_decision_navigation_type_get(pPolicy);
918 switch (ewkNavigationType)
920 case EWK_POLICY_NAVIGATION_TYPE_LINK_CLICKED:
921 navigationType = WEB_NAVIGATION_LINK_CLICKED;
923 case EWK_POLICY_NAVIGATION_TYPE_FORM_SUBMITTED:
924 navigationType = WEB_NAVIGATION_FORM_SUBMITTED;
926 case EWK_POLICY_NAVIGATION_TYPE_BACK_FORWARD:
927 navigationType = WEB_NAVIGATION_BACKFORWARD;
929 case EWK_POLICY_NAVIGATION_TYPE_RELOAD:
930 navigationType = WEB_NAVIGATION_RELOAD;
932 case EWK_POLICY_NAVIGATION_TYPE_FORM_RESUBMITTED:
933 navigationType = WEB_NAVIGATION_FORM_RESUBMITTED;
935 case EWK_POLICY_NAVIGATION_TYPE_OTHER:
936 navigationType = WEB_NAVIGATION_OTHER;
942 if (pImpl->GetLoadingListener()->OnLoadingRequested(url, navigationType))
944 ewk_policy_decision_ignore(pPolicy);
950 String currentUrl(pImpl->GetUrl());
951 String redirectUrl(pImpl->GetProtocolFromUri(url, currentUrl));
952 if (redirectUrl != L"")
954 pImpl->LoadUrl(redirectUrl);
955 ewk_policy_decision_ignore(pPolicy);
963 String uriScheme(uri.GetScheme());
964 SysLog(NID_WEB_CTRL, "The current value of scheme is %ls", uriScheme.GetPointer());
966 if ((uriScheme != L"http") && (uriScheme != L"https") && (uriScheme != L"file"))
968 ewk_policy_decision_ignore(pPolicy);
970 if (uriScheme == L"")
975 result r = E_SUCCESS;
977 if (uriScheme == L"tel")
979 String operationId(L"http://tizen.org/appcontrol/operation/dial");
980 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
982 else if (uriScheme == L"mailto" || uriScheme == L"sms" || uriScheme == L"smsto" || uriScheme == L"mms" || uriScheme == L"mmsto" )
984 String operationId(L"http://tizen.org/appcontrol/operation/compose");
985 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
989 String operationId(L"http://tizen.org/appcontrol/operation/view");
990 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
992 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
997 ewk_policy_decision_use(pPolicy);
1002 OnLoadingStarted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1004 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1005 SysAssertf(pImpl, "Failed to request");
1007 if (pImpl->GetLoadingListener())
1009 result r = E_SUCCESS;
1011 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_STARTED));
1012 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1014 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1015 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1016 pEventArg.release();
1022 OnPageTitleReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1024 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1025 char* pTitle = reinterpret_cast< char* >(pEventInfo);
1026 SysAssertf(pImpl, "Failed to request");
1028 SysLog(NID_WEB_CTRL, "The current value of title is %s", pTitle);
1030 if (pImpl->GetLoadingListener())
1032 result r = E_SUCCESS;
1034 std::unique_ptr<String> pPageTitle(new (std::nothrow) String(pTitle));
1035 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED));
1036 SysTryReturnVoidResult(NID_WEB_CTRL, pPageTitle.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1038 r = pEventArg->SetEventInfo(_LoadingEventArg::PAGE_TITLE, *pPageTitle.get());
1039 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1040 pPageTitle.release();
1042 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1043 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1044 pEventArg.release();
1050 OnEstimatedProgress(void* pUserData, Evas_Object* pView, void* pEventInfo)
1052 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1053 double* pProgress = reinterpret_cast< double* >(pEventInfo);
1054 SysAssertf(pImpl, "Failed to request");
1056 SysLog(NID_WEB_CTRL, "The current value of progress is %lf", *pProgress);
1058 if (pImpl->GetLoadingListener())
1060 result r = E_SUCCESS;
1062 std::unique_ptr<Integer> pProgressPercentage(new (std::nothrow) Integer(static_cast< int >(*pProgress * 100)));
1063 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PROGRESS));
1064 SysTryReturnVoidResult(NID_WEB_CTRL, pProgressPercentage.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1066 r = pEventArg->SetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS, *pProgressPercentage.get());
1067 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1068 pProgressPercentage.release();
1070 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1071 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1072 pEventArg.release();
1078 OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1080 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1081 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
1082 SysAssertf(pImpl && pPolicy, "Failed to request");
1084 result r = E_SUCCESS;
1086 _SystemResource* pSysResource = _SystemResource::GetInstance();
1087 SysAssertf(pSysResource != null, "Failed to get _SystemResource instance");
1089 const char* pUrl = ewk_policy_decision_url_get(pPolicy);
1090 int code = ewk_policy_decision_response_status_code_get(pPolicy);
1091 String mime(ewk_policy_decision_response_mime_get(pPolicy));
1092 SysSecureLog(NID_WEB_CTRL, "url : %s, mime : %ls, code : %d", pUrl, mime.GetPointer(), code);
1094 ILoadingListener* pLoadingListener = pImpl->GetLoadingListener();
1096 String url(ewk_policy_decision_url_get(pPolicy));
1098 if (pLoadingListener && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy)))
1100 const Eina_Hash* pHeader = ewk_policy_decision_response_headers_get(pPolicy);
1102 DecisionPolicy policy;
1103 HttpHeader httpHeader;
1105 if (code >= REDIRECTION_HEADER_GROUP && code < REDIRECTION_HEADER_GROUP + 100)
1107 pImpl->SetRedirectRequested(true);
1111 eina_hash_foreach(pHeader, AddHttpHeaderData, &httpHeader);
1112 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1114 policy = pLoadingListener->OnWebDataReceived(mime, httpHeader);
1115 pImpl->SetPolicyDecision(policy);
1118 switch (pImpl->GetPolicyDecision())
1120 case WEB_DECISION_CONTINUE:
1122 String currentUrl(pImpl->GetUrl());
1123 String redirectUrl(pImpl->GetRedirectUri(url, currentUrl, mime));
1124 if (redirectUrl != L"")
1126 pImpl->LoadUrl(redirectUrl);
1127 ewk_policy_decision_ignore(pPolicy);
1132 if (pImpl->IsMimeSupported(mime) || mime == L"")
1139 ewk_policy_decision_ignore(pPolicy);
1141 String operationId(L"http://tizen.org/appcontrol/operation/view");
1143 r = _AppControlImpl::FindAndStart(operationId, &url, &mime, null, null, null);
1144 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS || r == E_OBJ_NOT_FOUND, r, "[%s] Propagating.", GetErrorMessage(r));
1146 if (r == E_OBJ_NOT_FOUND)
1148 _SelectBox* pSelectBox = new (std::nothrow) _SelectBox;
1149 SysTryReturnVoidResult(NID_WEB_CTRL, pSelectBox, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1151 r = pSelectBox->Construct(false, L"Select application", 1, null, url);
1152 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1154 pSelectBox->AddListItem(pSysResource->GetString(_RESOURCE_DOMAIN_ID_OSP, "IDS_BR_BODY_DOWNLOAD"), _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
1155 r = pSelectBox->ShowPopup();
1156 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1163 case WEB_DECISION_DOWNLOAD:
1165 ewk_policy_decision_ignore(pPolicy);
1167 _WebDataHandler* pDownloadHandler = pImpl->GetDownloadHandler();
1168 SysTryReturnVoidResult(NID_WEB_CTRL, pDownloadHandler, E_SYSTEM, "[%s] A system error has been occurred. Failed to get DownloadHandler.", GetErrorMessage(E_SYSTEM));
1170 Ewk_Context* pContext = ewk_view_context_get(pView);
1171 SysAssertf(pContext, "Failed to get webkit instance.");
1173 pDownloadHandler->StartDownload(pUrl);
1177 case WEB_DECISION_IGNORE:
1179 ewk_policy_decision_ignore(pPolicy);
1189 ewk_policy_decision_use(pPolicy);
1194 ewk_policy_decision_ignore(pPolicy);
1199 OnProgressCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1201 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1202 SysAssertf(pImpl, "Failed to request");
1204 if (pImpl->IsRedirectRequested())
1206 pImpl->SetRedirectRequested(false);
1209 if (pImpl->IsLoadingErrorOccurred())
1211 pImpl->SetLoadingErrorOccurred(false);
1212 evas_object_smart_callback_call(pView, "load,finished", NULL);
1218 OnLoadingErrorOccurred(void* pUserData, Evas_Object* pView, void* pEventInfo)
1220 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1221 Ewk_Error* pErrorData = reinterpret_cast< Ewk_Error* >(pEventInfo);
1222 SysAssertf(pImpl && pErrorData, "Failed to request");
1224 int code = ewk_error_code_get(pErrorData);
1225 const char* pDescription = ewk_error_description_get(pErrorData);
1227 SysLog(NID_WEB_CTRL, "The current value of code is %d, description is %s", code, pDescription);
1231 case EWK_ERROR_CODE_FRAMELOADINTERRUPTEDBYPOLICYCHANGE:
1232 pImpl->SetLoadingErrorOccurred(true);
1235 case EWK_ERROR_CODE_PLUGINWILLHANDLELOAD:
1236 evas_object_smart_callback_call(pView, "load,finished", NULL);
1239 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
1240 pImpl->SetLoadingErrorOccurred(true);
1241 evas_object_smart_callback_call(pView, "load,stop", NULL);
1245 pImpl->SetLoadingErrorOccurred(true);
1246 if (pImpl->GetLoadingListener())
1248 result r = E_SUCCESS;
1250 r = FireLoadingErrorOccurredEvent(pImpl, code, pDescription);
1251 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1259 OnLoadingCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
1261 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1262 SysAssertf(pImpl, "Failed to request");
1264 if (pImpl->GetLoadingListener())
1266 result r = E_SUCCESS;
1268 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_CANCELED));
1269 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1271 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1272 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1273 pEventArg.release();
1280 OnLoadingCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1282 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1283 SysAssertf(pImpl, "Failed to request");
1285 if (pImpl->GetLoadingListener())
1287 result r = E_SUCCESS;
1289 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_COMPLETED));
1290 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1292 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1293 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1294 pEventArg.release();
1301 OnFaviconReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1303 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1304 SysAssertf(pImpl, "Failed to request");
1306 if (pImpl->GetLoadingListener())
1308 result r = E_SUCCESS;
1310 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED));
1311 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1313 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1314 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1315 pEventArg.release();
1322 OnDidStartDownloadCallback(const char* pUrl, void* pUserData)
1324 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1325 SysAssertf(pUrl && pImpl != null, "Failed to request");
1327 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s", pUrl);
1332 FireWebPageShowRequestedEvent(_WebImpl* pImpl, int event)
1334 result r = E_SUCCESS;
1336 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1337 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1339 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1340 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1341 pEventArg.release();
1348 OnWebPageShowRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1350 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1351 SysAssertf(pImpl, "Failed to request");
1353 if (pImpl->GetUiEventListener())
1355 result r = E_SUCCESS;
1357 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED);
1358 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1360 if (pImpl->GetUiEventListenerF())
1362 result r = E_SUCCESS;
1364 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT);
1365 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1371 OnWebWindowCreateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1373 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(pUserData);
1374 Evas_Object** pChildView = reinterpret_cast< Evas_Object** >(pEventInfo);
1375 SysAssertf(pParentImpl && pChildView, "Failed to request");
1377 IWebUiEventListener* pUserUiListener = pParentImpl->GetUiEventListener();
1378 IWebUiEventListenerF* pUserUiListenerF = pParentImpl->GetUiEventListenerF();
1379 if (pUserUiListener)
1381 Web* pWeb = pUserUiListener->OnWebWindowCreateRequested();
1384 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1385 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1387 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1388 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1391 if (pUserUiListenerF)
1393 Web* pWeb = pUserUiListenerF->OnWebWindowCreateRequested();
1396 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1397 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1399 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1400 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1407 FireWebWindowClosedRequestedEvent(_WebImpl* pImpl, int event)
1409 result r = E_SUCCESS;
1411 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1412 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1414 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1415 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1416 pEventArg.release();
1423 OnWebWindowClosedRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1425 _WebImpl* pChildImpl = reinterpret_cast< _WebImpl* >(pUserData);
1426 SysAssertf(pChildImpl, "Failed to request");
1428 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, PARENT_WEB_CTRL));
1429 if (pParentImpl == null)
1434 if (pParentImpl->GetUiEventListener())
1436 result r = E_SUCCESS;
1438 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED);
1439 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1441 if (pParentImpl->GetUiEventListenerF())
1443 result r = E_SUCCESS;
1445 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT);
1446 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1452 FireWebPreventDefaultTriggeredEvent(_WebImpl* pImpl, int event, bool trigger)
1454 result r = E_SUCCESS;
1456 std::unique_ptr<Boolean> pPreventTrigger(new (std::nothrow) Boolean(trigger));
1457 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1458 SysTryReturnResult(NID_WEB_CTRL, pPreventTrigger.get() && pEventArg.get(), E_OUT_OF_MEMORY, " Memory allocation failed." );
1460 r = pEventArg->SetEventInfo(_WebUiEventArg::PREVENT_DEFAULT, *pPreventTrigger.get());
1461 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1462 pPreventTrigger.release();
1464 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1465 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1466 pEventArg.release();
1473 OnWebPreventDefaultTriggered(void* pUserData, Evas_Object* pView, void* pEventInfo)
1475 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1476 Eina_Bool* pTrigger = reinterpret_cast< Eina_Bool* >(pEventInfo);
1477 SysAssertf(pImpl && pTrigger, "Failed to request");
1479 if (pImpl->GetUiEventListener())
1481 result r = E_SUCCESS;
1483 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED, static_cast< bool >(*pTrigger));
1484 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1486 if (pImpl->GetUiEventListenerF())
1488 result r = E_SUCCESS;
1490 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT, static_cast< bool >(*pTrigger));
1491 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1497 FireWebPageBlockSelectedEvent(_WebImpl* pImpl)
1499 result r = E_SUCCESS;
1501 std::unique_ptr<Point> startPoint(new (std::nothrow) Point());
1502 std::unique_ptr<Point> endPoint(new (std::nothrow) Point());
1503 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1505 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1507 if ((endPoint->x != 0) && (endPoint->y != 0))
1509 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED));
1510 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1512 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1513 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1514 startPoint.release();
1516 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1517 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1520 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1521 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1522 pEventArg.release();
1530 FireWebPageBlockSelectedEventF(_WebImpl* pImpl)
1532 result r = E_SUCCESS;
1534 std::unique_ptr<FloatPoint> startPoint(new (std::nothrow) FloatPoint());
1535 std::unique_ptr<FloatPoint> endPoint(new (std::nothrow) FloatPoint());
1537 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1539 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1541 if ((endPoint->x != 0.0f) && (endPoint->y != 0.0f))
1543 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT));
1544 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1546 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1547 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1548 startPoint.release();
1550 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1551 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1554 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1555 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1556 pEventArg.release();
1564 OnWebPageBlockSelected(void* pUserData, Evas_Object* pView, void* pEventInfo)
1566 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1567 SysAssertf(pImpl, "Failed to request");
1569 if (pImpl->GetUiEventListener())
1571 result r = E_SUCCESS;
1573 r = FireWebPageBlockSelectedEvent(pImpl);
1574 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1576 if (pImpl->GetUiEventListenerF())
1578 result r = E_SUCCESS;
1580 r = FireWebPageBlockSelectedEventF(pImpl);
1581 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1587 OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo)
1589 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1590 char* pJsonText = reinterpret_cast< char* >(pEventInfo);
1591 SysAssertf(pImpl && pJsonText, "Failed to request");
1593 result r = E_SUCCESS;
1595 SysLog(NID_WEB_CTRL, "The current value of jsontext is %s", pJsonText);
1597 std::unique_ptr<_JsBridgeArg> pEventArg(new (std::nothrow) _JsBridgeArg());
1598 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1600 r = pEventArg->Construct(pJsonText);
1601 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1603 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1604 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1605 pEventArg.release();
1610 OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo)
1612 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1613 Eina_Rectangle* pEinaRect = reinterpret_cast< Eina_Rectangle* >(pEventInfo);
1614 SysAssertf(pImpl && pEinaRect, "Failed to request");
1616 if (pImpl->IsVisible() == false)
1618 evas_object_focus_set(pView, EINA_FALSE);
1621 if (pImpl->GetSetting().GetInputStyle() == INPUT_STYLE_OVERLAY)
1623 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1624 SysAssertf(pXformer, "Failed to get CoordinateTransformer");
1626 Rectangle rect(pEinaRect->x, pEinaRect->y, pEinaRect->w, pEinaRect->h);
1628 if (rect.height == 0)
1633 _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl));
1636 pFormImpl->DeflateClientRectHeight(pXformer->TransformVertical(rect.height));
1638 if (pFormImpl->HasFooter())
1640 pFormImpl->GetCore().SetKeypadShowState(true);
1645 if (pImpl->GetWebKeypadEventListener())
1647 if (pImpl->IsKeypadVisible() == true)
1649 if ((pImpl->GetPreviousKeypadBounds().width == rect.width) && (pImpl->GetPreviousKeypadBounds().height != rect.height))
1651 pImpl->GetWebKeypadEventListener()->OnWebKeypadBoundsChanged(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1656 pImpl->GetWebKeypadEventListener()->OnWebKeypadWillOpen(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1659 pImpl->SetKeypadVisibleState(true);
1660 pImpl->SetPreviousKeypadBounds(rect);
1664 result r = pImpl->SetFullScreenKeypad();
1665 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1671 OnWebKeypadOpened(void* pUserData, Evas_Object* pView, void* pEventInfo)
1673 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1674 SysAssertf(pImpl, "Failed to request");
1676 if (pImpl->GetWebKeypadEventListener())
1678 pImpl->GetWebKeypadEventListener()->OnWebKeypadOpened(*static_cast< Web* >(&pImpl->GetPublic()));
1684 OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo)
1686 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1687 SysAssertf(pImpl, "Failed to request");
1689 _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl));
1692 pFormImpl->DeflateClientRectHeight(0);
1694 if (pFormImpl->HasFooter())
1696 pFormImpl->GetCore().SetKeypadShowState(false);
1701 if (pImpl->GetWebKeypadEventListener())
1703 pImpl->GetWebKeypadEventListener()->OnWebKeypadClosed(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1706 pImpl->SetKeypadVisibleState(false);
1711 OnWindowObjectFocusGained(void* pUserData, Evas_Object* pWin, void* pEvent_info)
1713 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1714 SysAssertf(pImpl, "Failed to request");
1716 if (pImpl->IsKeypadOpened() == true && pImpl->IsVisible() == true && pImpl->IsFocused() == true)
1718 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
1719 SysAssertf(pWebCore, "Failed to get Web core object");
1721 evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE);
1723 pImpl->SetKeypadVisibleState(true);
1729 OnWebNativeNodeFocusGained(void* pUserData, Evas* pCanvas, Evas_Object* pView, void* pEventInfo)
1731 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1732 SysAssertf(pImpl, "Failed to request");
1734 if (pImpl->IsKeypadOpened() == true)
1736 pImpl->SetKeypadOpened(false);
1742 OnColorPickerProviderRequested(Ewk_View_Smart_Data* pSmartData, int red, int green, int blue, int alpha)
1744 SysAssertf(pSmartData, "invalid smartdata");
1745 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1746 SysAssertf(pWebImpl, "Failed to get Impl");
1748 result r = E_SUCCESS;
1750 if (pWebImpl->GetColorpicker())
1757 r = pWebImpl->ShowColorPicker(red, green, blue, alpha, color);
1758 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1760 byte r1, g1, b1, a1;
1761 color.GetColorComponents(r1, g1, b1, a1);
1762 ewk_view_color_picker_color_set(pSmartData->self, r1, g1, b1, a1);
1769 OnColorPickerProviderDismissed(Ewk_View_Smart_Data* pSmartData)
1771 SysAssertf(pSmartData, "invalid smartdata");
1773 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1774 SysAssertf(pWebImpl, "Failed to get Impl");
1776 return pWebImpl->HideColorPicker();
1781 OnDatePickerProviderRequested(Ewk_View_Smart_Data* pSmartData, Ewk_Input_Type inputType, const char* inputValue)
1783 SysAssertf(pSmartData, "Failed to request");
1784 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1785 SysAssertf(pWebImpl, "Failed to get Impl");
1787 result r = E_SUCCESS;
1789 if (pWebImpl->GetDatepicker())
1791 ewk_view_focused_input_element_value_set(pSmartData->self, inputValue);
1798 r = pWebImpl->ShowDatePicker(inputType, inputValue, dateStr);
1799 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1801 std::unique_ptr<char[]> pDateStr(_StringConverter::CopyToCharArrayN(dateStr));
1802 SysTryReturn(NID_WEB_CTRL, pDateStr.get(), EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1804 ewk_view_focused_input_element_value_set(pSmartData->self, pDateStr.get());
1811 OnSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex)
1813 SysAssertf(pSmartData, "Failed to request");
1815 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1816 SysAssertf(pWebImpl, "Failed to get Impl");
1818 result r = pWebImpl->ShowSelectBoxPopup(false, L"", pItems, pSmartData->self, selectedIndex);
1819 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1826 OnMultiSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* pItems)
1828 SysAssertf(pSmartData, "Failed to request");
1830 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1831 SysAssertf(pWebImpl, "Failed to get Impl");
1833 result r = pWebImpl->ShowSelectBoxPopup(true, L"", pItems, pSmartData->self, 0);
1834 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1841 OnSelectBoxClosed(Ewk_View_Smart_Data* pSmartData)
1843 SysAssertf(pSmartData, "invalid smartdata");
1845 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1846 SysAssertf(pWebImpl, "Failed to get Impl");
1848 result r = pWebImpl->ClearSelectBoxPopup();
1849 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1856 OnSelectBoxUpdateRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, Eina_List* pItems, int selectedIndex)
1858 SysAssertf(pSmartData, "invalid smartdata");
1860 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1861 SysAssertf(pWebImpl, "Failed to get Impl");
1863 result r = pWebImpl->UpdateSelectBoxPopup(pItems, selectedIndex, false);
1864 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1871 OnFormDataCandidateShow(Ewk_View_Smart_Data *pSmartData, int x, int y, int w, int h)
1873 SysAssertf(pSmartData, "Failed to request");
1875 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1876 SysAssertf(pWebImpl, "Failed to get Impl");
1878 Rectangle windowRect(x, y, w, h);
1879 result r = pWebImpl->ShowFormDataWindow(windowRect, pSmartData->self);
1880 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1887 OnFormDataCandidateHide(Ewk_View_Smart_Data *pSmartData)
1889 SysAssertf(pSmartData, "Failed to request");
1891 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1892 SysAssertf(pWebImpl, "Failed to get Impl");
1894 if (pWebImpl->IsFormDataWindowVisible())
1896 pWebImpl->HideFormDataWindow();
1904 OnFormDataCandidateUpdate(Ewk_View_Smart_Data *pSmartData, Eina_List *pDataList)
1906 SysAssertf(pSmartData, "Failed to request");
1908 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1909 SysAssertf(pWebImpl, "Failed to get Impl");
1911 pWebImpl->SetFormDataList(pDataList);
1918 OnFormDataCandidateIsShowing(Ewk_View_Smart_Data *pSmartData)
1920 SysAssertf(pSmartData, "Failed to request");
1922 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1923 SysAssertf(pWebImpl, "Failed to get Impl");
1925 if (pWebImpl->IsFormDataWindowVisible())
1937 OnCookiesPolicyGot(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *pError, void *pUserData)
1939 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
1940 SysAssertf(pPresenter && !pError, "Failed to request");
1942 bool ret = EINA_TRUE;
1946 case EWK_COOKIE_ACCEPT_POLICY_ALWAYS:
1948 case EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY:
1952 case EWK_COOKIE_ACCEPT_POLICY_NEVER:
1961 SysLog(NID_WEB_CTRL, "The current value of policy is %d", ret);
1963 pPresenter->EndAsyncProcess(ret);
1968 OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData)
1970 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
1971 SysAssertf(pPresenter, "Failed to request");
1973 String result(pResult);
1974 SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer());
1976 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, WEB_CTRL));
1977 _WebManager* pWebManager = _WebManager::GetInstance();
1978 if (pWebManager->IsValidCallback(reinterpret_cast< int >(pImpl), reinterpret_cast< int >(pPresenter)))
1980 pPresenter->EndAsyncProcess(result);
1986 OnTextFound(void* pUserData, Evas_Object* pView, void* pEventInfo)
1988 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1989 SysAssertf(pImpl, "Failed to request");
1991 int* pTotalCount = reinterpret_cast< int* >(pEventInfo);
1992 SysLog(NID_WEB_CTRL, "The current value of totalCount is %d", *pTotalCount);
1994 _WebPresenter* pWebPresenter = pImpl->GetSearchPresenter();
1998 pWebPresenter->EndAsyncProcess(*pTotalCount);
2002 if (pImpl->GetTextSearchListener())
2004 result r = E_SUCCESS;
2008 if (*pTotalCount > 0)
2010 ordinal = pImpl->GetAsyncSearchOrdinal();
2011 pImpl->SetAsyncSearchResult(*pTotalCount);
2014 if (pImpl->GetPendingAsyncSearchCount() > 0)
2019 std::unique_ptr<Integer> pCount(new (std::nothrow) Integer(*pTotalCount));
2020 std::unique_ptr<Integer> pOrdinal(new (std::nothrow) Integer(ordinal));
2021 std::unique_ptr<_TextSearchEventArg> pEventArg(new (std::nothrow) _TextSearchEventArg(WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND));
2022 SysTryReturnVoidResult(NID_WEB_CTRL, pCount.get() && pOrdinal.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2024 r = pEventArg->SetEventInfo(_TextSearchEventArg::TOTAL_COUNT, *pCount.get());
2025 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2028 r = pEventArg->SetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL, *pOrdinal.get());
2029 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2032 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
2033 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2034 pEventArg.release();
2040 class _JsBridgeHashCodeProvider
2041 : public Tizen::Base::Collection::IHashCodeProviderT< Tizen::Base::String >
2044 _JsBridgeHashCodeProvider(){}
2045 virtual ~_JsBridgeHashCodeProvider(void) {}
2048 int GetHashCode(const Tizen::Base::String& obj) const
2050 return obj.GetHashCode();
2056 //Comparer implementation
2057 class _JsBridgeComparer
2058 : public Tizen::Base::Collection::IComparerT< Tizen::Base::String >
2061 _JsBridgeComparer(){}
2062 virtual ~_JsBridgeComparer(void) {}
2065 result Compare(const Tizen::Base::String& obj1, const Tizen::Base::String& obj2, int& cmp) const
2082 _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
2083 : _ContainerImpl(pWeb, pCore)
2084 , __isFooterVisible(false)
2085 , __isKeypadVisible(false)
2086 , __isKeypadOpened(false)
2087 , __isLoadingErrorOccurred(false)
2088 , __isRedirectRequested(false)
2089 , __isCertificateRequested(false)
2090 , __isCertificateConfirmed(false)
2091 , __isFormDataVisible(false)
2092 , __keypadBounds(0, 0, 0, 0)
2094 , __pUserLoadingListener(null)
2095 , __pUserUiListener(null)
2096 , __pUserUiListenerF(null)
2097 , __pUserKeypadEventListener(null)
2098 , __pTextSearchListener(null)
2100 , __pJsBridgeList(null)
2101 , __pJsProvider(null)
2102 , __pJsComparer(null)
2103 , __pWebDownloadHandler(null)
2105 , __pAuthChallenge(null)
2106 , __pAuthPopup(null)
2107 , __pUserMediaConfirmPopup(null)
2108 , __pContentHandlerConfirmPopup(null)
2109 , __pProtocolHandlerConfirmPopup(null)
2110 , __pGeolocationConfirmPopup(null)
2111 , __pNotificationConfirmPopup(null)
2112 , __pScriptAlertConfirmPopup(null)
2113 , __pScriptConfirmPopup(null)
2114 , __pAppCacheConfirmPopup(null)
2115 , __pDbQuotaConfirmPopup(null)
2116 , __pLocalFsQuotaConfirmPopup(null)
2117 , __pIndexedDbQuotaConfirmPopup(null)
2118 , __pPromptPopup(null)
2119 , __pCertConfirmPopup(null)
2120 , __pSelectBox(null)
2121 , __pDatePicker(null)
2122 , __pColorPicker(null)
2123 , __pFormDataWindow(null)
2125 , __policy(WEB_DECISION_CONTINUE)
2126 , __defaultUserAgent(L"")
2127 , __pFormDataList(null)
2128 , __popupClosed(false)
2130 __textSearch.__searchAll = false;
2131 __textSearch.__searchForward = true;
2132 __textSearch.__caseSensitive = false;
2133 __textSearch.__pending = 0;
2134 __textSearch.__currentIndex = 1;
2135 __textSearch.__totalCount = -1;
2136 __textSearch.__text = L"";
2140 _WebImpl::~_WebImpl()
2142 _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
2143 pManagerImpl->SetDownloadListener(null);
2145 _WebManager* pWebManager = _WebManager::GetInstance();
2146 pWebManager->RemoveWeb(reinterpret_cast< int >(this));
2148 RemoveEventListenerCallback();
2150 ClearCertificateDb();
2155 _WebImpl::CreateWebImplN(Web* pControl, const Rectangle& bounds)
2157 result r = E_SUCCESS;
2159 r = GET_SIZE_INFO(Web).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2160 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2162 _Web* pCore = _Web::CreateWebN();
2163 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2165 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2167 r = CheckConstruction(pCore, pImpl);
2168 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2170 r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2171 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2173 r = pImpl->Construct();
2174 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2186 _WebImpl::CreateWebImplN(Web* pControl, const FloatRectangle& bounds)
2188 result r = E_SUCCESS;
2190 r = GET_SIZE_INFO(Web).CheckInitialSizeValidF(FloatDimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2191 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2193 _Web* pCore = _Web::CreateWebN();
2194 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2196 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2198 r = CheckConstruction(pCore, pImpl);
2199 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2201 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2202 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2204 r = pImpl->Construct();
2205 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2217 _WebImpl::Construct(void)
2219 result r = E_SUCCESS;
2221 r = __mutex.Create();
2222 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2224 r = __textSearch.__searchQueue.Construct();
2225 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2227 r = __webNotificationList.Construct();
2228 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2230 r = InitJsBridgeList();
2231 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2234 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2236 _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
2237 SysTryReturn(NID_WEB_CTRL, pManagerImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2239 pManagerImpl->SetDownloadListener(this);
2241 __pWebCore = dynamic_cast< _Web* >(&(GetCore()));
2242 SysTryReturnResult(NID_WEB_CTRL, __pWebCore, E_SYSTEM, "A system error has been occurred. Failed to get web control");
2249 _WebImpl::InitializeSetting(void)
2251 result r = E_SUCCESS;
2253 WebSetting* pWebSetting = __pWebCore->GetSetting();
2254 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(pWebSetting);
2256 SetCookieEnabled(pWebSettingImpl->IsCookieEnabled());
2257 SetPrivateBrowsingEnabled(pWebSettingImpl->IsPrivateBrowsingEnabled());
2259 __defaultUserAgent = pWebSettingImpl->GetUserAgent();
2261 r = SetSetting(*pWebSetting);
2262 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2264 SetEventListenerCallback();
2271 _WebImpl::IsLayoutable(void) const
2278 _WebImpl::InitWebEvent(void)
2280 __pWebEvent = std::unique_ptr<_WebEvent>(new (std::nothrow) _WebEvent());
2281 SysTryReturnResult(NID_WEB_CTRL, __pWebEvent.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2283 return __pWebEvent->Construct(*this);
2288 _WebImpl::GetWebEvent(void) const
2290 return __pWebEvent.get();
2295 _WebImpl::ConvertToSlpHeaderN(const HttpHeader& header) const
2297 Eina_Hash* pHttpHeader = null;
2299 std::unique_ptr<IList> pFieldNameList(header.GetFieldNamesN());
2300 if (pFieldNameList.get())
2302 pHttpHeader = eina_hash_string_small_new(FreeCharArray);
2303 SysTryReturn(NID_WEB_CTRL, pHttpHeader, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2305 int count = pFieldNameList->GetCount();
2307 for (int i = 0; i < count; i++)
2309 String* pFieldName = dynamic_cast< String* >(pFieldNameList->GetAt(i));
2310 SysTryCatch(NID_WEB_CTRL, pFieldName, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2312 std::unique_ptr<char[]> pKey(_StringConverter::CopyToCharArrayN(*pFieldName));
2313 SysTryCatch(NID_WEB_CTRL, pKey.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2315 std::unique_ptr<IEnumerator> pFieldValueEnum(header.GetFieldValuesN(*pFieldName));
2316 SysTryCatch(NID_WEB_CTRL, pFieldValueEnum.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2318 while (pFieldValueEnum->MoveNext() == E_SUCCESS)
2320 Eina_Bool ret = false;
2322 String* pFieldValue = dynamic_cast< String* >(pFieldValueEnum->GetCurrent());
2323 SysTryCatch(NID_WEB_CTRL, pFieldValue, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2325 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(*pFieldValue));
2326 SysTryCatch(NID_WEB_CTRL, pValue.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2328 ret = eina_hash_add(pHttpHeader, pKey.get(), pValue.release());
2329 SysTryCatch(NID_WEB_CTRL, ret == EINA_TRUE, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2336 eina_hash_free(pHttpHeader);
2343 _WebImpl::LoadUrl(const String& url) const
2345 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2346 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2348 ewk_view_url_set(__pWebCore->GetWebNativeNode(), pUrl.get());
2355 _WebImpl::LoadUrl(const String& url, const HttpHeader& header)
2357 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2358 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2360 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2362 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_GET, pHttpHeader, null);
2364 eina_hash_free(pHttpHeader);
2371 _WebImpl::LoadUrlWithPostRequest(const String& url, const HttpHeader& header, const ByteBuffer& body) const
2373 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2374 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2376 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2378 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_POST, pHttpHeader, reinterpret_cast< const char* >(body.GetPointer()));
2380 eina_hash_free(pHttpHeader);
2387 _WebImpl::LoadData(const String& baseUrl, const ByteBuffer& content, const String& mime, const String& encoding) const
2389 SysTryReturnResult(NID_WEB_CTRL, content.GetLimit() > 0, E_INVALID_ARG, "The content buffer is empty.");
2391 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(baseUrl));
2392 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
2393 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(encoding));
2394 SysTryReturn(NID_WEB_CTRL, pUrl.get() && pMime.get() && pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2396 ewk_view_contents_set(__pWebCore->GetWebNativeNode(), reinterpret_cast< const char* >(content.GetPointer()), content.GetLimit(), pMime.get(), pEncoding.get(), pUrl.get());
2403 _WebImpl::Pause(void)
2405 ewk_view_suspend(__pWebCore->GetWebNativeNode());
2410 _WebImpl::Resume(void)
2412 ewk_view_resume(__pWebCore->GetWebNativeNode());
2417 _WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List* pItems, Evas_Object* pWebView, int selectedIndex)
2419 __pSelectBox.reset();
2421 SysTryReturnResult(NID_WEB_CTRL, eina_list_count(pItems) > 0, E_SYSTEM, "ItemCount is invalid.");
2423 result r = E_SUCCESS;
2425 std::unique_ptr<_SelectBox> pSelectBox(new (std::nothrow) _SelectBox());
2426 SysTryReturnResult(NID_WEB_CTRL, pSelectBox.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2428 r = pSelectBox->Construct(isMultiSelect, title, DEFAULT_LIST_ITEM_COUNT, pWebView);
2429 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2431 r = pSelectBox->UpdateList(pItems, selectedIndex, false, false);
2432 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2434 __pSelectBox = std::move(pSelectBox);
2436 return __pSelectBox->ShowPopup();
2441 _WebImpl::UpdateSelectBoxPopup(Eina_List* pItems, int selectedIndex, bool isGroupedList)
2443 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2445 return __pSelectBox->UpdateList(pItems, selectedIndex, true, isGroupedList);
2450 _WebImpl::ClearSelectBoxPopup(void)
2452 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2454 __pSelectBox.reset();
2461 _WebImpl::GetDatepicker(void)
2463 _InputPickerPopup* pInputPicker =null;
2466 pInputPicker = __pDatePicker.get();
2468 return pInputPicker;
2473 _WebImpl::GetColorpicker(void)
2475 _InputPickerPopup* pInputPicker =null;
2478 pInputPicker = __pColorPicker.get();
2480 return pInputPicker;
2485 _WebImpl::CanGoBack(void) const
2487 return static_cast< bool >(ewk_view_back_possible(__pWebCore->GetWebNativeNode()));
2492 _WebImpl::CanGoForward(void) const
2494 return static_cast< bool >(ewk_view_forward_possible(__pWebCore->GetWebNativeNode()));
2499 _WebImpl::GoBack(void) const
2501 ewk_view_back(__pWebCore->GetWebNativeNode());
2506 _WebImpl::GoForward(void) const
2508 ewk_view_forward(__pWebCore->GetWebNativeNode());
2513 _WebImpl::GetUrl(void) const
2515 return ewk_view_url_get(__pWebCore->GetWebNativeNode());
2520 _WebImpl::GetTitle(void) const
2522 return ewk_view_title_get(__pWebCore->GetWebNativeNode());
2527 _WebImpl::StopLoading(void) const
2529 ewk_view_stop(__pWebCore->GetWebNativeNode());
2534 _WebImpl::Reload(void) const
2536 ewk_view_reload(__pWebCore->GetWebNativeNode());
2541 _WebImpl::EvaluateJavascriptN(const String& scriptCode)
2543 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2549 std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(scriptCode));
2550 SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2552 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
2553 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2555 ewk_view_script_execute(pView, pScript.get(), OnScriptExecuted, pPresenter.get());
2557 std::unique_ptr<String> pResult(new (std::nothrow) String(L""));
2558 SysTryReturn(NID_WEB_CTRL, pResult.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2560 pPresenter->WaitAsyncProcess(*pResult.get());
2562 return pResult.release();
2567 _WebImpl::SetZoomLevel(float level)
2569 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);
2571 ewk_view_scale_set(__pWebCore->GetWebNativeNode(), static_cast< double >(level), 0, 0);
2578 _WebImpl::GetZoomLevel(void) const
2580 return static_cast< float >(ewk_view_scale_get(__pWebCore->GetWebNativeNode()));
2584 const PageNavigationList*
2585 _WebImpl::GetBackForwardListN(void) const
2587 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2593 result r = E_SUCCESS;
2595 _PageNavigationListImpl* pNavigationListImpl = null;
2596 _HistoryItemImpl* pHistoryItemImpl = null;
2598 std::unique_ptr<PageNavigationList> pNavigationList;
2599 std::unique_ptr<ArrayList, AllElementsDeleter> pHistoryList;
2602 int forwardCount = 0;
2607 Ewk_History* pEwkHistoryList = ewk_view_history_get(pView);
2608 SysTryReturn(NID_WEB_CTRL, pEwkHistoryList, null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get full history.", GetErrorMessage(E_SYSTEM));
2610 Ewk_History_Item* pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, 0);
2611 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_DATA_NOT_FOUND, "[%s] There is no history.", GetErrorMessage(E_DATA_NOT_FOUND));
2613 pNavigationList = std::unique_ptr<PageNavigationList>(new (std::nothrow) PageNavigationList());
2614 SysTryCatch(NID_WEB_CTRL, pNavigationList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2616 pNavigationListImpl = _PageNavigationListImpl::GetInstance(pNavigationList.get());
2617 SysTryCatch(NID_WEB_CTRL, pNavigationListImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2619 pHistoryList = std::unique_ptr<ArrayList, AllElementsDeleter>(new (std::nothrow) ArrayList());
2620 SysTryCatch(NID_WEB_CTRL, pHistoryList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2622 r = pHistoryList->Construct();
2623 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2625 backCount = ewk_history_back_list_length_get(pEwkHistoryList);
2626 forwardCount = ewk_history_forward_list_length_get(pEwkHistoryList);
2627 SysLog(NID_WEB_CTRL, "The current value of backCount is %d, forwardCount is %d", backCount, forwardCount);
2629 for (int i = -backCount; i < forwardCount + 1; i++)
2631 std::unique_ptr<HistoryItem> pHistoryItem(new (std::nothrow) HistoryItem());
2632 SysTryCatch(NID_WEB_CTRL, pHistoryItem.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2634 pHistoryItemImpl = _HistoryItemImpl::GetInstance(pHistoryItem.get());
2635 SysTryCatch(NID_WEB_CTRL, pHistoryItemImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2637 pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, i);
2638 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2640 url = ewk_history_item_uri_get(pEwkItem);
2641 title = ewk_history_item_title_get(pEwkItem);
2642 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s, title is %s", url.GetPointer(), title.GetPointer());
2644 pHistoryItemImpl->SetHistoryItem(url, title);
2646 r = pHistoryList->Add(*pHistoryItem.get());
2647 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2648 pHistoryItem.release();
2651 pNavigationListImpl->SetPageNavigationList(pHistoryList.release(), backCount);
2653 ewk_history_free(pEwkHistoryList);
2655 return pNavigationList.release();
2658 ewk_history_free(pEwkHistoryList);
2665 _WebImpl::SearchText(const String& text, bool searchForward)
2667 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2673 result r = E_SUCCESS;
2675 Ewk_Find_Options condition = static_cast< Ewk_Find_Options >(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2679 condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS);
2682 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
2683 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2685 r = SynchronizeSearch(SEARCH_SYNC, pView, condition, text, searchForward, false, pPresenter.get());
2686 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
2689 pPresenter->WaitAsyncProcess(result);
2691 return static_cast < bool >(result);
2696 _WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive)
2698 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2704 result r = E_SUCCESS;
2706 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2710 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2713 r = SynchronizeSearch(SEARCH_ALL_ASYNC, pView, condition, text, true, caseSensitive);
2714 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2721 _WebImpl::SearchNextAsync(bool searchForward)
2723 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2729 SysTryReturnResult(NID_WEB_CTRL, __textSearch.__searchAll && __textSearch.__totalCount > -1, E_INVALID_OPERATION, "The SearchTextAllAsync() method is not called or completed.");
2730 SysTryReturnResult(NID_WEB_CTRL, (searchForward && __textSearch.__currentIndex < __textSearch.__totalCount) || (!searchForward && __textSearch.__currentIndex > 1)
2731 , E_OBJ_NOT_FOUND, "The Next instance is not available.");
2733 result r = E_SUCCESS;
2735 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2737 if (!__textSearch.__caseSensitive)
2739 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2744 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_BACKWARDS);
2747 r = SynchronizeSearch(SEARCH_NEXT_ASYNC, pView, condition, __textSearch.__text, searchForward);
2748 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2755 _WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text, bool searchForward, bool caseSensitive, _WebPresenter* pWebPresenter)
2757 MutexGuard lock(__mutex);
2759 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(text));
2760 SysTryReturn(NID_WEB_CTRL, pText.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2765 if (__textSearch.__searchAll)
2767 DisableAsyncSearch();
2769 __textSearch.__searchQueue.Enqueue(this);
2770 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2772 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2773 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2777 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2779 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2783 case SEARCH_ALL_ASYNC:
2784 __textSearch.__searchAll = true;
2785 __textSearch.__text = text;
2786 __textSearch.__searchForward = true;
2787 __textSearch.__caseSensitive = caseSensitive;
2788 __textSearch.__totalCount = -1;
2789 __textSearch.__currentIndex = 1;
2791 __textSearch.__searchQueue.Enqueue(this);
2792 __textSearch.__searchQueue.Enqueue(this);
2794 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2795 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2798 case SEARCH_NEXT_ASYNC:
2799 __textSearch.__searchForward = searchForward;
2801 CalculateAsyncSearchOrdinal();
2803 __textSearch.__searchQueue.Enqueue(this);
2805 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2817 _WebImpl::SetAsyncSearchResult(int totalCount)
2819 __textSearch.__totalCount = totalCount;
2824 _WebImpl::GetSearchPresenter(void)
2826 MutexGuard lock(__mutex);
2828 return dynamic_cast< _WebPresenter* >(__textSearch.__searchQueue.Dequeue());
2833 _WebImpl::GetPendingAsyncSearchCount(void) const
2835 return __textSearch.__searchQueue.GetCount();
2840 _WebImpl::CalculateAsyncSearchOrdinal(void)
2842 if (__textSearch.__searchForward)
2844 __textSearch.__currentIndex++;
2848 __textSearch.__currentIndex--;
2854 _WebImpl::GetAsyncSearchOrdinal(void) const
2856 return __textSearch.__currentIndex;
2861 _WebImpl::DisableAsyncSearch(void)
2863 __textSearch.__searchAll = false;
2868 _WebImpl::SetSetting(const WebSetting& setting)
2870 if (__pWebCore->GetWebNativeNode())
2872 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2873 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2874 SysAssertf(pContext && pSettings, "Failed to get webkit instance.");
2876 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(setting.GetDefaultTextEncoding()));
2877 SysTryReturn(NID_WEB_CTRL, pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2879 ewk_settings_default_encoding_set(pSettings, pEncoding.get());
2881 switch (setting.GetCacheControl())
2883 case WEB_CACHE_VALIDATED:
2884 ewk_context_cache_disabled_set(pContext, EINA_FALSE);
2887 case WEB_CACHE_IGNORE:
2888 ewk_context_cache_disabled_set(pContext, EINA_TRUE);
2895 if (setting.GetInputStyle() == INPUT_STYLE_OVERLAY)
2897 ewk_settings_default_keypad_enabled_set(pSettings, EINA_TRUE);
2901 ewk_settings_default_keypad_enabled_set(pSettings, EINA_FALSE);
2904 ewk_settings_font_default_size_set(pSettings, static_cast< Eina_Bool >(setting.GetFontSize()));
2906 ewk_settings_javascript_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsJavascriptEnabled()));
2908 ewk_settings_loads_images_automatically_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoImageLoadEnabled()));
2910 if (__defaultUserAgent != setting.GetUserAgent())
2912 std::unique_ptr<char[]> pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent()));
2913 SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2915 ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get());
2918 ewk_settings_auto_fitting_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFittingEnabled()));
2920 ewk_settings_scripts_window_open_set(pSettings, static_cast< Eina_Bool >(setting.IsJavaScriptPopupEnabled()));
2922 ewk_settings_form_candidate_data_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFormDataShowEnabled()));
2924 ewk_settings_autofill_password_form_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoLoginFormFillEnabled()));
2927 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting());
2929 pWebSettingImpl->SetCertificateErrorHandlingMode(setting.GetCertificateErrorHandlingMode());
2930 pWebSettingImpl->SetDefaultTextEncoding(setting.GetDefaultTextEncoding());
2931 pWebSettingImpl->SetCacheControl(setting.GetCacheControl());
2932 pWebSettingImpl->SetFontSize(setting.GetFontSize());
2933 pWebSettingImpl->SetJavascriptEnabled(setting.IsJavascriptEnabled());
2934 pWebSettingImpl->SetAutoImageLoadEnabled(setting.IsAutoImageLoadEnabled());
2935 pWebSettingImpl->SetInputStyle(setting.GetInputStyle());
2936 pWebSettingImpl->SetUserAgent(setting.GetUserAgent());
2937 pWebSettingImpl->SetAutoFittingEnabled(setting.IsAutoFittingEnabled());
2938 pWebSettingImpl->SetJavaScriptPopupEnabled(setting.IsJavaScriptPopupEnabled());
2939 pWebSettingImpl->SetGeolocationEnabled(setting.IsGeolocationEnabled());
2940 pWebSettingImpl->SetAutoFormDataShowEnabled(setting.IsAutoFormDataShowEnabled());
2941 pWebSettingImpl->SetAutoLoginFormFillEnabled(setting.IsAutoLoginFormFillEnabled());
2948 _WebImpl::GetSetting(void) const
2950 return *__pWebCore->GetSetting();
2954 const HitElementResult*
2955 _WebImpl::GetElementByPointN(const Point& point) const
2957 return GetElementByPointN(_CoordinateSystemUtils::ConvertToFloat(point));
2961 const HitElementResult*
2962 _WebImpl::GetElementByPointN(const FloatPoint& point) const
2964 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2970 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));
2972 result r = E_SUCCESS;
2974 _HitElementResultImpl* pHitElementResultImpl = null;
2976 std::unique_ptr<HitElementResult> pHitElementResult;
2977 std::unique_ptr<Bitmap> pImage;
2978 std::unique_ptr<HashMap, AllElementsDeleter> pAttributeMap;
2980 Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(point)));
2982 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
2983 SysTryReturn(NID_WEB_CTRL, pEwkHitTest, null, E_SYSTEM, "[%s] Failed to get hit test.", GetErrorMessage(E_SYSTEM));
2985 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
2986 Ewk_Hit_Test_Result_Context context = ewk_hit_test_result_context_get(pEwkHitTest);
2987 String url(ewk_hit_test_link_uri_get(pEwkHitTest));
2988 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
2989 String nodeValue(ewk_hit_test_node_value_get(pEwkHitTest));
2991 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls, tag is %ls, value is %ls", url.GetPointer(), tagName.GetPointer(), nodeValue.GetPointer());
2993 pHitElementResult = std::unique_ptr<HitElementResult>(new (std::nothrow) HitElementResult());
2994 SysTryCatch(NID_WEB_CTRL, pHitElementResult.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2996 pHitElementResultImpl = _HitElementResultImpl::GetInstance(pHitElementResult.get());
2997 SysTryCatch(NID_WEB_CTRL, pHitElementResultImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2999 if (context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE)
3005 int imageLength = ewk_hit_test_image_buffer_length_get(pEwkHitTest);
3006 void* pImageBuffer = ewk_hit_test_image_buffer_get(pEwkHitTest);
3007 const char* pExtension = ewk_hit_test_image_file_name_extension_get(pEwkHitTest);
3008 SysLog(NID_WEB_CTRL, "The current value of imageBuffer is %u, bufferLength is %d, extension is %s", pImageBuffer, imageLength, pExtension);
3010 r = buf.Construct(imageLength);
3011 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3013 r = buf.SetArray(reinterpret_cast< byte* >(pImageBuffer), 0, imageLength);
3014 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3018 // ToDo : webkit doesn't support types such as IMG_FORMAT_WBMP and IMG_FORMAT_TIFF
3019 // webkit support types such as ico and vp8 additionally
3020 if (strcmp(pExtension, "gif") == 0)
3022 format = IMG_FORMAT_GIF;
3024 else if (strcmp(pExtension, "jpg") == 0)
3026 format = IMG_FORMAT_JPG;
3028 else if (strcmp(pExtension, "png") == 0)
3030 format = IMG_FORMAT_PNG;
3032 else if (strcmp(pExtension, "bmp") == 0)
3034 format = IMG_FORMAT_BMP;
3038 SysLogException(NID_WEB_CTRL, E_UNSUPPORTED_FORMAT, "[%s] The %s format is not supported", GetErrorMessage(E_UNSUPPORTED_FORMAT), pExtension);
3042 r = image.Construct();
3043 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3045 pImage = std::unique_ptr<Bitmap>(image.DecodeN(buf, format, BITMAP_PIXEL_FORMAT_RGB565));
3046 SysTryCatch(NID_WEB_CTRL, pImage.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3051 pAttributeMap = std::unique_ptr<HashMap, AllElementsDeleter>(new (std::nothrow) HashMap());
3052 SysTryCatch(NID_WEB_CTRL, pAttributeMap.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3054 r = pAttributeMap->Construct(eina_hash_population(pAttrHash));
3055 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3057 eina_hash_foreach(pAttrHash, AddHttpAttributeData, pAttributeMap.get());
3058 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3061 pHitElementResultImpl->SetHitElementResult(pAttributeMap.release(), pImage.release(), tagName, nodeValue, url);
3063 ewk_hit_test_free(pEwkHitTest);
3065 return pHitElementResult.release();
3068 ewk_hit_test_free(pEwkHitTest);
3075 _WebImpl::IsLoading(void) const
3077 double percent = ewk_view_load_progress_get(__pWebCore->GetWebNativeNode());
3079 if (Double::Compare(percent, 0.0) > 0 && Double::Compare(percent, 1.0) < 0)
3091 _WebImpl::GetTextFromBlock(void) const
3093 return ewk_view_text_selection_text_get(__pWebCore->GetWebNativeNode());
3098 _WebImpl::IsPrivateBrowsingEnabled(void) const
3100 if (__pWebCore->GetWebNativeNode() == null)
3102 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsPrivateBrowsingEnabled();
3105 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3106 SysAssertf(pSettings, "Failed to get webkit instance.");
3108 return static_cast< bool >(ewk_settings_private_browsing_enabled_get(pSettings));
3113 _WebImpl::SetPrivateBrowsingEnabled(bool enable)
3115 if (__pWebCore->GetWebNativeNode() == null)
3117 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetPrivateBrowsingEnabled(enable);
3121 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3122 SysAssertf(pSettings, "Failed to get webkit instance.");
3124 ewk_settings_private_browsing_enabled_set(pSettings, static_cast< Eina_Bool >(enable));
3129 _WebImpl::ClearHistory(void)
3131 ewk_view_back_forward_list_clear(__pWebCore->GetWebNativeNode());
3136 _WebImpl::ClearCache(void)
3138 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3140 ewk_context_cache_clear(pContext);
3145 _WebImpl::ClearCookie(void)
3147 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3148 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3150 ewk_cookie_manager_cookies_clear(pCookieManager);
3155 _WebImpl::ClearFormData(void)
3157 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3159 ewk_context_form_candidate_data_clear(pContext);
3164 _WebImpl::ClearLoginFormData(void)
3166 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3168 ewk_context_form_password_data_clear(pContext);
3173 _WebImpl::IsCookieEnabled(void) const
3175 if (__pWebCore->GetWebNativeNode() == null)
3177 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsCookieEnabled();
3180 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3181 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3182 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3184 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
3185 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3187 ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, pPresenter.get());
3189 bool result = false;
3190 pPresenter->WaitAsyncProcess(result);
3197 _WebImpl::SetCookieEnabled(bool enable)
3199 if (__pWebCore->GetWebNativeNode() == null)
3201 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetCookiEnabled(enable);
3206 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3207 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3208 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3212 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
3216 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER);
3217 ewk_cookie_manager_cookies_clear(pCookieManager);
3223 _WebImpl::SavePageAsPdf(const String& filePath, const Dimension* pSize) const
3225 result r = E_SUCCESS;
3227 std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
3228 SysTryReturn(NID_WEB_CTRL, pFilePath.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3231 String fileExtension = File::GetFileExtension(filePath);
3232 int pathLength = filePath.GetLength();
3235 SysTryReturnResult(NID_WEB_CTRL, fileExtension.Equals("pdf", false), E_INVALID_ARG, "Invalid argument(s) is used. File extension is not pdf.");
3237 r = filePath.LastIndexOf(L"/", pathLength - 1, index);
3238 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3239 r = filePath.SubString(0, index + 1, dirPath);
3240 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3242 std::unique_ptr<char[]> pDirPath(_StringConverter::CopyToCharArrayN(dirPath));
3243 SysTryReturnResult(NID_WEB_CTRL, access(pDirPath.get(), W_OK) == 0, E_INACCESSIBLE_PATH, "Directory permission is read-only.");
3247 SysTryReturnResult(NID_WEB_CTRL, pSize->width > 0 && pSize->height > 0, E_INVALID_ARG, "Invalid argument(s) is used. Size of pdf file is invalid.");
3249 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), pSize->width, pSize->height, pFilePath.get());
3253 Evas_Coord contentsWidth;
3254 Evas_Coord contentsHeight;
3256 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &contentsWidth, &contentsHeight);
3257 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), contentsWidth, contentsHeight, pFilePath.get());
3265 _WebImpl::IsMimeSupported(const String& mime) const
3267 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
3268 SysTryReturn(NID_WEB_CTRL, pMime.get(), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3270 return static_cast< bool >(ewk_frame_can_show_mime_type(ewk_view_main_frame_get(__pWebCore->GetWebNativeNode()), pMime.get()));
3275 _WebImpl::SetLoadingListener(ILoadingListener* pLoadingListener)
3277 __pUserLoadingListener = const_cast< ILoadingListener* >(pLoadingListener);
3282 _WebImpl::SetWebUiEventListener(IWebUiEventListener* pUiEventListener)
3284 __pUserUiListener = pUiEventListener;
3289 _WebImpl::SetWebUiEventListenerF(IWebUiEventListenerF* pUiEventListener)
3291 __pUserUiListenerF = pUiEventListener;
3296 _WebImpl::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener)
3298 __pUserKeypadEventListener = pKeypadEventListener;
3303 _WebImpl::SetDownloadListener(IWebDownloadListener* pDownLoadListener)
3305 if (__pWebDownloadHandler.get() == null)
3307 __pWebDownloadHandler = std::unique_ptr<_WebDataHandler>(new (std::nothrow) _WebDataHandler());
3308 SysTryReturnVoidResult(NID_WEB_CTRL, __pWebDownloadHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3311 __pWebDownloadHandler->SetDownloadListener(pDownLoadListener);
3312 __pWebDownloadHandler->SetWebEvent(__pWebEvent.get());
3317 _WebImpl::SetTextSearchListener(ITextSearchListener* pTextSearchListener)
3319 __pTextSearchListener = pTextSearchListener;
3324 _WebImpl::SetScrollEnabled(bool enable)
3326 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetScrollEnabled(enable);
3331 _WebImpl::IsScrollEnabled(void) const
3333 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled();
3338 _WebImpl::InitJsBridgeList(void)
3340 result r = E_SUCCESS;
3342 __pJsProvider = std::unique_ptr<_JsBridgeHashCodeProvider>(new (std::nothrow) _JsBridgeHashCodeProvider());
3343 SysTryReturnResult(NID_WEB_CTRL, __pJsProvider.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3345 __pJsComparer = std::unique_ptr<_JsBridgeComparer>(new (std::nothrow) _JsBridgeComparer());
3346 SysTryReturnResult(NID_WEB_CTRL, __pJsComparer.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3348 std::unique_ptr<HashMapT< String, IJavaScriptBridge* > > pJsBridgeList(new (std::nothrow) HashMapT< String, IJavaScriptBridge* >);
3349 SysTryReturnResult(NID_WEB_CTRL, pJsBridgeList.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3351 r = pJsBridgeList->Construct(0, 0, *__pJsProvider.get(), *__pJsComparer.get());
3352 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3354 __pJsBridgeList = std::move(pJsBridgeList);
3361 _WebImpl::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3363 result r = E_SUCCESS;
3365 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3366 String key(pJsBridge->GetName());
3368 r = __pJsBridgeList->Add(key, pJsBridge);
3369 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3376 _WebImpl::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3378 result r = E_SUCCESS;
3380 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3381 String key(pJsBridge->GetName());
3383 r = __pJsBridgeList->Remove(key);
3384 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3391 _WebImpl::FindJsInterface(const IJsonValue* pValue) const
3393 result r = E_SUCCESS;
3395 IJsonValue* pJsonValue = null;
3396 IJavaScriptBridge* pJsBridge = null;
3398 String key(L"name");
3400 const JsonObject* pJsonObject = dynamic_cast< const JsonObject* >(pValue);
3401 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));
3403 r = pJsonObject->GetValue(&key, pJsonValue);
3404 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS && pJsonValue, null, r, "[%s] Propagating.", GetErrorMessage(r));
3406 JsonString* pBridgeName = dynamic_cast< JsonString* >(pJsonValue);
3407 SysTryReturn(NID_WEB_CTRL, pBridgeName, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. name key is missing." , GetErrorMessage(E_INVALID_ARG));
3409 r = __pJsBridgeList->GetValue(static_cast< String >(*pBridgeName), pJsBridge);
3410 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3417 _WebImpl::GetLoadingListener(void) const
3419 return __pUserLoadingListener;
3423 IWebUiEventListener*
3424 _WebImpl::GetUiEventListener(void) const
3426 return __pUserUiListener;
3430 IWebUiEventListenerF*
3431 _WebImpl::GetUiEventListenerF(void) const
3433 return __pUserUiListenerF;
3437 IWebKeypadEventListener*
3438 _WebImpl::GetWebKeypadEventListener(void) const
3440 return __pUserKeypadEventListener;
3444 ITextSearchListener*
3445 _WebImpl::GetTextSearchListener(void) const
3447 return __pTextSearchListener;
3452 _WebImpl::SetEventListenerCallback(void) const
3454 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3457 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3458 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3460 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3461 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3463 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3464 SysAssertf(pSmartData, "Failed to request");
3466 Ewk_View_Smart_Class *pSmart = const_cast<Ewk_View_Smart_Class*>(pSmartData->api);
3467 SysAssertf(pSmart, "Failed to request");
3469 pSmart->popup_menu_show = OnSelectBoxRequested;
3470 pSmart->multiple_popup_menu_show = OnMultiSelectBoxRequested;
3471 pSmart->popup_menu_hide = OnSelectBoxClosed;
3472 pSmart->popup_menu_update = OnSelectBoxUpdateRequested;
3474 pSmart->input_picker_show = OnDatePickerProviderRequested;
3475 pSmart->input_picker_color_request = OnColorPickerProviderRequested;
3476 pSmart->input_picker_color_dismiss = OnColorPickerProviderDismissed;
3478 pSmart->formdata_candidate_show = OnFormDataCandidateShow;
3479 pSmart->formdata_candidate_hide = OnFormDataCandidateHide;
3480 pSmart->formdata_candidate_update_data = OnFormDataCandidateUpdate;
3481 pSmart->formdata_candidate_is_showing = OnFormDataCandidateIsShowing;
3483 evas_object_data_set(pWebNativeNode, WEB_CTRL, this);
3485 // add loading event callbacks for ILoadingListener
3486 evas_object_smart_callback_add(pWebNativeNode, "create,window", OnWebWindowCreateRequested, this);
3487 evas_object_smart_callback_add(pWebNativeNode, "close,window", OnWebWindowClosedRequested, this);
3489 evas_object_smart_callback_add(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested, this);
3490 evas_object_smart_callback_add(pWebNativeNode, "load,started", OnLoadingStarted, this);
3491 evas_object_smart_callback_add(pWebNativeNode, "load,finished", OnLoadingCompleted, this);
3492 evas_object_smart_callback_add(pWebNativeNode, "load,progress", OnEstimatedProgress, this);
3493 evas_object_smart_callback_add(pWebNativeNode, "load,progress,finished", OnProgressCompleted, this);
3494 evas_object_smart_callback_add(pWebNativeNode, "load,stop", OnLoadingCanceled, this);
3495 evas_object_smart_callback_add(pWebNativeNode, "load,error", OnLoadingErrorOccurred, this);
3496 evas_object_smart_callback_add(pWebNativeNode, "title,changed", OnPageTitleReceived, this);
3498 evas_object_smart_callback_add(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest, this);
3500 evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3502 evas_object_smart_callback_add(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged, this);
3503 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened, this);
3504 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed, this);
3506 evas_object_smart_callback_add(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested, this);
3507 evas_object_smart_callback_add(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled, this);
3509 evas_object_smart_callback_add(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested, this);
3511 ewk_view_javascript_alert_callback_set(pWebNativeNode, OnScriptAlertRequested, const_cast< _WebImpl* >(this));
3512 ewk_view_javascript_prompt_callback_set(pWebNativeNode, OnScriptPromptRequested, const_cast< _WebImpl* >(this));
3513 ewk_view_javascript_confirm_callback_set(pWebNativeNode, OnScriptConfirmRequested, const_cast< _WebImpl* >(this));
3515 evas_object_smart_callback_add(pWebNativeNode, "policy,response,decide", OnWebDataReceived, this);
3517 evas_object_smart_callback_add(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested, this);
3518 evas_object_smart_callback_add(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested, this);
3519 evas_object_smart_callback_add(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted, this);
3521 evas_object_smart_callback_add(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested, this);
3522 evas_object_smart_callback_add(pWebNativeNode, "notification,show", OnNotificationShow, this);
3523 evas_object_smart_callback_add(pWebNativeNode, "notification,cancel", OnNotificationCancel, this);
3525 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested, this);
3526 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered, this);
3527 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested, this);
3529 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested, this);
3530 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered, this);
3531 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested, this);
3532 evas_object_smart_callback_add(pWebNativeNode, "text,found", OnTextFound, this);
3534 evas_object_smart_callback_add(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered, this);
3535 evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this);
3537 evas_object_smart_callback_add(pWebNativeNode, "text,selected", OnWebPageBlockSelected, this);
3539 evas_object_smart_callback_add(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered, this);
3540 evas_object_smart_callback_add(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited, this);
3542 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3543 SysAssertf(pContext, "Failed to get webkit instance.");
3544 ewk_context_did_start_download_callback_set(pContext, OnDidStartDownloadCallback, const_cast< _WebImpl* >(this));
3545 ewk_context_vibration_client_callbacks_set(pContext, OnVibrationRequested, OnVibrationCanceled, const_cast< _WebImpl* >(this));
3547 ewk_view_application_cache_permission_callback_set(pWebNativeNode, OnApplicationCachePermissionRequested, const_cast< _WebImpl* >(this));
3548 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, OnIndexedDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3549 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, OnDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3550 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, OnLocalFileSystemQuotaExceeded, const_cast< _WebImpl* >(this));
3552 evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this);
3558 _WebImpl::RemoveEventListenerCallback(void) const
3560 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3563 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3564 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3566 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3567 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3569 evas_object_smart_callback_del(pWebNativeNode, "create,window", OnWebWindowCreateRequested);
3570 evas_object_smart_callback_del(pWebNativeNode, "close,window", OnWebWindowClosedRequested);
3572 evas_object_smart_callback_del(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested);
3573 evas_object_smart_callback_del(pWebNativeNode, "load,started", OnLoadingStarted);
3574 evas_object_smart_callback_del(pWebNativeNode, "load,finished", OnLoadingCompleted);
3575 evas_object_smart_callback_del(pWebNativeNode, "load,progress", OnEstimatedProgress);
3576 evas_object_smart_callback_del(pWebNativeNode, "load,progress,finished", OnProgressCompleted);
3577 evas_object_smart_callback_del(pWebNativeNode, "load,stop", OnLoadingCanceled);
3578 evas_object_smart_callback_del(pWebNativeNode, "load,error", OnLoadingErrorOccurred);
3579 evas_object_smart_callback_del(pWebNativeNode, "title,changed", OnPageTitleReceived);
3581 evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest);
3583 evas_object_smart_callback_del_full(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3585 evas_object_smart_callback_del(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged);
3586 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened);
3587 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed);
3589 evas_object_smart_callback_del(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested);
3590 evas_object_smart_callback_del(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled);
3592 evas_object_smart_callback_del(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested);
3594 ewk_view_javascript_alert_callback_set(pWebNativeNode, null, null);
3595 ewk_view_javascript_prompt_callback_set(pWebNativeNode, null, null);
3596 ewk_view_javascript_confirm_callback_set(pWebNativeNode, null, null);
3598 evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived);
3600 evas_object_smart_callback_del(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested);
3601 evas_object_smart_callback_del(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested);
3602 evas_object_smart_callback_del(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted);
3604 evas_object_smart_callback_del(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested);
3605 evas_object_smart_callback_del(pWebNativeNode, "notification,show", OnNotificationShow);
3606 evas_object_smart_callback_del(pWebNativeNode, "notification,cancel", OnNotificationCancel);
3607 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested);
3608 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered);
3609 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested);
3611 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested);
3612 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered);
3613 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested);
3615 evas_object_smart_callback_del(pWebNativeNode, "text,found", OnTextFound);
3617 evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered);
3618 evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived);
3620 evas_object_smart_callback_del(pWebNativeNode, "text,selected", OnWebPageBlockSelected);
3622 evas_object_smart_callback_del(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered);
3623 evas_object_smart_callback_del(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited);
3625 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3626 SysAssertf(pContext, "Failed to get webkit instance.");
3627 ewk_context_vibration_client_callbacks_set(pContext, null, null, null);
3629 ewk_view_application_cache_permission_callback_set(pWebNativeNode, null, null);
3630 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, null, null);
3631 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, null, null);
3632 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, null, null);
3634 evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained);
3640 _WebImpl::ClearCertificateDb(void)
3642 result r = E_SUCCESS;
3644 String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
3645 String table(CERTIFICATE_TABLE_NAME);
3648 r = db.Construct(certificatePath, "r+", null);
3649 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3651 db.BeginTransaction();
3653 r = db.ExecuteSql(L"Delete From " + table, true);
3654 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3656 db.CommitTransaction();
3661 db.RollbackTransaction();
3666 _WebImpl::SetBlockSelectionPosition(const Point& startPoint)
3668 return SetBlockSelectionPosition(_CoordinateSystemUtils::ConvertToFloat(startPoint));
3673 _WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint)
3675 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3676 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pView);
3677 if (pSmartData && pSmartData->api)
3679 Point absPoint( _CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(startPoint)));
3681 Eina_Bool ret = pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y);
3684 pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y);
3686 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3687 SysTryReturnResult(NID_WEB_CTRL, pEwkHitTest, E_SYSTEM, "Failed to get hit test.");
3689 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3691 if (tagName.Equals(L"INPUT", false) || tagName.Equals(L"TEXTAREA", false))
3693 ewk_view_command_execute(pView, "SelectWord", 0);
3697 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
3698 char* pValue = reinterpret_cast< char* >(eina_hash_find(pAttrHash, "contenteditable"));
3701 ewk_view_command_execute(pView, "SelectWord", 0);
3707 SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up.");
3709 evas_object_smart_callback_call(pView, "text,selected", NULL);
3716 _WebImpl::ReleaseBlock(void)
3718 ewk_view_text_selection_range_clear(__pWebCore->GetWebNativeNode());
3723 _WebImpl::GetBlockRange(Point& startPoint, Point& endPoint) const
3725 FloatPoint tempStartPoint;
3726 FloatPoint tempEndPoint;
3728 GetBlockRange(tempStartPoint, tempEndPoint);
3730 startPoint = _CoordinateSystemUtils::ConvertToInteger(tempStartPoint);
3731 endPoint = _CoordinateSystemUtils::ConvertToInteger(tempEndPoint);
3736 _WebImpl::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const
3738 Eina_Rectangle leftHandle;
3739 Eina_Rectangle rightHandle;
3741 EINA_RECTANGLE_SET(&leftHandle, 0, 0, 0, 0);
3742 EINA_RECTANGLE_SET(&rightHandle, 0, 0, 0, 0);
3744 ewk_view_text_selection_range_get(__pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle);
3746 startPoint.x = _CoordinateSystemUtils::ConvertToFloat(leftHandle.x);
3747 startPoint.y = _CoordinateSystemUtils::ConvertToFloat(leftHandle.y);
3748 endPoint.x = _CoordinateSystemUtils::ConvertToFloat(rightHandle.x + rightHandle.w);
3749 endPoint.y = _CoordinateSystemUtils::ConvertToFloat(rightHandle.y + rightHandle.h);
3751 if ((endPoint.x != 0.0f) && (endPoint.y != 0.0f))
3753 startPoint = __pWebCore->GetRelativeCoordinate(startPoint);
3754 endPoint = __pWebCore->GetRelativeCoordinate(endPoint);
3760 _WebImpl::GetFaviconN(void) const
3762 result r = E_SUCCESS;
3764 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3765 Ewk_Context* pContext = ewk_view_context_get(pView);
3766 const char* pUrl = ewk_view_url_get(pView);
3767 Evas* pEvas = evas_object_evas_get(pView);
3769 Evas_Object* pFavicon = ewk_context_icon_database_icon_object_add(pContext, pUrl, pEvas);
3775 Tizen::Graphics::BufferInfo bufferInfo;
3777 r = _Utility::GetPixelBufferFromEvasObject(pFavicon, bufferInfo);
3778 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3780 const Dimension dimension(bufferInfo.width, bufferInfo.height);
3781 Tizen::Base::ByteBuffer byteBuffer;
3783 r = byteBuffer.Construct((byte*)bufferInfo.pPixels, 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 );
3784 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3786 std::unique_ptr<Bitmap> pImage(new (std::nothrow) Bitmap());
3787 SysTryReturn(NID_WEB_CTRL, pImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3789 r = pImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888);
3790 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3792 return pImage.release();
3798 _WebImpl::ScrollBy(const Tizen::Graphics::Point& diff)
3800 ewk_view_scroll_by(__pWebCore->GetWebNativeNode(), diff.x, diff.y);
3805 _WebImpl::ScrollTo(const Tizen::Graphics::Point& dest)
3807 ewk_view_scroll_set(__pWebCore->GetWebNativeNode(), dest.x, dest.y);
3812 _WebImpl::GetScrollPosition(void) const
3816 ewk_view_scroll_pos_get(__pWebCore->GetWebNativeNode(), &position.x, &position.y);
3823 _WebImpl::GetPageSize(void) const
3825 Evas_Coord width = 0;
3826 Evas_Coord height = 0;
3828 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &width, &height);
3830 Dimension size(static_cast< int >(width), static_cast< int >(height));
3837 _WebImpl::AddHttpHeaderField(const String& name, const String& value)
3839 SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing.");
3841 std::unique_ptr<char[]> pName(_StringConverter::CopyToCharArrayN(name));
3842 SysTryReturn(NID_WEB_CTRL, pName.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3844 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(value));
3846 ewk_view_custom_header_add(__pWebCore->GetWebNativeNode(), pName.get(), pValue.get());
3853 _WebImpl::RemoveHttpHeaderField(const String& name)
3855 SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing.");
3857 std::unique_ptr<char[]> pName(_StringConverter::CopyToCharArrayN(name));
3858 SysTryReturn(NID_WEB_CTRL, pName.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3860 ewk_view_custom_header_remove(__pWebCore->GetWebNativeNode(), pName.get());
3867 _WebImpl::SetLoadingErrorOccurred(bool arg)
3869 __isLoadingErrorOccurred = arg;
3874 _WebImpl::IsLoadingErrorOccurred(void) const
3876 return __isLoadingErrorOccurred;
3881 _WebImpl::SetRedirectRequested(bool arg)
3883 __isRedirectRequested = arg;
3888 _WebImpl::IsRedirectRequested(void) const
3890 return __isRedirectRequested;
3895 _WebImpl::SetPolicyDecision(DecisionPolicy policy)
3902 _WebImpl::GetPolicyDecision(void) const
3909 _WebImpl::SetCertificateRequested(bool arg)
3911 __isCertificateRequested = arg;
3916 _WebImpl::IsCertificateRequested(void) const
3918 return __isCertificateRequested;
3923 _WebImpl::SetCertificateConfirmed(bool arg)
3925 __isCertificateConfirmed = arg;
3930 _WebImpl::IsCertificateConfirmed(void) const
3932 return __isCertificateConfirmed;
3937 _WebImpl::SetFullScreenKeypad(void)
3939 result r = E_SUCCESS;
3941 std::unique_ptr<Keypad> pKeypad(new (std::nothrow) Keypad());
3942 SysTryReturnResult(NID_WEB_CTRL, pKeypad.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
3944 r = pKeypad->Construct(KEYPAD_STYLE_NORMAL, 100);
3945 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3947 String text(ewk_view_focused_input_element_value_get(__pWebCore->GetWebNativeNode()));
3948 pKeypad->SetText(text);
3950 r = pKeypad->SetShowState(true);
3951 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3953 r = pKeypad->Show();
3954 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3956 pKeypad->AddTextEventListener(*this);
3958 __pKeypad = std::move(pKeypad);
3965 _WebImpl::RemoveFullScreenKeypad(void)
3967 __pKeypad->RemoveTextEventListener(*this);
3974 _WebImpl::IsFooterVisible(void) const
3976 return __isFooterVisible;
3981 _WebImpl::SetFooterVisibleState(bool isFooterVisible)
3983 __isFooterVisible = isFooterVisible;
3988 _WebImpl::IsKeypadVisible(void) const
3990 return __isKeypadVisible;
3995 _WebImpl::SetKeypadVisibleState(bool isKeypadVisible)
3997 __isKeypadVisible = isKeypadVisible;
4002 _WebImpl::IsKeypadOpened(void) const
4004 return __isKeypadOpened;
4008 _WebImpl::SetKeypadOpened(bool isKeypadOpened)
4010 __isKeypadOpened = isKeypadOpened;
4015 _WebImpl::GetPreviousKeypadBounds(void) const
4017 return __keypadBounds;
4022 _WebImpl::SetPreviousKeypadBounds(Rectangle& bounds)
4024 __keypadBounds = bounds;
4029 _WebImpl::OnTextValueChangeCanceled(const Control& source)
4031 RemoveFullScreenKeypad();
4036 _WebImpl::OnTextValueChanged(const Control& source)
4038 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(__pKeypad->GetText()));
4040 ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get());
4042 RemoveFullScreenKeypad();
4047 _WebImpl::OnHandleJavaScriptRequestByEventArg(const IEventArg& arg)
4049 const _JsBridgeArg* pEventArg = dynamic_cast< const _JsBridgeArg* >(&arg);
4050 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. arg is not _JsBridgeArg object.");
4052 std::unique_ptr<IJsonValue> pJsonValue(JsonParser::ParseN(*(pEventArg->GetJsonData())));
4053 SysTryReturn(NID_WEB_JSON, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4055 IJavaScriptBridge* pJsInterface = FindJsInterface(pJsonValue.get());
4056 SysTryReturnResult(NID_WEB_CTRL, pJsInterface, E_OBJ_NOT_FOUND, "JsInterface instance is not available.");
4058 pJsInterface->HandleJavaScriptRequestN(pJsonValue.release());
4065 _WebImpl::OnHandleLoadingEvent(const IEventArg& arg)
4067 result r = E_SUCCESS;
4069 const _LoadingEventArg* pEventArg = dynamic_cast< const _LoadingEventArg* >(&arg);
4070 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4072 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4074 ILoadingListener* pLoadingListner = GetLoadingListener();
4075 SysTryReturnResult(NID_WEB_CTRL, pLoadingListner, E_SYSTEM, "A system error has been occurred. Loading listener was not set or null.");
4077 switch (pEventArg->GetEventType())
4079 case WEB_EVENT_LOADINGLISTENER_STARTED:
4081 pLoadingListner->OnLoadingStarted();
4085 case WEB_EVENT_LOADINGLISTENER_PROGRESS:
4087 const Integer* pProgressPercentage = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS));
4088 SysTryReturn(NID_WEB_CTRL, pProgressPercentage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4090 pLoadingListner->OnEstimatedProgress(pProgressPercentage->ToInt());
4094 case WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED:
4096 const String* pPageTitle = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::PAGE_TITLE));
4097 SysTryReturn(NID_WEB_CTRL, pPageTitle, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4099 pLoadingListner->OnPageTitleReceived(*pPageTitle);
4103 case WEB_EVENT_LOADINGLISTENER_CANCELED:
4105 pLoadingListner->OnLoadingCanceled();
4109 case WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED:
4111 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_TYPE));
4112 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4114 const String* pErrorMessage = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_MESSAGE));
4115 SysTryReturn(NID_WEB_CTRL, pErrorMessage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4117 LoadingErrorType errorType = ConvertErrorCode(pErrorType->ToInt());
4119 pLoadingListner->OnLoadingErrorOccurred(errorType, *pErrorMessage);
4123 case WEB_EVENT_LOADINGLISTENER_COMPLETED:
4125 pLoadingListner->OnLoadingCompleted();
4129 case WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED:
4131 pLoadingListner->OnHttpAuthenticationCanceled();
4135 case WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED:
4137 std::unique_ptr<Bitmap> pFavicon(GetFaviconN());
4138 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4142 pLoadingListner->OnFaviconReceived(*pFavicon.get());
4158 _WebImpl::OnHandleWebDownloadEvent(const IEventArg& arg)
4160 result r = E_SUCCESS;
4162 const _WebDownloadEventArg* pEventArg = dynamic_cast< const _WebDownloadEventArg* >(&arg);
4163 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4165 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4167 IWebDownloadListener* pWebDownloadListener = __pWebDownloadHandler->GetDownloadListener();
4168 SysTryReturnResult(NID_WEB_CTRL, pWebDownloadListener, E_SYSTEM, "A system error has been occurred. Web Downloading listener was not set or null.");
4170 switch (pEventArg->GetEventType())
4172 case WEB_EVENT_WEBDOWNLOADLISTENER_DATA_RECEIVED:
4174 const ByteBuffer* pChunk = dynamic_cast< const ByteBuffer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::CHUNKED_DATA));
4175 SysTryReturn(NID_WEB_CTRL, pChunk, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4177 pWebDownloadListener->OnWebChunkedDataReceived(*pChunk);
4181 case WEB_EVENT_WEBDOWNLOADLISTENER_COMPLETED:
4183 pWebDownloadListener->OnWebDataDownloadCompleted();
4187 case WEB_EVENT_WEBDOWNLOADLISTENER_FAILED:
4189 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::ERROR_TYPE));
4190 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4192 LoadingErrorType errorType = static_cast < LoadingErrorType >(pErrorType->ToInt());
4194 pWebDownloadListener->OnWebDownloadFailed(errorType);
4209 _WebImpl::OnHandleWebUiEvent(const IEventArg& arg)
4211 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4212 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4214 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4216 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListener, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4218 switch (pEventArg->GetEventType())
4220 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED:
4222 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4224 Point* pStartPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4225 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4227 Point* pEndPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4228 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4230 __pUserUiListener->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4234 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED:
4236 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4238 __pUserUiListener->OnWebPageShowRequested(*pWeb);
4242 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED:
4244 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4246 __pUserUiListener->OnWebWindowCloseRequested(*pWeb);
4250 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED:
4252 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4254 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4255 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4257 __pUserUiListener->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4272 _WebImpl::OnHandleWebUiEventF(const IEventArg& arg)
4274 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4275 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4277 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4279 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListenerF, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4281 switch (pEventArg->GetEventType())
4283 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT:
4285 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4287 FloatPoint* pStartPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4288 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4290 FloatPoint* pEndPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4291 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4293 __pUserUiListenerF->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4297 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT:
4299 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4301 __pUserUiListenerF->OnWebPageShowRequested(*pWeb);
4305 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT:
4307 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4309 __pUserUiListenerF->OnWebWindowCloseRequested(*pWeb);
4313 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT:
4315 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4317 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4318 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4320 __pUserUiListenerF->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4335 _WebImpl::OnHandleTextSearchEvent(const IEventArg& arg)
4337 result r = E_SUCCESS;
4339 const _TextSearchEventArg* pEventArg = dynamic_cast< const _TextSearchEventArg* >(&arg);
4340 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4342 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4344 ITextSearchListener* pTextSearchListner = GetTextSearchListener();
4345 SysTryReturnResult(NID_WEB_CTRL, pTextSearchListner, E_SYSTEM, "A system error has been occurred. Web text search listener was not set or null.");
4347 switch (pEventArg->GetEventType())
4349 case WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND:
4351 Integer* pTotalCount= dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::TOTAL_COUNT)));
4352 SysTryReturn(NID_WEB_CTRL, pTotalCount, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4354 Integer* pCurrentOrdinal = dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL)));
4355 SysTryReturn(NID_WEB_CTRL, pCurrentOrdinal, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4357 pTextSearchListner->OnTextFound(pTotalCount->ToInt(), pCurrentOrdinal->ToInt());
4372 _WebImpl::VibrationRequested(uint64_t duration)
4374 result r = E_SUCCESS;
4376 __pVibrator.reset();
4378 std::unique_ptr<_VibratorImpl> pVibrator(new (std::nothrow) _VibratorImpl);
4379 SysTryReturnResult(NID_WEB_CTRL, pVibrator.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4381 r = pVibrator->Construct();
4382 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4384 __pVibrator = std::move(pVibrator);
4386 IntensityDurationVibrationPattern pattern = {static_cast< int >(duration), -1};
4388 r = __pVibrator->Start(&pattern, 1, 1);
4389 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4396 _WebImpl::VibrationCanceled(void)
4398 __pVibrator.reset();
4403 _WebImpl::HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge)
4405 result r = E_SUCCESS;
4407 String host(ewk_auth_challenge_url_get(pChallenge));
4408 String realm(ewk_auth_challenge_realm_get(pChallenge));
4410 __pAuthChallenge.reset();
4412 std::unique_ptr<AuthenticationChallenge> pAuthChallenge(new (std::nothrow) AuthenticationChallenge());
4413 SysTryReturnResult(NID_WEB_CTRL, pAuthChallenge, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4415 _AuthenticationChallengeImpl* pAuthImpl = _AuthenticationChallengeImpl::GetInstance(pAuthChallenge.get());
4416 SysTryReturn(NID_WEB_CTRL, pAuthImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4418 pAuthImpl->SetAuthenticationChallengeHandler(pChallenge);
4419 pAuthImpl->SetWebEvasObject(__pWebCore->GetWebNativeNode());
4421 __pAuthChallenge = std::move(pAuthChallenge);
4423 ewk_auth_challenge_suspend(pChallenge);
4424 if (__pUserLoadingListener && __pUserLoadingListener->OnHttpAuthenticationRequestedN(host, realm, *__pAuthChallenge.get()))
4426 __pAuthChallenge.release();
4430 r = ShowAuthenticationPopup(host, realm, __pAuthChallenge.get());
4431 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4439 _WebImpl::ShowAuthenticationPopup(const String& host, const String& realm, AuthenticationChallenge* pAuthChallenge)
4441 result r = E_SUCCESS;
4443 std::unique_ptr<_AuthConfirmPopup> pAuthPopup(new (std::nothrow) _AuthConfirmPopup());
4444 SysTryReturnResult(NID_WEB_CTRL, pAuthPopup, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4446 r = pAuthPopup->Construct(host, realm, pAuthChallenge);
4447 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4449 __pAuthPopup = std::move(pAuthPopup);
4451 int modalResult = 0;
4453 r = __pAuthPopup->ShowAndWait(modalResult);
4454 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4459 __pAuthPopup.reset();
4467 _WebImpl::ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk_Certificate_Policy_Decision* pPolicy)
4469 result r = E_SUCCESS;
4471 std::unique_ptr<_CertificateConfirmPopup> pCertConfirmPopup(new (std::nothrow) _CertificateConfirmPopup());
4472 SysTryReturnResult(NID_WEB_CTRL, pCertConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4474 r = pCertConfirmPopup->Construct(userConfirmMode, pPolicy);
4475 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4477 __pCertConfirmPopup = std::move(pCertConfirmPopup);
4479 int modalResult = 0;
4481 r = __pCertConfirmPopup->ShowAndWait(modalResult);
4482 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4484 if (__pCertConfirmPopup.get() && userConfirmMode == CERTIFICATE_POPUP_MODE_USER_CONFIRM)
4486 __isCertificateConfirmed = __pCertConfirmPopup->GetConfirmResult();
4490 if (__pCertConfirmPopup.get())
4492 __pCertConfirmPopup.reset();
4500 _WebImpl::ShowPromptPopup(String msg, String defVal)
4502 result r = E_SUCCESS;
4504 std::unique_ptr< _PromptPopup > pPromptPopup(new (std::nothrow) _PromptPopup());
4505 SysTryReturnResult(NID_WEB_CTRL, pPromptPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4507 r = pPromptPopup->Construct(msg, defVal, __pWebCore->GetWebNativeNode(), this);
4508 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4510 __pPromptPopup = std::move(pPromptPopup);
4512 r = __pPromptPopup->ShowPopup();
4513 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4518 __pPromptPopup.reset();
4526 _WebImpl::ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4528 result r = E_SUCCESS;
4530 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4531 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4533 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, this, true, msg);
4534 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4536 int modalResult = 0;
4538 switch(userConfirmMode)
4540 case USER_CONTENT_HANDLER:
4542 __pContentHandlerConfirmPopup = std::move(pUserConfirmPopup);
4544 r = __pContentHandlerConfirmPopup->ShowAndWait(modalResult);
4545 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pContentHandlerConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4547 __pContentHandlerConfirmPopup.reset();
4549 ewk_view_resume(__pWebCore->GetWebNativeNode());
4553 case USER_PROTOCOL_HANDLER:
4555 __pProtocolHandlerConfirmPopup = std::move(pUserConfirmPopup);
4557 r = __pProtocolHandlerConfirmPopup->ShowAndWait(modalResult);
4558 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pProtocolHandlerConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4560 __pProtocolHandlerConfirmPopup.reset();
4562 ewk_view_resume(__pWebCore->GetWebNativeNode());
4566 case USER_CONFIRM_APP_CACHE:
4568 __pAppCacheConfirmPopup = std::move(pUserConfirmPopup);
4570 r = __pAppCacheConfirmPopup->ShowAndWait(modalResult);
4571 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pAppCacheConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4573 __pAppCacheConfirmPopup.reset();
4575 ewk_view_resume(__pWebCore->GetWebNativeNode());
4579 case USER_CONFIRM_DB_QUOTA_EXCEDED:
4581 __pDbQuotaConfirmPopup = std::move(pUserConfirmPopup);
4583 r = __pDbQuotaConfirmPopup->ShowAndWait(modalResult);
4584 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pDbQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4586 __pDbQuotaConfirmPopup.reset();
4588 ewk_view_resume(__pWebCore->GetWebNativeNode());
4592 case USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED:
4594 __pLocalFsQuotaConfirmPopup = std::move(pUserConfirmPopup);
4596 r = __pLocalFsQuotaConfirmPopup->ShowAndWait(modalResult);
4597 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pLocalFsQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4599 __pLocalFsQuotaConfirmPopup.reset();
4601 ewk_view_resume(__pWebCore->GetWebNativeNode());
4605 case USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED:
4607 __pIndexedDbQuotaConfirmPopup = std::move(pUserConfirmPopup);
4609 r = __pIndexedDbQuotaConfirmPopup->ShowAndWait(modalResult);
4610 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pIndexedDbQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4612 __pIndexedDbQuotaConfirmPopup.reset();
4614 ewk_view_resume(__pWebCore->GetWebNativeNode());
4627 _WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4629 result r = E_SUCCESS;
4631 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4632 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4634 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, this, false, msg);
4635 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4637 switch(userConfirmMode)
4639 case USER_CONFIRM_USERMEDIA:
4641 __pUserMediaConfirmPopup.reset();
4643 __pUserMediaConfirmPopup = std::move(pUserConfirmPopup);
4645 r = __pUserMediaConfirmPopup->ShowPopup();
4646 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pUserMediaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4648 __pUserMediaConfirmPopup.release();
4651 case USER_CONFIRM_GEOLOCATION:
4653 __pGeolocationConfirmPopup.reset();
4655 __pGeolocationConfirmPopup = std::move(pUserConfirmPopup);
4657 r = __pGeolocationConfirmPopup->ShowPopup();
4658 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pGeolocationConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4660 __pGeolocationConfirmPopup.release();
4663 case USER_CONFIRM_NOTIFICATION:
4665 __pNotificationConfirmPopup.reset();
4667 __pNotificationConfirmPopup = std::move(pUserConfirmPopup);
4669 r = __pNotificationConfirmPopup->ShowPopup();
4670 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pNotificationConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4672 __pNotificationConfirmPopup.release();
4675 case USER_SCRIPT_ALERT:
4677 __pScriptAlertConfirmPopup.reset();
4679 __pScriptAlertConfirmPopup = std::move(pUserConfirmPopup);
4681 r = __pScriptAlertConfirmPopup->ShowPopup();
4682 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pScriptAlertConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4684 __pScriptAlertConfirmPopup.release();
4687 case USER_SCRIPT_CONFIRM:
4689 __pScriptConfirmPopup.reset();
4691 __pScriptConfirmPopup = std::move(pUserConfirmPopup);
4693 r = __pScriptConfirmPopup->ShowPopup();
4694 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pScriptConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4696 __pScriptConfirmPopup.release();
4712 _WebImpl::GetParentFormImpl(_ControlImpl* pControlImpl)
4715 _FormImpl* pFormImpl = null;
4717 _ControlImpl* pParentControlImpl = dynamic_cast< _ControlImpl* >(pControlImpl->GetParent());
4718 if (!pParentControlImpl)
4723 pFormImpl = dynamic_cast< _FormImpl* >(pParentControlImpl);
4729 return GetParentFormImpl(pParentControlImpl);
4734 _WebImpl::OnFocusGained(const _ControlImpl& source)
4736 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
4737 SysAssertf(pSettings, "Failed to get webkit instance.");
4738 ewk_settings_clear_text_selection_automatically_set(pSettings, true);
4745 _WebImpl::OnFocusLost(const _ControlImpl& source)
4747 if(IsKeypadVisible() == true)
4749 SetKeypadOpened(true);
4751 SetKeypadVisibleState(false);
4754 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
4755 SysAssertf(pSettings, "Failed to get webkit instance.");
4756 ewk_settings_clear_text_selection_automatically_set(pSettings, false);
4758 evas_object_focus_set(__pWebCore->GetWebNativeNode(), EINA_FALSE);
4765 _WebImpl::HasValidNativeNode(void) const
4767 if (__pWebCore && __pWebCore->GetWebNativeNode())
4777 _WebImpl::OnPreAttachedToMainTree(void)
4779 result r = E_SUCCESS;
4781 if (IsVisible() == true)
4783 _WebManager* pWebManager = _WebManager::GetInstance();
4784 pWebManager->SetActiveWeb(this);
4787 r = _ContainerImpl::OnPreAttachedToMainTree();
4788 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4790 if (!HasValidNativeNode())
4792 r = __pWebCore->InitializeWebNativeNode();
4793 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4795 _ControlManager* pControlManager = _ControlManager::GetInstance();
4796 SysTryReturnResult(NID_WEB_CTRL, pControlManager, E_SYSTEM, "Failed to get the ControlManager instance.");
4797 OnChangeLayout(pControlManager->GetScreenRotation());
4799 r = InitializeSetting();
4800 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4802 _WebManager* pWebManager = _WebManager::GetInstance();
4803 pWebManager->AddWeb(reinterpret_cast< int >(this));
4811 _WebImpl::OnDetachingFromMainTree(void)
4813 result r = E_SUCCESS;
4815 _WebManager* pWebManager = _WebManager::GetInstance();
4816 pWebManager->RemoveActiveWeb(this);
4818 r = _ContainerImpl::OnDetachingFromMainTree();
4819 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4826 _WebImpl::OnChangeLayout(_ControlRotation rotation)
4832 case _CONTROL_ROTATION_0:
4835 case _CONTROL_ROTATION_90:
4838 case _CONTROL_ROTATION_180:
4841 case _CONTROL_ROTATION_270:
4847 ewk_view_orientation_send(__pWebCore->GetWebNativeNode(), degree);
4852 _WebImpl::OnChangeLayout(_ControlOrientation orientation)
4854 _ContainerImpl::OnChangeLayout(orientation);
4856 if (__pColorPicker.get())
4858 __pColorPicker->ChangeLayout(orientation);
4861 HideFormDataWindow();
4863 std::unique_ptr< IEnumerator > pEnum(__webNotificationList.GetEnumeratorN());
4864 _WebNotification* pWebNotification = null;
4866 while (pEnum->MoveNext() == E_SUCCESS)
4868 pWebNotification = static_cast< _WebNotification* >(pEnum->GetCurrent());
4869 pWebNotification->OnChangeLayout();
4875 _WebImpl::OnAncestorVisibleStateChanged(const _Control& control)
4877 _WebManager* pWebManager = _WebManager::GetInstance();
4878 if (IsVisible() == true)
4880 pWebManager->SetActiveWeb(this);
4881 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_VISIBLE, false);
4885 pWebManager->RemoveActiveWeb(this);
4886 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_HIDDEN, false);
4892 _WebImpl::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
4896 case ID_CERTIFICATE_CONFIRM_POPUP_CLOSE:
4897 __pCertConfirmPopup.reset();
4899 case ID_PROMPT_POPUP_CLOSE:
4900 __pPromptPopup.reset();
4902 case ID_USER_CONFIRM_USERMEDIA_CLOSE:
4903 __pUserMediaConfirmPopup.reset();
4905 case ID_USER_CONFIRM_GEOLOCATION_CLOSE:
4906 __pGeolocationConfirmPopup.reset();
4908 case ID_USER_CONFIRM_NOTIFICATION_CLOSE:
4909 __pNotificationConfirmPopup.reset();
4911 case ID_USER_SCRIPT_ALERT_CLOSE:
4912 __pScriptAlertConfirmPopup.reset();
4914 case ID_USER_SCRIPT_CONFIRM_CLOSE:
4915 __pScriptConfirmPopup.reset();
4924 _WebImpl::GetDownloadHandler(void) const
4926 return __pWebDownloadHandler.get();
4931 _WebImpl::HideColorPicker(void)
4933 __pColorPicker.reset();
4940 _WebImpl::ShowColorPicker(int red, int green, int blue, int alpha, Color& color)
4942 result r = E_SUCCESS;
4944 std::unique_ptr<_InputPickerPopup> pColorHadler(new (std::nothrow) _InputPickerPopup());
4945 SysTryReturnResult(NID_WEB_CTRL, pColorHadler.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4947 Tizen::Graphics::Color colorVal(static_cast< byte >(red), static_cast< byte >(green), static_cast< byte >(blue), static_cast< byte >(alpha));
4949 r = pColorHadler->Construct(colorVal, this);
4950 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4952 __pColorPicker = std::move(pColorHadler);
4954 r = __pColorPicker->ShowPopup();
4955 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4959 color = __pColorPicker->GetColor();
4965 __pColorPicker.reset();
4973 _WebImpl::ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue, String& dateStr)
4975 result r = E_SUCCESS;
4977 std::unique_ptr<_InputPickerPopup> pInputPicker(new (std::nothrow) _InputPickerPopup());
4978 SysTryReturnResult(NID_WEB_CTRL, pInputPicker.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4980 r = pInputPicker->Construct(String(inputValue), inputType, this);
4981 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4983 __pDatePicker = std::move(pInputPicker);
4985 r = __pDatePicker->ShowPopup();
4986 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4990 dateStr = __pDatePicker->GetDate();
4996 __pDatePicker.reset();
5004 _WebImpl::GetInstance(Web* pWeb)
5006 return dynamic_cast< _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
5011 _WebImpl::GetInstance(const Web* pWeb)
5013 return dynamic_cast< const _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
5018 _WebImpl::SearchHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
5020 int checkReturn = 0;
5022 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5025 if( checkmime == true)
5027 table = CUSTOM_CONTENT_TABLE_NAME;
5031 table = CUSTOM_PROTOCOL_TABLE_NAME;
5034 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
5035 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
5036 String target(ewk_custom_handlers_data_target_get(pHandlerData));
5038 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
5040 result r = db.Construct(handlerPath, "r+", null);
5041 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5043 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select allow From " + table + L" Where baseUrl = '" + baseUri + L"' AND url = '" + uri + L"' AND mime = '" + target + L"'"));
5044 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5048 r = pEnum->MoveNext();
5049 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5050 r = pEnum->GetIntAt(0, checkReturn);
5051 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5063 _WebImpl::UnregistrationHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
5067 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5070 if( checkmime == true)
5072 table = CUSTOM_CONTENT_TABLE_NAME;
5076 table = CUSTOM_PROTOCOL_TABLE_NAME;
5079 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
5080 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
5081 String target(ewk_custom_handlers_data_target_get(pHandlerData));
5083 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
5085 result r = db.Construct(handlerPath, "r+", null);
5086 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5088 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select id From " + table + L" Where baseUrl = '" + baseUri + L"' AND url = '" + uri + L"' AND mime = '" + target + L"'"));
5089 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5093 r = pEnum->MoveNext();
5094 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5095 r = pEnum->GetIntAt(0, checkId);
5096 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5098 std::unique_ptr<DbStatement> pDeleteStmt(db.CreateStatementN(L"Delete From " + table + L" Where id = (?)"));
5099 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5101 r = pDeleteStmt->BindInt(0, checkId);
5102 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5104 db.BeginTransaction();
5106 std::unique_ptr<DbEnumerator> pEnum(db.ExecuteStatementN(*pDeleteStmt));
5108 db.CommitTransaction();
5115 const Tizen::Base::String
5116 _WebImpl::GetProtocolFromUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri)
5118 if (originUri == L"" || currentUri == L"")
5123 result r = E_SUCCESS;
5126 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5127 String originReplace(originUri);
5128 String table(CUSTOM_PROTOCOL_TABLE_NAME);
5132 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
5133 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5135 r = currentUri.SubString(0, found + 1, baseUri);
5136 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5138 r = db.Construct(handlerPath, "r+", null);
5139 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5141 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select mime, url, allow From " + table + L" Where baseUrl = '" + baseUri + "'"));
5142 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, L"", GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
5146 while (pEnum->MoveNext() == E_SUCCESS)
5151 String originScheme;
5153 r = pEnum->GetStringAt(0, protocol);
5154 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5156 r = pEnum->GetStringAt(1, queryUrl);
5157 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5159 r = pEnum->GetIntAt(2, allow);
5160 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5167 String protocolScheme(protocol + L":");
5169 r = originReplace.SubString(0, protocolScheme.GetLength(), originScheme);
5170 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5172 if ((originReplace.GetLength() >= protocolScheme.GetLength()) && originScheme.Equals(protocolScheme, false))
5174 if (queryUrl.IndexOf(L"%s", 0, foundQuery) == E_SUCCESS)
5176 r = originReplace.Replace(originScheme, "");
5177 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5179 queryUrl.Replace("%s", originReplace, 0);
5180 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5192 const Tizen::Base::String
5193 _WebImpl::GetRedirectUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri, const Tizen::Base::String& mime)
5195 if (originUri == L"" || currentUri == L"" || mime == L"")
5200 result r = E_SUCCESS;
5203 String originUrlStr = originUri;
5204 const String replaceStr = L"%s";
5206 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5207 String table(CUSTOM_CONTENT_TABLE_NAME);
5211 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
5212 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5214 r = currentUri.SubString(0, found + 1, baseUri);
5215 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5217 r = db.Construct(handlerPath, "r+", null);
5218 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5220 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select allow, url From " + table + L" Where baseUrl = '" + baseUri + "' AND mime = '" + mime + L"'"));
5224 r = pEnum->MoveNext();
5225 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5226 r = pEnum->GetIntAt(0, allow);
5227 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5228 r = pEnum->GetStringAt(1, contentUrl);
5229 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5237 if (contentUrl != L"")
5239 r = contentUrl.Replace(replaceStr, originUrlStr, 0);
5240 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5252 _WebImpl::SetFormDataList(Eina_List* pFormDataList)
5254 __pFormDataList = pFormDataList;
5259 _WebImpl::IsFormDataWindowVisible(void) const
5261 return __isFormDataVisible;
5266 _WebImpl::ShowFormDataWindow(const Rectangle& windowRect, Evas_Object* pWebView)
5268 Rectangle rect(_CoordinateSystemUtils::InverseTransform(Rectangle(windowRect.x, windowRect.y + windowRect.height, windowRect.width, windowRect.height)));
5270 if (__isFormDataVisible)
5272 result r = __pFormDataWindow->UpdateList(__pFormDataList, rect);
5273 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5277 __pFormDataWindow.reset();
5279 std::unique_ptr<_FormDataWindow> pFormDataWindow( new (std::nothrow) _FormDataWindow());
5280 SysTryReturnResult(NID_WEB_CTRL, pFormDataWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
5282 result r = pFormDataWindow->Construct(rect, this, pWebView);
5283 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5285 r = pFormDataWindow->UpdateList(__pFormDataList, rect);
5286 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5288 r = pFormDataWindow->LaunchFormDataWindow();
5289 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5291 __pFormDataWindow = std::move(pFormDataWindow);
5292 __isFormDataVisible = true;
5300 _WebImpl::HideFormDataWindow(bool delWindow)
5304 __pFormDataWindow.reset();
5307 __isFormDataVisible = false;
5312 _WebImpl::ClearWebNotification(_WebNotification* pWebNotification)
5314 __webNotificationList.Remove(*pWebNotification);
5319 _WebImpl::SetWebNotification(_WebNotification* pWebNotification)
5321 __webNotificationList.Add(pWebNotification);
5326 _WebImpl::OnDownloadCompleted(RequestId reqId, const String &path)
5328 _ContentManagerImpl::ScanFile(path);
5332 }}} // Tizen::Web::Controls