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 <FGrpColor.h>
41 #include <FGrpPoint.h>
42 #include <FGrpRectangle.h>
43 #include <FIoDbEnumerator.h>
44 #include <FIoDbStatement.h>
46 #include <FMediaImage.h>
47 #include <FMediaImageTypes.h>
48 #include <FNetHttpHttpHeader.h>
49 #include <FSysVibrator.h>
50 #include <FUiControl.h>
51 #include <FUiCtrlKeypad.h>
52 #include <FWebCtrlHitElementResult.h>
53 #include <FWebCtrlITextSearchListener.h>
54 #include <FWebCtrlIWebDownloadListener.h>
55 #include <FWebCtrlIWebUiEventListener.h>
56 #include <FWebCtrlIWebUiEventListenerF.h>
57 #include <FWebCtrlIWebKeypadEventListener.h>
58 #include <FWebCtrlIJavaScriptBridge.h>
59 #include <FWebCtrlPageNavigationList.h>
60 #include <FWebCtrlAuthenticationChallenge.h>
61 #include <FWebCtrlWeb.h>
62 #include <FWebCtrlWebSetting.h>
63 #include <FWebHistoryItem.h>
64 #include <FWebJsonJsonObject.h>
65 #include <FWebJsonJsonParser.h>
66 #include <FWebJsonJsonString.h>
67 #include <FApp_AppControlImpl.h>
68 #include <FApp_AppControlManager.h>
69 #include <FApp_AppInfo.h>
70 #include <FApp_AppManagerImpl.h>
71 #include <FBase_StringConverter.h>
72 #include <FGrp_CoordinateSystem.h>
73 #include <FGrp_Screen.h>
74 #include <FIo_DatabaseImpl.h>
75 #include <FIo_NormalFile.h>
76 #include <FSys_SettingInfoImpl.h>
77 #include <FSys_SystemResource.h>
78 #include <FSys_VibratorImpl.h>
79 #include <FUi_Control.h>
80 #include <FUi_CoordinateSystemUtils.h>
81 #include <FUi_EcoreEvasMgr.h>
82 #include <FUi_EcoreEvas.h>
83 #include <FUi_ResourceSizeInfo.h>
84 #include <FUi_Window.h>
85 #include <FUiAnim_EflNode.h>
86 #include <FUiAnim_VisualElement.h>
87 #include <FUiCtrl_FooterImpl.h>
88 #include <FUiCtrl_FormImpl.h>
89 #include "FWeb_HistoryItemImpl.h"
90 #include "FWebCtrl_AppControlListener.h"
91 #include "FWebCtrl_AuthConfirmPopup.h"
92 #include "FWebCtrl_AuthenticationChallengeImpl.h"
93 #include "FWebCtrl_EflWebkit.h"
94 #include "FWebCtrl_FormDataWindow.h"
95 #include "FWebCtrl_GeolocationPermissionManagerImpl.h"
96 #include "FWebCtrl_HitElementResultImpl.h"
97 #include "FWebCtrl_InputPickerPopup.h"
98 #include "FWebCtrl_WebNotification.h"
99 #include "FWebCtrl_PageNavigationListImpl.h"
100 #include "FWebCtrl_PromptPopup.h"
101 #include "FWebCtrl_SelectBox.h"
102 #include "FWebCtrl_Utility.h"
103 #include "FWebCtrl_Web.h"
104 #include "FWebCtrl_WebDataHandler.h"
105 #include "FWebCtrl_WebEvent.h"
106 #include "FWebCtrl_WebEventArg.h"
107 #include "FWebCtrl_WebImpl.h"
108 #include "FWebCtrl_WebManager.h"
109 #include "FWebCtrl_WebPresenter.h"
110 #include "FWebCtrl_WebSettingImpl.h"
113 using namespace Tizen::App;
114 using namespace Tizen::Base;
115 using namespace Tizen::Base::Collection;
116 using namespace Tizen::Base::Runtime;
117 using namespace Tizen::Base::Utility;
118 using namespace Tizen::Content;
119 using namespace Tizen::Graphics;
120 using namespace Tizen::Io;
121 using namespace Tizen::Media;
122 using namespace Tizen::Net::Http;
123 using namespace Tizen::System;
124 using namespace Tizen::Ui;
125 using namespace Tizen::Ui::Animations;
126 using namespace Tizen::Ui::Controls;
127 using namespace Tizen::Web::Json;
130 namespace Tizen { namespace Web { namespace Controls
134 static const char WEB_CTRL[] = "webcontrol";
135 static const char PARENT_WEB_CTRL[] = "parentwebcontrol";
138 static const float MIN_ZOOM_LEVEL = 0.3;
139 static const float MAX_ZOOM_LEVEL = 2;
142 static const int REDIRECTION_HEADER_GROUP = 300;
145 static const int MAX_TEXT_MATCH = pow(2, 31) - 1;
148 static const int PORTRAIT_KEYPAD_HEIGHT = 444;
149 static const int LANDSCAPE_KEYPAD_HEIGHT = 316;
150 static const int DEFAULT_LIST_ITEM_COUNT = 4;
154 AddHttpAttributeData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData)
156 result r = E_SUCCESS;
158 std::unique_ptr<String> pAttrKey(new (std::nothrow) String(reinterpret_cast< char* >(const_cast< void* >(pKey))));
159 std::unique_ptr<String> pAttrValue(new (std::nothrow) String(reinterpret_cast< char* >(pValue)));
160 SysTryReturn(NID_WEB_CTRL, pAttrKey.get() && pAttrValue.get(), EINA_FALSE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
162 SysSecureLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", pAttrKey->GetPointer(), pAttrValue->GetPointer());
164 r = reinterpret_cast< HashMap* >(pUserData)->Add(*pAttrKey, *pAttrValue);
165 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
167 pAttrValue.release();
174 FreeCharArray(void* pData)
176 delete[] reinterpret_cast<char*>(pData);
181 ConvertErrorCode(int error)
183 LoadingErrorType errorCode = WEB_ERROR_UNKNOWN;
187 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
189 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE:
191 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE_PROXY:
193 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT:
195 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT_PROXY:
197 case EWK_ERROR_NETWORK_STATUS_IO_ERROR:
199 case EWK_ERROR_NETWORK_STATUS_MALFORMED:
201 case EWK_ERROR_NETWORK_STATUS_TRY_AGAIN:
203 case EWK_ERROR_NETWORK_STATUS_TOO_MANY_REDIRECTS:
205 case EWK_ERROR_NETWORK_STATUS_TLS_FAILED:
207 case EWK_ERROR_NETWORK_STATUS_INTERNAL_SERVER_ERROR:
209 case EWK_ERROR_NETWORK_STATUS_BAD_GATEWAY:
211 case EWK_ERROR_NETWORK_STATUS_SERVICE_UNAVAILABLE:
213 case EWK_ERROR_NETWORK_STATUS_GATEWAY_TIMEOUT:
214 errorCode = WEB_NO_CONNECTION;
217 case EWK_ERROR_NETWORK_STATUS_BAD_REQUEST:
219 case EWK_ERROR_NETWORK_STATUS_REQUEST_URI_TOO_LONG:
220 errorCode = WEB_BAD_URL;
223 case EWK_ERROR_NETWORK_STATUS_FORBIDDEN:
224 errorCode = WEB_FILE_ACCESS_FAILED;
227 case EWK_ERROR_NETWORK_STATUS_REQUEST_TIMEOUT:
228 errorCode = WEB_REQUEST_TIMEOUT;
231 case EWK_ERROR_NETWORK_STATUS_UNSUPPORTED_MEDIA_TYPE:
232 errorCode = WEB_MIME_NOT_SUPPORTED;
235 case EWK_ERROR_NETWORK_STATUS_INSUFFICIENT_STORAGE:
236 errorCode = WEB_OUT_OF_MEMORY;
239 case EWK_ERROR_NETWORK_STATUS_REQUEST_ENTITY_TOO_LARGE:
240 errorCode = WEB_REQUEST_MAX_EXCEEDED;
243 case EWK_ERROR_NETWORK_STATUS_CONTINUE:
245 case EWK_ERROR_NETWORK_STATUS_SWITCHING_PROTOCOLS:
247 case EWK_ERROR_NETWORK_STATUS_PROCESSING:
249 case EWK_ERROR_NETWORK_STATUS_OK:
251 case EWK_ERROR_NETWORK_STATUS_CREATED:
253 case EWK_ERROR_NETWORK_STATUS_ACCEPTED:
255 case EWK_ERROR_NETWORK_STATUS_NON_AUTHORITATIVE:
257 case EWK_ERROR_NETWORK_STATUS_NO_CONTENT:
259 case EWK_ERROR_NETWORK_STATUS_RESET_CONTENT:
261 case EWK_ERROR_NETWORK_STATUS_PARTIAL_CONTENT:
263 case EWK_ERROR_NETWORK_STATUS_MULTI_STATUS:
265 case EWK_ERROR_NETWORK_STATUS_MULTIPLE_CHOICES:
267 case EWK_ERROR_NETWORK_STATUS_MOVED_PERMANENTLY:
269 case EWK_ERROR_NETWORK_STATUS_FOUND:
271 case EWK_ERROR_NETWORK_STATUS_SEE_OTHER:
273 case EWK_ERROR_NETWORK_STATUS_NOT_MODIFIED:
275 case EWK_ERROR_NETWORK_STATUS_USE_PROXY:
277 case EWK_ERROR_NETWORK_STATUS_NOT_APPEARING_IN_THIS_PROTOCOL:
279 case EWK_ERROR_NETWORK_STATUS_TEMPORARY_REDIRECT:
280 errorCode = WEB_HTTP_RESPONSE;
283 case EWK_ERROR_NETWORK_STATUS_SSL_FAILED:
284 errorCode = WEB_INVALID_CERTIFICATE;
288 errorCode = WEB_ERROR_UNKNOWN;
297 FireLoadingErrorOccurredEvent(_WebImpl* pImpl, int code, const char* pDescription)
299 result r = E_SUCCESS;
301 std::unique_ptr<Integer> pErrorCode(new (std::nothrow) Integer(code));
302 std::unique_ptr<String> pErrorDescription(new (std::nothrow) String(pDescription));
303 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED));
304 SysTryReturnResult(NID_WEB_CTRL, pErrorCode.get() && pErrorDescription.get() && pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
306 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_TYPE, *pErrorCode.get());
307 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
308 pErrorCode.release();
310 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_MESSAGE, *pErrorDescription.get());
311 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
312 pErrorDescription.release();
314 r = pImpl->GetWebEvent()->FireAsync(*pEventArg);
315 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
323 OnScriptAlertRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
325 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
327 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
328 String msg(pMessage);
330 result r = pImpl->ShowUserConfirmPopupAsync(USER_SCRIPT_ALERT, pView, msg);
331 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
335 ewk_view_javascript_alert_reply(pView);
341 OnScriptConfirmRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
343 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
345 result r = E_SUCCESS;
346 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
347 String msg(pMessage);
349 r = pImpl->ShowUserConfirmPopupAsync(USER_SCRIPT_CONFIRM, pView, msg);
350 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
354 ewk_view_javascript_confirm_reply(pView, EINA_FALSE);
360 OnScriptPromptRequested(Evas_Object* pView, const char* pMessage, const char* pDefaultValue, void* pUserData)
362 SysLog(NID_WEB_CTRL, "The current value of message is %s, defaulValue is %s", pMessage, pDefaultValue);
364 result r = E_SUCCESS;
365 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
367 String msg(pMessage);
368 String defVal(pDefaultValue);
370 r = pImpl->ShowPromptPopup(msg, defVal);
371 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
376 ewk_view_javascript_prompt_reply(pView, null);
383 OnCertificateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
385 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
386 Ewk_Certificate_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Certificate_Policy_Decision* >(pEventInfo);
387 SysAssertf(pImpl && pPolicy, "Failed to request");
389 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
391 switch (pImpl->GetSetting().GetCertificateErrorHandlingMode())
393 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM:
395 if (pImpl->IsCertificateRequested())
397 ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast< Eina_Bool >(pImpl->IsCertificateConfirmed()));
401 result r = E_SUCCESS;
403 std::unique_ptr<DbEnumerator> pEnum;
405 String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
406 String table(CERTIFICATE_TABLE_NAME);
409 String pem(ewk_certificate_policy_decision_certificate_pem_get(pPolicy));
411 r = db.Construct(certificatePath, "r", null);
412 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
414 pEnum = std::unique_ptr<DbEnumerator>(db.QueryN(L"Select allow From " + table + L" Where pem = '" + pem + L"'"));
417 r = pEnum->MoveNext();
418 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
421 r = pEnum->GetIntAt(0, allow);
422 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
424 SysLog(NID_WEB_CTRL, "The current value of allow is %d", allow);
426 ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast < Eina_Bool >(allow));
427 pImpl->SetCertificateConfirmed(static_cast < bool >(allow));
431 r = pImpl->ShowCertificateConfirmPopup(CERTIFICATE_POPUP_MODE_USER_CONFIRM, pPolicy);
432 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
434 ewk_view_resume(pWebCore->GetWebNativeNode());
439 pImpl->SetCertificateRequested(true);
443 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CANCEL:
444 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE);
446 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE :
447 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_TRUE);
456 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE);
457 pImpl->SetCertificateConfirmed(false);
458 pImpl->SetCertificateRequested(true);
460 ewk_view_resume(pWebCore->GetWebNativeNode());
465 OnHttpAuthenticationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
467 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
468 Ewk_Auth_Challenge* pChallenge = reinterpret_cast< Ewk_Auth_Challenge* >(pEventInfo);
469 SysAssertf(pImpl && pChallenge, "Failed to request");
471 result r = E_SUCCESS;
473 r = pImpl->HttpAuthenticationRequested(pChallenge);
474 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
478 ewk_auth_challenge_credential_cancel(pChallenge);
479 evas_object_smart_callback_call(pView, "authentication,canceled", NULL);
484 OnHttpAuthenticationCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
486 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
487 SysAssertf(pImpl , "Failed to request");
489 if (pImpl->GetLoadingListener())
491 result r = E_SUCCESS;
493 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED));
494 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
496 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
497 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
503 OnApplicationCachePermissionRequested(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, void* pUserData)
505 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
506 SysAssertf(pImpl , "Failed to request");
508 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
510 result r = msg.Format(256, L"Allow %s to use offline application cache?", pHostName);
511 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
513 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_APP_CACHE, pView, msg);
514 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
521 OnIndexedDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData)
523 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
524 SysAssertf(pImpl , "Failed to request");
526 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
528 result r = msg.Format(512, L"%s Used %lld of storage. Allow %s to use upto 2GB of indexed db?", pHostName, currentQuota, pHostName);
529 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
531 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED, pView, msg);
532 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
539 OnDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, const char* database_name, unsigned long long expectedQuota, void* pUserData)
541 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
542 SysAssertf(pImpl , "Failed to request");
544 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
546 result r = msg.Format(512, L"Allow %s to open %s use upto %lld of web database?", pHostName, database_name, expectedQuota);
547 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
549 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_DB_QUOTA_EXCEDED, pView, msg);
550 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
556 Eina_Bool OnLocalFileSystemQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData)
558 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
559 SysAssertf(pImpl , "Failed to request");
561 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
563 result r = msg.Format(512, L"%s Used %lld of storgae. Allow %s to use upto 2GB of file system?", pHostName, currentQuota, pHostName);
564 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
566 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED, pView, msg);
567 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
574 OnGeolocationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
576 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
577 Ewk_Geolocation_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Geolocation_Permission_Request* >(pEventInfo);
578 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
580 if (pImpl->GetSetting().IsGeolocationEnabled())
582 result r = E_SUCCESS;
584 std::unique_ptr<DbEnumerator> pEnum;
586 String geolocationPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
587 String table(GEOLOCATION_TABLE_NAME);
590 const Ewk_Security_Origin* pSecurityOrigin = ewk_geolocation_permission_request_origin_get(pPermissionRequest);
591 String origin = _Utility::CreateOrigin(pSecurityOrigin);
593 r = db.Construct(geolocationPath, "r", null);
594 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
596 pEnum = std::unique_ptr<DbEnumerator>(db.QueryN(L"Select permission From " + table + L" Where origin = '" + origin + L"'"));
599 r = pEnum->MoveNext();
600 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
603 r = pEnum->GetIntAt(0, permission);
604 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
606 SysLog(NID_WEB_CTRL, "The current value of permission is %d", permission);
608 ewk_geolocation_permission_request_set(pPermissionRequest, static_cast < Eina_Bool >(permission));
612 ewk_geolocation_permission_request_suspend(pPermissionRequest);
614 r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_GEOLOCATION, pPermissionRequest);
615 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
622 ewk_geolocation_permission_request_set(pPermissionRequest, EINA_FALSE);
627 OnGetUserMediaPermissionRequsted(void* pUserData, Evas_Object* pView, void* pEventInfo)
629 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
630 Ewk_User_Media_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_User_Media_Permission_Request* >(pEventInfo);
631 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
633 result r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_USERMEDIA, pEventInfo);
634 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
638 ewk_user_media_permission_request_set(pPermissionRequest, EINA_FALSE);
643 OnNotificationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
645 result r = E_SUCCESS;
646 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
648 Ewk_Notification_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Notification_Permission_Request* >(pEventInfo);
649 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
651 ewk_notification_permission_request_suspend(pPermissionRequest);
653 r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_NOTIFICATION, pPermissionRequest);
654 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
658 ewk_notification_permission_request_set(pPermissionRequest, EINA_FALSE);
663 OnNotificationShow(void* pUserData, Evas_Object* pView, void* pEventInfo)
665 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
666 Ewk_Notification* pNotification = reinterpret_cast< Ewk_Notification* >(pEventInfo);
667 SysAssertf(pImpl && pNotification, "Failed to request");
669 result r = E_SUCCESS;
670 Ewk_Context* pContext = ewk_view_context_get(pView);
671 SysAssertf(pContext, "Failed to get webkit instance.");
672 uint64_t notificationId = ewk_notification_id_get(pNotification);
674 //ewk_notification_security_origin_get(pNotification)
676 const char* text = ewk_notification_body_get(pNotification);
677 SysSecureLog(NID_WEB_CTRL, "The current value of icon path is %s",ewk_notification_icon_url_get(pNotification));
679 std::unique_ptr<_WebNotification> pNotificationWindow( new (std::nothrow) _WebNotification());
680 SysTryReturnVoidResult(NID_WEB_CTRL, pNotificationWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
682 r = pNotificationWindow->Construct(pContext, notificationId, pImpl);
683 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Error propogated.", GetErrorMessage(r));
685 pNotificationWindow->SetText(String(text));
686 pNotificationWindow->LaunchNotification();
687 pImpl->SetWebNotification(pNotificationWindow.release());
689 ewk_notification_showed(pContext, notificationId);
694 OnNotificationCancel(void* pUserData, Evas_Object* pView, void* pEventInfo)
696 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
697 uint64_t* pNotificationID = reinterpret_cast< uint64_t* >(pEventInfo);
698 SysAssertf(pImpl && pNotificationID, "Failed to request");
700 //ToDo : Where is ewk API for cancel operation?
705 OnProtocolHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
707 result r = E_SUCCESS;
708 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
709 SysAssertf(pImpl, "Failed to request");
711 r = pImpl->ShowUserConfirmPopup(USER_PROTOCOL_HANDLER, pEventInfo);
712 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
717 OnIsProtocolHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
719 int checkHandler = 0;
720 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
721 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
722 SysAssertf(pImpl && pHandlerData, "Failed to request");
724 checkHandler = pImpl->SearchHandler(pHandlerData, false);
725 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
726 switch (checkHandler)
731 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
734 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
737 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
745 OnProtocolHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
747 result r = E_SUCCESS;
748 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
749 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
750 SysAssertf(pImpl && pHandlerData, "Failed to request");
752 r = pImpl->UnregistrationHandler(pHandlerData, false);
753 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
758 OnContentHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
760 result r = E_SUCCESS;
761 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
762 SysAssertf(pImpl, "Failed to request");
764 r = pImpl->ShowUserConfirmPopup(USER_CONTENT_HANDLER, pEventInfo);
765 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
770 OnIsContentHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
772 int checkHandler = 0;
773 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
774 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
775 SysAssertf(pImpl && pHandlerData, "Failed to request");
777 checkHandler = pImpl->SearchHandler(pHandlerData, true);
778 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
780 switch (checkHandler)
785 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
788 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
791 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
800 OnContentHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
802 result r = E_SUCCESS;
803 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
804 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
805 SysAssertf(pImpl && pHandlerData, "Failed to request");
807 r = pImpl->UnregistrationHandler(pHandlerData, true);
808 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
813 OnFullScreenEntered(void* pUserData, Evas_Object* pView, void* pEventInfo)
815 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
816 bool* pIsHandleNeeded = reinterpret_cast< bool* >(pEventInfo);
817 SysAssertf(pImpl, "Failed to request");
819 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
820 SysAssertf(pWebCore, "Failed to get Web core object");
822 if (pIsHandleNeeded && *pIsHandleNeeded)
824 pWebCore->SetFullScreenEntered(true);
830 OnFullScreenExited(void* pUserData, Evas_Object* pView, void* pEventInfo)
832 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
833 SysAssertf(pImpl, "Failed to request");
835 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
836 SysAssertf(pWebCore, "Failed to get Web core object");
838 pWebCore->SetFullScreenEntered(false);
843 OnFocusDownRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
845 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
846 SysAssertf(pImpl, "Failed to request");
848 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
849 pWebCore->SetFocusEnd(true);
854 OnFocusUpRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
856 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
857 SysAssertf(pImpl, "Failed to request");
859 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
860 pWebCore->SetFocusEnd(true);
865 OnVibrationRequested(uint64_t duration, void* pUserData)
867 result r = E_SUCCESS;
869 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
870 SysAssertf(pImpl, "Failed to request");
872 r = pImpl->VibrationRequested(duration);
873 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
878 OnVibrationCanceled(void* pUserData)
880 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
881 SysAssertf(pImpl, "Failed to request");
883 pImpl->VibrationCanceled();
888 OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
890 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
891 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
892 SysAssertf(pImpl && pPolicy, "Failed to request");
894 String url(ewk_policy_decision_url_get(pPolicy));
895 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls", url.GetPointer());
897 if (ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy))
898 && !pImpl->IsRedirectRequested())
900 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
901 SysAssertf(pWebCore, "Failed to get Web core object");
903 pWebCore->SetFullScreenEntered(false);
905 pImpl->SetCertificateRequested(false);
907 if (pImpl->GetTextSearchListener())
909 pImpl->DisableAsyncSearch();
912 ILoadingListener* pLoadingListener = pImpl->GetLoadingListener();
913 if (pLoadingListener)
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 (pLoadingListener->OnLoadingRequested(url, navigationType))
944 ewk_policy_decision_ignore(pPolicy);
951 if (url == L"about:blank")
953 ewk_policy_decision_use(pPolicy);
958 String currentUrl(pImpl->GetUrl());
959 String redirectUrl(pImpl->GetProtocolFromUri(url, currentUrl));
960 if (redirectUrl != L"")
962 ewk_policy_decision_ignore(pPolicy);
964 pImpl->LoadUrl(redirectUrl);
972 String uriScheme(uri.GetScheme());
973 SysSecureLog(NID_WEB_CTRL, "The current value of scheme is %ls", uriScheme.GetPointer());
975 if ((uriScheme != L"http") && (uriScheme != L"https") && (uriScheme != L"file") && (uriScheme != L""))
977 result r = E_SUCCESS;
979 if (uriScheme == L"tel")
981 String operationId(L"http://tizen.org/appcontrol/operation/dial");
982 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
984 else if (uriScheme == L"mailto" || uriScheme == L"sms" || uriScheme == L"smsto" || uriScheme == L"mms" || uriScheme == L"mmsto" )
986 String operationId(L"http://tizen.org/appcontrol/operation/compose");
987 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
991 String operationId(L"http://tizen.org/appcontrol/operation/view");
992 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
997 ewk_policy_decision_ignore(pPolicy);
1003 ewk_policy_decision_use(pPolicy);
1008 OnLoadingStarted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1010 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1011 SysAssertf(pImpl, "Failed to request");
1013 if (pImpl->GetLoadingListener())
1015 result r = E_SUCCESS;
1017 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_STARTED));
1018 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1020 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1021 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1022 pEventArg.release();
1028 OnPageTitleReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1030 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1031 char* pTitle = reinterpret_cast< char* >(pEventInfo);
1032 SysAssertf(pImpl, "Failed to request");
1034 SysLog(NID_WEB_CTRL, "The current value of title is %s", pTitle);
1036 if (pImpl->GetLoadingListener())
1038 result r = E_SUCCESS;
1040 std::unique_ptr<String> pPageTitle(new (std::nothrow) String(pTitle));
1041 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED));
1042 SysTryReturnVoidResult(NID_WEB_CTRL, pPageTitle.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1044 r = pEventArg->SetEventInfo(_LoadingEventArg::PAGE_TITLE, *pPageTitle.get());
1045 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1046 pPageTitle.release();
1048 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1049 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1050 pEventArg.release();
1056 OnEstimatedProgress(void* pUserData, Evas_Object* pView, void* pEventInfo)
1058 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1059 double* pProgress = reinterpret_cast< double* >(pEventInfo);
1060 SysAssertf(pImpl, "Failed to request");
1062 SysLog(NID_WEB_CTRL, "The current value of progress is %lf", *pProgress);
1064 if (pImpl->GetLoadingListener())
1066 result r = E_SUCCESS;
1068 std::unique_ptr<Integer> pProgressPercentage(new (std::nothrow) Integer(static_cast< int >(*pProgress * 100)));
1069 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PROGRESS));
1070 SysTryReturnVoidResult(NID_WEB_CTRL, pProgressPercentage.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1072 r = pEventArg->SetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS, *pProgressPercentage.get());
1073 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1074 pProgressPercentage.release();
1076 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1077 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1078 pEventArg.release();
1084 OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1086 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1087 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
1088 SysAssertf(pImpl && pPolicy, "Failed to request");
1090 result r = E_SUCCESS;
1092 int code = ewk_policy_decision_response_status_code_get(pPolicy);
1093 String url(ewk_policy_decision_url_get(pPolicy));
1094 String mime(ewk_policy_decision_response_mime_get(pPolicy));
1095 SysSecureLog(NID_WEB_CTRL, "code : %d, url : %ls, mime : %ls", code, url.GetPointer(), mime.GetPointer());
1097 if (ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy)))
1099 if (code >= REDIRECTION_HEADER_GROUP && code < REDIRECTION_HEADER_GROUP + 100)
1101 pImpl->SetRedirectRequested(true);
1105 ILoadingListener* pLoadingListener = pImpl->GetLoadingListener();
1106 if (pLoadingListener)
1108 HttpHeader httpHeader;
1110 Eina_Iterator* iterator = eina_hash_iterator_tuple_new(ewk_policy_decision_response_headers_get(pPolicy));
1113 Eina_Hash_Tuple *tuple = null;
1115 EINA_ITERATOR_FOREACH(iterator, tuple)
1117 String key(reinterpret_cast< const char* >(tuple->key));
1118 String value(reinterpret_cast< char* >(tuple->data));
1120 SysSecureLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", key.GetPointer(), value.GetPointer());
1122 r = httpHeader.AddField(key, value);
1123 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1126 eina_iterator_free(iterator);
1129 pImpl->SetPolicyDecision(pLoadingListener->OnWebDataReceived(mime, httpHeader));
1133 pImpl->SetPolicyDecision(WEB_DECISION_CONTINUE);
1137 switch (pImpl->GetPolicyDecision())
1139 case WEB_DECISION_CONTINUE:
1141 String currentUrl(pImpl->GetUrl());
1142 String redirectUrl(pImpl->GetRedirectUri(url, currentUrl, mime));
1143 if (redirectUrl != L"")
1145 ewk_policy_decision_ignore(pPolicy);
1147 pImpl->LoadUrl(redirectUrl);
1152 if (ewk_policy_decision_type_get(pPolicy) == EWK_POLICY_DECISION_USE)
1158 ewk_policy_decision_ignore(pPolicy);
1160 String operationId(L"http://tizen.org/appcontrol/operation/view");
1162 r = _AppControlImpl::FindAndStart(operationId, &url, &mime, null, null, null);
1163 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS || r == E_OBJ_NOT_FOUND, r, "[%s] Propagating.", GetErrorMessage(r));
1164 if (r == E_OBJ_NOT_FOUND)
1166 String operationId(L"http://tizen.org/appcontrol/operation/download");
1168 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
1169 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1177 case WEB_DECISION_DOWNLOAD:
1179 ewk_policy_decision_ignore(pPolicy);
1181 _WebDataHandler* pDownloadHandler = pImpl->GetDownloadHandler();
1182 SysTryReturnVoidResult(NID_WEB_CTRL, pDownloadHandler, E_SYSTEM, "[%s] A system error has been occurred. Failed to get DownloadHandler.", GetErrorMessage(E_SYSTEM));
1184 Ewk_Context* pContext = ewk_view_context_get(pView);
1185 SysAssertf(pContext, "Failed to get webkit instance.");
1187 pDownloadHandler->StartDownload(url);
1192 case WEB_DECISION_IGNORE:
1194 ewk_policy_decision_ignore(pPolicy);
1205 ewk_policy_decision_use(pPolicy);
1210 ewk_policy_decision_ignore(pPolicy);
1215 OnProgressCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1217 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1218 SysAssertf(pImpl, "Failed to request");
1220 if (pImpl->IsRedirectRequested())
1222 pImpl->SetRedirectRequested(false);
1225 if (pImpl->IsLoadingErrorOccurred())
1227 pImpl->SetLoadingErrorOccurred(false);
1228 evas_object_smart_callback_call(pView, "load,finished", NULL);
1234 OnLoadingErrorOccurred(void* pUserData, Evas_Object* pView, void* pEventInfo)
1236 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1237 Ewk_Error* pErrorData = reinterpret_cast< Ewk_Error* >(pEventInfo);
1238 SysAssertf(pImpl && pErrorData, "Failed to request");
1240 int code = ewk_error_code_get(pErrorData);
1241 const char* pDescription = ewk_error_description_get(pErrorData);
1243 SysLog(NID_WEB_CTRL, "The current value of code is %d, description is %s", code, pDescription);
1247 case EWK_ERROR_CODE_FRAMELOADINTERRUPTEDBYPOLICYCHANGE:
1248 pImpl->SetLoadingErrorOccurred(true);
1251 case EWK_ERROR_CODE_PLUGINWILLHANDLELOAD:
1252 evas_object_smart_callback_call(pView, "load,finished", NULL);
1255 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
1256 pImpl->SetLoadingErrorOccurred(true);
1257 evas_object_smart_callback_call(pView, "load,stop", NULL);
1261 pImpl->SetLoadingErrorOccurred(true);
1262 if (pImpl->GetLoadingListener())
1264 result r = E_SUCCESS;
1266 r = FireLoadingErrorOccurredEvent(pImpl, code, pDescription);
1267 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1275 OnLoadingCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
1277 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1278 SysAssertf(pImpl, "Failed to request");
1280 if (pImpl->GetLoadingListener())
1282 result r = E_SUCCESS;
1284 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_CANCELED));
1285 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1287 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1288 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1289 pEventArg.release();
1296 OnLoadingCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1298 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1299 SysAssertf(pImpl, "Failed to request");
1301 if (pImpl->GetLoadingListener())
1303 result r = E_SUCCESS;
1305 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_COMPLETED));
1306 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1308 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1309 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1310 pEventArg.release();
1316 OnLoadingCommitted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1318 evas_object_focus_set(pView, EINA_FALSE);
1323 OnFaviconReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1325 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1326 SysAssertf(pImpl, "Failed to request");
1328 if (pImpl->GetLoadingListener())
1330 result r = E_SUCCESS;
1332 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED));
1333 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1335 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1336 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1337 pEventArg.release();
1344 OnDidStartDownloadCallback(const char* pUrl, void* pUserData)
1346 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1347 SysAssertf(pUrl && pImpl != null, "Failed to request");
1349 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s", pUrl);
1354 FireWebPageShowRequestedEvent(_WebImpl* pImpl, int event)
1356 result r = E_SUCCESS;
1358 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1359 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1361 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1362 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1363 pEventArg.release();
1370 OnWebPageShowRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1372 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1373 SysAssertf(pImpl, "Failed to request");
1375 if (pImpl->GetUiEventListener())
1377 result r = E_SUCCESS;
1379 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED);
1380 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1382 if (pImpl->GetUiEventListenerF())
1384 result r = E_SUCCESS;
1386 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT);
1387 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1393 OnWebWindowCreateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1395 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(pUserData);
1396 Evas_Object** pChildView = reinterpret_cast< Evas_Object** >(pEventInfo);
1397 SysAssertf(pParentImpl && pChildView, "Failed to request");
1399 IWebUiEventListener* pUserUiListener = pParentImpl->GetUiEventListener();
1400 IWebUiEventListenerF* pUserUiListenerF = pParentImpl->GetUiEventListenerF();
1401 if (pUserUiListener)
1403 Web* pWeb = pUserUiListener->OnWebWindowCreateRequested();
1406 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1407 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1409 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1410 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1413 if (pUserUiListenerF)
1415 Web* pWeb = pUserUiListenerF->OnWebWindowCreateRequested();
1418 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1419 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1421 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1422 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1429 FireWebWindowClosedRequestedEvent(_WebImpl* pImpl, int event)
1431 result r = E_SUCCESS;
1433 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1434 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1436 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1437 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1438 pEventArg.release();
1445 OnWebWindowClosedRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1447 _WebImpl* pChildImpl = reinterpret_cast< _WebImpl* >(pUserData);
1448 SysAssertf(pChildImpl, "Failed to request");
1450 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, PARENT_WEB_CTRL));
1451 if (pParentImpl == null)
1456 if (pParentImpl->GetUiEventListener())
1458 result r = E_SUCCESS;
1460 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED);
1461 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1463 if (pParentImpl->GetUiEventListenerF())
1465 result r = E_SUCCESS;
1467 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT);
1468 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1474 FireWebPreventDefaultTriggeredEvent(_WebImpl* pImpl, int event, bool trigger)
1476 result r = E_SUCCESS;
1478 std::unique_ptr<Boolean> pPreventTrigger(new (std::nothrow) Boolean(trigger));
1479 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1480 SysTryReturnResult(NID_WEB_CTRL, pPreventTrigger.get() && pEventArg.get(), E_OUT_OF_MEMORY, " Memory allocation failed." );
1482 r = pEventArg->SetEventInfo(_WebUiEventArg::PREVENT_DEFAULT, *pPreventTrigger.get());
1483 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1484 pPreventTrigger.release();
1486 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1487 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1488 pEventArg.release();
1495 OnWebPreventDefaultTriggered(void* pUserData, Evas_Object* pView, void* pEventInfo)
1497 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1498 Eina_Bool* pTrigger = reinterpret_cast< Eina_Bool* >(pEventInfo);
1499 SysAssertf(pImpl && pTrigger, "Failed to request");
1501 if (pImpl->GetUiEventListener())
1503 result r = E_SUCCESS;
1505 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED, static_cast< bool >(*pTrigger));
1506 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1508 if (pImpl->GetUiEventListenerF())
1510 result r = E_SUCCESS;
1512 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT, static_cast< bool >(*pTrigger));
1513 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1519 FireWebPageBlockSelectedEvent(_WebImpl* pImpl)
1521 result r = E_SUCCESS;
1523 std::unique_ptr<Point> startPoint(new (std::nothrow) Point());
1524 std::unique_ptr<Point> endPoint(new (std::nothrow) Point());
1525 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1527 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1529 if ((endPoint->x != 0) && (endPoint->y != 0))
1531 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED));
1532 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1534 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1535 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1536 startPoint.release();
1538 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1539 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1542 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1543 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1544 pEventArg.release();
1552 FireWebPageBlockSelectedEventF(_WebImpl* pImpl)
1554 result r = E_SUCCESS;
1556 std::unique_ptr<FloatPoint> startPoint(new (std::nothrow) FloatPoint());
1557 std::unique_ptr<FloatPoint> endPoint(new (std::nothrow) FloatPoint());
1559 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1561 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1562 if ((endPoint->x != 0.0f) && (endPoint->y != 0.0f))
1564 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT));
1565 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1567 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1568 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1569 startPoint.release();
1571 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1572 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1575 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1576 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1577 pEventArg.release();
1585 OnWebPageBlockSelected(void* pUserData, Evas_Object* pView, void* pEventInfo)
1587 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1588 SysAssertf(pImpl, "Failed to request");
1590 if (pImpl->GetUiEventListener())
1592 result r = E_SUCCESS;
1594 r = FireWebPageBlockSelectedEvent(pImpl);
1595 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1597 if (pImpl->GetUiEventListenerF())
1599 result r = E_SUCCESS;
1601 r = FireWebPageBlockSelectedEventF(pImpl);
1602 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1608 OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo)
1610 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1611 char* pJsonText = reinterpret_cast< char* >(pEventInfo);
1612 SysAssertf(pImpl && pJsonText, "Failed to request");
1614 result r = E_SUCCESS;
1616 SysLog(NID_WEB_CTRL, "The current value of jsontext is %s", pJsonText);
1618 std::unique_ptr<_JsBridgeArg> pEventArg(new (std::nothrow) _JsBridgeArg());
1619 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1621 r = pEventArg->Construct(pJsonText);
1622 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1624 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1625 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1626 pEventArg.release();
1631 OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo)
1633 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1634 Eina_Rectangle* pEinaRect = reinterpret_cast< Eina_Rectangle* >(pEventInfo);
1635 SysAssertf(pImpl && pEinaRect, "Failed to request");
1637 if (pImpl->GetSetting().GetInputStyle() == INPUT_STYLE_OVERLAY)
1639 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1640 SysAssertf(pXformer, "Failed to get CoordinateTransformer");
1642 Rectangle rect(pEinaRect->x, pEinaRect->y, pEinaRect->w, pEinaRect->h);
1644 if (rect.height == 0)
1649 _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl));
1652 pFormImpl->DeflateClientRectHeight(pXformer->TransformVertical(rect.height));
1655 if (pImpl->GetWebKeypadEventListener())
1657 if (pImpl->IsKeypadVisible() == true)
1659 if ((pImpl->GetPreviousKeypadBounds().width == rect.width) && (pImpl->GetPreviousKeypadBounds().height != rect.height))
1661 pImpl->GetWebKeypadEventListener()->OnWebKeypadBoundsChanged(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1666 pImpl->GetWebKeypadEventListener()->OnWebKeypadWillOpen(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1670 pImpl->SetPreviousKeypadBounds(rect);
1674 result r = pImpl->SetFullScreenKeypad();
1675 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1681 OnWebKeypadOpened(void* pUserData, Evas_Object* pView, void* pEventInfo)
1683 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1684 SysAssertf(pImpl, "Failed to request");
1686 pImpl->SetKeypadVisibleState(true);
1688 _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl));
1691 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1692 SysAssertf(pXformer, "Failed to get CoordinateTransformer");
1694 pFormImpl->DeflateClientRectHeight(pXformer->TransformVertical(pImpl->GetPreviousKeypadBounds().height));
1696 if (pFormImpl->HasFooter())
1698 pFormImpl->GetCore().SetKeypadShowState(true);
1703 if (pImpl->GetWebKeypadEventListener())
1705 pImpl->GetWebKeypadEventListener()->OnWebKeypadOpened(*static_cast< Web* >(&pImpl->GetPublic()));
1711 OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo)
1713 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1714 SysAssertf(pImpl, "Failed to request");
1716 _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl));
1719 pFormImpl->DeflateClientRectHeight(0);
1721 if (pFormImpl->HasFooter())
1723 pFormImpl->GetCore().SetKeypadShowState(false);
1728 if (pImpl->GetWebKeypadEventListener())
1730 pImpl->GetWebKeypadEventListener()->OnWebKeypadClosed(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1733 pImpl->SetKeypadVisibleState(false);
1738 OnWindowObjectFocusLost(void* pUserData, Evas_Object* pWin, void* pEvent_info)
1740 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1741 SysAssertf(pImpl, "Failed to request");
1743 pImpl->SetWinFocusLost(true);
1748 OnWindowObjectFocusGained(void* pUserData, Evas_Object* pWin, void* pEvent_info)
1750 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1751 SysAssertf(pImpl, "Failed to request");
1753 if (pImpl->IsVisible() == true && pImpl->IsFocused() == true)
1755 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
1756 SysAssertf(pWebCore, "Failed to get Web core object");
1758 if (pImpl->IsWinFocusLost() == true)
1760 Ewk_Settings* pSettings = ewk_view_settings_get(pWebCore->GetWebNativeNode());
1761 SysAssertf(pSettings, "Failed to get settings instance.");
1763 if (ewk_settings_clear_text_selection_automatically_get(pSettings) == EINA_FALSE)
1765 ewk_settings_clear_text_selection_automatically_set(pSettings, EINA_TRUE);
1767 evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE);
1769 else if (pImpl->IsKeypadOpened() == true)
1771 evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE);
1776 pImpl->SetWinFocusLost(false);
1781 OnWebNativeNodeFocusGained(void* pUserData, Evas* pCanvas, Evas_Object* pView, void* pEventInfo)
1783 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1784 SysAssertf(pImpl, "Failed to request");
1786 if (pImpl->IsKeypadOpened() == true)
1788 pImpl->SetKeypadOpened(false);
1790 else if (pImpl->IsWinFocusLost() == true && pImpl->IsFocused() == false)
1792 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
1793 SysAssertf(pWebCore, "Failed to get Web core object");
1795 evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_FALSE);
1801 OnWebNativeNodeFocusLost(void* pUserData, Evas* pCanvas, Evas_Object* pView, void* pEventInfo)
1803 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1804 SysAssertf(pImpl, "Failed to request");
1806 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
1807 SysAssertf(pWebCore, "Failed to get Web core object");
1809 Eina_Rectangle leftHandle;
1810 Eina_Rectangle rightHandle;
1812 EINA_RECTANGLE_SET(&leftHandle, 0, 0, 0, 0);
1813 EINA_RECTANGLE_SET(&rightHandle, 0, 0, 0, 0);
1815 if (pImpl->IsWinFocusLost() == true && ewk_view_text_selection_range_get(pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle))
1817 Ewk_Settings* pSettings = ewk_view_settings_get(pWebCore->GetWebNativeNode());
1818 SysAssertf(pSettings, "Failed to get settings instance.");
1820 ewk_settings_clear_text_selection_automatically_set(pSettings, EINA_FALSE);
1826 OnColorPickerProviderRequested(Ewk_View_Smart_Data* pSmartData, int red, int green, int blue, int alpha)
1828 SysAssertf(pSmartData, "invalid smartdata");
1829 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1830 SysAssertf(pWebImpl, "Failed to get Impl");
1832 result r = E_SUCCESS;
1834 if (pWebImpl->GetColorpicker())
1841 r = pWebImpl->ShowColorPicker(red, green, blue, alpha, color);
1842 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1844 byte r1, g1, b1, a1;
1845 color.GetColorComponents(r1, g1, b1, a1);
1846 ewk_view_color_picker_color_set(pSmartData->self, r1, g1, b1, a1);
1853 OnColorPickerProviderDismissed(Ewk_View_Smart_Data* pSmartData)
1855 SysAssertf(pSmartData, "invalid smartdata");
1857 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1858 SysAssertf(pWebImpl, "Failed to get Impl");
1860 return pWebImpl->HideColorPicker();
1865 OnDatePickerProviderRequested(Ewk_View_Smart_Data* pSmartData, Ewk_Input_Type inputType, const char* inputValue)
1867 SysAssertf(pSmartData, "Failed to request");
1868 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1869 SysAssertf(pWebImpl, "Failed to get Impl");
1871 result r = E_SUCCESS;
1873 if (pWebImpl->GetDatepicker())
1875 ewk_view_focused_input_element_value_set(pSmartData->self, inputValue);
1882 r = pWebImpl->ShowDatePicker(inputType, inputValue, dateStr);
1883 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1885 std::unique_ptr<char[]> pDateStr(_StringConverter::CopyToCharArrayN(dateStr));
1886 SysTryReturn(NID_WEB_CTRL, pDateStr.get(), EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1888 ewk_view_focused_input_element_value_set(pSmartData->self, pDateStr.get());
1895 OnSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex)
1897 SysAssertf(pSmartData, "Failed to request");
1899 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1900 SysAssertf(pWebImpl, "Failed to get Impl");
1902 result r = pWebImpl->ShowSelectBoxPopup(false, L"", pItems, pSmartData->self, selectedIndex);
1903 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1910 OnMultiSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* pItems)
1912 SysAssertf(pSmartData, "Failed to request");
1914 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1915 SysAssertf(pWebImpl, "Failed to get Impl");
1917 result r = pWebImpl->ShowSelectBoxPopup(true, L"", pItems, pSmartData->self, 0);
1918 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1925 OnSelectBoxClosed(Ewk_View_Smart_Data* pSmartData)
1927 SysAssertf(pSmartData, "invalid smartdata");
1929 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1930 SysAssertf(pWebImpl, "Failed to get Impl");
1932 result r = pWebImpl->ClearSelectBoxPopup();
1933 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1940 OnSelectBoxUpdateRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, Eina_List* pItems, int selectedIndex)
1942 SysAssertf(pSmartData, "invalid smartdata");
1944 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1945 SysAssertf(pWebImpl, "Failed to get Impl");
1947 result r = pWebImpl->UpdateSelectBoxPopup(pItems, selectedIndex, false);
1948 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1955 OnFormDataCandidateShow(Ewk_View_Smart_Data *pSmartData, int x, int y, int w, int h)
1957 SysAssertf(pSmartData, "Failed to request");
1959 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1960 SysAssertf(pWebImpl, "Failed to get Impl");
1962 Rectangle windowRect(x, y, w, h);
1963 result r = pWebImpl->ShowFormDataWindow(windowRect, pSmartData->self);
1964 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1971 OnFormDataCandidateHide(Ewk_View_Smart_Data *pSmartData)
1973 SysAssertf(pSmartData, "Failed to request");
1975 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1976 SysAssertf(pWebImpl, "Failed to get Impl");
1978 if (pWebImpl->IsFormDataWindowVisible())
1980 pWebImpl->HideFormDataWindow();
1988 OnFormDataCandidateUpdate(Ewk_View_Smart_Data *pSmartData, Eina_List *pDataList)
1990 SysAssertf(pSmartData, "Failed to request");
1992 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1993 SysAssertf(pWebImpl, "Failed to get Impl");
1995 pWebImpl->SetFormDataList(pDataList);
2002 OnFormDataCandidateIsShowing(Ewk_View_Smart_Data *pSmartData)
2004 SysAssertf(pSmartData, "Failed to request");
2006 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
2007 SysAssertf(pWebImpl, "Failed to get Impl");
2009 if (pWebImpl->IsFormDataWindowVisible())
2021 OnCookiesPolicyGot(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *pError, void *pUserData)
2023 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
2024 SysAssertf(pPresenter && !pError, "Failed to request");
2026 bool ret = EINA_TRUE;
2030 case EWK_COOKIE_ACCEPT_POLICY_ALWAYS:
2032 case EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY:
2036 case EWK_COOKIE_ACCEPT_POLICY_NEVER:
2045 SysLog(NID_WEB_CTRL, "The current value of policy is %d", ret);
2047 pPresenter->EndAsyncProcess(ret);
2052 OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData)
2054 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
2055 SysAssertf(pPresenter, "Failed to request");
2057 String result(pResult);
2058 SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer());
2060 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, WEB_CTRL));
2061 _WebManager* pWebManager = _WebManager::GetInstance();
2062 if (pWebManager->IsValidCallback(reinterpret_cast< int >(pImpl), reinterpret_cast< int >(pPresenter)))
2064 pPresenter->EndAsyncProcess(result);
2070 OnTextFound(void* pUserData, Evas_Object* pView, void* pEventInfo)
2072 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2073 SysAssertf(pImpl, "Failed to request");
2075 int* pTotalCount = reinterpret_cast< int* >(pEventInfo);
2076 SysLog(NID_WEB_CTRL, "The current value of totalCount is %d", *pTotalCount);
2078 _WebPresenter* pWebPresenter = pImpl->GetSearchPresenter();
2082 pWebPresenter->EndAsyncProcess(*pTotalCount);
2086 if (pImpl->GetTextSearchListener())
2088 result r = E_SUCCESS;
2092 if (*pTotalCount > 0)
2094 ordinal = pImpl->GetAsyncSearchOrdinal();
2095 pImpl->SetAsyncSearchResult(*pTotalCount);
2098 if (pImpl->GetPendingAsyncSearchCount() > 0)
2103 std::unique_ptr<Integer> pCount(new (std::nothrow) Integer(*pTotalCount));
2104 std::unique_ptr<Integer> pOrdinal(new (std::nothrow) Integer(ordinal));
2105 std::unique_ptr<_TextSearchEventArg> pEventArg(new (std::nothrow) _TextSearchEventArg(WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND));
2106 SysTryReturnVoidResult(NID_WEB_CTRL, pCount.get() && pOrdinal.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2108 r = pEventArg->SetEventInfo(_TextSearchEventArg::TOTAL_COUNT, *pCount.get());
2109 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2112 r = pEventArg->SetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL, *pOrdinal.get());
2113 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2116 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
2117 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2118 pEventArg.release();
2124 class _JsBridgeHashCodeProvider
2125 : public Tizen::Base::Collection::IHashCodeProviderT< Tizen::Base::String >
2128 _JsBridgeHashCodeProvider(){}
2129 virtual ~_JsBridgeHashCodeProvider(void) {}
2132 int GetHashCode(const Tizen::Base::String& obj) const
2134 return obj.GetHashCode();
2140 //Comparer implementation
2141 class _JsBridgeComparer
2142 : public Tizen::Base::Collection::IComparerT< Tizen::Base::String >
2145 _JsBridgeComparer(){}
2146 virtual ~_JsBridgeComparer(void) {}
2149 result Compare(const Tizen::Base::String& obj1, const Tizen::Base::String& obj2, int& cmp) const
2166 _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
2167 : _ContainerImpl(pWeb, pCore)
2168 , __isFooterVisible(false)
2169 , __isKeypadVisible(false)
2170 , __isKeypadOpened(false)
2171 , __isWinFocusLost(false)
2172 , __isLoadingErrorOccurred(false)
2173 , __isRedirectRequested(false)
2174 , __isCertificateRequested(false)
2175 , __isCertificateConfirmed(false)
2176 , __isFormDataVisible(false)
2177 , __keypadBounds(0, 0, 0, 0)
2179 , __pUserLoadingListener(null)
2180 , __pUserUiListener(null)
2181 , __pUserUiListenerF(null)
2182 , __pUserKeypadEventListener(null)
2183 , __pTextSearchListener(null)
2185 , __pJsBridgeList(null)
2186 , __pJsProvider(null)
2187 , __pJsComparer(null)
2188 , __pWebDownloadHandler(null)
2190 , __pAuthChallenge(null)
2191 , __pAuthPopup(null)
2192 , __pUserMediaConfirmPopup(null)
2193 , __pContentHandlerConfirmPopup(null)
2194 , __pProtocolHandlerConfirmPopup(null)
2195 , __pGeolocationConfirmPopup(null)
2196 , __pNotificationConfirmPopup(null)
2197 , __pScriptAlertConfirmPopup(null)
2198 , __pScriptConfirmPopup(null)
2199 , __pAppCacheConfirmPopup(null)
2200 , __pDbQuotaConfirmPopup(null)
2201 , __pLocalFsQuotaConfirmPopup(null)
2202 , __pIndexedDbQuotaConfirmPopup(null)
2203 , __pPromptPopup(null)
2204 , __pCertConfirmPopup(null)
2205 , __pSelectBox(null)
2206 , __pDatePicker(null)
2207 , __pColorPicker(null)
2208 , __pFormDataWindow(null)
2210 , __policy(WEB_DECISION_CONTINUE)
2211 , __defaultUserAgent(L"")
2212 , __pFormDataList(null)
2213 , __popupClosed(false)
2215 __textSearch.__searchAll = false;
2216 __textSearch.__searchForward = true;
2217 __textSearch.__caseSensitive = false;
2218 __textSearch.__pending = 0;
2219 __textSearch.__currentIndex = 1;
2220 __textSearch.__totalCount = -1;
2221 __textSearch.__text = L"";
2225 _WebImpl::~_WebImpl()
2227 _WebManager* pWebManager = _WebManager::GetInstance();
2228 SysTryCatch(NID_WEB_CTRL, pWebManager, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2230 pWebManager->RemoveWeb(reinterpret_cast< int >(this));
2231 pWebManager->RemoveActiveWeb(this);
2234 RemoveEventListenerCallback();
2236 ClearCertificateDb();
2241 _WebImpl::CreateWebImplN(Web* pControl, const Rectangle& bounds)
2243 result r = E_SUCCESS;
2245 r = GET_SIZE_INFO(Web).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2246 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2248 _Web* pCore = _Web::CreateWebN();
2249 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2251 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2253 r = CheckConstruction(pCore, pImpl);
2254 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2256 r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2257 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2259 r = pImpl->Construct();
2260 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2272 _WebImpl::CreateWebImplN(Web* pControl, const FloatRectangle& bounds)
2274 result r = E_SUCCESS;
2276 r = GET_SIZE_INFO(Web).CheckInitialSizeValidF(FloatDimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2277 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2279 _Web* pCore = _Web::CreateWebN();
2280 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2282 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2284 r = CheckConstruction(pCore, pImpl);
2285 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2287 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2288 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2290 r = pImpl->Construct();
2291 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2303 _WebImpl::Construct(void)
2305 result r = E_SUCCESS;
2307 r = __mutex.Create();
2308 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2310 r = __textSearch.__searchQueue.Construct();
2311 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2313 r = __webNotificationList.Construct();
2314 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2316 r = InitJsBridgeList();
2317 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2320 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2322 __pWebCore = dynamic_cast< _Web* >(&(GetCore()));
2323 SysTryReturnResult(NID_WEB_CTRL, __pWebCore, E_SYSTEM, "A system error has been occurred. Failed to get web control");
2330 _WebImpl::InitializeSetting(void)
2332 result r = E_SUCCESS;
2334 WebSetting* pWebSetting = __pWebCore->GetSetting();
2335 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(pWebSetting);
2337 SetCookieEnabled(pWebSettingImpl->IsCookieEnabled());
2338 SetPrivateBrowsingEnabled(pWebSettingImpl->IsPrivateBrowsingEnabled());
2340 __defaultUserAgent = pWebSettingImpl->GetUserAgent();
2342 r = SetSetting(*pWebSetting);
2343 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2345 SetEventListenerCallback();
2352 _WebImpl::IsLayoutable(void) const
2359 _WebImpl::InitWebEvent(void)
2361 __pWebEvent = std::unique_ptr<_WebEvent>(new (std::nothrow) _WebEvent());
2362 SysTryReturnResult(NID_WEB_CTRL, __pWebEvent.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2364 return __pWebEvent->Construct(*this);
2369 _WebImpl::GetWebEvent(void) const
2371 return __pWebEvent.get();
2376 _WebImpl::ConvertToSlpHeaderN(const HttpHeader& header) const
2378 Eina_Hash* pHttpHeader = null;
2380 std::unique_ptr<IList> pFieldNameList(header.GetFieldNamesN());
2381 if (pFieldNameList.get())
2383 pHttpHeader = eina_hash_string_small_new(FreeCharArray);
2384 SysTryReturn(NID_WEB_CTRL, pHttpHeader, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2386 int count = pFieldNameList->GetCount();
2388 for (int i = 0; i < count; i++)
2390 String* pFieldName = dynamic_cast< String* >(pFieldNameList->GetAt(i));
2391 SysTryCatch(NID_WEB_CTRL, pFieldName, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2393 std::unique_ptr<char[]> pKey(_StringConverter::CopyToCharArrayN(*pFieldName));
2394 SysTryCatch(NID_WEB_CTRL, pKey.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2396 std::unique_ptr<IEnumerator> pFieldValueEnum(header.GetFieldValuesN(*pFieldName));
2397 SysTryCatch(NID_WEB_CTRL, pFieldValueEnum.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2399 while (pFieldValueEnum->MoveNext() == E_SUCCESS)
2401 Eina_Bool ret = false;
2403 String* pFieldValue = dynamic_cast< String* >(pFieldValueEnum->GetCurrent());
2404 SysTryCatch(NID_WEB_CTRL, pFieldValue, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2406 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(*pFieldValue));
2407 SysTryCatch(NID_WEB_CTRL, pValue.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2409 ret = eina_hash_add(pHttpHeader, pKey.get(), pValue.release());
2410 SysTryCatch(NID_WEB_CTRL, ret == EINA_TRUE, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2417 eina_hash_free(pHttpHeader);
2424 _WebImpl::LoadUrl(const String& url) const
2426 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2427 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2429 ewk_view_url_set(__pWebCore->GetWebNativeNode(), pUrl.get());
2436 _WebImpl::LoadUrl(const String& url, const HttpHeader& header)
2438 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2439 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2441 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2443 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_GET, pHttpHeader, null);
2445 eina_hash_free(pHttpHeader);
2452 _WebImpl::LoadUrlWithPostRequest(const String& url, const HttpHeader& header, const ByteBuffer& body) const
2454 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2455 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2457 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2459 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_POST, pHttpHeader, reinterpret_cast< const char* >(body.GetPointer()));
2461 eina_hash_free(pHttpHeader);
2468 _WebImpl::LoadData(const String& baseUrl, const ByteBuffer& content, const String& mime, const String& encoding) const
2470 SysTryReturnResult(NID_WEB_CTRL, content.GetLimit() > 0, E_INVALID_ARG, "The content buffer is empty.");
2472 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(baseUrl));
2473 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
2474 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(encoding));
2475 SysTryReturn(NID_WEB_CTRL, pUrl.get() && pMime.get() && pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2477 ewk_view_contents_set(__pWebCore->GetWebNativeNode(), reinterpret_cast< const char* >(content.GetPointer()), content.GetLimit(), pMime.get(), pEncoding.get(), pUrl.get());
2484 _WebImpl::Pause(void)
2486 ewk_view_suspend(__pWebCore->GetWebNativeNode());
2491 _WebImpl::Resume(void)
2493 ewk_view_resume(__pWebCore->GetWebNativeNode());
2498 _WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List* pItems, Evas_Object* pWebView, int selectedIndex)
2500 __pSelectBox.reset();
2502 SysTryReturnResult(NID_WEB_CTRL, eina_list_count(pItems) > 0, E_SYSTEM, "ItemCount is invalid.");
2504 result r = E_SUCCESS;
2506 std::unique_ptr<_SelectBox> pSelectBox(new (std::nothrow) _SelectBox());
2507 SysTryReturnResult(NID_WEB_CTRL, pSelectBox.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2509 r = pSelectBox->Construct(this, isMultiSelect, title, DEFAULT_LIST_ITEM_COUNT, pWebView);
2510 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2512 r = pSelectBox->UpdateList(pItems, selectedIndex, false, false);
2513 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2515 __pSelectBox = std::move(pSelectBox);
2517 return __pSelectBox->ShowPopup();
2522 _WebImpl::UpdateSelectBoxPopup(Eina_List* pItems, int selectedIndex, bool isGroupedList)
2524 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2526 return __pSelectBox->UpdateList(pItems, selectedIndex, true, isGroupedList);
2531 _WebImpl::ClearSelectBoxPopup(void)
2533 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2535 __pSelectBox.reset();
2544 _WebImpl::GetDatepicker(void)
2546 _InputPickerPopup* pInputPicker =null;
2549 pInputPicker = __pDatePicker.get();
2551 return pInputPicker;
2556 _WebImpl::GetColorpicker(void)
2558 _InputPickerPopup* pInputPicker =null;
2561 pInputPicker = __pColorPicker.get();
2563 return pInputPicker;
2568 _WebImpl::CanGoBack(void) const
2570 return static_cast< bool >(ewk_view_back_possible(__pWebCore->GetWebNativeNode()));
2575 _WebImpl::CanGoForward(void) const
2577 return static_cast< bool >(ewk_view_forward_possible(__pWebCore->GetWebNativeNode()));
2582 _WebImpl::GoBack(void) const
2584 ewk_view_back(__pWebCore->GetWebNativeNode());
2589 _WebImpl::GoForward(void) const
2591 ewk_view_forward(__pWebCore->GetWebNativeNode());
2596 _WebImpl::GetUrl(void) const
2598 return ewk_view_url_get(__pWebCore->GetWebNativeNode());
2603 _WebImpl::GetTitle(void) const
2605 return ewk_view_title_get(__pWebCore->GetWebNativeNode());
2610 _WebImpl::StopLoading(void) const
2612 ewk_view_stop(__pWebCore->GetWebNativeNode());
2617 _WebImpl::Reload(void) const
2619 ewk_view_reload(__pWebCore->GetWebNativeNode());
2624 _WebImpl::EvaluateJavascriptN(const String& scriptCode)
2626 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2632 std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(scriptCode));
2633 SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2635 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
2636 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2638 ewk_view_script_execute(pView, pScript.get(), OnScriptExecuted, pPresenter.get());
2640 String* pResult = new (std::nothrow) String(L"");
2641 SysTryReturn(NID_WEB_CTRL, pResult, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2643 pPresenter->WaitAsyncProcess(*pResult);
2650 _WebImpl::SetZoomLevel(float level)
2652 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);
2654 ewk_view_scale_set(__pWebCore->GetWebNativeNode(), static_cast< double >(level), 0, 0);
2661 _WebImpl::GetZoomLevel(void) const
2663 return static_cast< float >(ewk_view_scale_get(__pWebCore->GetWebNativeNode()));
2667 const PageNavigationList*
2668 _WebImpl::GetBackForwardListN(void) const
2670 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2676 result r = E_SUCCESS;
2678 _PageNavigationListImpl* pNavigationListImpl = null;
2679 _HistoryItemImpl* pHistoryItemImpl = null;
2681 std::unique_ptr<PageNavigationList> pNavigationList;
2682 std::unique_ptr<ArrayList, AllElementsDeleter> pHistoryList;
2685 int forwardCount = 0;
2690 Ewk_History* pEwkHistoryList = ewk_view_history_get(pView);
2691 SysTryReturn(NID_WEB_CTRL, pEwkHistoryList, null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get full history.", GetErrorMessage(E_SYSTEM));
2693 Ewk_History_Item* pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, 0);
2694 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_DATA_NOT_FOUND, "[%s] There is no history.", GetErrorMessage(E_DATA_NOT_FOUND));
2696 pNavigationList = std::unique_ptr<PageNavigationList>(new (std::nothrow) PageNavigationList());
2697 SysTryCatch(NID_WEB_CTRL, pNavigationList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2699 pNavigationListImpl = _PageNavigationListImpl::GetInstance(pNavigationList.get());
2700 SysTryCatch(NID_WEB_CTRL, pNavigationListImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2702 pHistoryList = std::unique_ptr<ArrayList, AllElementsDeleter>(new (std::nothrow) ArrayList());
2703 SysTryCatch(NID_WEB_CTRL, pHistoryList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2705 r = pHistoryList->Construct();
2706 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2708 backCount = ewk_history_back_list_length_get(pEwkHistoryList);
2709 forwardCount = ewk_history_forward_list_length_get(pEwkHistoryList);
2710 SysLog(NID_WEB_CTRL, "The current value of backCount is %d, forwardCount is %d", backCount, forwardCount);
2712 for (int i = -backCount; i < forwardCount + 1; i++)
2714 std::unique_ptr<HistoryItem> pHistoryItem(new (std::nothrow) HistoryItem());
2715 SysTryCatch(NID_WEB_CTRL, pHistoryItem.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2717 pHistoryItemImpl = _HistoryItemImpl::GetInstance(pHistoryItem.get());
2718 SysTryCatch(NID_WEB_CTRL, pHistoryItemImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2720 pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, i);
2721 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2723 url = ewk_history_item_uri_get(pEwkItem);
2724 title = ewk_history_item_title_get(pEwkItem);
2725 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s, title is %s", url.GetPointer(), title.GetPointer());
2727 pHistoryItemImpl->SetHistoryItem(url, title);
2729 r = pHistoryList->Add(*pHistoryItem.get());
2730 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2731 pHistoryItem.release();
2734 pNavigationListImpl->SetPageNavigationList(pHistoryList.release(), backCount);
2736 ewk_history_free(pEwkHistoryList);
2738 return pNavigationList.release();
2741 ewk_history_free(pEwkHistoryList);
2748 _WebImpl::SearchText(const String& text, bool searchForward)
2750 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2756 result r = E_SUCCESS;
2758 Ewk_Find_Options condition = static_cast< Ewk_Find_Options >(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2762 condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS);
2765 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
2766 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2768 r = SynchronizeSearch(SEARCH_SYNC, pView, condition, text, searchForward, false, pPresenter.get());
2769 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
2772 pPresenter->WaitAsyncProcess(result);
2774 return static_cast < bool >(result);
2779 _WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive)
2781 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2787 result r = E_SUCCESS;
2789 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2793 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2796 r = SynchronizeSearch(SEARCH_ALL_ASYNC, pView, condition, text, true, caseSensitive);
2797 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2804 _WebImpl::SearchNextAsync(bool searchForward)
2806 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2812 SysTryReturnResult(NID_WEB_CTRL, __textSearch.__searchAll && __textSearch.__totalCount > -1, E_INVALID_OPERATION, "The SearchTextAllAsync() method is not called or completed.");
2813 SysTryReturnResult(NID_WEB_CTRL, (searchForward && __textSearch.__currentIndex < __textSearch.__totalCount) || (!searchForward && __textSearch.__currentIndex > 1)
2814 , E_OBJ_NOT_FOUND, "The Next instance is not available.");
2816 result r = E_SUCCESS;
2818 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2820 if (!__textSearch.__caseSensitive)
2822 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2827 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_BACKWARDS);
2830 r = SynchronizeSearch(SEARCH_NEXT_ASYNC, pView, condition, __textSearch.__text, searchForward);
2831 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2838 _WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text, bool searchForward, bool caseSensitive, _WebPresenter* pWebPresenter)
2840 MutexGuard lock(__mutex);
2842 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(text));
2843 SysTryReturn(NID_WEB_CTRL, pText.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2848 if (__textSearch.__searchAll)
2850 DisableAsyncSearch();
2852 __textSearch.__searchQueue.Enqueue(this);
2853 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2855 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2856 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2860 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2862 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2866 case SEARCH_ALL_ASYNC:
2867 __textSearch.__searchAll = true;
2868 __textSearch.__text = text;
2869 __textSearch.__searchForward = true;
2870 __textSearch.__caseSensitive = caseSensitive;
2871 __textSearch.__totalCount = -1;
2872 __textSearch.__currentIndex = 1;
2874 __textSearch.__searchQueue.Enqueue(this);
2875 __textSearch.__searchQueue.Enqueue(this);
2877 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2878 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2881 case SEARCH_NEXT_ASYNC:
2882 __textSearch.__searchForward = searchForward;
2884 CalculateAsyncSearchOrdinal();
2886 __textSearch.__searchQueue.Enqueue(this);
2888 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2900 _WebImpl::SetAsyncSearchResult(int totalCount)
2902 __textSearch.__totalCount = totalCount;
2907 _WebImpl::GetSearchPresenter(void)
2909 MutexGuard lock(__mutex);
2911 return dynamic_cast< _WebPresenter* >(__textSearch.__searchQueue.Dequeue());
2916 _WebImpl::GetPendingAsyncSearchCount(void) const
2918 return __textSearch.__searchQueue.GetCount();
2923 _WebImpl::CalculateAsyncSearchOrdinal(void)
2925 if (__textSearch.__searchForward)
2927 __textSearch.__currentIndex++;
2931 __textSearch.__currentIndex--;
2937 _WebImpl::GetAsyncSearchOrdinal(void) const
2939 return __textSearch.__currentIndex;
2944 _WebImpl::DisableAsyncSearch(void)
2946 __textSearch.__searchAll = false;
2951 _WebImpl::SetSetting(const WebSetting& setting)
2953 if (__pWebCore->GetWebNativeNode())
2955 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2956 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2957 SysAssertf(pContext && pSettings, "Failed to get webkit instance.");
2959 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(setting.GetDefaultTextEncoding()));
2960 SysTryReturn(NID_WEB_CTRL, pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2962 ewk_settings_default_encoding_set(pSettings, pEncoding.get());
2964 switch (setting.GetCacheControl())
2966 case WEB_CACHE_VALIDATED:
2967 ewk_context_cache_disabled_set(pContext, EINA_FALSE);
2970 case WEB_CACHE_IGNORE:
2971 ewk_context_cache_disabled_set(pContext, EINA_TRUE);
2978 if (setting.GetInputStyle() == INPUT_STYLE_OVERLAY)
2980 ewk_settings_default_keypad_enabled_set(pSettings, EINA_TRUE);
2984 ewk_settings_default_keypad_enabled_set(pSettings, EINA_FALSE);
2987 ewk_settings_font_default_size_set(pSettings, static_cast< Eina_Bool >(setting.GetFontSize()));
2989 ewk_settings_javascript_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsJavascriptEnabled()));
2991 ewk_settings_loads_images_automatically_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoImageLoadEnabled()));
2993 if (__defaultUserAgent != setting.GetUserAgent())
2995 std::unique_ptr<char[]> pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent()));
2996 SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2998 ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get());
3001 ewk_settings_auto_fitting_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFittingEnabled()));
3003 ewk_settings_scripts_window_open_set(pSettings, static_cast< Eina_Bool >(setting.IsJavaScriptPopupEnabled()));
3005 ewk_settings_form_candidate_data_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFormDataShowEnabled()));
3007 ewk_settings_autofill_password_form_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoLoginFormFillEnabled()));
3010 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting());
3012 pWebSettingImpl->SetCertificateErrorHandlingMode(setting.GetCertificateErrorHandlingMode());
3013 pWebSettingImpl->SetDefaultTextEncoding(setting.GetDefaultTextEncoding());
3014 pWebSettingImpl->SetCacheControl(setting.GetCacheControl());
3015 pWebSettingImpl->SetFontSize(setting.GetFontSize());
3016 pWebSettingImpl->SetJavascriptEnabled(setting.IsJavascriptEnabled());
3017 pWebSettingImpl->SetAutoImageLoadEnabled(setting.IsAutoImageLoadEnabled());
3018 pWebSettingImpl->SetInputStyle(setting.GetInputStyle());
3019 pWebSettingImpl->SetUserAgent(setting.GetUserAgent());
3020 pWebSettingImpl->SetAutoFittingEnabled(setting.IsAutoFittingEnabled());
3021 pWebSettingImpl->SetJavaScriptPopupEnabled(setting.IsJavaScriptPopupEnabled());
3022 pWebSettingImpl->SetGeolocationEnabled(setting.IsGeolocationEnabled());
3023 pWebSettingImpl->SetAutoFormDataShowEnabled(setting.IsAutoFormDataShowEnabled());
3024 pWebSettingImpl->SetAutoLoginFormFillEnabled(setting.IsAutoLoginFormFillEnabled());
3031 _WebImpl::GetSetting(void) const
3033 return *__pWebCore->GetSetting();
3037 const HitElementResult*
3038 _WebImpl::GetElementByPointN(const Point& point) const
3040 return GetElementByPointN(_CoordinateSystemUtils::ConvertToFloat(point));
3044 const HitElementResult*
3045 _WebImpl::GetElementByPointN(const FloatPoint& point) const
3047 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3053 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));
3055 result r = E_SUCCESS;
3057 _HitElementResultImpl* pHitElementResultImpl = null;
3059 std::unique_ptr<HitElementResult> pHitElementResult;
3060 std::unique_ptr<Bitmap> pImage;
3061 std::unique_ptr<HashMap, AllElementsDeleter> pAttributeMap;
3063 Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(point)));
3065 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3066 SysTryReturn(NID_WEB_CTRL, pEwkHitTest, null, E_SYSTEM, "[%s] Failed to get hit test.", GetErrorMessage(E_SYSTEM));
3068 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
3069 Ewk_Hit_Test_Result_Context context = ewk_hit_test_result_context_get(pEwkHitTest);
3070 String url(ewk_hit_test_link_uri_get(pEwkHitTest));
3071 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3072 String nodeValue(ewk_hit_test_node_value_get(pEwkHitTest));
3074 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls, tag is %ls, value is %ls", url.GetPointer(), tagName.GetPointer(), nodeValue.GetPointer());
3076 pHitElementResult = std::unique_ptr<HitElementResult>(new (std::nothrow) HitElementResult());
3077 SysTryCatch(NID_WEB_CTRL, pHitElementResult.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3079 pHitElementResultImpl = _HitElementResultImpl::GetInstance(pHitElementResult.get());
3080 SysTryCatch(NID_WEB_CTRL, pHitElementResultImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3082 if (context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE)
3088 int imageLength = ewk_hit_test_image_buffer_length_get(pEwkHitTest);
3089 void* pImageBuffer = ewk_hit_test_image_buffer_get(pEwkHitTest);
3090 const char* pExtension = ewk_hit_test_image_file_name_extension_get(pEwkHitTest);
3091 SysLog(NID_WEB_CTRL, "The current value of imageBuffer is %u, bufferLength is %d, extension is %s", pImageBuffer, imageLength, pExtension);
3093 r = buf.Construct(imageLength);
3094 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3096 r = buf.SetArray(reinterpret_cast< byte* >(pImageBuffer), 0, imageLength);
3097 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3101 // ToDo : webkit doesn't support types such as IMG_FORMAT_WBMP and IMG_FORMAT_TIFF
3102 // webkit support types such as ico and vp8 additionally
3103 if (strcmp(pExtension, "gif") == 0)
3105 format = IMG_FORMAT_GIF;
3107 else if (strcmp(pExtension, "jpg") == 0)
3109 format = IMG_FORMAT_JPG;
3111 else if (strcmp(pExtension, "png") == 0)
3113 format = IMG_FORMAT_PNG;
3115 else if (strcmp(pExtension, "bmp") == 0)
3117 format = IMG_FORMAT_BMP;
3121 SysLogException(NID_WEB_CTRL, E_UNSUPPORTED_FORMAT, "[%s] The %s format is not supported", GetErrorMessage(E_UNSUPPORTED_FORMAT), pExtension);
3125 r = image.Construct();
3126 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3128 pImage = std::unique_ptr<Bitmap>(image.DecodeN(buf, format, BITMAP_PIXEL_FORMAT_RGB565));
3129 SysTryCatch(NID_WEB_CTRL, pImage.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3134 pAttributeMap = std::unique_ptr<HashMap, AllElementsDeleter>(new (std::nothrow) HashMap());
3135 SysTryCatch(NID_WEB_CTRL, pAttributeMap.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3137 r = pAttributeMap->Construct(eina_hash_population(pAttrHash));
3138 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3140 eina_hash_foreach(pAttrHash, AddHttpAttributeData, pAttributeMap.get());
3141 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3144 pHitElementResultImpl->SetHitElementResult(pAttributeMap.release(), pImage.release(), tagName, nodeValue, url);
3146 ewk_hit_test_free(pEwkHitTest);
3148 return pHitElementResult.release();
3151 ewk_hit_test_free(pEwkHitTest);
3158 _WebImpl::IsLoading(void) const
3160 double percent = ewk_view_load_progress_get(__pWebCore->GetWebNativeNode());
3162 if (Double::Compare(percent, 0.0) > 0 && Double::Compare(percent, 1.0) < 0)
3174 _WebImpl::GetTextFromBlock(void) const
3176 return ewk_view_text_selection_text_get(__pWebCore->GetWebNativeNode());
3181 _WebImpl::IsPrivateBrowsingEnabled(void) const
3183 if (__pWebCore->GetWebNativeNode() == null)
3185 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsPrivateBrowsingEnabled();
3188 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3189 SysAssertf(pSettings, "Failed to get webkit instance.");
3191 return static_cast< bool >(ewk_settings_private_browsing_enabled_get(pSettings));
3196 _WebImpl::SetPrivateBrowsingEnabled(bool enable)
3198 if (__pWebCore->GetWebNativeNode() == null)
3200 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetPrivateBrowsingEnabled(enable);
3204 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3205 SysAssertf(pSettings, "Failed to get webkit instance.");
3207 ewk_settings_private_browsing_enabled_set(pSettings, static_cast< Eina_Bool >(enable));
3212 _WebImpl::ClearHistory(void)
3214 ewk_view_back_forward_list_clear(__pWebCore->GetWebNativeNode());
3219 _WebImpl::ClearCache(void)
3221 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3223 ewk_context_cache_clear(pContext);
3228 _WebImpl::ClearCookie(void)
3230 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3231 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3233 ewk_cookie_manager_cookies_clear(pCookieManager);
3238 _WebImpl::ClearFormData(void)
3240 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3242 ewk_context_form_candidate_data_clear(pContext);
3247 _WebImpl::ClearLoginFormData(void)
3249 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3251 ewk_context_form_password_data_clear(pContext);
3256 _WebImpl::IsCookieEnabled(void) const
3258 if (__pWebCore->GetWebNativeNode() == null)
3260 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsCookieEnabled();
3263 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3264 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3265 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3267 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
3268 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3270 ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, pPresenter.get());
3272 bool result = false;
3273 pPresenter->WaitAsyncProcess(result);
3280 _WebImpl::SetCookieEnabled(bool enable)
3282 if (__pWebCore->GetWebNativeNode() == null)
3284 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetCookiEnabled(enable);
3289 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3290 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3291 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3295 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
3299 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER);
3300 ewk_cookie_manager_cookies_clear(pCookieManager);
3306 _WebImpl::SavePageAsPdf(const String& filePath, const Dimension* pSize) const
3308 result r = E_SUCCESS;
3310 std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
3311 SysTryReturn(NID_WEB_CTRL, pFilePath.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3314 String fileExtension = File::GetFileExtension(filePath);
3315 int pathLength = filePath.GetLength();
3318 SysTryReturnResult(NID_WEB_CTRL, fileExtension.Equals("pdf", false), E_INVALID_ARG, "Invalid argument(s) is used. File extension is not pdf.");
3320 r = filePath.LastIndexOf(L"/", pathLength - 1, index);
3321 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3322 r = filePath.SubString(0, index + 1, dirPath);
3323 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3325 std::unique_ptr<char[]> pDirPath(_StringConverter::CopyToCharArrayN(dirPath));
3326 SysTryReturnResult(NID_WEB_CTRL, access(pDirPath.get(), W_OK) == 0, E_INACCESSIBLE_PATH, "Directory permission is read-only.");
3330 SysTryReturnResult(NID_WEB_CTRL, pSize->width > 0 && pSize->height > 0, E_INVALID_ARG, "Invalid argument(s) is used. Size of pdf file is invalid.");
3332 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), pSize->width, pSize->height, pFilePath.get());
3336 Evas_Coord contentsWidth;
3337 Evas_Coord contentsHeight;
3339 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &contentsWidth, &contentsHeight);
3340 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), contentsWidth, contentsHeight, pFilePath.get());
3348 _WebImpl::IsMimeSupported(const String& mime) const
3350 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
3351 SysTryReturn(NID_WEB_CTRL, pMime.get(), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3353 return static_cast< bool >(ewk_frame_can_show_mime_type(ewk_view_main_frame_get(__pWebCore->GetWebNativeNode()), pMime.get()));
3358 _WebImpl::SetLoadingListener(ILoadingListener* pLoadingListener)
3360 __pUserLoadingListener = const_cast< ILoadingListener* >(pLoadingListener);
3365 _WebImpl::SetWebUiEventListener(IWebUiEventListener* pUiEventListener)
3367 __pUserUiListener = pUiEventListener;
3372 _WebImpl::SetWebUiEventListenerF(IWebUiEventListenerF* pUiEventListener)
3374 __pUserUiListenerF = pUiEventListener;
3379 _WebImpl::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener)
3381 __pUserKeypadEventListener = pKeypadEventListener;
3386 _WebImpl::SetDownloadListener(IWebDownloadListener* pDownLoadListener)
3388 if (__pWebDownloadHandler.get() == null)
3390 __pWebDownloadHandler = std::unique_ptr<_WebDataHandler>(new (std::nothrow) _WebDataHandler());
3391 SysTryReturnVoidResult(NID_WEB_CTRL, __pWebDownloadHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3394 __pWebDownloadHandler->SetDownloadListener(pDownLoadListener);
3395 __pWebDownloadHandler->SetWebEvent(__pWebEvent.get());
3400 _WebImpl::SetTextSearchListener(ITextSearchListener* pTextSearchListener)
3402 __pTextSearchListener = pTextSearchListener;
3407 _WebImpl::SetScrollEnabled(bool enable)
3409 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetScrollEnabled(enable);
3414 _WebImpl::IsScrollEnabled(void) const
3416 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled();
3421 _WebImpl::InitJsBridgeList(void)
3423 result r = E_SUCCESS;
3425 __pJsProvider = std::unique_ptr<_JsBridgeHashCodeProvider>(new (std::nothrow) _JsBridgeHashCodeProvider());
3426 SysTryReturnResult(NID_WEB_CTRL, __pJsProvider.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3428 __pJsComparer = std::unique_ptr<_JsBridgeComparer>(new (std::nothrow) _JsBridgeComparer());
3429 SysTryReturnResult(NID_WEB_CTRL, __pJsComparer.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3431 std::unique_ptr<HashMapT< String, IJavaScriptBridge* > > pJsBridgeList(new (std::nothrow) HashMapT< String, IJavaScriptBridge* >);
3432 SysTryReturnResult(NID_WEB_CTRL, pJsBridgeList.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3434 r = pJsBridgeList->Construct(0, 0, *__pJsProvider.get(), *__pJsComparer.get());
3435 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3437 __pJsBridgeList = std::move(pJsBridgeList);
3444 _WebImpl::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3446 result r = E_SUCCESS;
3448 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3449 String key(pJsBridge->GetName());
3451 r = __pJsBridgeList->Add(key, pJsBridge);
3452 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3459 _WebImpl::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3461 result r = E_SUCCESS;
3463 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3464 String key(pJsBridge->GetName());
3466 r = __pJsBridgeList->Remove(key);
3467 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3474 _WebImpl::FindJsInterface(const IJsonValue* pValue) const
3476 result r = E_SUCCESS;
3478 IJsonValue* pJsonValue = null;
3479 IJavaScriptBridge* pJsBridge = null;
3481 String key(L"name");
3483 const JsonObject* pJsonObject = dynamic_cast< const JsonObject* >(pValue);
3484 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));
3486 r = pJsonObject->GetValue(&key, pJsonValue);
3487 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS && pJsonValue, null, r, "[%s] Propagating.", GetErrorMessage(r));
3489 JsonString* pBridgeName = dynamic_cast< JsonString* >(pJsonValue);
3490 SysTryReturn(NID_WEB_CTRL, pBridgeName, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. name key is missing." , GetErrorMessage(E_INVALID_ARG));
3492 r = __pJsBridgeList->GetValue(static_cast< String >(*pBridgeName), pJsBridge);
3493 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3500 _WebImpl::GetLoadingListener(void) const
3502 return __pUserLoadingListener;
3506 IWebUiEventListener*
3507 _WebImpl::GetUiEventListener(void) const
3509 return __pUserUiListener;
3513 IWebUiEventListenerF*
3514 _WebImpl::GetUiEventListenerF(void) const
3516 return __pUserUiListenerF;
3520 IWebKeypadEventListener*
3521 _WebImpl::GetWebKeypadEventListener(void) const
3523 return __pUserKeypadEventListener;
3527 ITextSearchListener*
3528 _WebImpl::GetTextSearchListener(void) const
3530 return __pTextSearchListener;
3535 _WebImpl::SetEventListenerCallback(void) const
3537 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3540 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3541 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3543 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3544 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3546 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3547 SysAssertf(pSmartData, "Failed to request");
3549 Ewk_View_Smart_Class *pSmart = const_cast<Ewk_View_Smart_Class*>(pSmartData->api);
3550 SysAssertf(pSmart, "Failed to request");
3552 pSmart->popup_menu_show = OnSelectBoxRequested;
3553 pSmart->multiple_popup_menu_show = OnMultiSelectBoxRequested;
3554 pSmart->popup_menu_hide = OnSelectBoxClosed;
3555 pSmart->popup_menu_update = OnSelectBoxUpdateRequested;
3557 pSmart->input_picker_show = OnDatePickerProviderRequested;
3558 pSmart->input_picker_color_request = OnColorPickerProviderRequested;
3559 pSmart->input_picker_color_dismiss = OnColorPickerProviderDismissed;
3561 pSmart->formdata_candidate_show = OnFormDataCandidateShow;
3562 pSmart->formdata_candidate_hide = OnFormDataCandidateHide;
3563 pSmart->formdata_candidate_update_data = OnFormDataCandidateUpdate;
3564 pSmart->formdata_candidate_is_showing = OnFormDataCandidateIsShowing;
3566 evas_object_data_set(pWebNativeNode, WEB_CTRL, this);
3568 // add loading event callbacks for ILoadingListener
3569 evas_object_smart_callback_add(pWebNativeNode, "create,window", OnWebWindowCreateRequested, this);
3570 evas_object_smart_callback_add(pWebNativeNode, "close,window", OnWebWindowClosedRequested, this);
3572 evas_object_smart_callback_add(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested, this);
3573 evas_object_smart_callback_add(pWebNativeNode, "load,started", OnLoadingStarted, this);
3574 evas_object_smart_callback_add(pWebNativeNode, "load,finished", OnLoadingCompleted, this);
3575 evas_object_smart_callback_add(pWebNativeNode, "load,progress", OnEstimatedProgress, this);
3576 evas_object_smart_callback_add(pWebNativeNode, "load,progress,finished", OnProgressCompleted, this);
3577 evas_object_smart_callback_add(pWebNativeNode, "load,stop", OnLoadingCanceled, this);
3578 evas_object_smart_callback_add(pWebNativeNode, "load,error", OnLoadingErrorOccurred, this);
3579 evas_object_smart_callback_add(pWebNativeNode, "title,changed", OnPageTitleReceived, this);
3580 evas_object_smart_callback_add(pWebNativeNode, "load,committed", OnLoadingCommitted, this);
3582 evas_object_smart_callback_add(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest, this);
3584 evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3585 evas_object_smart_callback_add(pWinObject, "focus,out", OnWindowObjectFocusLost, this);
3587 evas_object_smart_callback_add(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged, this);
3588 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened, this);
3589 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed, this);
3591 evas_object_smart_callback_add(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested, this);
3592 evas_object_smart_callback_add(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled, this);
3594 evas_object_smart_callback_add(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested, this);
3596 ewk_view_javascript_alert_callback_set(pWebNativeNode, OnScriptAlertRequested, const_cast< _WebImpl* >(this));
3597 ewk_view_javascript_prompt_callback_set(pWebNativeNode, OnScriptPromptRequested, const_cast< _WebImpl* >(this));
3598 ewk_view_javascript_confirm_callback_set(pWebNativeNode, OnScriptConfirmRequested, const_cast< _WebImpl* >(this));
3600 evas_object_smart_callback_add(pWebNativeNode, "policy,response,decide", OnWebDataReceived, this);
3602 evas_object_smart_callback_add(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested, this);
3603 evas_object_smart_callback_add(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested, this);
3604 evas_object_smart_callback_add(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted, this);
3606 evas_object_smart_callback_add(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested, this);
3607 evas_object_smart_callback_add(pWebNativeNode, "notification,show", OnNotificationShow, this);
3608 evas_object_smart_callback_add(pWebNativeNode, "notification,cancel", OnNotificationCancel, this);
3610 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested, this);
3611 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered, this);
3612 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested, this);
3614 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested, this);
3615 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered, this);
3616 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested, this);
3617 evas_object_smart_callback_add(pWebNativeNode, "text,found", OnTextFound, this);
3619 evas_object_smart_callback_add(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered, this);
3620 evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this);
3622 evas_object_smart_callback_add(pWebNativeNode, "magnifier,hide", OnWebPageBlockSelected, this);
3624 evas_object_smart_callback_add(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered, this);
3625 evas_object_smart_callback_add(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited, this);
3627 evas_object_smart_callback_add(pWebNativeNode, "keyevent,down,not,handled", OnFocusDownRequested, this);
3628 evas_object_smart_callback_add(pWebNativeNode, "keyevent,up,not,handled", OnFocusUpRequested, this);
3630 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3631 SysAssertf(pContext, "Failed to get webkit instance.");
3632 ewk_context_did_start_download_callback_set(pContext, OnDidStartDownloadCallback, const_cast< _WebImpl* >(this));
3633 ewk_context_vibration_client_callbacks_set(pContext, OnVibrationRequested, OnVibrationCanceled, const_cast< _WebImpl* >(this));
3635 ewk_view_application_cache_permission_callback_set(pWebNativeNode, OnApplicationCachePermissionRequested, const_cast< _WebImpl* >(this));
3636 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, OnIndexedDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3637 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, OnDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3638 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, OnLocalFileSystemQuotaExceeded, const_cast< _WebImpl* >(this));
3640 evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this);
3641 evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_OUT, OnWebNativeNodeFocusLost, this);
3647 _WebImpl::RemoveEventListenerCallback(void) const
3649 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3652 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3653 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3655 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3656 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3658 evas_object_smart_callback_del(pWebNativeNode, "create,window", OnWebWindowCreateRequested);
3659 evas_object_smart_callback_del(pWebNativeNode, "close,window", OnWebWindowClosedRequested);
3661 evas_object_smart_callback_del(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested);
3662 evas_object_smart_callback_del(pWebNativeNode, "load,started", OnLoadingStarted);
3663 evas_object_smart_callback_del(pWebNativeNode, "load,finished", OnLoadingCompleted);
3664 evas_object_smart_callback_del(pWebNativeNode, "load,progress", OnEstimatedProgress);
3665 evas_object_smart_callback_del(pWebNativeNode, "load,progress,finished", OnProgressCompleted);
3666 evas_object_smart_callback_del(pWebNativeNode, "load,stop", OnLoadingCanceled);
3667 evas_object_smart_callback_del(pWebNativeNode, "load,error", OnLoadingErrorOccurred);
3668 evas_object_smart_callback_del(pWebNativeNode, "title,changed", OnPageTitleReceived);
3669 evas_object_smart_callback_del(pWebNativeNode, "load,committed", OnLoadingCommitted);
3671 evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest);
3673 evas_object_smart_callback_del_full(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3674 evas_object_smart_callback_del_full(pWinObject, "focus,out", OnWindowObjectFocusLost, this);
3676 evas_object_smart_callback_del(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged);
3677 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened);
3678 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed);
3680 evas_object_smart_callback_del(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested);
3681 evas_object_smart_callback_del(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled);
3683 evas_object_smart_callback_del(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested);
3685 ewk_view_javascript_alert_callback_set(pWebNativeNode, null, null);
3686 ewk_view_javascript_prompt_callback_set(pWebNativeNode, null, null);
3687 ewk_view_javascript_confirm_callback_set(pWebNativeNode, null, null);
3689 evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived);
3691 evas_object_smart_callback_del(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested);
3692 evas_object_smart_callback_del(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested);
3693 evas_object_smart_callback_del(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted);
3695 evas_object_smart_callback_del(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested);
3696 evas_object_smart_callback_del(pWebNativeNode, "notification,show", OnNotificationShow);
3697 evas_object_smart_callback_del(pWebNativeNode, "notification,cancel", OnNotificationCancel);
3698 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested);
3699 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered);
3700 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested);
3702 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested);
3703 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered);
3704 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested);
3706 evas_object_smart_callback_del(pWebNativeNode, "text,found", OnTextFound);
3708 evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered);
3709 evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived);
3711 evas_object_smart_callback_del(pWebNativeNode, "magnifier,hide", OnWebPageBlockSelected);
3713 evas_object_smart_callback_del(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered);
3714 evas_object_smart_callback_del(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited);
3716 evas_object_smart_callback_del(pWebNativeNode, "keyevent,down,not,handled", OnFocusDownRequested);
3717 evas_object_smart_callback_del(pWebNativeNode, "keyevent,up,not,handled", OnFocusUpRequested);
3719 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3720 SysAssertf(pContext, "Failed to get webkit instance.");
3721 ewk_context_vibration_client_callbacks_set(pContext, null, null, null);
3723 ewk_view_application_cache_permission_callback_set(pWebNativeNode, null, null);
3724 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, null, null);
3725 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, null, null);
3726 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, null, null);
3728 evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained);
3729 evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_OUT, OnWebNativeNodeFocusLost);
3735 _WebImpl::ClearCertificateDb(void)
3737 result r = E_SUCCESS;
3739 String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
3740 String table(CERTIFICATE_TABLE_NAME);
3743 r = db.Construct(certificatePath, "r+", null);
3744 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3746 db.BeginTransaction();
3748 r = db.ExecuteSql(L"Delete From " + table, true);
3749 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3751 db.CommitTransaction();
3756 db.RollbackTransaction();
3761 _WebImpl::SetBlockSelectionPosition(const Point& startPoint)
3763 return SetBlockSelectionPosition(_CoordinateSystemUtils::ConvertToFloat(startPoint));
3768 _WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint)
3770 Evas_Object* pWebview = __pWebCore->GetWebNativeNode();
3776 Ewk_View_Smart_Data* pSmartData = reinterpret_cast< Ewk_View_Smart_Data* >(evas_object_smart_data_get(pWebview));
3777 SysAssertf(pSmartData && pSmartData->api, "Failed to get webkit instance.");
3778 Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(startPoint)));
3780 Eina_Bool ret = pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y);
3783 pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y);
3785 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pWebview, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3786 SysTryReturnResult(NID_WEB_CTRL, pEwkHitTest, E_SYSTEM, "Failed to get hit test.");
3788 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3790 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
3791 char* pValue = reinterpret_cast< char* >(eina_hash_find(pAttrHash, "contenteditable"));
3792 if (tagName.Equals(L"INPUT", false) || tagName.Equals(L"TEXTAREA", false) || pValue)
3794 ewk_view_command_execute(pWebview, "SelectWord", 0);
3795 evas_object_smart_callback_call(pWebview, "magnifier,hide", NULL);
3799 SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up.");
3806 _WebImpl::ReleaseBlock(void)
3808 ewk_view_text_selection_range_clear(__pWebCore->GetWebNativeNode());
3813 _WebImpl::GetBlockRange(Point& startPoint, Point& endPoint) const
3815 FloatPoint tempStartPoint;
3816 FloatPoint tempEndPoint;
3818 GetBlockRange(tempStartPoint, tempEndPoint);
3820 startPoint = _CoordinateSystemUtils::ConvertToInteger(tempStartPoint);
3821 endPoint = _CoordinateSystemUtils::ConvertToInteger(tempEndPoint);
3826 _WebImpl::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const
3828 Eina_Rectangle leftHandle;
3829 Eina_Rectangle rightHandle;
3831 EINA_RECTANGLE_SET(&leftHandle, 0, 0, 0, 0);
3832 EINA_RECTANGLE_SET(&rightHandle, 0, 0, 0, 0);
3834 ewk_view_text_selection_range_get(__pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle);
3836 startPoint.x = _CoordinateSystemUtils::ConvertToFloat(leftHandle.x);
3837 startPoint.y = _CoordinateSystemUtils::ConvertToFloat(leftHandle.y);
3838 endPoint.x = _CoordinateSystemUtils::ConvertToFloat(rightHandle.x + rightHandle.w);
3839 endPoint.y = _CoordinateSystemUtils::ConvertToFloat(rightHandle.y + rightHandle.h);
3841 if ((endPoint.x != 0.0f) && (endPoint.y != 0.0f))
3843 startPoint = __pWebCore->GetRelativeCoordinate(startPoint);
3844 endPoint = __pWebCore->GetRelativeCoordinate(endPoint);
3850 _WebImpl::GetFaviconN(void) const
3852 result r = E_SUCCESS;
3854 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3855 Ewk_Context* pContext = ewk_view_context_get(pView);
3856 const char* pUrl = ewk_view_url_get(pView);
3857 Evas* pEvas = evas_object_evas_get(pView);
3859 Evas_Object* pFavicon = ewk_context_icon_database_icon_object_add(pContext, pUrl, pEvas);
3865 Tizen::Graphics::BufferInfo bufferInfo;
3867 r = _Utility::GetPixelBufferFromEvasObject(pFavicon, bufferInfo);
3868 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3870 const Dimension dimension(bufferInfo.width, bufferInfo.height);
3871 Tizen::Base::ByteBuffer byteBuffer;
3873 r = byteBuffer.Construct((byte*)bufferInfo.pPixels, 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 );
3874 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3876 std::unique_ptr<Bitmap> pImage(new (std::nothrow) Bitmap());
3877 SysTryReturn(NID_WEB_CTRL, pImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3879 r = pImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888);
3880 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3882 return pImage.release();
3888 _WebImpl::ScrollBy(const Tizen::Graphics::Point& diff)
3890 ewk_view_scroll_by(__pWebCore->GetWebNativeNode(), diff.x, diff.y);
3895 _WebImpl::ScrollTo(const Tizen::Graphics::Point& dest)
3897 ewk_view_scroll_set(__pWebCore->GetWebNativeNode(), dest.x, dest.y);
3902 _WebImpl::GetScrollPosition(void) const
3906 ewk_view_scroll_pos_get(__pWebCore->GetWebNativeNode(), &position.x, &position.y);
3913 _WebImpl::GetPageSize(void) const
3915 Evas_Coord width = 0;
3916 Evas_Coord height = 0;
3918 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &width, &height);
3920 Dimension size(static_cast< int >(width), static_cast< int >(height));
3927 _WebImpl::AddHttpHeaderField(const String& name, const String& value)
3929 SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing.");
3931 std::unique_ptr<char[]> pName(_StringConverter::CopyToCharArrayN(name));
3932 SysTryReturn(NID_WEB_CTRL, pName.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3934 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(value));
3936 ewk_view_custom_header_add(__pWebCore->GetWebNativeNode(), pName.get(), pValue.get());
3943 _WebImpl::RemoveHttpHeaderField(const String& name)
3945 SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing.");
3947 std::unique_ptr<char[]> pName(_StringConverter::CopyToCharArrayN(name));
3948 SysTryReturn(NID_WEB_CTRL, pName.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3950 ewk_view_custom_header_remove(__pWebCore->GetWebNativeNode(), pName.get());
3957 _WebImpl::SetLoadingErrorOccurred(bool arg)
3959 __isLoadingErrorOccurred = arg;
3964 _WebImpl::IsLoadingErrorOccurred(void) const
3966 return __isLoadingErrorOccurred;
3971 _WebImpl::SetRedirectRequested(bool arg)
3973 __isRedirectRequested = arg;
3978 _WebImpl::IsRedirectRequested(void) const
3980 return __isRedirectRequested;
3985 _WebImpl::SetPolicyDecision(DecisionPolicy policy)
3992 _WebImpl::GetPolicyDecision(void) const
3999 _WebImpl::SetCertificateRequested(bool arg)
4001 __isCertificateRequested = arg;
4006 _WebImpl::IsCertificateRequested(void) const
4008 return __isCertificateRequested;
4013 _WebImpl::SetCertificateConfirmed(bool arg)
4015 __isCertificateConfirmed = arg;
4020 _WebImpl::IsCertificateConfirmed(void) const
4022 return __isCertificateConfirmed;
4027 _WebImpl::SetFullScreenKeypad(void)
4029 result r = E_SUCCESS;
4031 std::unique_ptr<Keypad> pKeypad(new (std::nothrow) Keypad());
4032 SysTryReturnResult(NID_WEB_CTRL, pKeypad.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4034 r = pKeypad->Construct(KEYPAD_STYLE_NORMAL, 100);
4035 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4037 String text(ewk_view_focused_input_element_value_get(__pWebCore->GetWebNativeNode()));
4038 pKeypad->SetText(text);
4040 r = pKeypad->SetShowState(true);
4041 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4043 r = pKeypad->Show();
4044 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4046 pKeypad->AddTextEventListener(*this);
4048 __pKeypad = std::move(pKeypad);
4055 _WebImpl::RemoveFullScreenKeypad(void)
4057 __pKeypad->RemoveTextEventListener(*this);
4064 _WebImpl::IsFooterVisible(void) const
4066 return __isFooterVisible;
4071 _WebImpl::SetFooterVisibleState(bool isFooterVisible)
4073 __isFooterVisible = isFooterVisible;
4078 _WebImpl::IsKeypadVisible(void) const
4080 return __isKeypadVisible;
4085 _WebImpl::SetKeypadVisibleState(bool isKeypadVisible)
4087 __isKeypadVisible = isKeypadVisible;
4092 _WebImpl::IsKeypadOpened(void) const
4094 return __isKeypadOpened;
4098 _WebImpl::SetKeypadOpened(bool isKeypadOpened)
4100 __isKeypadOpened = isKeypadOpened;
4105 _WebImpl::IsWinFocusLost(void) const
4107 return __isWinFocusLost;
4112 _WebImpl::SetWinFocusLost(bool isWinFocusLost)
4114 __isWinFocusLost = isWinFocusLost;
4119 _WebImpl::GetPreviousKeypadBounds(void) const
4121 return __keypadBounds;
4126 _WebImpl::SetPreviousKeypadBounds(Rectangle& bounds)
4128 __keypadBounds = bounds;
4133 _WebImpl::OnTextValueChangeCanceled(const Control& source)
4135 RemoveFullScreenKeypad();
4140 _WebImpl::OnTextValueChanged(const Control& source)
4142 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(__pKeypad->GetText()));
4144 ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get());
4146 RemoveFullScreenKeypad();
4151 _WebImpl::OnHandleJavaScriptRequestByEventArg(const IEventArg& arg)
4153 const _JsBridgeArg* pEventArg = dynamic_cast< const _JsBridgeArg* >(&arg);
4154 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. arg is not _JsBridgeArg object.");
4156 std::unique_ptr<IJsonValue> pJsonValue(JsonParser::ParseN(*(pEventArg->GetJsonData())));
4157 SysTryReturn(NID_WEB_JSON, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4159 IJavaScriptBridge* pJsInterface = FindJsInterface(pJsonValue.get());
4160 SysTryReturnResult(NID_WEB_CTRL, pJsInterface, E_OBJ_NOT_FOUND, "JsInterface instance is not available.");
4162 pJsInterface->HandleJavaScriptRequestN(pJsonValue.release());
4169 _WebImpl::OnHandleLoadingEvent(const IEventArg& arg)
4171 result r = E_SUCCESS;
4173 const _LoadingEventArg* pEventArg = dynamic_cast< const _LoadingEventArg* >(&arg);
4174 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4176 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4178 ILoadingListener* pLoadingListner = GetLoadingListener();
4179 SysTryReturnResult(NID_WEB_CTRL, pLoadingListner, E_SYSTEM, "A system error has been occurred. Loading listener was not set or null.");
4181 switch (pEventArg->GetEventType())
4183 case WEB_EVENT_LOADINGLISTENER_STARTED:
4185 pLoadingListner->OnLoadingStarted();
4189 case WEB_EVENT_LOADINGLISTENER_PROGRESS:
4191 const Integer* pProgressPercentage = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS));
4192 SysTryReturn(NID_WEB_CTRL, pProgressPercentage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4194 pLoadingListner->OnEstimatedProgress(pProgressPercentage->ToInt());
4198 case WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED:
4200 const String* pPageTitle = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::PAGE_TITLE));
4201 SysTryReturn(NID_WEB_CTRL, pPageTitle, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4203 pLoadingListner->OnPageTitleReceived(*pPageTitle);
4207 case WEB_EVENT_LOADINGLISTENER_CANCELED:
4209 pLoadingListner->OnLoadingCanceled();
4213 case WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED:
4215 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_TYPE));
4216 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4218 const String* pErrorMessage = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_MESSAGE));
4219 SysTryReturn(NID_WEB_CTRL, pErrorMessage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4221 LoadingErrorType errorType = ConvertErrorCode(pErrorType->ToInt());
4223 pLoadingListner->OnLoadingErrorOccurred(errorType, *pErrorMessage);
4227 case WEB_EVENT_LOADINGLISTENER_COMPLETED:
4229 pLoadingListner->OnLoadingCompleted();
4233 case WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED:
4235 pLoadingListner->OnHttpAuthenticationCanceled();
4239 case WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED:
4241 std::unique_ptr<Bitmap> pFavicon(GetFaviconN());
4242 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4246 pLoadingListner->OnFaviconReceived(*pFavicon.get());
4262 _WebImpl::OnHandleWebDownloadEvent(const IEventArg& arg)
4264 result r = E_SUCCESS;
4266 const _WebDownloadEventArg* pEventArg = dynamic_cast< const _WebDownloadEventArg* >(&arg);
4267 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4269 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4271 IWebDownloadListener* pWebDownloadListener = __pWebDownloadHandler->GetDownloadListener();
4272 SysTryReturnResult(NID_WEB_CTRL, pWebDownloadListener, E_SYSTEM, "A system error has been occurred. Web Downloading listener was not set or null.");
4274 switch (pEventArg->GetEventType())
4276 case WEB_EVENT_WEBDOWNLOADLISTENER_DATA_RECEIVED:
4278 const ByteBuffer* pChunk = dynamic_cast< const ByteBuffer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::CHUNKED_DATA));
4279 SysTryReturn(NID_WEB_CTRL, pChunk, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4281 pWebDownloadListener->OnWebChunkedDataReceived(*pChunk);
4285 case WEB_EVENT_WEBDOWNLOADLISTENER_COMPLETED:
4287 pWebDownloadListener->OnWebDataDownloadCompleted();
4291 case WEB_EVENT_WEBDOWNLOADLISTENER_FAILED:
4293 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::ERROR_TYPE));
4294 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4296 LoadingErrorType errorType = static_cast < LoadingErrorType >(pErrorType->ToInt());
4298 pWebDownloadListener->OnWebDownloadFailed(errorType);
4313 _WebImpl::OnHandleWebUiEvent(const IEventArg& arg)
4315 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4316 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4318 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4320 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListener, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4322 switch (pEventArg->GetEventType())
4324 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED:
4326 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4328 Point* pStartPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4329 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4331 Point* pEndPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4332 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4334 __pUserUiListener->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4338 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED:
4340 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4342 __pUserUiListener->OnWebPageShowRequested(*pWeb);
4346 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED:
4348 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4350 __pUserUiListener->OnWebWindowCloseRequested(*pWeb);
4354 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED:
4356 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4358 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4359 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4361 __pUserUiListener->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4376 _WebImpl::OnHandleWebUiEventF(const IEventArg& arg)
4378 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4379 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4381 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4383 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListenerF, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4385 switch (pEventArg->GetEventType())
4387 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT:
4389 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4391 FloatPoint* pStartPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4392 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4394 FloatPoint* pEndPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4395 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4397 __pUserUiListenerF->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4401 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT:
4403 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4405 __pUserUiListenerF->OnWebPageShowRequested(*pWeb);
4409 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT:
4411 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4413 __pUserUiListenerF->OnWebWindowCloseRequested(*pWeb);
4417 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT:
4419 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4421 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4422 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4424 __pUserUiListenerF->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4439 _WebImpl::OnHandleTextSearchEvent(const IEventArg& arg)
4441 result r = E_SUCCESS;
4443 const _TextSearchEventArg* pEventArg = dynamic_cast< const _TextSearchEventArg* >(&arg);
4444 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4446 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4448 ITextSearchListener* pTextSearchListner = GetTextSearchListener();
4449 SysTryReturnResult(NID_WEB_CTRL, pTextSearchListner, E_SYSTEM, "A system error has been occurred. Web text search listener was not set or null.");
4451 switch (pEventArg->GetEventType())
4453 case WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND:
4455 Integer* pTotalCount= dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::TOTAL_COUNT)));
4456 SysTryReturn(NID_WEB_CTRL, pTotalCount, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4458 Integer* pCurrentOrdinal = dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL)));
4459 SysTryReturn(NID_WEB_CTRL, pCurrentOrdinal, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4461 pTextSearchListner->OnTextFound(pTotalCount->ToInt(), pCurrentOrdinal->ToInt());
4476 _WebImpl::VibrationRequested(uint64_t duration)
4478 result r = E_SUCCESS;
4480 __pVibrator.reset();
4482 std::unique_ptr<_VibratorImpl> pVibrator(new (std::nothrow) _VibratorImpl);
4483 SysTryReturnResult(NID_WEB_CTRL, pVibrator.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4485 r = pVibrator->Construct();
4486 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4488 __pVibrator = std::move(pVibrator);
4490 IntensityDurationVibrationPattern pattern = {static_cast< int >(duration), -1};
4492 r = __pVibrator->Start(&pattern, 1, 1);
4493 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4500 _WebImpl::VibrationCanceled(void)
4502 __pVibrator.reset();
4507 _WebImpl::HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge)
4509 result r = E_SUCCESS;
4511 String host(ewk_auth_challenge_url_get(pChallenge));
4512 String realm(ewk_auth_challenge_realm_get(pChallenge));
4514 __pAuthChallenge.reset();
4516 std::unique_ptr<AuthenticationChallenge> pAuthChallenge(new (std::nothrow) AuthenticationChallenge());
4517 SysTryReturnResult(NID_WEB_CTRL, pAuthChallenge, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4519 _AuthenticationChallengeImpl* pAuthImpl = _AuthenticationChallengeImpl::GetInstance(pAuthChallenge.get());
4520 SysTryReturn(NID_WEB_CTRL, pAuthImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4522 pAuthImpl->SetAuthenticationChallengeHandler(pChallenge);
4523 pAuthImpl->SetWebEvasObject(__pWebCore->GetWebNativeNode());
4525 __pAuthChallenge = std::move(pAuthChallenge);
4527 ewk_auth_challenge_suspend(pChallenge);
4528 if (__pUserLoadingListener && __pUserLoadingListener->OnHttpAuthenticationRequestedN(host, realm, *__pAuthChallenge.get()))
4530 __pAuthChallenge.release();
4534 r = ShowAuthenticationPopup(host, realm, __pAuthChallenge.get());
4535 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4543 _WebImpl::ShowAuthenticationPopup(const String& host, const String& realm, AuthenticationChallenge* pAuthChallenge)
4545 result r = E_SUCCESS;
4547 std::unique_ptr<_AuthConfirmPopup> pAuthPopup(new (std::nothrow) _AuthConfirmPopup());
4548 SysTryReturnResult(NID_WEB_CTRL, pAuthPopup, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4550 r = pAuthPopup->Construct(host, realm, pAuthChallenge);
4551 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4553 __pAuthPopup = std::move(pAuthPopup);
4555 int modalResult = 0;
4557 r = __pAuthPopup->ShowAndWait(modalResult);
4558 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4563 __pAuthPopup.reset();
4571 _WebImpl::ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk_Certificate_Policy_Decision* pPolicy)
4573 result r = E_SUCCESS;
4575 std::unique_ptr<_CertificateConfirmPopup> pCertConfirmPopup(new (std::nothrow) _CertificateConfirmPopup());
4576 SysTryReturnResult(NID_WEB_CTRL, pCertConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4578 r = pCertConfirmPopup->Construct(userConfirmMode, pPolicy);
4579 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4581 __pCertConfirmPopup = std::move(pCertConfirmPopup);
4583 int modalResult = 0;
4585 r = __pCertConfirmPopup->ShowAndWait(modalResult);
4586 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4588 if (__pCertConfirmPopup.get() && userConfirmMode == CERTIFICATE_POPUP_MODE_USER_CONFIRM)
4590 __isCertificateConfirmed = __pCertConfirmPopup->GetConfirmResult();
4594 if (__pCertConfirmPopup.get())
4596 __pCertConfirmPopup.reset();
4604 _WebImpl::ShowPromptPopup(String msg, String defVal)
4606 result r = E_SUCCESS;
4608 std::unique_ptr< _PromptPopup > pPromptPopup(new (std::nothrow) _PromptPopup());
4609 SysTryReturnResult(NID_WEB_CTRL, pPromptPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4611 r = pPromptPopup->Construct(msg, defVal, __pWebCore->GetWebNativeNode(), this);
4612 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4614 __pPromptPopup = std::move(pPromptPopup);
4616 r = __pPromptPopup->ShowPopup();
4617 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4622 __pPromptPopup.reset();
4630 _WebImpl::ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4632 result r = E_SUCCESS;
4634 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4635 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4637 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, this, true, msg);
4638 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4640 int modalResult = 0;
4642 switch(userConfirmMode)
4644 case USER_CONTENT_HANDLER:
4646 __pContentHandlerConfirmPopup = std::move(pUserConfirmPopup);
4648 r = __pContentHandlerConfirmPopup->ShowAndWait(modalResult);
4649 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pContentHandlerConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4651 __pContentHandlerConfirmPopup.reset();
4653 ewk_view_resume(__pWebCore->GetWebNativeNode());
4657 case USER_PROTOCOL_HANDLER:
4659 __pProtocolHandlerConfirmPopup = std::move(pUserConfirmPopup);
4661 r = __pProtocolHandlerConfirmPopup->ShowAndWait(modalResult);
4662 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pProtocolHandlerConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4664 __pProtocolHandlerConfirmPopup.reset();
4666 ewk_view_resume(__pWebCore->GetWebNativeNode());
4670 case USER_CONFIRM_APP_CACHE:
4672 __pAppCacheConfirmPopup = std::move(pUserConfirmPopup);
4674 r = __pAppCacheConfirmPopup->ShowAndWait(modalResult);
4675 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pAppCacheConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4677 __pAppCacheConfirmPopup.reset();
4679 ewk_view_resume(__pWebCore->GetWebNativeNode());
4683 case USER_CONFIRM_DB_QUOTA_EXCEDED:
4685 __pDbQuotaConfirmPopup = std::move(pUserConfirmPopup);
4687 r = __pDbQuotaConfirmPopup->ShowAndWait(modalResult);
4688 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pDbQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4690 __pDbQuotaConfirmPopup.reset();
4692 ewk_view_resume(__pWebCore->GetWebNativeNode());
4696 case USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED:
4698 __pLocalFsQuotaConfirmPopup = std::move(pUserConfirmPopup);
4700 r = __pLocalFsQuotaConfirmPopup->ShowAndWait(modalResult);
4701 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pLocalFsQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4703 __pLocalFsQuotaConfirmPopup.reset();
4705 ewk_view_resume(__pWebCore->GetWebNativeNode());
4709 case USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED:
4711 __pIndexedDbQuotaConfirmPopup = std::move(pUserConfirmPopup);
4713 r = __pIndexedDbQuotaConfirmPopup->ShowAndWait(modalResult);
4714 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pIndexedDbQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4716 __pIndexedDbQuotaConfirmPopup.reset();
4718 ewk_view_resume(__pWebCore->GetWebNativeNode());
4731 _WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4733 result r = E_SUCCESS;
4735 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4736 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4738 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, this, false, msg);
4739 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4741 switch(userConfirmMode)
4743 case USER_CONFIRM_USERMEDIA:
4745 __pUserMediaConfirmPopup.reset();
4747 __pUserMediaConfirmPopup = std::move(pUserConfirmPopup);
4749 r = __pUserMediaConfirmPopup->ShowPopup();
4750 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pUserMediaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4754 case USER_CONFIRM_GEOLOCATION:
4756 __pGeolocationConfirmPopup.reset();
4758 __pGeolocationConfirmPopup = std::move(pUserConfirmPopup);
4760 r = __pGeolocationConfirmPopup->ShowPopup();
4761 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pGeolocationConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4765 case USER_CONFIRM_NOTIFICATION:
4767 __pNotificationConfirmPopup.reset();
4769 __pNotificationConfirmPopup = std::move(pUserConfirmPopup);
4771 r = __pNotificationConfirmPopup->ShowPopup();
4772 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pNotificationConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4776 case USER_SCRIPT_ALERT:
4778 __pScriptAlertConfirmPopup.reset();
4780 __pScriptAlertConfirmPopup = std::move(pUserConfirmPopup);
4782 r = __pScriptAlertConfirmPopup->ShowPopup();
4783 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pScriptAlertConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4787 case USER_SCRIPT_CONFIRM:
4789 __pScriptConfirmPopup.reset();
4791 __pScriptConfirmPopup = std::move(pUserConfirmPopup);
4793 r = __pScriptConfirmPopup->ShowPopup();
4794 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pScriptConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4810 _WebImpl::GetParentFormImpl(_ControlImpl* pControlImpl)
4813 _FormImpl* pFormImpl = null;
4815 _ControlImpl* pParentControlImpl = dynamic_cast< _ControlImpl* >(pControlImpl->GetParent());
4816 if (!pParentControlImpl)
4821 pFormImpl = dynamic_cast< _FormImpl* >(pParentControlImpl);
4827 return GetParentFormImpl(pParentControlImpl);
4832 _WebImpl::OnFocusGained(const _ControlImpl& source)
4839 _WebImpl::OnFocusLost(const _ControlImpl& source)
4841 Evas_Object* pWebview = __pWebCore->GetWebNativeNode();
4847 if(IsKeypadVisible() == true)
4849 SetKeypadOpened(true);
4857 _WebImpl::HasValidNativeNode(void) const
4859 if (__pWebCore && __pWebCore->GetWebNativeNode())
4869 _WebImpl::OnPreAttachedToMainTree(void)
4871 result r = E_SUCCESS;
4873 if (IsVisible() == true)
4875 _WebManager* pWebManager = _WebManager::GetInstance();
4876 pWebManager->SetActiveWeb(this);
4879 r = _ContainerImpl::OnPreAttachedToMainTree();
4880 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4882 if (!HasValidNativeNode())
4884 r = __pWebCore->InitializeWebNativeNode();
4885 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4887 _ControlManager* pControlManager = _ControlManager::GetInstance();
4888 SysTryReturnResult(NID_WEB_CTRL, pControlManager, E_SYSTEM, "Failed to get the ControlManager instance.");
4889 OnChangeLayout(pControlManager->GetScreenRotation());
4891 r = InitializeSetting();
4892 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4894 SettingInfo::AddSettingEventListener(*this);
4896 _WebManager* pWebManager = _WebManager::GetInstance();
4897 pWebManager->AddWeb(reinterpret_cast< int >(this));
4905 _WebImpl::OnDetachingFromMainTree(void)
4907 result r = E_SUCCESS;
4909 _WebManager* pWebManager = _WebManager::GetInstance();
4910 pWebManager->RemoveActiveWeb(this);
4912 r = _ContainerImpl::OnDetachingFromMainTree();
4913 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4920 _WebImpl::OnSettingChanged(String& key)
4922 Evas_Object* pWebview = __pWebCore->GetWebNativeNode();
4928 if (key == L"http://tizen.org/setting/font.type")
4930 ewk_view_use_settings_font(pWebview);
4936 _WebImpl::OnChangeLayout(_ControlRotation rotation)
4938 Evas_Object* pWebview = __pWebCore->GetWebNativeNode();
4948 case _CONTROL_ROTATION_0:
4951 case _CONTROL_ROTATION_90:
4954 case _CONTROL_ROTATION_180:
4957 case _CONTROL_ROTATION_270:
4963 ewk_view_orientation_send(pWebview, degree);
4968 _WebImpl::OnChangeLayout(_ControlOrientation orientation)
4970 _ContainerImpl::OnChangeLayout(orientation);
4972 if (__pColorPicker.get())
4974 __pColorPicker->ChangeLayout(orientation);
4977 HideFormDataWindow();
4979 std::unique_ptr< IEnumerator > pEnum(__webNotificationList.GetEnumeratorN());
4980 _WebNotification* pWebNotification = null;
4982 while (pEnum->MoveNext() == E_SUCCESS)
4984 pWebNotification = static_cast< _WebNotification* >(pEnum->GetCurrent());
4985 pWebNotification->OnChangeLayout();
4988 if (IsKeypadVisible())
4990 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
4991 SysAssertf(pXformer, "Failed to get CoordinateTransformer");
4993 _FormImpl* pFormImpl = GetParentFormImpl(dynamic_cast< _ControlImpl* >(this));
4994 pFormImpl->DeflateClientRectHeight(pXformer->TransformVertical(GetPreviousKeypadBounds().height));
5000 _WebImpl::OnAncestorVisibleStateChanged(const _Control& control)
5002 Evas_Object* pWebview = __pWebCore->GetWebNativeNode();
5008 _WebManager* pWebManager = _WebManager::GetInstance();
5009 if (IsVisible() == true)
5011 pWebManager->SetActiveWeb(this);
5012 ewk_view_page_visibility_state_set(pWebview, EWK_PAGE_VISIBILITY_STATE_VISIBLE, false);
5016 pWebManager->RemoveActiveWeb(this);
5017 ewk_view_page_visibility_state_set(pWebview, EWK_PAGE_VISIBILITY_STATE_HIDDEN, false);
5023 _WebImpl::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
5025 _ContainerImpl::OnUserEventReceivedN(requestId, pArgs);
5029 case ID_CERTIFICATE_CONFIRM_POPUP_CLOSE:
5030 __pCertConfirmPopup.reset();
5032 case ID_PROMPT_POPUP_CLOSE:
5033 __pPromptPopup.reset();
5035 case ID_USER_CONFIRM_USERMEDIA_CLOSE:
5036 __pUserMediaConfirmPopup.reset();
5038 case ID_USER_CONFIRM_GEOLOCATION_CLOSE:
5039 __pGeolocationConfirmPopup.reset();
5041 case ID_USER_CONFIRM_NOTIFICATION_CLOSE:
5042 __pNotificationConfirmPopup.reset();
5044 case ID_USER_SCRIPT_ALERT_CLOSE:
5045 __pScriptAlertConfirmPopup.reset();
5047 case ID_USER_SCRIPT_CONFIRM_CLOSE:
5048 __pScriptConfirmPopup.reset();
5050 case ID_USER_SCRIPT_SELECTBOX_CLOSE:
5051 __pSelectBox.reset();
5062 _WebImpl::GetDownloadHandler(void) const
5064 return __pWebDownloadHandler.get();
5069 _WebImpl::HideColorPicker(void)
5071 __pColorPicker.reset();
5080 _WebImpl::ShowColorPicker(int red, int green, int blue, int alpha, Color& color)
5082 result r = E_SUCCESS;
5084 std::unique_ptr<_InputPickerPopup> pColorHadler(new (std::nothrow) _InputPickerPopup());
5085 SysTryReturnResult(NID_WEB_CTRL, pColorHadler.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
5087 Tizen::Graphics::Color colorVal(static_cast< byte >(red), static_cast< byte >(green), static_cast< byte >(blue), static_cast< byte >(alpha));
5089 r = pColorHadler->Construct(colorVal, this);
5090 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5092 __pColorPicker = std::move(pColorHadler);
5094 r = __pColorPicker->ShowPopup();
5095 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5099 color = __pColorPicker->GetColor();
5105 __pColorPicker.reset();
5114 _WebImpl::ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue, String& dateStr)
5116 result r = E_SUCCESS;
5118 std::unique_ptr<_InputPickerPopup> pInputPicker(new (std::nothrow) _InputPickerPopup());
5119 SysTryReturnResult(NID_WEB_CTRL, pInputPicker.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
5121 r = pInputPicker->Construct(String(inputValue), inputType, this);
5122 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5124 __pDatePicker = std::move(pInputPicker);
5126 r = __pDatePicker->ShowPopup();
5127 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5131 dateStr = __pDatePicker->GetDate();
5137 __pDatePicker.reset();
5146 _WebImpl::GetInstance(Web* pWeb)
5148 return dynamic_cast< _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
5153 _WebImpl::GetInstance(const Web* pWeb)
5155 return dynamic_cast< const _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
5160 _WebImpl::SearchHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
5162 int checkReturn = 0;
5164 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5167 if( checkmime == true)
5169 table = CUSTOM_CONTENT_TABLE_NAME;
5173 table = CUSTOM_PROTOCOL_TABLE_NAME;
5176 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
5177 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
5178 String target(ewk_custom_handlers_data_target_get(pHandlerData));
5180 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
5182 result r = db.Construct(handlerPath, "r+", null);
5183 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5185 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"'"));
5186 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5190 r = pEnum->MoveNext();
5191 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5192 r = pEnum->GetIntAt(0, checkReturn);
5193 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5205 _WebImpl::UnregistrationHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
5209 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5212 if( checkmime == true)
5214 table = CUSTOM_CONTENT_TABLE_NAME;
5218 table = CUSTOM_PROTOCOL_TABLE_NAME;
5221 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
5222 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
5223 String target(ewk_custom_handlers_data_target_get(pHandlerData));
5225 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
5227 result r = db.Construct(handlerPath, "r+", null);
5228 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5230 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"'"));
5231 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5235 r = pEnum->MoveNext();
5236 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5237 r = pEnum->GetIntAt(0, checkId);
5238 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5240 std::unique_ptr<DbStatement> pDeleteStmt(db.CreateStatementN(L"Delete From " + table + L" Where id = (?)"));
5241 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5243 r = pDeleteStmt->BindInt(0, checkId);
5244 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5246 db.BeginTransaction();
5248 std::unique_ptr<DbEnumerator> pEnum(db.ExecuteStatementN(*pDeleteStmt));
5250 db.CommitTransaction();
5257 const Tizen::Base::String
5258 _WebImpl::GetProtocolFromUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri)
5260 if (originUri == L"" || currentUri == L"")
5265 result r = E_SUCCESS;
5268 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5269 String originReplace(originUri);
5270 String table(CUSTOM_PROTOCOL_TABLE_NAME);
5274 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
5275 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5277 r = currentUri.SubString(0, found + 1, baseUri);
5278 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5280 r = db.Construct(handlerPath, "r+", null);
5281 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5283 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select mime, url, allow From " + table + L" Where baseUrl = '" + baseUri + "'"));
5284 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, L"", GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
5288 while (pEnum->MoveNext() == E_SUCCESS)
5293 String originScheme;
5295 r = pEnum->GetStringAt(0, protocol);
5296 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5298 r = pEnum->GetStringAt(1, queryUrl);
5299 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5301 r = pEnum->GetIntAt(2, allow);
5302 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5309 String protocolScheme(protocol + L":");
5311 r = originReplace.SubString(0, protocolScheme.GetLength(), originScheme);
5312 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5314 if ((originReplace.GetLength() >= protocolScheme.GetLength()) && originScheme.Equals(protocolScheme, false))
5316 if (queryUrl.IndexOf(L"%s", 0, foundQuery) == E_SUCCESS)
5318 r = originReplace.Replace(originScheme, "");
5319 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5321 queryUrl.Replace("%s", originReplace, 0);
5322 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5334 const Tizen::Base::String
5335 _WebImpl::GetRedirectUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri, const Tizen::Base::String& mime)
5337 if (originUri == L"" || currentUri == L"" || mime == L"")
5342 result r = E_SUCCESS;
5345 String originUrlStr = originUri;
5346 const String replaceStr = L"%s";
5348 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5349 String table(CUSTOM_CONTENT_TABLE_NAME);
5353 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
5354 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5356 r = currentUri.SubString(0, found + 1, baseUri);
5357 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5359 r = db.Construct(handlerPath, "r+", null);
5360 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5362 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select allow, url From " + table + L" Where baseUrl = '" + baseUri + "' AND mime = '" + mime + L"'"));
5366 r = pEnum->MoveNext();
5367 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5368 r = pEnum->GetIntAt(0, allow);
5369 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5370 r = pEnum->GetStringAt(1, contentUrl);
5371 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5379 if (contentUrl != L"")
5381 r = contentUrl.Replace(replaceStr, originUrlStr, 0);
5382 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5394 _WebImpl::SetFormDataList(Eina_List* pFormDataList)
5396 __pFormDataList = pFormDataList;
5401 _WebImpl::IsFormDataWindowVisible(void) const
5403 return __isFormDataVisible;
5408 _WebImpl::ShowFormDataWindow(const Rectangle& windowRect, Evas_Object* pWebView)
5410 Rectangle rect(_CoordinateSystemUtils::InverseTransform(Rectangle(windowRect.x, windowRect.y + windowRect.height, windowRect.width, windowRect.height)));
5412 if (__isFormDataVisible)
5414 result r = __pFormDataWindow->UpdateList(__pFormDataList, rect);
5415 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5419 __pFormDataWindow.reset();
5421 std::unique_ptr<_FormDataWindow> pFormDataWindow( new (std::nothrow) _FormDataWindow());
5422 SysTryReturnResult(NID_WEB_CTRL, pFormDataWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
5424 result r = pFormDataWindow->Construct(rect, this, pWebView);
5425 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5427 r = pFormDataWindow->UpdateList(__pFormDataList, rect);
5428 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5430 r = pFormDataWindow->LaunchFormDataWindow();
5431 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5433 __pFormDataWindow = std::move(pFormDataWindow);
5434 __isFormDataVisible = true;
5442 _WebImpl::HideFormDataWindow(bool delWindow)
5446 __pFormDataWindow.reset();
5449 __isFormDataVisible = false;
5454 _WebImpl::ClearWebNotification(_WebNotification* pWebNotification)
5456 __webNotificationList.Remove(*pWebNotification);
5461 _WebImpl::SetWebNotification(_WebNotification* pWebNotification)
5463 __webNotificationList.Add(pWebNotification);
5467 }}} // Tizen::Web::Controls