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_SystemResource.h>
77 #include <FSys_VibratorImpl.h>
78 #include <FUi_Control.h>
79 #include <FUi_CoordinateSystemUtils.h>
80 #include <FUi_EcoreEvasMgr.h>
81 #include <FUi_EcoreEvas.h>
82 #include <FUi_ResourceSizeInfo.h>
83 #include <FUi_Window.h>
84 #include <FUiAnim_EflNode.h>
85 #include <FUiAnim_VisualElement.h>
86 #include <FUiCtrl_FooterImpl.h>
87 #include <FUiCtrl_FormImpl.h>
88 #include "FWeb_HistoryItemImpl.h"
89 #include "FWebCtrl_AppControlListener.h"
90 #include "FWebCtrl_AuthConfirmPopup.h"
91 #include "FWebCtrl_AuthenticationChallengeImpl.h"
92 #include "FWebCtrl_EflWebkit.h"
93 #include "FWebCtrl_FormDataWindow.h"
94 #include "FWebCtrl_GeolocationPermissionManagerImpl.h"
95 #include "FWebCtrl_HitElementResultImpl.h"
96 #include "FWebCtrl_InputPickerPopup.h"
97 #include "FWebCtrl_WebNotification.h"
98 #include "FWebCtrl_PageNavigationListImpl.h"
99 #include "FWebCtrl_PromptPopup.h"
100 #include "FWebCtrl_SelectBox.h"
101 #include "FWebCtrl_Utility.h"
102 #include "FWebCtrl_Web.h"
103 #include "FWebCtrl_WebDataHandler.h"
104 #include "FWebCtrl_WebEvent.h"
105 #include "FWebCtrl_WebEventArg.h"
106 #include "FWebCtrl_WebImpl.h"
107 #include "FWebCtrl_WebManager.h"
108 #include "FWebCtrl_WebPresenter.h"
109 #include "FWebCtrl_WebSettingImpl.h"
112 using namespace Tizen::App;
113 using namespace Tizen::Base;
114 using namespace Tizen::Base::Collection;
115 using namespace Tizen::Base::Runtime;
116 using namespace Tizen::Base::Utility;
117 using namespace Tizen::Content;
118 using namespace Tizen::Graphics;
119 using namespace Tizen::Io;
120 using namespace Tizen::Media;
121 using namespace Tizen::Net::Http;
122 using namespace Tizen::System;
123 using namespace Tizen::Ui;
124 using namespace Tizen::Ui::Animations;
125 using namespace Tizen::Ui::Controls;
126 using namespace Tizen::Web::Json;
129 namespace Tizen { namespace Web { namespace Controls
133 static const char WEB_CTRL[] = "webcontrol";
134 static const char PARENT_WEB_CTRL[] = "parentwebcontrol";
137 static const float MIN_ZOOM_LEVEL = 0.3;
138 static const float MAX_ZOOM_LEVEL = 2;
141 static const int REDIRECTION_HEADER_GROUP = 300;
144 static const int MAX_TEXT_MATCH = pow(2, 31) - 1;
147 static const int PORTRAIT_KEYPAD_HEIGHT = 444;
148 static const int LANDSCAPE_KEYPAD_HEIGHT = 316;
149 static const int DEFAULT_LIST_ITEM_COUNT = 4;
153 AddHttpAttributeData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData)
155 result r = E_SUCCESS;
157 std::unique_ptr<String> pAttrKey(new (std::nothrow) String(reinterpret_cast< char* >(const_cast< void* >(pKey))));
158 std::unique_ptr<String> pAttrValue(new (std::nothrow) String(reinterpret_cast< char* >(pValue)));
159 SysTryReturn(NID_WEB_CTRL, pAttrKey.get() && pAttrValue.get(), EINA_FALSE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
161 SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", pAttrKey->GetPointer(), pAttrValue->GetPointer());
163 r = reinterpret_cast< HashMap* >(pUserData)->Add(*pAttrKey, *pAttrValue);
164 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
166 pAttrValue.release();
173 FreeCharArray(void* pData)
175 delete[] reinterpret_cast<char*>(pData);
180 ConvertErrorCode(int error)
182 LoadingErrorType errorCode = WEB_ERROR_UNKNOWN;
186 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
188 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE:
190 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE_PROXY:
192 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT:
194 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT_PROXY:
196 case EWK_ERROR_NETWORK_STATUS_IO_ERROR:
198 case EWK_ERROR_NETWORK_STATUS_MALFORMED:
200 case EWK_ERROR_NETWORK_STATUS_TRY_AGAIN:
202 case EWK_ERROR_NETWORK_STATUS_TOO_MANY_REDIRECTS:
204 case EWK_ERROR_NETWORK_STATUS_TLS_FAILED:
206 case EWK_ERROR_NETWORK_STATUS_INTERNAL_SERVER_ERROR:
208 case EWK_ERROR_NETWORK_STATUS_BAD_GATEWAY:
210 case EWK_ERROR_NETWORK_STATUS_SERVICE_UNAVAILABLE:
212 case EWK_ERROR_NETWORK_STATUS_GATEWAY_TIMEOUT:
213 errorCode = WEB_NO_CONNECTION;
216 case EWK_ERROR_NETWORK_STATUS_BAD_REQUEST:
218 case EWK_ERROR_NETWORK_STATUS_REQUEST_URI_TOO_LONG:
219 errorCode = WEB_BAD_URL;
222 case EWK_ERROR_NETWORK_STATUS_FORBIDDEN:
223 errorCode = WEB_FILE_ACCESS_FAILED;
226 case EWK_ERROR_NETWORK_STATUS_REQUEST_TIMEOUT:
227 errorCode = WEB_REQUEST_TIMEOUT;
230 case EWK_ERROR_NETWORK_STATUS_UNSUPPORTED_MEDIA_TYPE:
231 errorCode = WEB_MIME_NOT_SUPPORTED;
234 case EWK_ERROR_NETWORK_STATUS_INSUFFICIENT_STORAGE:
235 errorCode = WEB_OUT_OF_MEMORY;
238 case EWK_ERROR_NETWORK_STATUS_REQUEST_ENTITY_TOO_LARGE:
239 errorCode = WEB_REQUEST_MAX_EXCEEDED;
242 case EWK_ERROR_NETWORK_STATUS_CONTINUE:
244 case EWK_ERROR_NETWORK_STATUS_SWITCHING_PROTOCOLS:
246 case EWK_ERROR_NETWORK_STATUS_PROCESSING:
248 case EWK_ERROR_NETWORK_STATUS_OK:
250 case EWK_ERROR_NETWORK_STATUS_CREATED:
252 case EWK_ERROR_NETWORK_STATUS_ACCEPTED:
254 case EWK_ERROR_NETWORK_STATUS_NON_AUTHORITATIVE:
256 case EWK_ERROR_NETWORK_STATUS_NO_CONTENT:
258 case EWK_ERROR_NETWORK_STATUS_RESET_CONTENT:
260 case EWK_ERROR_NETWORK_STATUS_PARTIAL_CONTENT:
262 case EWK_ERROR_NETWORK_STATUS_MULTI_STATUS:
264 case EWK_ERROR_NETWORK_STATUS_MULTIPLE_CHOICES:
266 case EWK_ERROR_NETWORK_STATUS_MOVED_PERMANENTLY:
268 case EWK_ERROR_NETWORK_STATUS_FOUND:
270 case EWK_ERROR_NETWORK_STATUS_SEE_OTHER:
272 case EWK_ERROR_NETWORK_STATUS_NOT_MODIFIED:
274 case EWK_ERROR_NETWORK_STATUS_USE_PROXY:
276 case EWK_ERROR_NETWORK_STATUS_NOT_APPEARING_IN_THIS_PROTOCOL:
278 case EWK_ERROR_NETWORK_STATUS_TEMPORARY_REDIRECT:
279 errorCode = WEB_HTTP_RESPONSE;
282 case EWK_ERROR_NETWORK_STATUS_SSL_FAILED:
283 errorCode = WEB_INVALID_CERTIFICATE;
287 errorCode = WEB_ERROR_UNKNOWN;
296 FireLoadingErrorOccurredEvent(_WebImpl* pImpl, int code, const char* pDescription)
298 result r = E_SUCCESS;
300 std::unique_ptr<Integer> pErrorCode(new (std::nothrow) Integer(code));
301 std::unique_ptr<String> pErrorDescription(new (std::nothrow) String(pDescription));
302 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED));
303 SysTryReturnResult(NID_WEB_CTRL, pErrorCode.get() && pErrorDescription.get() && pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
305 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_TYPE, *pErrorCode.get());
306 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
307 pErrorCode.release();
309 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_MESSAGE, *pErrorDescription.get());
310 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
311 pErrorDescription.release();
313 r = pImpl->GetWebEvent()->FireAsync(*pEventArg);
314 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
322 OnScriptAlertRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
324 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
326 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
327 String msg(pMessage);
329 result r = pImpl->ShowUserConfirmPopupAsync(USER_SCRIPT_ALERT, pView, msg);
330 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
334 ewk_view_javascript_alert_reply(pView);
340 OnScriptConfirmRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
342 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
344 result r = E_SUCCESS;
345 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
346 String msg(pMessage);
348 r = pImpl->ShowUserConfirmPopupAsync(USER_SCRIPT_CONFIRM, pView, msg);
349 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
353 ewk_view_javascript_confirm_reply(pView, EINA_FALSE);
359 OnScriptPromptRequested(Evas_Object* pView, const char* pMessage, const char* pDefaultValue, void* pUserData)
361 SysLog(NID_WEB_CTRL, "The current value of message is %s, defaulValue is %s", pMessage, pDefaultValue);
363 result r = E_SUCCESS;
364 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
366 String msg(pMessage);
367 String defVal(pDefaultValue);
369 r = pImpl->ShowPromptPopup(msg, defVal);
370 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
375 ewk_view_javascript_prompt_reply(pView, null);
382 OnCertificateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
384 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
385 Ewk_Certificate_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Certificate_Policy_Decision* >(pEventInfo);
386 SysAssertf(pImpl && pPolicy, "Failed to request");
388 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
390 switch (pImpl->GetSetting().GetCertificateErrorHandlingMode())
392 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM:
394 if (pImpl->IsCertificateRequested())
396 ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast< Eina_Bool >(pImpl->IsCertificateConfirmed()));
400 result r = E_SUCCESS;
402 std::unique_ptr<DbEnumerator> pEnum;
404 String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
405 String table(CERTIFICATE_TABLE_NAME);
408 String pem(ewk_certificate_policy_decision_certificate_pem_get(pPolicy));
410 r = db.Construct(certificatePath, "r", null);
411 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
413 pEnum = std::unique_ptr<DbEnumerator>(db.QueryN(L"Select allow From " + table + L" Where pem = '" + pem + L"'"));
416 r = pEnum->MoveNext();
417 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
420 r = pEnum->GetIntAt(0, allow);
421 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
423 SysLog(NID_WEB_CTRL, "The current value of allow is %d", allow);
425 ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast < Eina_Bool >(allow));
426 pImpl->SetCertificateConfirmed(static_cast < bool >(allow));
430 r = pImpl->ShowCertificateConfirmPopup(CERTIFICATE_POPUP_MODE_USER_CONFIRM, pPolicy);
431 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
433 ewk_view_resume(pWebCore->GetWebNativeNode());
438 pImpl->SetCertificateRequested(true);
442 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CANCEL:
443 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE);
445 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE :
446 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_TRUE);
455 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE);
456 pImpl->SetCertificateConfirmed(false);
457 pImpl->SetCertificateRequested(true);
459 ewk_view_resume(pWebCore->GetWebNativeNode());
464 OnHttpAuthenticationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
466 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
467 Ewk_Auth_Challenge* pChallenge = reinterpret_cast< Ewk_Auth_Challenge* >(pEventInfo);
468 SysAssertf(pImpl && pChallenge, "Failed to request");
470 result r = E_SUCCESS;
472 r = pImpl->HttpAuthenticationRequested(pChallenge);
473 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
477 ewk_auth_challenge_credential_cancel(pChallenge);
478 evas_object_smart_callback_call(pView, "authentication,canceled", NULL);
483 OnHttpAuthenticationCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
485 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
486 SysAssertf(pImpl , "Failed to request");
488 if (pImpl->GetLoadingListener())
490 result r = E_SUCCESS;
492 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED));
493 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
495 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
496 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
502 OnApplicationCachePermissionRequested(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, void* pUserData)
504 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
505 SysAssertf(pImpl , "Failed to request");
507 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
509 result r = msg.Format(256, L"Allow %s to use offline application cache?", pHostName);
510 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
512 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_APP_CACHE, pView, msg);
513 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
520 OnIndexedDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData)
522 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
523 SysAssertf(pImpl , "Failed to request");
525 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
527 result r = msg.Format(512, L"%s Used %lld of storage. Allow %s to use upto 2GB of indexed db?", pHostName, currentQuota, pHostName);
528 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
530 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED, pView, msg);
531 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
538 OnDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, const char* database_name, unsigned long long expectedQuota, void* pUserData)
540 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
541 SysAssertf(pImpl , "Failed to request");
543 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
545 result r = msg.Format(512, L"Allow %s to open %s use upto %lld of web database?", pHostName, database_name, expectedQuota);
546 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
548 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_DB_QUOTA_EXCEDED, pView, msg);
549 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
555 Eina_Bool OnLocalFileSystemQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData)
557 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
558 SysAssertf(pImpl , "Failed to request");
560 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
562 result r = msg.Format(512, L"%s Used %lld of storgae. Allow %s to use upto 2GB of file system?", pHostName, currentQuota, pHostName);
563 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
565 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED, pView, msg);
566 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
573 OnGeolocationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
575 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
576 Ewk_Geolocation_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Geolocation_Permission_Request* >(pEventInfo);
577 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
579 if (pImpl->GetSetting().IsGeolocationEnabled())
581 result r = E_SUCCESS;
583 std::unique_ptr<DbEnumerator> pEnum;
585 String geolocationPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
586 String table(GEOLOCATION_TABLE_NAME);
589 const Ewk_Security_Origin* pSecurityOrigin = ewk_geolocation_permission_request_origin_get(pPermissionRequest);
590 String origin = _Utility::CreateOrigin(pSecurityOrigin);
592 r = db.Construct(geolocationPath, "r", null);
593 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
595 pEnum = std::unique_ptr<DbEnumerator>(db.QueryN(L"Select permission From " + table + L" Where origin = '" + origin + L"'"));
598 r = pEnum->MoveNext();
599 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
602 r = pEnum->GetIntAt(0, permission);
603 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
605 SysLog(NID_WEB_CTRL, "The current value of permission is %d", permission);
607 ewk_geolocation_permission_request_set(pPermissionRequest, static_cast < Eina_Bool >(permission));
611 ewk_geolocation_permission_request_suspend(pPermissionRequest);
613 r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_GEOLOCATION, pPermissionRequest);
614 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
621 ewk_geolocation_permission_request_set(pPermissionRequest, EINA_FALSE);
626 OnGetUserMediaPermissionRequsted(void* pUserData, Evas_Object* pView, void* pEventInfo)
628 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
629 Ewk_User_Media_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_User_Media_Permission_Request* >(pEventInfo);
630 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
632 result r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_USERMEDIA, pEventInfo);
633 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
637 ewk_user_media_permission_request_set(pPermissionRequest, EINA_FALSE);
642 OnNotificationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
644 result r = E_SUCCESS;
645 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
647 Ewk_Notification_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Notification_Permission_Request* >(pEventInfo);
648 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
650 ewk_notification_permission_request_suspend(pPermissionRequest);
652 r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_NOTIFICATION, pPermissionRequest);
653 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
657 ewk_notification_permission_request_set(pPermissionRequest, EINA_FALSE);
662 OnNotificationShow(void* pUserData, Evas_Object* pView, void* pEventInfo)
664 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
665 Ewk_Notification* pNotification = reinterpret_cast< Ewk_Notification* >(pEventInfo);
666 SysAssertf(pImpl && pNotification, "Failed to request");
668 result r = E_SUCCESS;
669 Ewk_Context* pContext = ewk_view_context_get(pView);
670 SysAssertf(pContext, "Failed to get webkit instance.");
671 uint64_t notificationId = ewk_notification_id_get(pNotification);
673 //ewk_notification_security_origin_get(pNotification)
675 const char* text = ewk_notification_body_get(pNotification);
676 SysSecureLog(NID_WEB_CTRL, "The current value of icon path is %s",ewk_notification_icon_url_get(pNotification));
678 std::unique_ptr<_WebNotification> pNotificationWindow( new (std::nothrow) _WebNotification());
679 SysTryReturnVoidResult(NID_WEB_CTRL, pNotificationWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
681 r = pNotificationWindow->Construct(pContext, notificationId, pImpl);
682 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Error propogated.", GetErrorMessage(r));
684 pNotificationWindow->SetText(String(text));
685 pNotificationWindow->LaunchNotification();
686 pImpl->SetWebNotification(pNotificationWindow.release());
688 ewk_notification_showed(pContext, notificationId);
693 OnNotificationCancel(void* pUserData, Evas_Object* pView, void* pEventInfo)
695 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
696 uint64_t* pNotificationID = reinterpret_cast< uint64_t* >(pEventInfo);
697 SysAssertf(pImpl && pNotificationID, "Failed to request");
699 //ToDo : Where is ewk API for cancel operation?
704 OnProtocolHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
706 result r = E_SUCCESS;
707 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
708 SysAssertf(pImpl, "Failed to request");
710 r = pImpl->ShowUserConfirmPopup(USER_PROTOCOL_HANDLER, pEventInfo);
711 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
716 OnIsProtocolHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
718 int checkHandler = 0;
719 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
720 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
721 SysAssertf(pImpl && pHandlerData, "Failed to request");
723 checkHandler = pImpl->SearchHandler(pHandlerData, false);
724 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
725 switch (checkHandler)
730 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
733 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
736 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
744 OnProtocolHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
746 result r = E_SUCCESS;
747 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
748 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
749 SysAssertf(pImpl && pHandlerData, "Failed to request");
751 r = pImpl->UnregistrationHandler(pHandlerData, false);
752 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
757 OnContentHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
759 result r = E_SUCCESS;
760 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
761 SysAssertf(pImpl, "Failed to request");
763 r = pImpl->ShowUserConfirmPopup(USER_CONTENT_HANDLER, pEventInfo);
764 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
769 OnIsContentHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
771 int checkHandler = 0;
772 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
773 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
774 SysAssertf(pImpl && pHandlerData, "Failed to request");
776 checkHandler = pImpl->SearchHandler(pHandlerData, true);
777 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
779 switch (checkHandler)
784 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
787 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
790 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
799 OnContentHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
801 result r = E_SUCCESS;
802 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
803 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
804 SysAssertf(pImpl && pHandlerData, "Failed to request");
806 r = pImpl->UnregistrationHandler(pHandlerData, true);
807 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
812 OnFullScreenEntered(void* pUserData, Evas_Object* pView, void* pEventInfo)
814 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
815 bool* pIsHandleNeeded = reinterpret_cast< bool* >(pEventInfo);
816 SysAssertf(pImpl, "Failed to request");
818 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
819 SysAssertf(pWebCore, "Failed to get Web core object");
821 if (pIsHandleNeeded && *pIsHandleNeeded)
823 pWebCore->SetFullScreenEntered(true);
829 OnFullScreenExited(void* pUserData, Evas_Object* pView, void* pEventInfo)
831 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
832 SysAssertf(pImpl, "Failed to request");
834 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
835 SysAssertf(pWebCore, "Failed to get Web core object");
837 pWebCore->SetFullScreenEntered(false);
842 OnFocusDownRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
844 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
845 SysAssertf(pImpl, "Failed to request");
847 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
848 pWebCore->SetFocusEnd(true);
853 OnFocusUpRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
855 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
856 SysAssertf(pImpl, "Failed to request");
858 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
859 pWebCore->SetFocusEnd(true);
864 OnVibrationRequested(uint64_t duration, void* pUserData)
866 result r = E_SUCCESS;
868 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
869 SysAssertf(pImpl, "Failed to request");
871 r = pImpl->VibrationRequested(duration);
872 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
877 OnVibrationCanceled(void* pUserData)
879 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
880 SysAssertf(pImpl, "Failed to request");
882 pImpl->VibrationCanceled();
887 OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
889 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
890 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
891 SysAssertf(pImpl && pPolicy, "Failed to request");
893 String url(ewk_policy_decision_url_get(pPolicy));
894 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls", url.GetPointer());
896 if (ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy))
897 && !pImpl->IsRedirectRequested())
899 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
900 SysAssertf(pWebCore, "Failed to get Web core object");
902 pWebCore->SetFullScreenEntered(false);
904 pImpl->SetCertificateRequested(false);
906 if (pImpl->GetTextSearchListener())
908 pImpl->DisableAsyncSearch();
911 ILoadingListener* pLoadingListener = pImpl->GetLoadingListener();
912 if (pLoadingListener)
914 WebNavigationType navigationType = WEB_NAVIGATION_OTHER;
915 Ewk_Policy_Navigation_Type ewkNavigationType = ewk_policy_decision_navigation_type_get(pPolicy);
917 switch (ewkNavigationType)
919 case EWK_POLICY_NAVIGATION_TYPE_LINK_CLICKED:
920 navigationType = WEB_NAVIGATION_LINK_CLICKED;
922 case EWK_POLICY_NAVIGATION_TYPE_FORM_SUBMITTED:
923 navigationType = WEB_NAVIGATION_FORM_SUBMITTED;
925 case EWK_POLICY_NAVIGATION_TYPE_BACK_FORWARD:
926 navigationType = WEB_NAVIGATION_BACKFORWARD;
928 case EWK_POLICY_NAVIGATION_TYPE_RELOAD:
929 navigationType = WEB_NAVIGATION_RELOAD;
931 case EWK_POLICY_NAVIGATION_TYPE_FORM_RESUBMITTED:
932 navigationType = WEB_NAVIGATION_FORM_RESUBMITTED;
934 case EWK_POLICY_NAVIGATION_TYPE_OTHER:
935 navigationType = WEB_NAVIGATION_OTHER;
941 if (pLoadingListener->OnLoadingRequested(url, navigationType))
943 ewk_policy_decision_ignore(pPolicy);
950 if (url == L"about:blank")
952 ewk_policy_decision_use(pPolicy);
957 String currentUrl(pImpl->GetUrl());
958 String redirectUrl(pImpl->GetProtocolFromUri(url, currentUrl));
959 if (redirectUrl != L"")
961 ewk_policy_decision_ignore(pPolicy);
963 pImpl->LoadUrl(redirectUrl);
971 String uriScheme(uri.GetScheme());
972 SysSecureLog(NID_WEB_CTRL, "The current value of scheme is %ls", uriScheme.GetPointer());
974 if ((uriScheme != L"http") && (uriScheme != L"https") && (uriScheme != L"file"))
976 ewk_policy_decision_ignore(pPolicy);
978 if (uriScheme == L"")
983 result r = E_SUCCESS;
985 if (uriScheme == L"tel")
987 String operationId(L"http://tizen.org/appcontrol/operation/dial");
988 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
990 else if (uriScheme == L"mailto" || uriScheme == L"sms" || uriScheme == L"smsto" || uriScheme == L"mms" || uriScheme == L"mmsto" )
992 String operationId(L"http://tizen.org/appcontrol/operation/compose");
993 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
997 String operationId(L"http://tizen.org/appcontrol/operation/view");
998 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
1000 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1005 ewk_policy_decision_use(pPolicy);
1010 OnLoadingStarted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1012 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1013 SysAssertf(pImpl, "Failed to request");
1015 if (pImpl->GetLoadingListener())
1017 result r = E_SUCCESS;
1019 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_STARTED));
1020 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1022 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1023 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1024 pEventArg.release();
1030 OnPageTitleReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1032 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1033 char* pTitle = reinterpret_cast< char* >(pEventInfo);
1034 SysAssertf(pImpl, "Failed to request");
1036 SysLog(NID_WEB_CTRL, "The current value of title is %s", pTitle);
1038 if (pImpl->GetLoadingListener())
1040 result r = E_SUCCESS;
1042 std::unique_ptr<String> pPageTitle(new (std::nothrow) String(pTitle));
1043 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED));
1044 SysTryReturnVoidResult(NID_WEB_CTRL, pPageTitle.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1046 r = pEventArg->SetEventInfo(_LoadingEventArg::PAGE_TITLE, *pPageTitle.get());
1047 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1048 pPageTitle.release();
1050 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1051 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1052 pEventArg.release();
1058 OnEstimatedProgress(void* pUserData, Evas_Object* pView, void* pEventInfo)
1060 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1061 double* pProgress = reinterpret_cast< double* >(pEventInfo);
1062 SysAssertf(pImpl, "Failed to request");
1064 SysLog(NID_WEB_CTRL, "The current value of progress is %lf", *pProgress);
1066 if (pImpl->GetLoadingListener())
1068 result r = E_SUCCESS;
1070 std::unique_ptr<Integer> pProgressPercentage(new (std::nothrow) Integer(static_cast< int >(*pProgress * 100)));
1071 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PROGRESS));
1072 SysTryReturnVoidResult(NID_WEB_CTRL, pProgressPercentage.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1074 r = pEventArg->SetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS, *pProgressPercentage.get());
1075 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1076 pProgressPercentage.release();
1078 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1079 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1080 pEventArg.release();
1086 OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1088 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1089 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
1090 SysAssertf(pImpl && pPolicy, "Failed to request");
1092 result r = E_SUCCESS;
1094 int code = ewk_policy_decision_response_status_code_get(pPolicy);
1095 String url(ewk_policy_decision_url_get(pPolicy));
1096 String mime(ewk_policy_decision_response_mime_get(pPolicy));
1097 SysSecureLog(NID_WEB_CTRL, "code : %d, url : %ls, mime : %ls", code, url.GetPointer(), mime.GetPointer());
1099 if (ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy)))
1101 if (code >= REDIRECTION_HEADER_GROUP && code < REDIRECTION_HEADER_GROUP + 100)
1103 pImpl->SetRedirectRequested(true);
1107 ILoadingListener* pLoadingListener = pImpl->GetLoadingListener();
1108 if (pLoadingListener)
1110 HttpHeader httpHeader;
1112 Eina_Iterator* iterator = eina_hash_iterator_tuple_new(ewk_policy_decision_response_headers_get(pPolicy));
1115 Eina_Hash_Tuple *tuple = null;
1117 EINA_ITERATOR_FOREACH(iterator, tuple)
1119 String key(reinterpret_cast< const char* >(tuple->key));
1120 String value(reinterpret_cast< char* >(tuple->data));
1122 SysSecureLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", key.GetPointer(), value.GetPointer());
1124 r = httpHeader.AddField(key, value);
1125 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1128 eina_iterator_free(iterator);
1131 pImpl->SetPolicyDecision(pLoadingListener->OnWebDataReceived(mime, httpHeader));
1135 pImpl->SetPolicyDecision(WEB_DECISION_CONTINUE);
1139 switch (pImpl->GetPolicyDecision())
1141 case WEB_DECISION_CONTINUE:
1143 String currentUrl(pImpl->GetUrl());
1144 String redirectUrl(pImpl->GetRedirectUri(url, currentUrl, mime));
1145 if (redirectUrl != L"")
1147 ewk_policy_decision_ignore(pPolicy);
1149 pImpl->LoadUrl(redirectUrl);
1154 if (ewk_policy_decision_type_get(pPolicy) == EWK_POLICY_DECISION_USE)
1160 ewk_policy_decision_ignore(pPolicy);
1162 String operationId(L"http://tizen.org/appcontrol/operation/view");
1164 r = _AppControlImpl::FindAndStart(operationId, &url, &mime, null, null, null);
1165 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS || r == E_OBJ_NOT_FOUND, r, "[%s] Propagating.", GetErrorMessage(r));
1166 if (r == E_OBJ_NOT_FOUND)
1168 String operationId(L"http://tizen.org/appcontrol/operation/download");
1170 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
1171 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1179 case WEB_DECISION_DOWNLOAD:
1181 ewk_policy_decision_ignore(pPolicy);
1183 _WebDataHandler* pDownloadHandler = pImpl->GetDownloadHandler();
1184 SysTryReturnVoidResult(NID_WEB_CTRL, pDownloadHandler, E_SYSTEM, "[%s] A system error has been occurred. Failed to get DownloadHandler.", GetErrorMessage(E_SYSTEM));
1186 Ewk_Context* pContext = ewk_view_context_get(pView);
1187 SysAssertf(pContext, "Failed to get webkit instance.");
1189 pDownloadHandler->StartDownload(url);
1194 case WEB_DECISION_IGNORE:
1196 ewk_policy_decision_ignore(pPolicy);
1207 ewk_policy_decision_use(pPolicy);
1212 ewk_policy_decision_ignore(pPolicy);
1217 OnProgressCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1219 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1220 SysAssertf(pImpl, "Failed to request");
1222 if (pImpl->IsRedirectRequested())
1224 pImpl->SetRedirectRequested(false);
1227 if (pImpl->IsLoadingErrorOccurred())
1229 pImpl->SetLoadingErrorOccurred(false);
1230 evas_object_smart_callback_call(pView, "load,finished", NULL);
1236 OnLoadingErrorOccurred(void* pUserData, Evas_Object* pView, void* pEventInfo)
1238 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1239 Ewk_Error* pErrorData = reinterpret_cast< Ewk_Error* >(pEventInfo);
1240 SysAssertf(pImpl && pErrorData, "Failed to request");
1242 int code = ewk_error_code_get(pErrorData);
1243 const char* pDescription = ewk_error_description_get(pErrorData);
1245 SysLog(NID_WEB_CTRL, "The current value of code is %d, description is %s", code, pDescription);
1249 case EWK_ERROR_CODE_FRAMELOADINTERRUPTEDBYPOLICYCHANGE:
1250 pImpl->SetLoadingErrorOccurred(true);
1253 case EWK_ERROR_CODE_PLUGINWILLHANDLELOAD:
1254 evas_object_smart_callback_call(pView, "load,finished", NULL);
1257 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
1258 pImpl->SetLoadingErrorOccurred(true);
1259 evas_object_smart_callback_call(pView, "load,stop", NULL);
1263 pImpl->SetLoadingErrorOccurred(true);
1264 if (pImpl->GetLoadingListener())
1266 result r = E_SUCCESS;
1268 r = FireLoadingErrorOccurredEvent(pImpl, code, pDescription);
1269 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1277 OnLoadingCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
1279 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1280 SysAssertf(pImpl, "Failed to request");
1282 if (pImpl->GetLoadingListener())
1284 result r = E_SUCCESS;
1286 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_CANCELED));
1287 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1289 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1290 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1291 pEventArg.release();
1298 OnLoadingCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1300 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1301 SysAssertf(pImpl, "Failed to request");
1303 if (pImpl->GetLoadingListener())
1305 result r = E_SUCCESS;
1307 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_COMPLETED));
1308 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1310 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1311 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1312 pEventArg.release();
1319 OnLoadingCommitted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1321 evas_object_focus_set(pView, EINA_FALSE);
1326 OnFaviconReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1328 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1329 SysAssertf(pImpl, "Failed to request");
1331 if (pImpl->GetLoadingListener())
1333 result r = E_SUCCESS;
1335 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED));
1336 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1338 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1339 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1340 pEventArg.release();
1347 OnDidStartDownloadCallback(const char* pUrl, void* pUserData)
1349 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1350 SysAssertf(pUrl && pImpl != null, "Failed to request");
1352 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s", pUrl);
1357 FireWebPageShowRequestedEvent(_WebImpl* pImpl, int event)
1359 result r = E_SUCCESS;
1361 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1362 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1364 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1365 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1366 pEventArg.release();
1373 OnWebPageShowRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1375 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1376 SysAssertf(pImpl, "Failed to request");
1378 if (pImpl->GetUiEventListener())
1380 result r = E_SUCCESS;
1382 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED);
1383 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1385 if (pImpl->GetUiEventListenerF())
1387 result r = E_SUCCESS;
1389 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT);
1390 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1396 OnWebWindowCreateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1398 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(pUserData);
1399 Evas_Object** pChildView = reinterpret_cast< Evas_Object** >(pEventInfo);
1400 SysAssertf(pParentImpl && pChildView, "Failed to request");
1402 IWebUiEventListener* pUserUiListener = pParentImpl->GetUiEventListener();
1403 IWebUiEventListenerF* pUserUiListenerF = pParentImpl->GetUiEventListenerF();
1404 if (pUserUiListener)
1406 Web* pWeb = pUserUiListener->OnWebWindowCreateRequested();
1409 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1410 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1412 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1413 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1416 if (pUserUiListenerF)
1418 Web* pWeb = pUserUiListenerF->OnWebWindowCreateRequested();
1421 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1422 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1424 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1425 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1432 FireWebWindowClosedRequestedEvent(_WebImpl* pImpl, int event)
1434 result r = E_SUCCESS;
1436 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1437 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1439 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1440 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1441 pEventArg.release();
1448 OnWebWindowClosedRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1450 _WebImpl* pChildImpl = reinterpret_cast< _WebImpl* >(pUserData);
1451 SysAssertf(pChildImpl, "Failed to request");
1453 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, PARENT_WEB_CTRL));
1454 if (pParentImpl == null)
1459 if (pParentImpl->GetUiEventListener())
1461 result r = E_SUCCESS;
1463 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED);
1464 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1466 if (pParentImpl->GetUiEventListenerF())
1468 result r = E_SUCCESS;
1470 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT);
1471 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1477 FireWebPreventDefaultTriggeredEvent(_WebImpl* pImpl, int event, bool trigger)
1479 result r = E_SUCCESS;
1481 std::unique_ptr<Boolean> pPreventTrigger(new (std::nothrow) Boolean(trigger));
1482 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1483 SysTryReturnResult(NID_WEB_CTRL, pPreventTrigger.get() && pEventArg.get(), E_OUT_OF_MEMORY, " Memory allocation failed." );
1485 r = pEventArg->SetEventInfo(_WebUiEventArg::PREVENT_DEFAULT, *pPreventTrigger.get());
1486 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1487 pPreventTrigger.release();
1489 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1490 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1491 pEventArg.release();
1498 OnWebPreventDefaultTriggered(void* pUserData, Evas_Object* pView, void* pEventInfo)
1500 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1501 Eina_Bool* pTrigger = reinterpret_cast< Eina_Bool* >(pEventInfo);
1502 SysAssertf(pImpl && pTrigger, "Failed to request");
1504 if (pImpl->GetUiEventListener())
1506 result r = E_SUCCESS;
1508 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED, static_cast< bool >(*pTrigger));
1509 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1511 if (pImpl->GetUiEventListenerF())
1513 result r = E_SUCCESS;
1515 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT, static_cast< bool >(*pTrigger));
1516 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1522 FireWebPageBlockSelectedEvent(_WebImpl* pImpl)
1524 result r = E_SUCCESS;
1526 std::unique_ptr<Point> startPoint(new (std::nothrow) Point());
1527 std::unique_ptr<Point> endPoint(new (std::nothrow) Point());
1528 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1530 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1532 if ((endPoint->x != 0) && (endPoint->y != 0))
1534 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED));
1535 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1537 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1538 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1539 startPoint.release();
1541 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1542 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1545 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1546 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1547 pEventArg.release();
1555 FireWebPageBlockSelectedEventF(_WebImpl* pImpl)
1557 result r = E_SUCCESS;
1559 std::unique_ptr<FloatPoint> startPoint(new (std::nothrow) FloatPoint());
1560 std::unique_ptr<FloatPoint> endPoint(new (std::nothrow) FloatPoint());
1562 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1564 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1565 if ((endPoint->x != 0.0f) && (endPoint->y != 0.0f))
1567 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT));
1568 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1570 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1571 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1572 startPoint.release();
1574 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1575 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1578 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1579 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1580 pEventArg.release();
1588 OnWebPageBlockSelected(void* pUserData, Evas_Object* pView, void* pEventInfo)
1590 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1591 SysAssertf(pImpl, "Failed to request");
1593 if (pImpl->GetUiEventListener())
1595 result r = E_SUCCESS;
1597 r = FireWebPageBlockSelectedEvent(pImpl);
1598 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1600 if (pImpl->GetUiEventListenerF())
1602 result r = E_SUCCESS;
1604 r = FireWebPageBlockSelectedEventF(pImpl);
1605 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1611 OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo)
1613 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1614 char* pJsonText = reinterpret_cast< char* >(pEventInfo);
1615 SysAssertf(pImpl && pJsonText, "Failed to request");
1617 result r = E_SUCCESS;
1619 SysLog(NID_WEB_CTRL, "The current value of jsontext is %s", pJsonText);
1621 std::unique_ptr<_JsBridgeArg> pEventArg(new (std::nothrow) _JsBridgeArg());
1622 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1624 r = pEventArg->Construct(pJsonText);
1625 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1627 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1628 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1629 pEventArg.release();
1634 OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo)
1636 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1637 Eina_Rectangle* pEinaRect = reinterpret_cast< Eina_Rectangle* >(pEventInfo);
1638 SysAssertf(pImpl && pEinaRect, "Failed to request");
1640 if (pImpl->GetSetting().GetInputStyle() == INPUT_STYLE_OVERLAY)
1642 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1643 SysAssertf(pXformer, "Failed to get CoordinateTransformer");
1645 Rectangle rect(pEinaRect->x, pEinaRect->y, pEinaRect->w, pEinaRect->h);
1647 if (rect.height == 0)
1652 _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl));
1655 pFormImpl->DeflateClientRectHeight(pXformer->TransformVertical(rect.height));
1658 if (pImpl->GetWebKeypadEventListener())
1660 if (pImpl->IsKeypadVisible() == true)
1662 if ((pImpl->GetPreviousKeypadBounds().width == rect.width) && (pImpl->GetPreviousKeypadBounds().height != rect.height))
1664 pImpl->GetWebKeypadEventListener()->OnWebKeypadBoundsChanged(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1669 pImpl->GetWebKeypadEventListener()->OnWebKeypadWillOpen(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1672 pImpl->SetPreviousKeypadBounds(rect);
1676 result r = pImpl->SetFullScreenKeypad();
1677 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1683 OnWebKeypadOpened(void* pUserData, Evas_Object* pView, void* pEventInfo)
1685 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1686 SysAssertf(pImpl, "Failed to request");
1688 pImpl->SetKeypadVisibleState(true);
1690 _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl));
1693 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1694 SysAssertf(pXformer, "Failed to get CoordinateTransformer");
1696 pFormImpl->DeflateClientRectHeight(pXformer->TransformVertical(pImpl->GetPreviousKeypadBounds().height));
1698 if (pFormImpl->HasFooter())
1700 pFormImpl->GetCore().SetKeypadShowState(true);
1705 if (pImpl->GetWebKeypadEventListener())
1707 pImpl->GetWebKeypadEventListener()->OnWebKeypadOpened(*static_cast< Web* >(&pImpl->GetPublic()));
1713 OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo)
1715 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1716 SysAssertf(pImpl, "Failed to request");
1718 _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl));
1721 pFormImpl->DeflateClientRectHeight(0);
1723 if (pFormImpl->HasFooter())
1725 pFormImpl->GetCore().SetKeypadShowState(false);
1730 if (pImpl->GetWebKeypadEventListener())
1732 pImpl->GetWebKeypadEventListener()->OnWebKeypadClosed(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1735 pImpl->SetKeypadVisibleState(false);
1740 OnWindowObjectFocusLost(void* pUserData, Evas_Object* pWin, void* pEvent_info)
1742 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1743 SysAssertf(pImpl, "Failed to request");
1745 pImpl->SetWinFocusLost(true);
1750 OnWindowObjectFocusGained(void* pUserData, Evas_Object* pWin, void* pEvent_info)
1752 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1753 SysAssertf(pImpl, "Failed to request");
1755 if (pImpl->IsVisible() == true && pImpl->IsFocused() == true)
1757 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
1758 SysAssertf(pWebCore, "Failed to get Web core object");
1760 if (pImpl->IsWinFocusLost() == true)
1762 if (pImpl->IsKeypadOpened() == true)
1764 evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE);
1767 Ewk_Settings* pSettings = ewk_view_settings_get(pWebCore->GetWebNativeNode());
1768 SysAssertf(pSettings, "Failed to get settings instance.");
1770 if (ewk_settings_clear_text_selection_automatically_get(pSettings) == EINA_FALSE)
1772 ewk_settings_clear_text_selection_automatically_set(pSettings, EINA_TRUE);
1774 evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE);
1779 pImpl->SetWinFocusLost(false);
1784 OnWebNativeNodeFocusGained(void* pUserData, Evas* pCanvas, Evas_Object* pView, void* pEventInfo)
1786 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1787 SysAssertf(pImpl, "Failed to request");
1789 if (pImpl->IsKeypadOpened() == true)
1791 pImpl->SetKeypadOpened(false);
1797 OnWebNativeNodeFocusLost(void* pUserData, Evas* pCanvas, Evas_Object* pView, void* pEventInfo)
1799 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1800 SysAssertf(pImpl, "Failed to request");
1802 if (pImpl->IsWinFocusLost() == true)
1804 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
1805 SysAssertf(pWebCore, "Failed to get Web core object");
1807 Ewk_Settings* pSettings = ewk_view_settings_get(pWebCore->GetWebNativeNode());
1808 SysAssertf(pSettings, "Failed to get settings instance.");
1810 ewk_settings_clear_text_selection_automatically_set(pSettings, EINA_FALSE);
1816 OnColorPickerProviderRequested(Ewk_View_Smart_Data* pSmartData, int red, int green, int blue, int alpha)
1818 SysAssertf(pSmartData, "invalid smartdata");
1819 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1820 SysAssertf(pWebImpl, "Failed to get Impl");
1822 result r = E_SUCCESS;
1824 if (pWebImpl->GetColorpicker())
1831 r = pWebImpl->ShowColorPicker(red, green, blue, alpha, color);
1832 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1834 byte r1, g1, b1, a1;
1835 color.GetColorComponents(r1, g1, b1, a1);
1836 ewk_view_color_picker_color_set(pSmartData->self, r1, g1, b1, a1);
1843 OnColorPickerProviderDismissed(Ewk_View_Smart_Data* pSmartData)
1845 SysAssertf(pSmartData, "invalid smartdata");
1847 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1848 SysAssertf(pWebImpl, "Failed to get Impl");
1850 return pWebImpl->HideColorPicker();
1855 OnDatePickerProviderRequested(Ewk_View_Smart_Data* pSmartData, Ewk_Input_Type inputType, const char* inputValue)
1857 SysAssertf(pSmartData, "Failed to request");
1858 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1859 SysAssertf(pWebImpl, "Failed to get Impl");
1861 result r = E_SUCCESS;
1863 if (pWebImpl->GetDatepicker())
1865 ewk_view_focused_input_element_value_set(pSmartData->self, inputValue);
1872 r = pWebImpl->ShowDatePicker(inputType, inputValue, dateStr);
1873 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1875 std::unique_ptr<char[]> pDateStr(_StringConverter::CopyToCharArrayN(dateStr));
1876 SysTryReturn(NID_WEB_CTRL, pDateStr.get(), EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1878 ewk_view_focused_input_element_value_set(pSmartData->self, pDateStr.get());
1885 OnSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex)
1887 SysAssertf(pSmartData, "Failed to request");
1889 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1890 SysAssertf(pWebImpl, "Failed to get Impl");
1892 result r = pWebImpl->ShowSelectBoxPopup(false, L"", pItems, pSmartData->self, selectedIndex);
1893 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1900 OnMultiSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* pItems)
1902 SysAssertf(pSmartData, "Failed to request");
1904 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1905 SysAssertf(pWebImpl, "Failed to get Impl");
1907 result r = pWebImpl->ShowSelectBoxPopup(true, L"", pItems, pSmartData->self, 0);
1908 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1915 OnSelectBoxClosed(Ewk_View_Smart_Data* pSmartData)
1917 SysAssertf(pSmartData, "invalid smartdata");
1919 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1920 SysAssertf(pWebImpl, "Failed to get Impl");
1922 result r = pWebImpl->ClearSelectBoxPopup();
1923 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1930 OnSelectBoxUpdateRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, Eina_List* pItems, int selectedIndex)
1932 SysAssertf(pSmartData, "invalid smartdata");
1934 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1935 SysAssertf(pWebImpl, "Failed to get Impl");
1937 result r = pWebImpl->UpdateSelectBoxPopup(pItems, selectedIndex, false);
1938 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1945 OnFormDataCandidateShow(Ewk_View_Smart_Data *pSmartData, int x, int y, int w, int h)
1947 SysAssertf(pSmartData, "Failed to request");
1949 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1950 SysAssertf(pWebImpl, "Failed to get Impl");
1952 Rectangle windowRect(x, y, w, h);
1953 result r = pWebImpl->ShowFormDataWindow(windowRect, pSmartData->self);
1954 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1961 OnFormDataCandidateHide(Ewk_View_Smart_Data *pSmartData)
1963 SysAssertf(pSmartData, "Failed to request");
1965 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1966 SysAssertf(pWebImpl, "Failed to get Impl");
1968 if (pWebImpl->IsFormDataWindowVisible())
1970 pWebImpl->HideFormDataWindow();
1978 OnFormDataCandidateUpdate(Ewk_View_Smart_Data *pSmartData, Eina_List *pDataList)
1980 SysAssertf(pSmartData, "Failed to request");
1982 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1983 SysAssertf(pWebImpl, "Failed to get Impl");
1985 pWebImpl->SetFormDataList(pDataList);
1992 OnFormDataCandidateIsShowing(Ewk_View_Smart_Data *pSmartData)
1994 SysAssertf(pSmartData, "Failed to request");
1996 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1997 SysAssertf(pWebImpl, "Failed to get Impl");
1999 if (pWebImpl->IsFormDataWindowVisible())
2011 OnCookiesPolicyGot(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *pError, void *pUserData)
2013 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
2014 SysAssertf(pPresenter && !pError, "Failed to request");
2016 bool ret = EINA_TRUE;
2020 case EWK_COOKIE_ACCEPT_POLICY_ALWAYS:
2022 case EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY:
2026 case EWK_COOKIE_ACCEPT_POLICY_NEVER:
2035 SysLog(NID_WEB_CTRL, "The current value of policy is %d", ret);
2037 pPresenter->EndAsyncProcess(ret);
2042 OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData)
2044 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
2045 SysAssertf(pPresenter, "Failed to request");
2047 String result(pResult);
2048 SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer());
2050 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, WEB_CTRL));
2051 _WebManager* pWebManager = _WebManager::GetInstance();
2052 if (pWebManager->IsValidCallback(reinterpret_cast< int >(pImpl), reinterpret_cast< int >(pPresenter)))
2054 pPresenter->EndAsyncProcess(result);
2060 OnTextFound(void* pUserData, Evas_Object* pView, void* pEventInfo)
2062 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2063 SysAssertf(pImpl, "Failed to request");
2065 int* pTotalCount = reinterpret_cast< int* >(pEventInfo);
2066 SysLog(NID_WEB_CTRL, "The current value of totalCount is %d", *pTotalCount);
2068 _WebPresenter* pWebPresenter = pImpl->GetSearchPresenter();
2072 pWebPresenter->EndAsyncProcess(*pTotalCount);
2076 if (pImpl->GetTextSearchListener())
2078 result r = E_SUCCESS;
2082 if (*pTotalCount > 0)
2084 ordinal = pImpl->GetAsyncSearchOrdinal();
2085 pImpl->SetAsyncSearchResult(*pTotalCount);
2088 if (pImpl->GetPendingAsyncSearchCount() > 0)
2093 std::unique_ptr<Integer> pCount(new (std::nothrow) Integer(*pTotalCount));
2094 std::unique_ptr<Integer> pOrdinal(new (std::nothrow) Integer(ordinal));
2095 std::unique_ptr<_TextSearchEventArg> pEventArg(new (std::nothrow) _TextSearchEventArg(WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND));
2096 SysTryReturnVoidResult(NID_WEB_CTRL, pCount.get() && pOrdinal.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2098 r = pEventArg->SetEventInfo(_TextSearchEventArg::TOTAL_COUNT, *pCount.get());
2099 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2102 r = pEventArg->SetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL, *pOrdinal.get());
2103 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2106 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
2107 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2108 pEventArg.release();
2114 class _JsBridgeHashCodeProvider
2115 : public Tizen::Base::Collection::IHashCodeProviderT< Tizen::Base::String >
2118 _JsBridgeHashCodeProvider(){}
2119 virtual ~_JsBridgeHashCodeProvider(void) {}
2122 int GetHashCode(const Tizen::Base::String& obj) const
2124 return obj.GetHashCode();
2130 //Comparer implementation
2131 class _JsBridgeComparer
2132 : public Tizen::Base::Collection::IComparerT< Tizen::Base::String >
2135 _JsBridgeComparer(){}
2136 virtual ~_JsBridgeComparer(void) {}
2139 result Compare(const Tizen::Base::String& obj1, const Tizen::Base::String& obj2, int& cmp) const
2156 _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
2157 : _ContainerImpl(pWeb, pCore)
2158 , __isFooterVisible(false)
2159 , __isKeypadVisible(false)
2160 , __isKeypadOpened(false)
2161 , __isWinFocusLost(false)
2162 , __isLoadingErrorOccurred(false)
2163 , __isRedirectRequested(false)
2164 , __isCertificateRequested(false)
2165 , __isCertificateConfirmed(false)
2166 , __isFormDataVisible(false)
2167 , __keypadBounds(0, 0, 0, 0)
2169 , __pUserLoadingListener(null)
2170 , __pUserUiListener(null)
2171 , __pUserUiListenerF(null)
2172 , __pUserKeypadEventListener(null)
2173 , __pTextSearchListener(null)
2175 , __pJsBridgeList(null)
2176 , __pJsProvider(null)
2177 , __pJsComparer(null)
2178 , __pWebDownloadHandler(null)
2180 , __pAuthChallenge(null)
2181 , __pAuthPopup(null)
2182 , __pUserMediaConfirmPopup(null)
2183 , __pContentHandlerConfirmPopup(null)
2184 , __pProtocolHandlerConfirmPopup(null)
2185 , __pGeolocationConfirmPopup(null)
2186 , __pNotificationConfirmPopup(null)
2187 , __pScriptAlertConfirmPopup(null)
2188 , __pScriptConfirmPopup(null)
2189 , __pAppCacheConfirmPopup(null)
2190 , __pDbQuotaConfirmPopup(null)
2191 , __pLocalFsQuotaConfirmPopup(null)
2192 , __pIndexedDbQuotaConfirmPopup(null)
2193 , __pPromptPopup(null)
2194 , __pCertConfirmPopup(null)
2195 , __pSelectBox(null)
2196 , __pDatePicker(null)
2197 , __pColorPicker(null)
2198 , __pFormDataWindow(null)
2200 , __policy(WEB_DECISION_CONTINUE)
2201 , __defaultUserAgent(L"")
2202 , __pFormDataList(null)
2203 , __popupClosed(false)
2205 __textSearch.__searchAll = false;
2206 __textSearch.__searchForward = true;
2207 __textSearch.__caseSensitive = false;
2208 __textSearch.__pending = 0;
2209 __textSearch.__currentIndex = 1;
2210 __textSearch.__totalCount = -1;
2211 __textSearch.__text = L"";
2215 _WebImpl::~_WebImpl()
2217 _WebManager* pWebManager = _WebManager::GetInstance();
2218 SysTryCatch(NID_WEB_CTRL, pWebManager, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2220 pWebManager->RemoveWeb(reinterpret_cast< int >(this));
2221 pWebManager->RemoveActiveWeb(this);
2224 RemoveEventListenerCallback();
2226 ClearCertificateDb();
2231 _WebImpl::CreateWebImplN(Web* pControl, const Rectangle& bounds)
2233 result r = E_SUCCESS;
2235 r = GET_SIZE_INFO(Web).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2236 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2238 _Web* pCore = _Web::CreateWebN();
2239 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2241 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2243 r = CheckConstruction(pCore, pImpl);
2244 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2246 r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2247 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2249 r = pImpl->Construct();
2250 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2262 _WebImpl::CreateWebImplN(Web* pControl, const FloatRectangle& bounds)
2264 result r = E_SUCCESS;
2266 r = GET_SIZE_INFO(Web).CheckInitialSizeValidF(FloatDimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2267 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2269 _Web* pCore = _Web::CreateWebN();
2270 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2272 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2274 r = CheckConstruction(pCore, pImpl);
2275 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2277 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2278 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2280 r = pImpl->Construct();
2281 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2293 _WebImpl::Construct(void)
2295 result r = E_SUCCESS;
2297 r = __mutex.Create();
2298 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2300 r = __textSearch.__searchQueue.Construct();
2301 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2303 r = __webNotificationList.Construct();
2304 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2306 r = InitJsBridgeList();
2307 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2310 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2312 __pWebCore = dynamic_cast< _Web* >(&(GetCore()));
2313 SysTryReturnResult(NID_WEB_CTRL, __pWebCore, E_SYSTEM, "A system error has been occurred. Failed to get web control");
2320 _WebImpl::InitializeSetting(void)
2322 result r = E_SUCCESS;
2324 WebSetting* pWebSetting = __pWebCore->GetSetting();
2325 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(pWebSetting);
2327 SetCookieEnabled(pWebSettingImpl->IsCookieEnabled());
2328 SetPrivateBrowsingEnabled(pWebSettingImpl->IsPrivateBrowsingEnabled());
2330 __defaultUserAgent = pWebSettingImpl->GetUserAgent();
2332 r = SetSetting(*pWebSetting);
2333 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2335 SetEventListenerCallback();
2342 _WebImpl::IsLayoutable(void) const
2349 _WebImpl::InitWebEvent(void)
2351 __pWebEvent = std::unique_ptr<_WebEvent>(new (std::nothrow) _WebEvent());
2352 SysTryReturnResult(NID_WEB_CTRL, __pWebEvent.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2354 return __pWebEvent->Construct(*this);
2359 _WebImpl::GetWebEvent(void) const
2361 return __pWebEvent.get();
2366 _WebImpl::ConvertToSlpHeaderN(const HttpHeader& header) const
2368 Eina_Hash* pHttpHeader = null;
2370 std::unique_ptr<IList> pFieldNameList(header.GetFieldNamesN());
2371 if (pFieldNameList.get())
2373 pHttpHeader = eina_hash_string_small_new(FreeCharArray);
2374 SysTryReturn(NID_WEB_CTRL, pHttpHeader, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2376 int count = pFieldNameList->GetCount();
2378 for (int i = 0; i < count; i++)
2380 String* pFieldName = dynamic_cast< String* >(pFieldNameList->GetAt(i));
2381 SysTryCatch(NID_WEB_CTRL, pFieldName, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2383 std::unique_ptr<char[]> pKey(_StringConverter::CopyToCharArrayN(*pFieldName));
2384 SysTryCatch(NID_WEB_CTRL, pKey.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2386 std::unique_ptr<IEnumerator> pFieldValueEnum(header.GetFieldValuesN(*pFieldName));
2387 SysTryCatch(NID_WEB_CTRL, pFieldValueEnum.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2389 while (pFieldValueEnum->MoveNext() == E_SUCCESS)
2391 Eina_Bool ret = false;
2393 String* pFieldValue = dynamic_cast< String* >(pFieldValueEnum->GetCurrent());
2394 SysTryCatch(NID_WEB_CTRL, pFieldValue, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2396 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(*pFieldValue));
2397 SysTryCatch(NID_WEB_CTRL, pValue.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2399 ret = eina_hash_add(pHttpHeader, pKey.get(), pValue.release());
2400 SysTryCatch(NID_WEB_CTRL, ret == EINA_TRUE, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2407 eina_hash_free(pHttpHeader);
2414 _WebImpl::LoadUrl(const String& url) const
2416 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2417 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2419 ewk_view_url_set(__pWebCore->GetWebNativeNode(), pUrl.get());
2426 _WebImpl::LoadUrl(const String& url, const HttpHeader& header)
2428 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2429 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2431 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2433 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_GET, pHttpHeader, null);
2435 eina_hash_free(pHttpHeader);
2442 _WebImpl::LoadUrlWithPostRequest(const String& url, const HttpHeader& header, const ByteBuffer& body) const
2444 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2445 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2447 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2449 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_POST, pHttpHeader, reinterpret_cast< const char* >(body.GetPointer()));
2451 eina_hash_free(pHttpHeader);
2458 _WebImpl::LoadData(const String& baseUrl, const ByteBuffer& content, const String& mime, const String& encoding) const
2460 SysTryReturnResult(NID_WEB_CTRL, content.GetLimit() > 0, E_INVALID_ARG, "The content buffer is empty.");
2462 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(baseUrl));
2463 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
2464 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(encoding));
2465 SysTryReturn(NID_WEB_CTRL, pUrl.get() && pMime.get() && pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2467 ewk_view_contents_set(__pWebCore->GetWebNativeNode(), reinterpret_cast< const char* >(content.GetPointer()), content.GetLimit(), pMime.get(), pEncoding.get(), pUrl.get());
2474 _WebImpl::Pause(void)
2476 ewk_view_suspend(__pWebCore->GetWebNativeNode());
2481 _WebImpl::Resume(void)
2483 ewk_view_resume(__pWebCore->GetWebNativeNode());
2488 _WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List* pItems, Evas_Object* pWebView, int selectedIndex)
2490 __pSelectBox.reset();
2492 SysTryReturnResult(NID_WEB_CTRL, eina_list_count(pItems) > 0, E_SYSTEM, "ItemCount is invalid.");
2494 result r = E_SUCCESS;
2496 std::unique_ptr<_SelectBox> pSelectBox(new (std::nothrow) _SelectBox());
2497 SysTryReturnResult(NID_WEB_CTRL, pSelectBox.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2499 r = pSelectBox->Construct(isMultiSelect, title, DEFAULT_LIST_ITEM_COUNT, pWebView);
2500 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2502 r = pSelectBox->UpdateList(pItems, selectedIndex, false, false);
2503 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2505 __pSelectBox = std::move(pSelectBox);
2507 return __pSelectBox->ShowPopup();
2512 _WebImpl::UpdateSelectBoxPopup(Eina_List* pItems, int selectedIndex, bool isGroupedList)
2514 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2516 return __pSelectBox->UpdateList(pItems, selectedIndex, true, isGroupedList);
2521 _WebImpl::ClearSelectBoxPopup(void)
2523 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2525 __pSelectBox.reset();
2534 _WebImpl::GetDatepicker(void)
2536 _InputPickerPopup* pInputPicker =null;
2539 pInputPicker = __pDatePicker.get();
2541 return pInputPicker;
2546 _WebImpl::GetColorpicker(void)
2548 _InputPickerPopup* pInputPicker =null;
2551 pInputPicker = __pColorPicker.get();
2553 return pInputPicker;
2558 _WebImpl::CanGoBack(void) const
2560 return static_cast< bool >(ewk_view_back_possible(__pWebCore->GetWebNativeNode()));
2565 _WebImpl::CanGoForward(void) const
2567 return static_cast< bool >(ewk_view_forward_possible(__pWebCore->GetWebNativeNode()));
2572 _WebImpl::GoBack(void) const
2574 ewk_view_back(__pWebCore->GetWebNativeNode());
2579 _WebImpl::GoForward(void) const
2581 ewk_view_forward(__pWebCore->GetWebNativeNode());
2586 _WebImpl::GetUrl(void) const
2588 return ewk_view_url_get(__pWebCore->GetWebNativeNode());
2593 _WebImpl::GetTitle(void) const
2595 return ewk_view_title_get(__pWebCore->GetWebNativeNode());
2600 _WebImpl::StopLoading(void) const
2602 ewk_view_stop(__pWebCore->GetWebNativeNode());
2607 _WebImpl::Reload(void) const
2609 ewk_view_reload(__pWebCore->GetWebNativeNode());
2614 _WebImpl::EvaluateJavascriptN(const String& scriptCode)
2616 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2622 std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(scriptCode));
2623 SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2625 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
2626 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2628 ewk_view_script_execute(pView, pScript.get(), OnScriptExecuted, pPresenter.get());
2630 String* pResult = new (std::nothrow) String(L"");
2631 SysTryReturn(NID_WEB_CTRL, pResult, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2633 pPresenter->WaitAsyncProcess(*pResult);
2640 _WebImpl::SetZoomLevel(float level)
2642 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);
2644 ewk_view_scale_set(__pWebCore->GetWebNativeNode(), static_cast< double >(level), 0, 0);
2651 _WebImpl::GetZoomLevel(void) const
2653 return static_cast< float >(ewk_view_scale_get(__pWebCore->GetWebNativeNode()));
2657 const PageNavigationList*
2658 _WebImpl::GetBackForwardListN(void) const
2660 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2666 result r = E_SUCCESS;
2668 _PageNavigationListImpl* pNavigationListImpl = null;
2669 _HistoryItemImpl* pHistoryItemImpl = null;
2671 std::unique_ptr<PageNavigationList> pNavigationList;
2672 std::unique_ptr<ArrayList, AllElementsDeleter> pHistoryList;
2675 int forwardCount = 0;
2680 Ewk_History* pEwkHistoryList = ewk_view_history_get(pView);
2681 SysTryReturn(NID_WEB_CTRL, pEwkHistoryList, null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get full history.", GetErrorMessage(E_SYSTEM));
2683 Ewk_History_Item* pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, 0);
2684 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_DATA_NOT_FOUND, "[%s] There is no history.", GetErrorMessage(E_DATA_NOT_FOUND));
2686 pNavigationList = std::unique_ptr<PageNavigationList>(new (std::nothrow) PageNavigationList());
2687 SysTryCatch(NID_WEB_CTRL, pNavigationList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2689 pNavigationListImpl = _PageNavigationListImpl::GetInstance(pNavigationList.get());
2690 SysTryCatch(NID_WEB_CTRL, pNavigationListImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2692 pHistoryList = std::unique_ptr<ArrayList, AllElementsDeleter>(new (std::nothrow) ArrayList());
2693 SysTryCatch(NID_WEB_CTRL, pHistoryList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2695 r = pHistoryList->Construct();
2696 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2698 backCount = ewk_history_back_list_length_get(pEwkHistoryList);
2699 forwardCount = ewk_history_forward_list_length_get(pEwkHistoryList);
2700 SysLog(NID_WEB_CTRL, "The current value of backCount is %d, forwardCount is %d", backCount, forwardCount);
2702 for (int i = -backCount; i < forwardCount + 1; i++)
2704 std::unique_ptr<HistoryItem> pHistoryItem(new (std::nothrow) HistoryItem());
2705 SysTryCatch(NID_WEB_CTRL, pHistoryItem.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2707 pHistoryItemImpl = _HistoryItemImpl::GetInstance(pHistoryItem.get());
2708 SysTryCatch(NID_WEB_CTRL, pHistoryItemImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2710 pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, i);
2711 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2713 url = ewk_history_item_uri_get(pEwkItem);
2714 title = ewk_history_item_title_get(pEwkItem);
2715 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s, title is %s", url.GetPointer(), title.GetPointer());
2717 pHistoryItemImpl->SetHistoryItem(url, title);
2719 r = pHistoryList->Add(*pHistoryItem.get());
2720 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2721 pHistoryItem.release();
2724 pNavigationListImpl->SetPageNavigationList(pHistoryList.release(), backCount);
2726 ewk_history_free(pEwkHistoryList);
2728 return pNavigationList.release();
2731 ewk_history_free(pEwkHistoryList);
2738 _WebImpl::SearchText(const String& text, bool searchForward)
2740 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2746 result r = E_SUCCESS;
2748 Ewk_Find_Options condition = static_cast< Ewk_Find_Options >(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2752 condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS);
2755 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
2756 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2758 r = SynchronizeSearch(SEARCH_SYNC, pView, condition, text, searchForward, false, pPresenter.get());
2759 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
2762 pPresenter->WaitAsyncProcess(result);
2764 return static_cast < bool >(result);
2769 _WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive)
2771 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2777 result r = E_SUCCESS;
2779 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2783 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2786 r = SynchronizeSearch(SEARCH_ALL_ASYNC, pView, condition, text, true, caseSensitive);
2787 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2794 _WebImpl::SearchNextAsync(bool searchForward)
2796 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2802 SysTryReturnResult(NID_WEB_CTRL, __textSearch.__searchAll && __textSearch.__totalCount > -1, E_INVALID_OPERATION, "The SearchTextAllAsync() method is not called or completed.");
2803 SysTryReturnResult(NID_WEB_CTRL, (searchForward && __textSearch.__currentIndex < __textSearch.__totalCount) || (!searchForward && __textSearch.__currentIndex > 1)
2804 , E_OBJ_NOT_FOUND, "The Next instance is not available.");
2806 result r = E_SUCCESS;
2808 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2810 if (!__textSearch.__caseSensitive)
2812 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2817 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_BACKWARDS);
2820 r = SynchronizeSearch(SEARCH_NEXT_ASYNC, pView, condition, __textSearch.__text, searchForward);
2821 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2828 _WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text, bool searchForward, bool caseSensitive, _WebPresenter* pWebPresenter)
2830 MutexGuard lock(__mutex);
2832 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(text));
2833 SysTryReturn(NID_WEB_CTRL, pText.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2838 if (__textSearch.__searchAll)
2840 DisableAsyncSearch();
2842 __textSearch.__searchQueue.Enqueue(this);
2843 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2845 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2846 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2850 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2852 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2856 case SEARCH_ALL_ASYNC:
2857 __textSearch.__searchAll = true;
2858 __textSearch.__text = text;
2859 __textSearch.__searchForward = true;
2860 __textSearch.__caseSensitive = caseSensitive;
2861 __textSearch.__totalCount = -1;
2862 __textSearch.__currentIndex = 1;
2864 __textSearch.__searchQueue.Enqueue(this);
2865 __textSearch.__searchQueue.Enqueue(this);
2867 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2868 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2871 case SEARCH_NEXT_ASYNC:
2872 __textSearch.__searchForward = searchForward;
2874 CalculateAsyncSearchOrdinal();
2876 __textSearch.__searchQueue.Enqueue(this);
2878 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2890 _WebImpl::SetAsyncSearchResult(int totalCount)
2892 __textSearch.__totalCount = totalCount;
2897 _WebImpl::GetSearchPresenter(void)
2899 MutexGuard lock(__mutex);
2901 return dynamic_cast< _WebPresenter* >(__textSearch.__searchQueue.Dequeue());
2906 _WebImpl::GetPendingAsyncSearchCount(void) const
2908 return __textSearch.__searchQueue.GetCount();
2913 _WebImpl::CalculateAsyncSearchOrdinal(void)
2915 if (__textSearch.__searchForward)
2917 __textSearch.__currentIndex++;
2921 __textSearch.__currentIndex--;
2927 _WebImpl::GetAsyncSearchOrdinal(void) const
2929 return __textSearch.__currentIndex;
2934 _WebImpl::DisableAsyncSearch(void)
2936 __textSearch.__searchAll = false;
2941 _WebImpl::SetSetting(const WebSetting& setting)
2943 if (__pWebCore->GetWebNativeNode())
2945 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2946 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2947 SysAssertf(pContext && pSettings, "Failed to get webkit instance.");
2949 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(setting.GetDefaultTextEncoding()));
2950 SysTryReturn(NID_WEB_CTRL, pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2952 ewk_settings_default_encoding_set(pSettings, pEncoding.get());
2954 switch (setting.GetCacheControl())
2956 case WEB_CACHE_VALIDATED:
2957 ewk_context_cache_disabled_set(pContext, EINA_FALSE);
2960 case WEB_CACHE_IGNORE:
2961 ewk_context_cache_disabled_set(pContext, EINA_TRUE);
2968 if (setting.GetInputStyle() == INPUT_STYLE_OVERLAY)
2970 ewk_settings_default_keypad_enabled_set(pSettings, EINA_TRUE);
2974 ewk_settings_default_keypad_enabled_set(pSettings, EINA_FALSE);
2977 ewk_settings_font_default_size_set(pSettings, static_cast< Eina_Bool >(setting.GetFontSize()));
2979 ewk_settings_javascript_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsJavascriptEnabled()));
2981 ewk_settings_loads_images_automatically_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoImageLoadEnabled()));
2983 if (__defaultUserAgent != setting.GetUserAgent())
2985 std::unique_ptr<char[]> pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent()));
2986 SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2988 ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get());
2991 ewk_settings_auto_fitting_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFittingEnabled()));
2993 ewk_settings_scripts_window_open_set(pSettings, static_cast< Eina_Bool >(setting.IsJavaScriptPopupEnabled()));
2995 ewk_settings_form_candidate_data_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFormDataShowEnabled()));
2997 ewk_settings_autofill_password_form_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoLoginFormFillEnabled()));
3000 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting());
3002 pWebSettingImpl->SetCertificateErrorHandlingMode(setting.GetCertificateErrorHandlingMode());
3003 pWebSettingImpl->SetDefaultTextEncoding(setting.GetDefaultTextEncoding());
3004 pWebSettingImpl->SetCacheControl(setting.GetCacheControl());
3005 pWebSettingImpl->SetFontSize(setting.GetFontSize());
3006 pWebSettingImpl->SetJavascriptEnabled(setting.IsJavascriptEnabled());
3007 pWebSettingImpl->SetAutoImageLoadEnabled(setting.IsAutoImageLoadEnabled());
3008 pWebSettingImpl->SetInputStyle(setting.GetInputStyle());
3009 pWebSettingImpl->SetUserAgent(setting.GetUserAgent());
3010 pWebSettingImpl->SetAutoFittingEnabled(setting.IsAutoFittingEnabled());
3011 pWebSettingImpl->SetJavaScriptPopupEnabled(setting.IsJavaScriptPopupEnabled());
3012 pWebSettingImpl->SetGeolocationEnabled(setting.IsGeolocationEnabled());
3013 pWebSettingImpl->SetAutoFormDataShowEnabled(setting.IsAutoFormDataShowEnabled());
3014 pWebSettingImpl->SetAutoLoginFormFillEnabled(setting.IsAutoLoginFormFillEnabled());
3021 _WebImpl::GetSetting(void) const
3023 return *__pWebCore->GetSetting();
3027 const HitElementResult*
3028 _WebImpl::GetElementByPointN(const Point& point) const
3030 return GetElementByPointN(_CoordinateSystemUtils::ConvertToFloat(point));
3034 const HitElementResult*
3035 _WebImpl::GetElementByPointN(const FloatPoint& point) const
3037 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3043 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));
3045 result r = E_SUCCESS;
3047 _HitElementResultImpl* pHitElementResultImpl = null;
3049 std::unique_ptr<HitElementResult> pHitElementResult;
3050 std::unique_ptr<Bitmap> pImage;
3051 std::unique_ptr<HashMap, AllElementsDeleter> pAttributeMap;
3053 Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(point)));
3055 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3056 SysTryReturn(NID_WEB_CTRL, pEwkHitTest, null, E_SYSTEM, "[%s] Failed to get hit test.", GetErrorMessage(E_SYSTEM));
3058 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
3059 Ewk_Hit_Test_Result_Context context = ewk_hit_test_result_context_get(pEwkHitTest);
3060 String url(ewk_hit_test_link_uri_get(pEwkHitTest));
3061 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3062 String nodeValue(ewk_hit_test_node_value_get(pEwkHitTest));
3064 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls, tag is %ls, value is %ls", url.GetPointer(), tagName.GetPointer(), nodeValue.GetPointer());
3066 pHitElementResult = std::unique_ptr<HitElementResult>(new (std::nothrow) HitElementResult());
3067 SysTryCatch(NID_WEB_CTRL, pHitElementResult.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3069 pHitElementResultImpl = _HitElementResultImpl::GetInstance(pHitElementResult.get());
3070 SysTryCatch(NID_WEB_CTRL, pHitElementResultImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3072 if (context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE)
3078 int imageLength = ewk_hit_test_image_buffer_length_get(pEwkHitTest);
3079 void* pImageBuffer = ewk_hit_test_image_buffer_get(pEwkHitTest);
3080 const char* pExtension = ewk_hit_test_image_file_name_extension_get(pEwkHitTest);
3081 SysLog(NID_WEB_CTRL, "The current value of imageBuffer is %u, bufferLength is %d, extension is %s", pImageBuffer, imageLength, pExtension);
3083 r = buf.Construct(imageLength);
3084 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3086 r = buf.SetArray(reinterpret_cast< byte* >(pImageBuffer), 0, imageLength);
3087 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3091 // ToDo : webkit doesn't support types such as IMG_FORMAT_WBMP and IMG_FORMAT_TIFF
3092 // webkit support types such as ico and vp8 additionally
3093 if (strcmp(pExtension, "gif") == 0)
3095 format = IMG_FORMAT_GIF;
3097 else if (strcmp(pExtension, "jpg") == 0)
3099 format = IMG_FORMAT_JPG;
3101 else if (strcmp(pExtension, "png") == 0)
3103 format = IMG_FORMAT_PNG;
3105 else if (strcmp(pExtension, "bmp") == 0)
3107 format = IMG_FORMAT_BMP;
3111 SysLogException(NID_WEB_CTRL, E_UNSUPPORTED_FORMAT, "[%s] The %s format is not supported", GetErrorMessage(E_UNSUPPORTED_FORMAT), pExtension);
3115 r = image.Construct();
3116 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3118 pImage = std::unique_ptr<Bitmap>(image.DecodeN(buf, format, BITMAP_PIXEL_FORMAT_RGB565));
3119 SysTryCatch(NID_WEB_CTRL, pImage.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3124 pAttributeMap = std::unique_ptr<HashMap, AllElementsDeleter>(new (std::nothrow) HashMap());
3125 SysTryCatch(NID_WEB_CTRL, pAttributeMap.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3127 r = pAttributeMap->Construct(eina_hash_population(pAttrHash));
3128 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3130 eina_hash_foreach(pAttrHash, AddHttpAttributeData, pAttributeMap.get());
3131 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3134 pHitElementResultImpl->SetHitElementResult(pAttributeMap.release(), pImage.release(), tagName, nodeValue, url);
3136 ewk_hit_test_free(pEwkHitTest);
3138 return pHitElementResult.release();
3141 ewk_hit_test_free(pEwkHitTest);
3148 _WebImpl::IsLoading(void) const
3150 double percent = ewk_view_load_progress_get(__pWebCore->GetWebNativeNode());
3152 if (Double::Compare(percent, 0.0) > 0 && Double::Compare(percent, 1.0) < 0)
3164 _WebImpl::GetTextFromBlock(void) const
3166 return ewk_view_text_selection_text_get(__pWebCore->GetWebNativeNode());
3171 _WebImpl::IsPrivateBrowsingEnabled(void) const
3173 if (__pWebCore->GetWebNativeNode() == null)
3175 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsPrivateBrowsingEnabled();
3178 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3179 SysAssertf(pSettings, "Failed to get webkit instance.");
3181 return static_cast< bool >(ewk_settings_private_browsing_enabled_get(pSettings));
3186 _WebImpl::SetPrivateBrowsingEnabled(bool enable)
3188 if (__pWebCore->GetWebNativeNode() == null)
3190 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetPrivateBrowsingEnabled(enable);
3194 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3195 SysAssertf(pSettings, "Failed to get webkit instance.");
3197 ewk_settings_private_browsing_enabled_set(pSettings, static_cast< Eina_Bool >(enable));
3202 _WebImpl::ClearHistory(void)
3204 ewk_view_back_forward_list_clear(__pWebCore->GetWebNativeNode());
3209 _WebImpl::ClearCache(void)
3211 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3213 ewk_context_cache_clear(pContext);
3218 _WebImpl::ClearCookie(void)
3220 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3221 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3223 ewk_cookie_manager_cookies_clear(pCookieManager);
3228 _WebImpl::ClearFormData(void)
3230 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3232 ewk_context_form_candidate_data_clear(pContext);
3237 _WebImpl::ClearLoginFormData(void)
3239 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3241 ewk_context_form_password_data_clear(pContext);
3246 _WebImpl::IsCookieEnabled(void) const
3248 if (__pWebCore->GetWebNativeNode() == null)
3250 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsCookieEnabled();
3253 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3254 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3255 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3257 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
3258 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3260 ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, pPresenter.get());
3262 bool result = false;
3263 pPresenter->WaitAsyncProcess(result);
3270 _WebImpl::SetCookieEnabled(bool enable)
3272 if (__pWebCore->GetWebNativeNode() == null)
3274 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetCookiEnabled(enable);
3279 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3280 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3281 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3285 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
3289 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER);
3290 ewk_cookie_manager_cookies_clear(pCookieManager);
3296 _WebImpl::SavePageAsPdf(const String& filePath, const Dimension* pSize) const
3298 result r = E_SUCCESS;
3300 std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
3301 SysTryReturn(NID_WEB_CTRL, pFilePath.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3304 String fileExtension = File::GetFileExtension(filePath);
3305 int pathLength = filePath.GetLength();
3308 SysTryReturnResult(NID_WEB_CTRL, fileExtension.Equals("pdf", false), E_INVALID_ARG, "Invalid argument(s) is used. File extension is not pdf.");
3310 r = filePath.LastIndexOf(L"/", pathLength - 1, index);
3311 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3312 r = filePath.SubString(0, index + 1, dirPath);
3313 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3315 std::unique_ptr<char[]> pDirPath(_StringConverter::CopyToCharArrayN(dirPath));
3316 SysTryReturnResult(NID_WEB_CTRL, access(pDirPath.get(), W_OK) == 0, E_INACCESSIBLE_PATH, "Directory permission is read-only.");
3320 SysTryReturnResult(NID_WEB_CTRL, pSize->width > 0 && pSize->height > 0, E_INVALID_ARG, "Invalid argument(s) is used. Size of pdf file is invalid.");
3322 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), pSize->width, pSize->height, pFilePath.get());
3326 Evas_Coord contentsWidth;
3327 Evas_Coord contentsHeight;
3329 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &contentsWidth, &contentsHeight);
3330 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), contentsWidth, contentsHeight, pFilePath.get());
3338 _WebImpl::IsMimeSupported(const String& mime) const
3340 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
3341 SysTryReturn(NID_WEB_CTRL, pMime.get(), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3343 return static_cast< bool >(ewk_frame_can_show_mime_type(ewk_view_main_frame_get(__pWebCore->GetWebNativeNode()), pMime.get()));
3348 _WebImpl::SetLoadingListener(ILoadingListener* pLoadingListener)
3350 __pUserLoadingListener = const_cast< ILoadingListener* >(pLoadingListener);
3355 _WebImpl::SetWebUiEventListener(IWebUiEventListener* pUiEventListener)
3357 __pUserUiListener = pUiEventListener;
3362 _WebImpl::SetWebUiEventListenerF(IWebUiEventListenerF* pUiEventListener)
3364 __pUserUiListenerF = pUiEventListener;
3369 _WebImpl::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener)
3371 __pUserKeypadEventListener = pKeypadEventListener;
3376 _WebImpl::SetDownloadListener(IWebDownloadListener* pDownLoadListener)
3378 if (__pWebDownloadHandler.get() == null)
3380 __pWebDownloadHandler = std::unique_ptr<_WebDataHandler>(new (std::nothrow) _WebDataHandler());
3381 SysTryReturnVoidResult(NID_WEB_CTRL, __pWebDownloadHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3384 __pWebDownloadHandler->SetDownloadListener(pDownLoadListener);
3385 __pWebDownloadHandler->SetWebEvent(__pWebEvent.get());
3390 _WebImpl::SetTextSearchListener(ITextSearchListener* pTextSearchListener)
3392 __pTextSearchListener = pTextSearchListener;
3397 _WebImpl::SetScrollEnabled(bool enable)
3399 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetScrollEnabled(enable);
3404 _WebImpl::IsScrollEnabled(void) const
3406 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled();
3411 _WebImpl::InitJsBridgeList(void)
3413 result r = E_SUCCESS;
3415 __pJsProvider = std::unique_ptr<_JsBridgeHashCodeProvider>(new (std::nothrow) _JsBridgeHashCodeProvider());
3416 SysTryReturnResult(NID_WEB_CTRL, __pJsProvider.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3418 __pJsComparer = std::unique_ptr<_JsBridgeComparer>(new (std::nothrow) _JsBridgeComparer());
3419 SysTryReturnResult(NID_WEB_CTRL, __pJsComparer.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3421 std::unique_ptr<HashMapT< String, IJavaScriptBridge* > > pJsBridgeList(new (std::nothrow) HashMapT< String, IJavaScriptBridge* >);
3422 SysTryReturnResult(NID_WEB_CTRL, pJsBridgeList.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3424 r = pJsBridgeList->Construct(0, 0, *__pJsProvider.get(), *__pJsComparer.get());
3425 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3427 __pJsBridgeList = std::move(pJsBridgeList);
3434 _WebImpl::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3436 result r = E_SUCCESS;
3438 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3439 String key(pJsBridge->GetName());
3441 r = __pJsBridgeList->Add(key, pJsBridge);
3442 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3449 _WebImpl::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3451 result r = E_SUCCESS;
3453 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3454 String key(pJsBridge->GetName());
3456 r = __pJsBridgeList->Remove(key);
3457 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3464 _WebImpl::FindJsInterface(const IJsonValue* pValue) const
3466 result r = E_SUCCESS;
3468 IJsonValue* pJsonValue = null;
3469 IJavaScriptBridge* pJsBridge = null;
3471 String key(L"name");
3473 const JsonObject* pJsonObject = dynamic_cast< const JsonObject* >(pValue);
3474 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));
3476 r = pJsonObject->GetValue(&key, pJsonValue);
3477 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS && pJsonValue, null, r, "[%s] Propagating.", GetErrorMessage(r));
3479 JsonString* pBridgeName = dynamic_cast< JsonString* >(pJsonValue);
3480 SysTryReturn(NID_WEB_CTRL, pBridgeName, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. name key is missing." , GetErrorMessage(E_INVALID_ARG));
3482 r = __pJsBridgeList->GetValue(static_cast< String >(*pBridgeName), pJsBridge);
3483 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3490 _WebImpl::GetLoadingListener(void) const
3492 return __pUserLoadingListener;
3496 IWebUiEventListener*
3497 _WebImpl::GetUiEventListener(void) const
3499 return __pUserUiListener;
3503 IWebUiEventListenerF*
3504 _WebImpl::GetUiEventListenerF(void) const
3506 return __pUserUiListenerF;
3510 IWebKeypadEventListener*
3511 _WebImpl::GetWebKeypadEventListener(void) const
3513 return __pUserKeypadEventListener;
3517 ITextSearchListener*
3518 _WebImpl::GetTextSearchListener(void) const
3520 return __pTextSearchListener;
3525 _WebImpl::SetEventListenerCallback(void) const
3527 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3530 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3531 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3533 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3534 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3536 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3537 SysAssertf(pSmartData, "Failed to request");
3539 Ewk_View_Smart_Class *pSmart = const_cast<Ewk_View_Smart_Class*>(pSmartData->api);
3540 SysAssertf(pSmart, "Failed to request");
3542 pSmart->popup_menu_show = OnSelectBoxRequested;
3543 pSmart->multiple_popup_menu_show = OnMultiSelectBoxRequested;
3544 pSmart->popup_menu_hide = OnSelectBoxClosed;
3545 pSmart->popup_menu_update = OnSelectBoxUpdateRequested;
3547 pSmart->input_picker_show = OnDatePickerProviderRequested;
3548 pSmart->input_picker_color_request = OnColorPickerProviderRequested;
3549 pSmart->input_picker_color_dismiss = OnColorPickerProviderDismissed;
3551 pSmart->formdata_candidate_show = OnFormDataCandidateShow;
3552 pSmart->formdata_candidate_hide = OnFormDataCandidateHide;
3553 pSmart->formdata_candidate_update_data = OnFormDataCandidateUpdate;
3554 pSmart->formdata_candidate_is_showing = OnFormDataCandidateIsShowing;
3556 evas_object_data_set(pWebNativeNode, WEB_CTRL, this);
3558 // add loading event callbacks for ILoadingListener
3559 evas_object_smart_callback_add(pWebNativeNode, "create,window", OnWebWindowCreateRequested, this);
3560 evas_object_smart_callback_add(pWebNativeNode, "close,window", OnWebWindowClosedRequested, this);
3562 evas_object_smart_callback_add(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested, this);
3563 evas_object_smart_callback_add(pWebNativeNode, "load,started", OnLoadingStarted, this);
3564 evas_object_smart_callback_add(pWebNativeNode, "load,finished", OnLoadingCompleted, this);
3565 evas_object_smart_callback_add(pWebNativeNode, "load,progress", OnEstimatedProgress, this);
3566 evas_object_smart_callback_add(pWebNativeNode, "load,progress,finished", OnProgressCompleted, this);
3567 evas_object_smart_callback_add(pWebNativeNode, "load,stop", OnLoadingCanceled, this);
3568 evas_object_smart_callback_add(pWebNativeNode, "load,error", OnLoadingErrorOccurred, this);
3569 evas_object_smart_callback_add(pWebNativeNode, "title,changed", OnPageTitleReceived, this);
3570 evas_object_smart_callback_add(pWebNativeNode, "load,committed", OnLoadingCommitted, this);
3572 evas_object_smart_callback_add(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest, this);
3574 evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3575 evas_object_smart_callback_add(pWinObject, "focus,out", OnWindowObjectFocusLost, this);
3577 evas_object_smart_callback_add(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged, this);
3578 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened, this);
3579 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed, this);
3581 evas_object_smart_callback_add(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested, this);
3582 evas_object_smart_callback_add(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled, this);
3584 evas_object_smart_callback_add(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested, this);
3586 ewk_view_javascript_alert_callback_set(pWebNativeNode, OnScriptAlertRequested, const_cast< _WebImpl* >(this));
3587 ewk_view_javascript_prompt_callback_set(pWebNativeNode, OnScriptPromptRequested, const_cast< _WebImpl* >(this));
3588 ewk_view_javascript_confirm_callback_set(pWebNativeNode, OnScriptConfirmRequested, const_cast< _WebImpl* >(this));
3590 evas_object_smart_callback_add(pWebNativeNode, "policy,response,decide", OnWebDataReceived, this);
3592 evas_object_smart_callback_add(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested, this);
3593 evas_object_smart_callback_add(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested, this);
3594 evas_object_smart_callback_add(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted, this);
3596 evas_object_smart_callback_add(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested, this);
3597 evas_object_smart_callback_add(pWebNativeNode, "notification,show", OnNotificationShow, this);
3598 evas_object_smart_callback_add(pWebNativeNode, "notification,cancel", OnNotificationCancel, this);
3600 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested, this);
3601 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered, this);
3602 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested, this);
3604 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested, this);
3605 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered, this);
3606 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested, this);
3607 evas_object_smart_callback_add(pWebNativeNode, "text,found", OnTextFound, this);
3609 evas_object_smart_callback_add(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered, this);
3610 evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this);
3612 evas_object_smart_callback_add(pWebNativeNode, "magnifier,hide", OnWebPageBlockSelected, this);
3614 evas_object_smart_callback_add(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered, this);
3615 evas_object_smart_callback_add(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited, this);
3617 evas_object_smart_callback_add(pWebNativeNode, "keyevent,down,not,handled", OnFocusDownRequested, this);
3618 evas_object_smart_callback_add(pWebNativeNode, "keyevent,up,not,handled", OnFocusUpRequested, this);
3620 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3621 SysAssertf(pContext, "Failed to get webkit instance.");
3622 ewk_context_did_start_download_callback_set(pContext, OnDidStartDownloadCallback, const_cast< _WebImpl* >(this));
3623 ewk_context_vibration_client_callbacks_set(pContext, OnVibrationRequested, OnVibrationCanceled, const_cast< _WebImpl* >(this));
3625 ewk_view_application_cache_permission_callback_set(pWebNativeNode, OnApplicationCachePermissionRequested, const_cast< _WebImpl* >(this));
3626 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, OnIndexedDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3627 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, OnDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3628 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, OnLocalFileSystemQuotaExceeded, const_cast< _WebImpl* >(this));
3630 evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this);
3631 evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_OUT, OnWebNativeNodeFocusLost, this);
3637 _WebImpl::RemoveEventListenerCallback(void) const
3639 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3642 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3643 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3645 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3646 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3648 evas_object_smart_callback_del(pWebNativeNode, "create,window", OnWebWindowCreateRequested);
3649 evas_object_smart_callback_del(pWebNativeNode, "close,window", OnWebWindowClosedRequested);
3651 evas_object_smart_callback_del(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested);
3652 evas_object_smart_callback_del(pWebNativeNode, "load,started", OnLoadingStarted);
3653 evas_object_smart_callback_del(pWebNativeNode, "load,finished", OnLoadingCompleted);
3654 evas_object_smart_callback_del(pWebNativeNode, "load,progress", OnEstimatedProgress);
3655 evas_object_smart_callback_del(pWebNativeNode, "load,progress,finished", OnProgressCompleted);
3656 evas_object_smart_callback_del(pWebNativeNode, "load,stop", OnLoadingCanceled);
3657 evas_object_smart_callback_del(pWebNativeNode, "load,error", OnLoadingErrorOccurred);
3658 evas_object_smart_callback_del(pWebNativeNode, "title,changed", OnPageTitleReceived);
3659 evas_object_smart_callback_del(pWebNativeNode, "load,committed", OnLoadingCommitted);
3661 evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest);
3663 evas_object_smart_callback_del_full(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3664 evas_object_smart_callback_del_full(pWinObject, "focus,out", OnWindowObjectFocusLost, this);
3666 evas_object_smart_callback_del(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged);
3667 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened);
3668 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed);
3670 evas_object_smart_callback_del(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested);
3671 evas_object_smart_callback_del(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled);
3673 evas_object_smart_callback_del(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested);
3675 ewk_view_javascript_alert_callback_set(pWebNativeNode, null, null);
3676 ewk_view_javascript_prompt_callback_set(pWebNativeNode, null, null);
3677 ewk_view_javascript_confirm_callback_set(pWebNativeNode, null, null);
3679 evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived);
3681 evas_object_smart_callback_del(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested);
3682 evas_object_smart_callback_del(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested);
3683 evas_object_smart_callback_del(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted);
3685 evas_object_smart_callback_del(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested);
3686 evas_object_smart_callback_del(pWebNativeNode, "notification,show", OnNotificationShow);
3687 evas_object_smart_callback_del(pWebNativeNode, "notification,cancel", OnNotificationCancel);
3688 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested);
3689 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered);
3690 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested);
3692 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested);
3693 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered);
3694 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested);
3696 evas_object_smart_callback_del(pWebNativeNode, "text,found", OnTextFound);
3698 evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered);
3699 evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived);
3701 evas_object_smart_callback_del(pWebNativeNode, "magnifier,hide", OnWebPageBlockSelected);
3703 evas_object_smart_callback_del(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered);
3704 evas_object_smart_callback_del(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited);
3706 evas_object_smart_callback_del(pWebNativeNode, "keyevent,down,not,handled", OnFocusDownRequested);
3707 evas_object_smart_callback_del(pWebNativeNode, "keyevent,up,not,handled", OnFocusUpRequested);
3709 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3710 SysAssertf(pContext, "Failed to get webkit instance.");
3711 ewk_context_vibration_client_callbacks_set(pContext, null, null, null);
3713 ewk_view_application_cache_permission_callback_set(pWebNativeNode, null, null);
3714 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, null, null);
3715 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, null, null);
3716 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, null, null);
3718 evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained);
3719 evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_OUT, OnWebNativeNodeFocusLost);
3725 _WebImpl::ClearCertificateDb(void)
3727 result r = E_SUCCESS;
3729 String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
3730 String table(CERTIFICATE_TABLE_NAME);
3733 r = db.Construct(certificatePath, "r+", null);
3734 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3736 db.BeginTransaction();
3738 r = db.ExecuteSql(L"Delete From " + table, true);
3739 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3741 db.CommitTransaction();
3746 db.RollbackTransaction();
3751 _WebImpl::SetBlockSelectionPosition(const Point& startPoint)
3753 return SetBlockSelectionPosition(_CoordinateSystemUtils::ConvertToFloat(startPoint));
3758 _WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint)
3760 Evas_Object* pWebview = __pWebCore->GetWebNativeNode();
3768 Ewk_View_Smart_Data* pSmartData = reinterpret_cast< Ewk_View_Smart_Data* >(evas_object_smart_data_get(pWebview));
3769 SysAssertf(pSmartData && pSmartData->api, "Failed to get webkit instance.");
3770 Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(startPoint)));
3772 Eina_Bool ret = pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y);
3775 pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y);
3777 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pWebview, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3778 SysTryReturnResult(NID_WEB_CTRL, pEwkHitTest, E_SYSTEM, "Failed to get hit test.");
3780 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3782 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
3783 char* pValue = reinterpret_cast< char* >(eina_hash_find(pAttrHash, "contenteditable"));
3784 if (tagName.Equals(L"INPUT", false) || tagName.Equals(L"TEXTAREA", false) || pValue)
3786 ewk_view_command_execute(pWebview, "SelectWord", 0);
3787 evas_object_smart_callback_call(pWebview, "magnifier,hide", NULL);
3791 SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up.");
3798 _WebImpl::ReleaseBlock(void)
3800 ewk_view_text_selection_range_clear(__pWebCore->GetWebNativeNode());
3805 _WebImpl::GetBlockRange(Point& startPoint, Point& endPoint) const
3807 FloatPoint tempStartPoint;
3808 FloatPoint tempEndPoint;
3810 GetBlockRange(tempStartPoint, tempEndPoint);
3812 startPoint = _CoordinateSystemUtils::ConvertToInteger(tempStartPoint);
3813 endPoint = _CoordinateSystemUtils::ConvertToInteger(tempEndPoint);
3818 _WebImpl::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const
3820 Eina_Rectangle leftHandle;
3821 Eina_Rectangle rightHandle;
3823 EINA_RECTANGLE_SET(&leftHandle, 0, 0, 0, 0);
3824 EINA_RECTANGLE_SET(&rightHandle, 0, 0, 0, 0);
3826 ewk_view_text_selection_range_get(__pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle);
3828 startPoint.x = _CoordinateSystemUtils::ConvertToFloat(leftHandle.x);
3829 startPoint.y = _CoordinateSystemUtils::ConvertToFloat(leftHandle.y);
3830 endPoint.x = _CoordinateSystemUtils::ConvertToFloat(rightHandle.x + rightHandle.w);
3831 endPoint.y = _CoordinateSystemUtils::ConvertToFloat(rightHandle.y + rightHandle.h);
3833 if ((endPoint.x != 0.0f) && (endPoint.y != 0.0f))
3835 startPoint = __pWebCore->GetRelativeCoordinate(startPoint);
3836 endPoint = __pWebCore->GetRelativeCoordinate(endPoint);
3842 _WebImpl::GetFaviconN(void) const
3844 result r = E_SUCCESS;
3846 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3847 Ewk_Context* pContext = ewk_view_context_get(pView);
3848 const char* pUrl = ewk_view_url_get(pView);
3849 Evas* pEvas = evas_object_evas_get(pView);
3851 Evas_Object* pFavicon = ewk_context_icon_database_icon_object_add(pContext, pUrl, pEvas);
3857 Tizen::Graphics::BufferInfo bufferInfo;
3859 r = _Utility::GetPixelBufferFromEvasObject(pFavicon, bufferInfo);
3860 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3862 const Dimension dimension(bufferInfo.width, bufferInfo.height);
3863 Tizen::Base::ByteBuffer byteBuffer;
3865 r = byteBuffer.Construct((byte*)bufferInfo.pPixels, 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 );
3866 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3868 std::unique_ptr<Bitmap> pImage(new (std::nothrow) Bitmap());
3869 SysTryReturn(NID_WEB_CTRL, pImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3871 r = pImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888);
3872 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3874 return pImage.release();
3880 _WebImpl::ScrollBy(const Tizen::Graphics::Point& diff)
3882 ewk_view_scroll_by(__pWebCore->GetWebNativeNode(), diff.x, diff.y);
3887 _WebImpl::ScrollTo(const Tizen::Graphics::Point& dest)
3889 ewk_view_scroll_set(__pWebCore->GetWebNativeNode(), dest.x, dest.y);
3894 _WebImpl::GetScrollPosition(void) const
3898 ewk_view_scroll_pos_get(__pWebCore->GetWebNativeNode(), &position.x, &position.y);
3905 _WebImpl::GetPageSize(void) const
3907 Evas_Coord width = 0;
3908 Evas_Coord height = 0;
3910 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &width, &height);
3912 Dimension size(static_cast< int >(width), static_cast< int >(height));
3919 _WebImpl::AddHttpHeaderField(const String& name, const String& value)
3921 SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing.");
3923 std::unique_ptr<char[]> pName(_StringConverter::CopyToCharArrayN(name));
3924 SysTryReturn(NID_WEB_CTRL, pName.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3926 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(value));
3928 ewk_view_custom_header_add(__pWebCore->GetWebNativeNode(), pName.get(), pValue.get());
3935 _WebImpl::RemoveHttpHeaderField(const String& name)
3937 SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing.");
3939 std::unique_ptr<char[]> pName(_StringConverter::CopyToCharArrayN(name));
3940 SysTryReturn(NID_WEB_CTRL, pName.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3942 ewk_view_custom_header_remove(__pWebCore->GetWebNativeNode(), pName.get());
3949 _WebImpl::SetLoadingErrorOccurred(bool arg)
3951 __isLoadingErrorOccurred = arg;
3956 _WebImpl::IsLoadingErrorOccurred(void) const
3958 return __isLoadingErrorOccurred;
3963 _WebImpl::SetRedirectRequested(bool arg)
3965 __isRedirectRequested = arg;
3970 _WebImpl::IsRedirectRequested(void) const
3972 return __isRedirectRequested;
3977 _WebImpl::SetPolicyDecision(DecisionPolicy policy)
3984 _WebImpl::GetPolicyDecision(void) const
3991 _WebImpl::SetCertificateRequested(bool arg)
3993 __isCertificateRequested = arg;
3998 _WebImpl::IsCertificateRequested(void) const
4000 return __isCertificateRequested;
4005 _WebImpl::SetCertificateConfirmed(bool arg)
4007 __isCertificateConfirmed = arg;
4012 _WebImpl::IsCertificateConfirmed(void) const
4014 return __isCertificateConfirmed;
4019 _WebImpl::SetFullScreenKeypad(void)
4021 result r = E_SUCCESS;
4023 std::unique_ptr<Keypad> pKeypad(new (std::nothrow) Keypad());
4024 SysTryReturnResult(NID_WEB_CTRL, pKeypad.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4026 r = pKeypad->Construct(KEYPAD_STYLE_NORMAL, 100);
4027 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4029 String text(ewk_view_focused_input_element_value_get(__pWebCore->GetWebNativeNode()));
4030 pKeypad->SetText(text);
4032 r = pKeypad->SetShowState(true);
4033 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4035 r = pKeypad->Show();
4036 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4038 pKeypad->AddTextEventListener(*this);
4040 __pKeypad = std::move(pKeypad);
4047 _WebImpl::RemoveFullScreenKeypad(void)
4049 __pKeypad->RemoveTextEventListener(*this);
4056 _WebImpl::IsFooterVisible(void) const
4058 return __isFooterVisible;
4063 _WebImpl::SetFooterVisibleState(bool isFooterVisible)
4065 __isFooterVisible = isFooterVisible;
4070 _WebImpl::IsKeypadVisible(void) const
4072 return __isKeypadVisible;
4077 _WebImpl::SetKeypadVisibleState(bool isKeypadVisible)
4079 __isKeypadVisible = isKeypadVisible;
4084 _WebImpl::IsKeypadOpened(void) const
4086 return __isKeypadOpened;
4090 _WebImpl::SetKeypadOpened(bool isKeypadOpened)
4092 __isKeypadOpened = isKeypadOpened;
4097 _WebImpl::IsWinFocusLost(void) const
4099 return __isWinFocusLost;
4104 _WebImpl::SetWinFocusLost(bool isWinFocusLost)
4106 __isWinFocusLost = isWinFocusLost;
4111 _WebImpl::GetPreviousKeypadBounds(void) const
4113 return __keypadBounds;
4118 _WebImpl::SetPreviousKeypadBounds(Rectangle& bounds)
4120 __keypadBounds = bounds;
4125 _WebImpl::OnTextValueChangeCanceled(const Control& source)
4127 RemoveFullScreenKeypad();
4132 _WebImpl::OnTextValueChanged(const Control& source)
4134 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(__pKeypad->GetText()));
4136 ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get());
4138 RemoveFullScreenKeypad();
4143 _WebImpl::OnHandleJavaScriptRequestByEventArg(const IEventArg& arg)
4145 const _JsBridgeArg* pEventArg = dynamic_cast< const _JsBridgeArg* >(&arg);
4146 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. arg is not _JsBridgeArg object.");
4148 std::unique_ptr<IJsonValue> pJsonValue(JsonParser::ParseN(*(pEventArg->GetJsonData())));
4149 SysTryReturn(NID_WEB_JSON, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4151 IJavaScriptBridge* pJsInterface = FindJsInterface(pJsonValue.get());
4152 SysTryReturnResult(NID_WEB_CTRL, pJsInterface, E_OBJ_NOT_FOUND, "JsInterface instance is not available.");
4154 pJsInterface->HandleJavaScriptRequestN(pJsonValue.release());
4161 _WebImpl::OnHandleLoadingEvent(const IEventArg& arg)
4163 result r = E_SUCCESS;
4165 const _LoadingEventArg* pEventArg = dynamic_cast< const _LoadingEventArg* >(&arg);
4166 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4168 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4170 ILoadingListener* pLoadingListner = GetLoadingListener();
4171 SysTryReturnResult(NID_WEB_CTRL, pLoadingListner, E_SYSTEM, "A system error has been occurred. Loading listener was not set or null.");
4173 switch (pEventArg->GetEventType())
4175 case WEB_EVENT_LOADINGLISTENER_STARTED:
4177 pLoadingListner->OnLoadingStarted();
4181 case WEB_EVENT_LOADINGLISTENER_PROGRESS:
4183 const Integer* pProgressPercentage = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS));
4184 SysTryReturn(NID_WEB_CTRL, pProgressPercentage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4186 pLoadingListner->OnEstimatedProgress(pProgressPercentage->ToInt());
4190 case WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED:
4192 const String* pPageTitle = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::PAGE_TITLE));
4193 SysTryReturn(NID_WEB_CTRL, pPageTitle, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4195 pLoadingListner->OnPageTitleReceived(*pPageTitle);
4199 case WEB_EVENT_LOADINGLISTENER_CANCELED:
4201 pLoadingListner->OnLoadingCanceled();
4205 case WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED:
4207 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_TYPE));
4208 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4210 const String* pErrorMessage = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_MESSAGE));
4211 SysTryReturn(NID_WEB_CTRL, pErrorMessage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4213 LoadingErrorType errorType = ConvertErrorCode(pErrorType->ToInt());
4215 pLoadingListner->OnLoadingErrorOccurred(errorType, *pErrorMessage);
4219 case WEB_EVENT_LOADINGLISTENER_COMPLETED:
4221 pLoadingListner->OnLoadingCompleted();
4225 case WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED:
4227 pLoadingListner->OnHttpAuthenticationCanceled();
4231 case WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED:
4233 std::unique_ptr<Bitmap> pFavicon(GetFaviconN());
4234 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4238 pLoadingListner->OnFaviconReceived(*pFavicon.get());
4254 _WebImpl::OnHandleWebDownloadEvent(const IEventArg& arg)
4256 result r = E_SUCCESS;
4258 const _WebDownloadEventArg* pEventArg = dynamic_cast< const _WebDownloadEventArg* >(&arg);
4259 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4261 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4263 IWebDownloadListener* pWebDownloadListener = __pWebDownloadHandler->GetDownloadListener();
4264 SysTryReturnResult(NID_WEB_CTRL, pWebDownloadListener, E_SYSTEM, "A system error has been occurred. Web Downloading listener was not set or null.");
4266 switch (pEventArg->GetEventType())
4268 case WEB_EVENT_WEBDOWNLOADLISTENER_DATA_RECEIVED:
4270 const ByteBuffer* pChunk = dynamic_cast< const ByteBuffer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::CHUNKED_DATA));
4271 SysTryReturn(NID_WEB_CTRL, pChunk, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4273 pWebDownloadListener->OnWebChunkedDataReceived(*pChunk);
4277 case WEB_EVENT_WEBDOWNLOADLISTENER_COMPLETED:
4279 pWebDownloadListener->OnWebDataDownloadCompleted();
4283 case WEB_EVENT_WEBDOWNLOADLISTENER_FAILED:
4285 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::ERROR_TYPE));
4286 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4288 LoadingErrorType errorType = static_cast < LoadingErrorType >(pErrorType->ToInt());
4290 pWebDownloadListener->OnWebDownloadFailed(errorType);
4305 _WebImpl::OnHandleWebUiEvent(const IEventArg& arg)
4307 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4308 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4310 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4312 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListener, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4314 switch (pEventArg->GetEventType())
4316 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED:
4318 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4320 Point* pStartPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4321 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4323 Point* pEndPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4324 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4326 __pUserUiListener->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4330 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED:
4332 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4334 __pUserUiListener->OnWebPageShowRequested(*pWeb);
4338 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED:
4340 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4342 __pUserUiListener->OnWebWindowCloseRequested(*pWeb);
4346 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED:
4348 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4350 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4351 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4353 __pUserUiListener->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4368 _WebImpl::OnHandleWebUiEventF(const IEventArg& arg)
4370 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4371 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4373 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4375 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListenerF, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4377 switch (pEventArg->GetEventType())
4379 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT:
4381 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4383 FloatPoint* pStartPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4384 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4386 FloatPoint* pEndPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4387 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4389 __pUserUiListenerF->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4393 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT:
4395 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4397 __pUserUiListenerF->OnWebPageShowRequested(*pWeb);
4401 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT:
4403 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4405 __pUserUiListenerF->OnWebWindowCloseRequested(*pWeb);
4409 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT:
4411 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4413 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4414 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4416 __pUserUiListenerF->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4431 _WebImpl::OnHandleTextSearchEvent(const IEventArg& arg)
4433 result r = E_SUCCESS;
4435 const _TextSearchEventArg* pEventArg = dynamic_cast< const _TextSearchEventArg* >(&arg);
4436 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4438 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4440 ITextSearchListener* pTextSearchListner = GetTextSearchListener();
4441 SysTryReturnResult(NID_WEB_CTRL, pTextSearchListner, E_SYSTEM, "A system error has been occurred. Web text search listener was not set or null.");
4443 switch (pEventArg->GetEventType())
4445 case WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND:
4447 Integer* pTotalCount= dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::TOTAL_COUNT)));
4448 SysTryReturn(NID_WEB_CTRL, pTotalCount, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4450 Integer* pCurrentOrdinal = dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL)));
4451 SysTryReturn(NID_WEB_CTRL, pCurrentOrdinal, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4453 pTextSearchListner->OnTextFound(pTotalCount->ToInt(), pCurrentOrdinal->ToInt());
4468 _WebImpl::VibrationRequested(uint64_t duration)
4470 result r = E_SUCCESS;
4472 __pVibrator.reset();
4474 std::unique_ptr<_VibratorImpl> pVibrator(new (std::nothrow) _VibratorImpl);
4475 SysTryReturnResult(NID_WEB_CTRL, pVibrator.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4477 r = pVibrator->Construct();
4478 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4480 __pVibrator = std::move(pVibrator);
4482 IntensityDurationVibrationPattern pattern = {static_cast< int >(duration), -1};
4484 r = __pVibrator->Start(&pattern, 1, 1);
4485 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4492 _WebImpl::VibrationCanceled(void)
4494 __pVibrator.reset();
4499 _WebImpl::HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge)
4501 result r = E_SUCCESS;
4503 String host(ewk_auth_challenge_url_get(pChallenge));
4504 String realm(ewk_auth_challenge_realm_get(pChallenge));
4506 __pAuthChallenge.reset();
4508 std::unique_ptr<AuthenticationChallenge> pAuthChallenge(new (std::nothrow) AuthenticationChallenge());
4509 SysTryReturnResult(NID_WEB_CTRL, pAuthChallenge, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4511 _AuthenticationChallengeImpl* pAuthImpl = _AuthenticationChallengeImpl::GetInstance(pAuthChallenge.get());
4512 SysTryReturn(NID_WEB_CTRL, pAuthImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4514 pAuthImpl->SetAuthenticationChallengeHandler(pChallenge);
4515 pAuthImpl->SetWebEvasObject(__pWebCore->GetWebNativeNode());
4517 __pAuthChallenge = std::move(pAuthChallenge);
4519 ewk_auth_challenge_suspend(pChallenge);
4520 if (__pUserLoadingListener && __pUserLoadingListener->OnHttpAuthenticationRequestedN(host, realm, *__pAuthChallenge.get()))
4522 __pAuthChallenge.release();
4526 r = ShowAuthenticationPopup(host, realm, __pAuthChallenge.get());
4527 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4535 _WebImpl::ShowAuthenticationPopup(const String& host, const String& realm, AuthenticationChallenge* pAuthChallenge)
4537 result r = E_SUCCESS;
4539 std::unique_ptr<_AuthConfirmPopup> pAuthPopup(new (std::nothrow) _AuthConfirmPopup());
4540 SysTryReturnResult(NID_WEB_CTRL, pAuthPopup, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4542 r = pAuthPopup->Construct(host, realm, pAuthChallenge);
4543 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4545 __pAuthPopup = std::move(pAuthPopup);
4547 int modalResult = 0;
4549 r = __pAuthPopup->ShowAndWait(modalResult);
4550 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4555 __pAuthPopup.reset();
4563 _WebImpl::ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk_Certificate_Policy_Decision* pPolicy)
4565 result r = E_SUCCESS;
4567 std::unique_ptr<_CertificateConfirmPopup> pCertConfirmPopup(new (std::nothrow) _CertificateConfirmPopup());
4568 SysTryReturnResult(NID_WEB_CTRL, pCertConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4570 r = pCertConfirmPopup->Construct(userConfirmMode, pPolicy);
4571 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4573 __pCertConfirmPopup = std::move(pCertConfirmPopup);
4575 int modalResult = 0;
4577 r = __pCertConfirmPopup->ShowAndWait(modalResult);
4578 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4580 if (__pCertConfirmPopup.get() && userConfirmMode == CERTIFICATE_POPUP_MODE_USER_CONFIRM)
4582 __isCertificateConfirmed = __pCertConfirmPopup->GetConfirmResult();
4586 if (__pCertConfirmPopup.get())
4588 __pCertConfirmPopup.reset();
4596 _WebImpl::ShowPromptPopup(String msg, String defVal)
4598 result r = E_SUCCESS;
4600 std::unique_ptr< _PromptPopup > pPromptPopup(new (std::nothrow) _PromptPopup());
4601 SysTryReturnResult(NID_WEB_CTRL, pPromptPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4603 r = pPromptPopup->Construct(msg, defVal, __pWebCore->GetWebNativeNode(), this);
4604 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4606 __pPromptPopup = std::move(pPromptPopup);
4608 r = __pPromptPopup->ShowPopup();
4609 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4614 __pPromptPopup.reset();
4622 _WebImpl::ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4624 result r = E_SUCCESS;
4626 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4627 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4629 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, this, true, msg);
4630 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4632 int modalResult = 0;
4634 switch(userConfirmMode)
4636 case USER_CONTENT_HANDLER:
4638 __pContentHandlerConfirmPopup = std::move(pUserConfirmPopup);
4640 r = __pContentHandlerConfirmPopup->ShowAndWait(modalResult);
4641 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pContentHandlerConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4643 __pContentHandlerConfirmPopup.reset();
4645 ewk_view_resume(__pWebCore->GetWebNativeNode());
4649 case USER_PROTOCOL_HANDLER:
4651 __pProtocolHandlerConfirmPopup = std::move(pUserConfirmPopup);
4653 r = __pProtocolHandlerConfirmPopup->ShowAndWait(modalResult);
4654 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pProtocolHandlerConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4656 __pProtocolHandlerConfirmPopup.reset();
4658 ewk_view_resume(__pWebCore->GetWebNativeNode());
4662 case USER_CONFIRM_APP_CACHE:
4664 __pAppCacheConfirmPopup = std::move(pUserConfirmPopup);
4666 r = __pAppCacheConfirmPopup->ShowAndWait(modalResult);
4667 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pAppCacheConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4669 __pAppCacheConfirmPopup.reset();
4671 ewk_view_resume(__pWebCore->GetWebNativeNode());
4675 case USER_CONFIRM_DB_QUOTA_EXCEDED:
4677 __pDbQuotaConfirmPopup = std::move(pUserConfirmPopup);
4679 r = __pDbQuotaConfirmPopup->ShowAndWait(modalResult);
4680 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pDbQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4682 __pDbQuotaConfirmPopup.reset();
4684 ewk_view_resume(__pWebCore->GetWebNativeNode());
4688 case USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED:
4690 __pLocalFsQuotaConfirmPopup = std::move(pUserConfirmPopup);
4692 r = __pLocalFsQuotaConfirmPopup->ShowAndWait(modalResult);
4693 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pLocalFsQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4695 __pLocalFsQuotaConfirmPopup.reset();
4697 ewk_view_resume(__pWebCore->GetWebNativeNode());
4701 case USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED:
4703 __pIndexedDbQuotaConfirmPopup = std::move(pUserConfirmPopup);
4705 r = __pIndexedDbQuotaConfirmPopup->ShowAndWait(modalResult);
4706 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pIndexedDbQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4708 __pIndexedDbQuotaConfirmPopup.reset();
4710 ewk_view_resume(__pWebCore->GetWebNativeNode());
4723 _WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4725 result r = E_SUCCESS;
4727 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4728 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4730 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, this, false, msg);
4731 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4733 switch(userConfirmMode)
4735 case USER_CONFIRM_USERMEDIA:
4737 __pUserMediaConfirmPopup.reset();
4739 __pUserMediaConfirmPopup = std::move(pUserConfirmPopup);
4741 r = __pUserMediaConfirmPopup->ShowPopup();
4742 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pUserMediaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4746 case USER_CONFIRM_GEOLOCATION:
4748 __pGeolocationConfirmPopup.reset();
4750 __pGeolocationConfirmPopup = std::move(pUserConfirmPopup);
4752 r = __pGeolocationConfirmPopup->ShowPopup();
4753 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pGeolocationConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4757 case USER_CONFIRM_NOTIFICATION:
4759 __pNotificationConfirmPopup.reset();
4761 __pNotificationConfirmPopup = std::move(pUserConfirmPopup);
4763 r = __pNotificationConfirmPopup->ShowPopup();
4764 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pNotificationConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4768 case USER_SCRIPT_ALERT:
4770 __pScriptAlertConfirmPopup.reset();
4772 __pScriptAlertConfirmPopup = std::move(pUserConfirmPopup);
4774 r = __pScriptAlertConfirmPopup->ShowPopup();
4775 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pScriptAlertConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4779 case USER_SCRIPT_CONFIRM:
4781 __pScriptConfirmPopup.reset();
4783 __pScriptConfirmPopup = std::move(pUserConfirmPopup);
4785 r = __pScriptConfirmPopup->ShowPopup();
4786 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pScriptConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4802 _WebImpl::GetParentFormImpl(_ControlImpl* pControlImpl)
4805 _FormImpl* pFormImpl = null;
4807 _ControlImpl* pParentControlImpl = dynamic_cast< _ControlImpl* >(pControlImpl->GetParent());
4808 if (!pParentControlImpl)
4813 pFormImpl = dynamic_cast< _FormImpl* >(pParentControlImpl);
4819 return GetParentFormImpl(pParentControlImpl);
4824 _WebImpl::OnFocusGained(const _ControlImpl& source)
4831 _WebImpl::OnFocusLost(const _ControlImpl& source)
4833 Evas_Object* pWebview = __pWebCore->GetWebNativeNode();
4839 if(IsKeypadVisible() == true)
4841 SetKeypadOpened(true);
4849 _WebImpl::HasValidNativeNode(void) const
4851 if (__pWebCore && __pWebCore->GetWebNativeNode())
4861 _WebImpl::OnPreAttachedToMainTree(void)
4863 result r = E_SUCCESS;
4865 if (IsVisible() == true)
4867 _WebManager* pWebManager = _WebManager::GetInstance();
4868 pWebManager->SetActiveWeb(this);
4871 r = _ContainerImpl::OnPreAttachedToMainTree();
4872 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4874 if (!HasValidNativeNode())
4876 r = __pWebCore->InitializeWebNativeNode();
4877 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4879 _ControlManager* pControlManager = _ControlManager::GetInstance();
4880 SysTryReturnResult(NID_WEB_CTRL, pControlManager, E_SYSTEM, "Failed to get the ControlManager instance.");
4881 OnChangeLayout(pControlManager->GetScreenRotation());
4883 r = InitializeSetting();
4884 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4886 _WebManager* pWebManager = _WebManager::GetInstance();
4887 pWebManager->AddWeb(reinterpret_cast< int >(this));
4895 _WebImpl::OnDetachingFromMainTree(void)
4897 result r = E_SUCCESS;
4899 _WebManager* pWebManager = _WebManager::GetInstance();
4900 pWebManager->RemoveActiveWeb(this);
4902 r = _ContainerImpl::OnDetachingFromMainTree();
4903 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4910 _WebImpl::OnChangeLayout(_ControlRotation rotation)
4916 case _CONTROL_ROTATION_0:
4919 case _CONTROL_ROTATION_90:
4922 case _CONTROL_ROTATION_180:
4925 case _CONTROL_ROTATION_270:
4931 ewk_view_orientation_send(__pWebCore->GetWebNativeNode(), degree);
4936 _WebImpl::OnChangeLayout(_ControlOrientation orientation)
4938 _ContainerImpl::OnChangeLayout(orientation);
4940 if (__pColorPicker.get())
4942 __pColorPicker->ChangeLayout(orientation);
4945 HideFormDataWindow();
4947 std::unique_ptr< IEnumerator > pEnum(__webNotificationList.GetEnumeratorN());
4948 _WebNotification* pWebNotification = null;
4950 while (pEnum->MoveNext() == E_SUCCESS)
4952 pWebNotification = static_cast< _WebNotification* >(pEnum->GetCurrent());
4953 pWebNotification->OnChangeLayout();
4959 _WebImpl::OnAncestorVisibleStateChanged(const _Control& control)
4961 _WebManager* pWebManager = _WebManager::GetInstance();
4962 if (IsVisible() == true)
4964 pWebManager->SetActiveWeb(this);
4965 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_VISIBLE, false);
4969 pWebManager->RemoveActiveWeb(this);
4970 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_HIDDEN, false);
4976 _WebImpl::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
4978 _ContainerImpl::OnUserEventReceivedN(requestId, pArgs);
4982 case ID_CERTIFICATE_CONFIRM_POPUP_CLOSE:
4983 __pCertConfirmPopup.reset();
4985 case ID_PROMPT_POPUP_CLOSE:
4986 __pPromptPopup.reset();
4988 case ID_USER_CONFIRM_USERMEDIA_CLOSE:
4989 __pUserMediaConfirmPopup.reset();
4991 case ID_USER_CONFIRM_GEOLOCATION_CLOSE:
4992 __pGeolocationConfirmPopup.reset();
4994 case ID_USER_CONFIRM_NOTIFICATION_CLOSE:
4995 __pNotificationConfirmPopup.reset();
4997 case ID_USER_SCRIPT_ALERT_CLOSE:
4998 __pScriptAlertConfirmPopup.reset();
5000 case ID_USER_SCRIPT_CONFIRM_CLOSE:
5001 __pScriptConfirmPopup.reset();
5012 _WebImpl::GetDownloadHandler(void) const
5014 return __pWebDownloadHandler.get();
5019 _WebImpl::HideColorPicker(void)
5021 __pColorPicker.reset();
5030 _WebImpl::ShowColorPicker(int red, int green, int blue, int alpha, Color& color)
5032 result r = E_SUCCESS;
5034 std::unique_ptr<_InputPickerPopup> pColorHadler(new (std::nothrow) _InputPickerPopup());
5035 SysTryReturnResult(NID_WEB_CTRL, pColorHadler.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
5037 Tizen::Graphics::Color colorVal(static_cast< byte >(red), static_cast< byte >(green), static_cast< byte >(blue), static_cast< byte >(alpha));
5039 r = pColorHadler->Construct(colorVal, this);
5040 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5042 __pColorPicker = std::move(pColorHadler);
5044 r = __pColorPicker->ShowPopup();
5045 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5049 color = __pColorPicker->GetColor();
5055 __pColorPicker.reset();
5064 _WebImpl::ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue, String& dateStr)
5066 result r = E_SUCCESS;
5068 std::unique_ptr<_InputPickerPopup> pInputPicker(new (std::nothrow) _InputPickerPopup());
5069 SysTryReturnResult(NID_WEB_CTRL, pInputPicker.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
5071 r = pInputPicker->Construct(String(inputValue), inputType, this);
5072 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5074 __pDatePicker = std::move(pInputPicker);
5076 r = __pDatePicker->ShowPopup();
5077 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5081 dateStr = __pDatePicker->GetDate();
5087 __pDatePicker.reset();
5096 _WebImpl::GetInstance(Web* pWeb)
5098 return dynamic_cast< _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
5103 _WebImpl::GetInstance(const Web* pWeb)
5105 return dynamic_cast< const _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
5110 _WebImpl::SearchHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
5112 int checkReturn = 0;
5114 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5117 if( checkmime == true)
5119 table = CUSTOM_CONTENT_TABLE_NAME;
5123 table = CUSTOM_PROTOCOL_TABLE_NAME;
5126 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
5127 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
5128 String target(ewk_custom_handlers_data_target_get(pHandlerData));
5130 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
5132 result r = db.Construct(handlerPath, "r+", null);
5133 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5135 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"'"));
5136 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5140 r = pEnum->MoveNext();
5141 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5142 r = pEnum->GetIntAt(0, checkReturn);
5143 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5155 _WebImpl::UnregistrationHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
5159 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5162 if( checkmime == true)
5164 table = CUSTOM_CONTENT_TABLE_NAME;
5168 table = CUSTOM_PROTOCOL_TABLE_NAME;
5171 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
5172 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
5173 String target(ewk_custom_handlers_data_target_get(pHandlerData));
5175 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
5177 result r = db.Construct(handlerPath, "r+", null);
5178 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5180 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"'"));
5181 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5185 r = pEnum->MoveNext();
5186 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5187 r = pEnum->GetIntAt(0, checkId);
5188 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5190 std::unique_ptr<DbStatement> pDeleteStmt(db.CreateStatementN(L"Delete From " + table + L" Where id = (?)"));
5191 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5193 r = pDeleteStmt->BindInt(0, checkId);
5194 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5196 db.BeginTransaction();
5198 std::unique_ptr<DbEnumerator> pEnum(db.ExecuteStatementN(*pDeleteStmt));
5200 db.CommitTransaction();
5207 const Tizen::Base::String
5208 _WebImpl::GetProtocolFromUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri)
5210 if (originUri == L"" || currentUri == L"")
5215 result r = E_SUCCESS;
5218 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5219 String originReplace(originUri);
5220 String table(CUSTOM_PROTOCOL_TABLE_NAME);
5224 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
5225 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5227 r = currentUri.SubString(0, found + 1, baseUri);
5228 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5230 r = db.Construct(handlerPath, "r+", null);
5231 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5233 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select mime, url, allow From " + table + L" Where baseUrl = '" + baseUri + "'"));
5234 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, L"", GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
5238 while (pEnum->MoveNext() == E_SUCCESS)
5243 String originScheme;
5245 r = pEnum->GetStringAt(0, protocol);
5246 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5248 r = pEnum->GetStringAt(1, queryUrl);
5249 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5251 r = pEnum->GetIntAt(2, allow);
5252 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5259 String protocolScheme(protocol + L":");
5261 r = originReplace.SubString(0, protocolScheme.GetLength(), originScheme);
5262 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5264 if ((originReplace.GetLength() >= protocolScheme.GetLength()) && originScheme.Equals(protocolScheme, false))
5266 if (queryUrl.IndexOf(L"%s", 0, foundQuery) == E_SUCCESS)
5268 r = originReplace.Replace(originScheme, "");
5269 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5271 queryUrl.Replace("%s", originReplace, 0);
5272 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5284 const Tizen::Base::String
5285 _WebImpl::GetRedirectUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri, const Tizen::Base::String& mime)
5287 if (originUri == L"" || currentUri == L"" || mime == L"")
5292 result r = E_SUCCESS;
5295 String originUrlStr = originUri;
5296 const String replaceStr = L"%s";
5298 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5299 String table(CUSTOM_CONTENT_TABLE_NAME);
5303 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
5304 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5306 r = currentUri.SubString(0, found + 1, baseUri);
5307 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5309 r = db.Construct(handlerPath, "r+", null);
5310 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5312 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select allow, url From " + table + L" Where baseUrl = '" + baseUri + "' AND mime = '" + mime + L"'"));
5316 r = pEnum->MoveNext();
5317 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5318 r = pEnum->GetIntAt(0, allow);
5319 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5320 r = pEnum->GetStringAt(1, contentUrl);
5321 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5329 if (contentUrl != L"")
5331 r = contentUrl.Replace(replaceStr, originUrlStr, 0);
5332 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5344 _WebImpl::SetFormDataList(Eina_List* pFormDataList)
5346 __pFormDataList = pFormDataList;
5351 _WebImpl::IsFormDataWindowVisible(void) const
5353 return __isFormDataVisible;
5358 _WebImpl::ShowFormDataWindow(const Rectangle& windowRect, Evas_Object* pWebView)
5360 Rectangle rect(_CoordinateSystemUtils::InverseTransform(Rectangle(windowRect.x, windowRect.y + windowRect.height, windowRect.width, windowRect.height)));
5362 if (__isFormDataVisible)
5364 result r = __pFormDataWindow->UpdateList(__pFormDataList, rect);
5365 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5369 __pFormDataWindow.reset();
5371 std::unique_ptr<_FormDataWindow> pFormDataWindow( new (std::nothrow) _FormDataWindow());
5372 SysTryReturnResult(NID_WEB_CTRL, pFormDataWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
5374 result r = pFormDataWindow->Construct(rect, this, pWebView);
5375 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5377 r = pFormDataWindow->UpdateList(__pFormDataList, rect);
5378 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5380 r = pFormDataWindow->LaunchFormDataWindow();
5381 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5383 __pFormDataWindow = std::move(pFormDataWindow);
5384 __isFormDataVisible = true;
5392 _WebImpl::HideFormDataWindow(bool delWindow)
5396 __pFormDataWindow.reset();
5399 __isFormDataVisible = false;
5404 _WebImpl::ClearWebNotification(_WebNotification* pWebNotification)
5406 __webNotificationList.Remove(*pWebNotification);
5411 _WebImpl::SetWebNotification(_WebNotification* pWebNotification)
5413 __webNotificationList.Add(pWebNotification);
5417 }}} // Tizen::Web::Controls