2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FWebCtrl_WebImpl.cpp
20 * @brief The file contains the definition of _WebImpl class.
22 * The file contains the definition of _WebImpl class.
24 #include <Ecore_IMF_Evas.h>
25 #include <Ecore_Evas.h>
26 #include <elm_config.h>
29 #include <ewk_popup_menu_item.h>
30 #include <libsoup/soup-status.h>
32 #include <FAppAppControl.h>
33 #include <FAppIAppControlListener.h>
34 #include <FBaseColAllElementsDeleter.h>
35 #include <FBaseColHashMapT.h>
36 #include <FBaseRtMutex.h>
37 #include <FBaseRtMutexGuard.h>
38 #include <FBaseSysLog.h>
39 #include <FBaseUtilUri.h>
40 #include <FGrpColor.h>
41 #include <FGrpPoint.h>
42 #include <FGrpRectangle.h>
43 #include <FIoDbEnumerator.h>
44 #include <FIoDbStatement.h>
46 #include <FMediaImage.h>
47 #include <FMediaImageTypes.h>
48 #include <FNetHttpHttpHeader.h>
49 #include <FSysVibrator.h>
50 #include <FUiControl.h>
51 #include <FUiCtrlKeypad.h>
52 #include <FWebCtrlHitElementResult.h>
53 #include <FWebCtrlITextSearchListener.h>
54 #include <FWebCtrlIWebDownloadListener.h>
55 #include <FWebCtrlIWebUiEventListener.h>
56 #include <FWebCtrlIWebUiEventListenerF.h>
57 #include <FWebCtrlIWebKeypadEventListener.h>
58 #include <FWebCtrlIJavaScriptBridge.h>
59 #include <FWebCtrlPageNavigationList.h>
60 #include <FWebCtrlAuthenticationChallenge.h>
61 #include <FWebCtrlWeb.h>
62 #include <FWebCtrlWebSetting.h>
63 #include <FWebHistoryItem.h>
64 #include <FWebJsonJsonObject.h>
65 #include <FWebJsonJsonParser.h>
66 #include <FWebJsonJsonString.h>
67 #include <FApp_AppControlImpl.h>
68 #include <FApp_AppControlManager.h>
69 #include <FApp_AppInfo.h>
70 #include <FApp_AppManagerImpl.h>
71 #include <FBase_StringConverter.h>
72 #include <FGrp_CoordinateSystem.h>
73 #include <FGrp_Screen.h>
74 #include <FIo_DatabaseImpl.h>
75 #include <FIo_NormalFile.h>
76 #include <FSys_SettingInfoImpl.h>
77 #include <FSys_SystemResource.h>
78 #include <FSys_VibratorImpl.h>
79 #include <FUi_Control.h>
80 #include <FUi_CoordinateSystemUtils.h>
81 #include <FUi_EcoreEvasMgr.h>
82 #include <FUi_EcoreEvas.h>
83 #include <FUi_ResourceSizeInfo.h>
84 #include <FUi_Window.h>
85 #include <FUiAnim_EflNode.h>
86 #include <FUiAnim_VisualElement.h>
87 #include <FUiCtrl_FooterImpl.h>
88 #include <FUiCtrl_FormImpl.h>
89 #include "FWeb_HistoryItemImpl.h"
90 #include "FWebCtrl_AppControlListener.h"
91 #include "FWebCtrl_AuthConfirmPopup.h"
92 #include "FWebCtrl_AuthenticationChallengeImpl.h"
93 #include "FWebCtrl_EflWebkit.h"
94 #include "FWebCtrl_FormDataWindow.h"
95 #include "FWebCtrl_GeolocationPermissionManagerImpl.h"
96 #include "FWebCtrl_HitElementResultImpl.h"
97 #include "FWebCtrl_InputPickerPopup.h"
98 #include "FWebCtrl_WebNotification.h"
99 #include "FWebCtrl_PageNavigationListImpl.h"
100 #include "FWebCtrl_PromptPopup.h"
101 #include "FWebCtrl_SelectBox.h"
102 #include "FWebCtrl_Utility.h"
103 #include "FWebCtrl_Web.h"
104 #include "FWebCtrl_WebDataHandler.h"
105 #include "FWebCtrl_WebEvent.h"
106 #include "FWebCtrl_WebEventArg.h"
107 #include "FWebCtrl_WebImpl.h"
108 #include "FWebCtrl_WebManager.h"
109 #include "FWebCtrl_WebPresenter.h"
110 #include "FWebCtrl_WebSettingImpl.h"
113 using namespace Tizen::App;
114 using namespace Tizen::Base;
115 using namespace Tizen::Base::Collection;
116 using namespace Tizen::Base::Runtime;
117 using namespace Tizen::Base::Utility;
118 using namespace Tizen::Content;
119 using namespace Tizen::Graphics;
120 using namespace Tizen::Io;
121 using namespace Tizen::Media;
122 using namespace Tizen::Net::Http;
123 using namespace Tizen::System;
124 using namespace Tizen::Ui;
125 using namespace Tizen::Ui::Animations;
126 using namespace Tizen::Ui::Controls;
127 using namespace Tizen::Web::Json;
130 namespace Tizen { namespace Web { namespace Controls
134 static const char WEB_CTRL[] = "webcontrol";
135 static const char PARENT_WEB_CTRL[] = "parentwebcontrol";
138 static const float MIN_ZOOM_LEVEL = 0.3;
139 static const float MAX_ZOOM_LEVEL = 2;
142 static const int REDIRECTION_HEADER_GROUP = 300;
145 static const int MAX_TEXT_MATCH = pow(2, 31) - 1;
148 static const int PORTRAIT_KEYPAD_HEIGHT = 444;
149 static const int LANDSCAPE_KEYPAD_HEIGHT = 316;
150 static const int DEFAULT_LIST_ITEM_COUNT = 4;
154 AddHttpAttributeData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData)
156 result r = E_SUCCESS;
158 std::unique_ptr<String> pAttrKey(new (std::nothrow) String(reinterpret_cast< char* >(const_cast< void* >(pKey))));
159 std::unique_ptr<String> pAttrValue(new (std::nothrow) String(reinterpret_cast< char* >(pValue)));
160 SysTryReturn(NID_WEB_CTRL, pAttrKey.get() && pAttrValue.get(), EINA_FALSE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
162 SysSecureLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", pAttrKey->GetPointer(), pAttrValue->GetPointer());
164 r = reinterpret_cast< HashMap* >(pUserData)->Add(*pAttrKey, *pAttrValue);
165 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
167 pAttrValue.release();
174 FreeCharArray(void* pData)
176 delete[] reinterpret_cast<char*>(pData);
181 ConvertErrorCode(int error)
183 LoadingErrorType errorCode = WEB_ERROR_UNKNOWN;
187 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
189 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE:
191 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE_PROXY:
193 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT:
195 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT_PROXY:
197 case EWK_ERROR_NETWORK_STATUS_IO_ERROR:
199 case EWK_ERROR_NETWORK_STATUS_MALFORMED:
201 case EWK_ERROR_NETWORK_STATUS_TRY_AGAIN:
203 case EWK_ERROR_NETWORK_STATUS_TOO_MANY_REDIRECTS:
205 case EWK_ERROR_NETWORK_STATUS_TLS_FAILED:
207 case EWK_ERROR_NETWORK_STATUS_INTERNAL_SERVER_ERROR:
209 case EWK_ERROR_NETWORK_STATUS_BAD_GATEWAY:
211 case EWK_ERROR_NETWORK_STATUS_SERVICE_UNAVAILABLE:
213 case EWK_ERROR_NETWORK_STATUS_GATEWAY_TIMEOUT:
214 errorCode = WEB_NO_CONNECTION;
217 case EWK_ERROR_NETWORK_STATUS_BAD_REQUEST:
219 case EWK_ERROR_NETWORK_STATUS_REQUEST_URI_TOO_LONG:
220 errorCode = WEB_BAD_URL;
223 case EWK_ERROR_NETWORK_STATUS_FORBIDDEN:
224 errorCode = WEB_FILE_ACCESS_FAILED;
227 case EWK_ERROR_NETWORK_STATUS_REQUEST_TIMEOUT:
228 errorCode = WEB_REQUEST_TIMEOUT;
231 case EWK_ERROR_NETWORK_STATUS_UNSUPPORTED_MEDIA_TYPE:
232 errorCode = WEB_MIME_NOT_SUPPORTED;
235 case EWK_ERROR_NETWORK_STATUS_INSUFFICIENT_STORAGE:
236 errorCode = WEB_OUT_OF_MEMORY;
239 case EWK_ERROR_NETWORK_STATUS_REQUEST_ENTITY_TOO_LARGE:
240 errorCode = WEB_REQUEST_MAX_EXCEEDED;
243 case EWK_ERROR_NETWORK_STATUS_CONTINUE:
245 case EWK_ERROR_NETWORK_STATUS_SWITCHING_PROTOCOLS:
247 case EWK_ERROR_NETWORK_STATUS_PROCESSING:
249 case EWK_ERROR_NETWORK_STATUS_OK:
251 case EWK_ERROR_NETWORK_STATUS_CREATED:
253 case EWK_ERROR_NETWORK_STATUS_ACCEPTED:
255 case EWK_ERROR_NETWORK_STATUS_NON_AUTHORITATIVE:
257 case EWK_ERROR_NETWORK_STATUS_NO_CONTENT:
259 case EWK_ERROR_NETWORK_STATUS_RESET_CONTENT:
261 case EWK_ERROR_NETWORK_STATUS_PARTIAL_CONTENT:
263 case EWK_ERROR_NETWORK_STATUS_MULTI_STATUS:
265 case EWK_ERROR_NETWORK_STATUS_MULTIPLE_CHOICES:
267 case EWK_ERROR_NETWORK_STATUS_MOVED_PERMANENTLY:
269 case EWK_ERROR_NETWORK_STATUS_FOUND:
271 case EWK_ERROR_NETWORK_STATUS_SEE_OTHER:
273 case EWK_ERROR_NETWORK_STATUS_NOT_MODIFIED:
275 case EWK_ERROR_NETWORK_STATUS_USE_PROXY:
277 case EWK_ERROR_NETWORK_STATUS_NOT_APPEARING_IN_THIS_PROTOCOL:
279 case EWK_ERROR_NETWORK_STATUS_TEMPORARY_REDIRECT:
280 errorCode = WEB_HTTP_RESPONSE;
283 case EWK_ERROR_NETWORK_STATUS_SSL_FAILED:
284 errorCode = WEB_INVALID_CERTIFICATE;
288 errorCode = WEB_ERROR_UNKNOWN;
297 FireLoadingErrorOccurredEvent(_WebImpl* pImpl, int code, const char* pDescription)
299 result r = E_SUCCESS;
301 std::unique_ptr<Integer> pErrorCode(new (std::nothrow) Integer(code));
302 std::unique_ptr<String> pErrorDescription(new (std::nothrow) String(pDescription));
303 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED));
304 SysTryReturnResult(NID_WEB_CTRL, pErrorCode.get() && pErrorDescription.get() && pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
306 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_TYPE, *pErrorCode.get());
307 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
308 pErrorCode.release();
310 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_MESSAGE, *pErrorDescription.get());
311 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
312 pErrorDescription.release();
314 r = pImpl->GetWebEvent()->FireAsync(*pEventArg);
315 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
323 OnScriptAlertRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
325 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
327 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
328 String msg(pMessage);
330 result r = pImpl->ShowUserConfirmPopupAsync(USER_SCRIPT_ALERT, pView, msg);
331 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
335 ewk_view_javascript_alert_reply(pView);
341 OnScriptConfirmRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
343 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
345 result r = E_SUCCESS;
346 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
347 String msg(pMessage);
349 r = pImpl->ShowUserConfirmPopupAsync(USER_SCRIPT_CONFIRM, pView, msg);
350 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
354 ewk_view_javascript_confirm_reply(pView, EINA_FALSE);
360 OnScriptPromptRequested(Evas_Object* pView, const char* pMessage, const char* pDefaultValue, void* pUserData)
362 SysLog(NID_WEB_CTRL, "The current value of message is %s, defaulValue is %s", pMessage, pDefaultValue);
364 result r = E_SUCCESS;
365 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
367 String msg(pMessage);
368 String defVal(pDefaultValue);
370 r = pImpl->ShowPromptPopup(msg, defVal);
371 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
376 ewk_view_javascript_prompt_reply(pView, null);
383 OnCertificateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
385 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
386 Ewk_Certificate_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Certificate_Policy_Decision* >(pEventInfo);
387 SysAssertf(pImpl && pPolicy, "Failed to request");
389 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
391 switch (pImpl->GetSetting().GetCertificateErrorHandlingMode())
393 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM:
395 if (pImpl->IsCertificateRequested())
397 ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast< Eina_Bool >(pImpl->IsCertificateConfirmed()));
401 result r = E_SUCCESS;
403 std::unique_ptr<DbEnumerator> pEnum;
405 String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
406 String table(CERTIFICATE_TABLE_NAME);
409 String pem(ewk_certificate_policy_decision_certificate_pem_get(pPolicy));
411 r = db.Construct(certificatePath, "r", null);
412 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
414 pEnum = std::unique_ptr<DbEnumerator>(db.QueryN(L"Select allow From " + table + L" Where pem = '" + pem + L"'"));
417 r = pEnum->MoveNext();
418 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
421 r = pEnum->GetIntAt(0, allow);
422 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
424 SysLog(NID_WEB_CTRL, "The current value of allow is %d", allow);
426 ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast < Eina_Bool >(allow));
427 pImpl->SetCertificateConfirmed(static_cast < bool >(allow));
431 r = pImpl->ShowCertificateConfirmPopup(CERTIFICATE_POPUP_MODE_USER_CONFIRM, pPolicy);
432 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
434 ewk_view_resume(pWebCore->GetWebNativeNode());
439 pImpl->SetCertificateRequested(true);
443 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CANCEL:
444 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE);
446 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE :
447 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_TRUE);
456 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE);
457 pImpl->SetCertificateConfirmed(false);
458 pImpl->SetCertificateRequested(true);
460 ewk_view_resume(pWebCore->GetWebNativeNode());
465 OnHttpAuthenticationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
467 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
468 Ewk_Auth_Challenge* pChallenge = reinterpret_cast< Ewk_Auth_Challenge* >(pEventInfo);
469 SysAssertf(pImpl && pChallenge, "Failed to request");
471 result r = E_SUCCESS;
473 r = pImpl->HttpAuthenticationRequested(pChallenge);
474 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
478 ewk_auth_challenge_credential_cancel(pChallenge);
479 evas_object_smart_callback_call(pView, "authentication,canceled", NULL);
484 OnHttpAuthenticationCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
486 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
487 SysAssertf(pImpl , "Failed to request");
489 if (pImpl->GetLoadingListener())
491 result r = E_SUCCESS;
493 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED));
494 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
496 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
497 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
503 OnApplicationCachePermissionRequested(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, void* pUserData)
505 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
506 SysAssertf(pImpl , "Failed to request");
508 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
510 result r = msg.Format(256, L"Allow %s to use offline application cache?", pHostName);
511 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
513 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_APP_CACHE, pView, msg);
514 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
521 OnIndexedDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData)
523 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
524 SysAssertf(pImpl , "Failed to request");
526 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
528 result r = msg.Format(512, L"%s Used %lld of storage. Allow %s to use upto 2GB of indexed db?", pHostName, currentQuota, pHostName);
529 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
531 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED, pView, msg);
532 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
539 OnDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, const char* database_name, unsigned long long expectedQuota, void* pUserData)
541 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
542 SysAssertf(pImpl , "Failed to request");
544 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
546 result r = msg.Format(512, L"Allow %s to open %s use upto %lld of web database?", pHostName, database_name, expectedQuota);
547 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
549 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_DB_QUOTA_EXCEDED, pView, msg);
550 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
556 Eina_Bool OnLocalFileSystemQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData)
558 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
559 SysAssertf(pImpl , "Failed to request");
561 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
563 result r = msg.Format(512, L"%s Used %lld of storgae. Allow %s to use upto 2GB of file system?", pHostName, currentQuota, pHostName);
564 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
566 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED, pView, msg);
567 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
574 OnGeolocationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
576 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
577 Ewk_Geolocation_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Geolocation_Permission_Request* >(pEventInfo);
578 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
580 if (pImpl->GetSetting().IsGeolocationEnabled())
582 result r = E_SUCCESS;
584 std::unique_ptr<DbEnumerator> pEnum;
586 String geolocationPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
587 String table(GEOLOCATION_TABLE_NAME);
590 const Ewk_Security_Origin* pSecurityOrigin = ewk_geolocation_permission_request_origin_get(pPermissionRequest);
591 String origin = _Utility::CreateOrigin(pSecurityOrigin);
593 r = db.Construct(geolocationPath, "r", null);
594 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
596 pEnum = std::unique_ptr<DbEnumerator>(db.QueryN(L"Select permission From " + table + L" Where origin = '" + origin + L"'"));
599 r = pEnum->MoveNext();
600 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
603 r = pEnum->GetIntAt(0, permission);
604 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
606 SysLog(NID_WEB_CTRL, "The current value of permission is %d", permission);
608 ewk_geolocation_permission_request_set(pPermissionRequest, static_cast < Eina_Bool >(permission));
612 ewk_geolocation_permission_request_suspend(pPermissionRequest);
614 r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_GEOLOCATION, pPermissionRequest);
615 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
622 ewk_geolocation_permission_request_set(pPermissionRequest, EINA_FALSE);
627 OnGetUserMediaPermissionRequsted(void* pUserData, Evas_Object* pView, void* pEventInfo)
629 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
630 Ewk_User_Media_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_User_Media_Permission_Request* >(pEventInfo);
631 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
633 result r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_USERMEDIA, pEventInfo);
634 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
638 ewk_user_media_permission_request_set(pPermissionRequest, EINA_FALSE);
643 OnNotificationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
645 result r = E_SUCCESS;
646 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
648 Ewk_Notification_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Notification_Permission_Request* >(pEventInfo);
649 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
651 ewk_notification_permission_request_suspend(pPermissionRequest);
653 r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_NOTIFICATION, pPermissionRequest);
654 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
658 ewk_notification_permission_request_set(pPermissionRequest, EINA_FALSE);
663 OnNotificationShow(void* pUserData, Evas_Object* pView, void* pEventInfo)
665 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
666 Ewk_Notification* pNotification = reinterpret_cast< Ewk_Notification* >(pEventInfo);
667 SysAssertf(pImpl && pNotification, "Failed to request");
669 result r = E_SUCCESS;
670 Ewk_Context* pContext = ewk_view_context_get(pView);
671 SysAssertf(pContext, "Failed to get webkit instance.");
672 uint64_t notificationId = ewk_notification_id_get(pNotification);
674 //ewk_notification_security_origin_get(pNotification)
676 const char* text = ewk_notification_body_get(pNotification);
677 SysSecureLog(NID_WEB_CTRL, "The current value of icon path is %s",ewk_notification_icon_url_get(pNotification));
679 std::unique_ptr<_WebNotification> pNotificationWindow( new (std::nothrow) _WebNotification());
680 SysTryReturnVoidResult(NID_WEB_CTRL, pNotificationWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
682 r = pNotificationWindow->Construct(pContext, notificationId, pImpl);
683 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Error propogated.", GetErrorMessage(r));
685 pNotificationWindow->SetText(String(text));
686 pNotificationWindow->LaunchNotification();
687 pImpl->SetWebNotification(pNotificationWindow.release());
689 ewk_notification_showed(pContext, notificationId);
694 OnNotificationCancel(void* pUserData, Evas_Object* pView, void* pEventInfo)
696 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
697 uint64_t* pNotificationID = reinterpret_cast< uint64_t* >(pEventInfo);
698 SysAssertf(pImpl && pNotificationID, "Failed to request");
700 //ToDo : Where is ewk API for cancel operation?
705 OnProtocolHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
707 result r = E_SUCCESS;
708 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
709 SysAssertf(pImpl, "Failed to request");
711 r = pImpl->ShowUserConfirmPopup(USER_PROTOCOL_HANDLER, pEventInfo);
712 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
717 OnIsProtocolHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
719 int checkHandler = 0;
720 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
721 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
722 SysAssertf(pImpl && pHandlerData, "Failed to request");
724 checkHandler = pImpl->SearchHandler(pHandlerData, false);
725 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
726 switch (checkHandler)
731 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
734 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
737 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
745 OnProtocolHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
747 result r = E_SUCCESS;
748 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
749 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
750 SysAssertf(pImpl && pHandlerData, "Failed to request");
752 r = pImpl->UnregistrationHandler(pHandlerData, false);
753 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
758 OnContentHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
760 result r = E_SUCCESS;
761 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
762 SysAssertf(pImpl, "Failed to request");
764 r = pImpl->ShowUserConfirmPopup(USER_CONTENT_HANDLER, pEventInfo);
765 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
770 OnIsContentHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
772 int checkHandler = 0;
773 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
774 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
775 SysAssertf(pImpl && pHandlerData, "Failed to request");
777 checkHandler = pImpl->SearchHandler(pHandlerData, true);
778 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
780 switch (checkHandler)
785 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
788 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
791 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
800 OnContentHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
802 result r = E_SUCCESS;
803 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
804 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
805 SysAssertf(pImpl && pHandlerData, "Failed to request");
807 r = pImpl->UnregistrationHandler(pHandlerData, true);
808 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
813 OnFullScreenEntered(void* pUserData, Evas_Object* pView, void* pEventInfo)
815 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
816 bool* pIsHandleNeeded = reinterpret_cast< bool* >(pEventInfo);
817 SysAssertf(pImpl, "Failed to request");
819 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
820 SysAssertf(pWebCore, "Failed to get Web core object");
822 if (pIsHandleNeeded && *pIsHandleNeeded)
824 pWebCore->SetFullScreenEntered(true);
830 OnFullScreenExited(void* pUserData, Evas_Object* pView, void* pEventInfo)
832 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
833 SysAssertf(pImpl, "Failed to request");
835 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
836 SysAssertf(pWebCore, "Failed to get Web core object");
838 pWebCore->SetFullScreenEntered(false);
843 OnFocusDownRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
845 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
846 SysAssertf(pImpl, "Failed to request");
848 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
849 pWebCore->SetFocusEnd(true);
854 OnFocusUpRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
856 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
857 SysAssertf(pImpl, "Failed to request");
859 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
860 pWebCore->SetFocusEnd(true);
865 OnVibrationRequested(uint64_t duration, void* pUserData)
867 result r = E_SUCCESS;
869 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
870 SysAssertf(pImpl, "Failed to request");
872 r = pImpl->VibrationRequested(duration);
873 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
878 OnVibrationCanceled(void* pUserData)
880 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
881 SysAssertf(pImpl, "Failed to request");
883 pImpl->VibrationCanceled();
888 OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
890 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
891 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
892 SysAssertf(pImpl && pPolicy, "Failed to request");
894 String url(ewk_policy_decision_url_get(pPolicy));
895 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls", url.GetPointer());
897 if (ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy))
898 && !pImpl->IsRedirectRequested())
900 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
901 SysAssertf(pWebCore, "Failed to get Web core object");
903 pWebCore->SetFullScreenEntered(false);
905 pImpl->SetCertificateRequested(false);
907 if (pImpl->GetTextSearchListener())
909 pImpl->DisableAsyncSearch();
912 ILoadingListener* pLoadingListener = pImpl->GetLoadingListener();
913 if (pLoadingListener)
915 WebNavigationType navigationType = WEB_NAVIGATION_OTHER;
916 Ewk_Policy_Navigation_Type ewkNavigationType = ewk_policy_decision_navigation_type_get(pPolicy);
918 switch (ewkNavigationType)
920 case EWK_POLICY_NAVIGATION_TYPE_LINK_CLICKED:
921 navigationType = WEB_NAVIGATION_LINK_CLICKED;
923 case EWK_POLICY_NAVIGATION_TYPE_FORM_SUBMITTED:
924 navigationType = WEB_NAVIGATION_FORM_SUBMITTED;
926 case EWK_POLICY_NAVIGATION_TYPE_BACK_FORWARD:
927 navigationType = WEB_NAVIGATION_BACKFORWARD;
929 case EWK_POLICY_NAVIGATION_TYPE_RELOAD:
930 navigationType = WEB_NAVIGATION_RELOAD;
932 case EWK_POLICY_NAVIGATION_TYPE_FORM_RESUBMITTED:
933 navigationType = WEB_NAVIGATION_FORM_RESUBMITTED;
935 case EWK_POLICY_NAVIGATION_TYPE_OTHER:
936 navigationType = WEB_NAVIGATION_OTHER;
942 if (pLoadingListener->OnLoadingRequested(url, navigationType))
944 ewk_policy_decision_ignore(pPolicy);
951 if (url == L"about:blank")
953 ewk_policy_decision_use(pPolicy);
958 String currentUrl(pImpl->GetUrl());
959 String redirectUrl(pImpl->GetProtocolFromUri(url, currentUrl));
960 if (redirectUrl != L"")
962 ewk_policy_decision_ignore(pPolicy);
964 pImpl->LoadUrl(redirectUrl);
972 String uriScheme(uri.GetScheme());
973 SysSecureLog(NID_WEB_CTRL, "The current value of scheme is %ls", uriScheme.GetPointer());
975 if ((uriScheme != L"http") && (uriScheme != L"https") && (uriScheme != L"file"))
977 ewk_policy_decision_ignore(pPolicy);
979 if (uriScheme == L"")
984 result r = E_SUCCESS;
986 if (uriScheme == L"tel")
988 String operationId(L"http://tizen.org/appcontrol/operation/dial");
989 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
991 else if (uriScheme == L"mailto" || uriScheme == L"sms" || uriScheme == L"smsto" || uriScheme == L"mms" || uriScheme == L"mmsto" )
993 String operationId(L"http://tizen.org/appcontrol/operation/compose");
994 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
998 String operationId(L"http://tizen.org/appcontrol/operation/view");
999 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
1001 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1006 ewk_policy_decision_use(pPolicy);
1011 OnLoadingStarted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1013 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1014 SysAssertf(pImpl, "Failed to request");
1016 if (pImpl->GetLoadingListener())
1018 result r = E_SUCCESS;
1020 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_STARTED));
1021 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1023 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1024 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1025 pEventArg.release();
1031 OnPageTitleReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1033 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1034 char* pTitle = reinterpret_cast< char* >(pEventInfo);
1035 SysAssertf(pImpl, "Failed to request");
1037 SysLog(NID_WEB_CTRL, "The current value of title is %s", pTitle);
1039 if (pImpl->GetLoadingListener())
1041 result r = E_SUCCESS;
1043 std::unique_ptr<String> pPageTitle(new (std::nothrow) String(pTitle));
1044 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED));
1045 SysTryReturnVoidResult(NID_WEB_CTRL, pPageTitle.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1047 r = pEventArg->SetEventInfo(_LoadingEventArg::PAGE_TITLE, *pPageTitle.get());
1048 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1049 pPageTitle.release();
1051 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1052 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1053 pEventArg.release();
1059 OnEstimatedProgress(void* pUserData, Evas_Object* pView, void* pEventInfo)
1061 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1062 double* pProgress = reinterpret_cast< double* >(pEventInfo);
1063 SysAssertf(pImpl, "Failed to request");
1065 SysLog(NID_WEB_CTRL, "The current value of progress is %lf", *pProgress);
1067 if (pImpl->GetLoadingListener())
1069 result r = E_SUCCESS;
1071 std::unique_ptr<Integer> pProgressPercentage(new (std::nothrow) Integer(static_cast< int >(*pProgress * 100)));
1072 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PROGRESS));
1073 SysTryReturnVoidResult(NID_WEB_CTRL, pProgressPercentage.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1075 r = pEventArg->SetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS, *pProgressPercentage.get());
1076 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1077 pProgressPercentage.release();
1079 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1080 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1081 pEventArg.release();
1087 OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1089 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1090 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
1091 SysAssertf(pImpl && pPolicy, "Failed to request");
1093 result r = E_SUCCESS;
1095 int code = ewk_policy_decision_response_status_code_get(pPolicy);
1096 String url(ewk_policy_decision_url_get(pPolicy));
1097 String mime(ewk_policy_decision_response_mime_get(pPolicy));
1098 SysSecureLog(NID_WEB_CTRL, "code : %d, url : %ls, mime : %ls", code, url.GetPointer(), mime.GetPointer());
1100 if (ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy)))
1102 if (code >= REDIRECTION_HEADER_GROUP && code < REDIRECTION_HEADER_GROUP + 100)
1104 pImpl->SetRedirectRequested(true);
1108 ILoadingListener* pLoadingListener = pImpl->GetLoadingListener();
1109 if (pLoadingListener)
1111 HttpHeader httpHeader;
1113 Eina_Iterator* iterator = eina_hash_iterator_tuple_new(ewk_policy_decision_response_headers_get(pPolicy));
1116 Eina_Hash_Tuple *tuple = null;
1118 EINA_ITERATOR_FOREACH(iterator, tuple)
1120 String key(reinterpret_cast< const char* >(tuple->key));
1121 String value(reinterpret_cast< char* >(tuple->data));
1123 SysSecureLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", key.GetPointer(), value.GetPointer());
1125 r = httpHeader.AddField(key, value);
1126 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1129 eina_iterator_free(iterator);
1132 pImpl->SetPolicyDecision(pLoadingListener->OnWebDataReceived(mime, httpHeader));
1136 pImpl->SetPolicyDecision(WEB_DECISION_CONTINUE);
1140 switch (pImpl->GetPolicyDecision())
1142 case WEB_DECISION_CONTINUE:
1144 String currentUrl(pImpl->GetUrl());
1145 String redirectUrl(pImpl->GetRedirectUri(url, currentUrl, mime));
1146 if (redirectUrl != L"")
1148 ewk_policy_decision_ignore(pPolicy);
1150 pImpl->LoadUrl(redirectUrl);
1155 if (ewk_policy_decision_type_get(pPolicy) == EWK_POLICY_DECISION_USE)
1161 ewk_policy_decision_ignore(pPolicy);
1163 String operationId(L"http://tizen.org/appcontrol/operation/view");
1165 r = _AppControlImpl::FindAndStart(operationId, &url, &mime, null, null, null);
1166 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS || r == E_OBJ_NOT_FOUND, r, "[%s] Propagating.", GetErrorMessage(r));
1167 if (r == E_OBJ_NOT_FOUND)
1169 String operationId(L"http://tizen.org/appcontrol/operation/download");
1171 r = _AppControlImpl::FindAndStart(operationId, &url, null, null, null, null);
1172 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1180 case WEB_DECISION_DOWNLOAD:
1182 ewk_policy_decision_ignore(pPolicy);
1184 _WebDataHandler* pDownloadHandler = pImpl->GetDownloadHandler();
1185 SysTryReturnVoidResult(NID_WEB_CTRL, pDownloadHandler, E_SYSTEM, "[%s] A system error has been occurred. Failed to get DownloadHandler.", GetErrorMessage(E_SYSTEM));
1187 Ewk_Context* pContext = ewk_view_context_get(pView);
1188 SysAssertf(pContext, "Failed to get webkit instance.");
1190 pDownloadHandler->StartDownload(url);
1195 case WEB_DECISION_IGNORE:
1197 ewk_policy_decision_ignore(pPolicy);
1208 ewk_policy_decision_use(pPolicy);
1213 ewk_policy_decision_ignore(pPolicy);
1218 OnProgressCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1220 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1221 SysAssertf(pImpl, "Failed to request");
1223 if (pImpl->IsRedirectRequested())
1225 pImpl->SetRedirectRequested(false);
1228 if (pImpl->IsLoadingErrorOccurred())
1230 pImpl->SetLoadingErrorOccurred(false);
1231 evas_object_smart_callback_call(pView, "load,finished", NULL);
1237 OnLoadingErrorOccurred(void* pUserData, Evas_Object* pView, void* pEventInfo)
1239 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1240 Ewk_Error* pErrorData = reinterpret_cast< Ewk_Error* >(pEventInfo);
1241 SysAssertf(pImpl && pErrorData, "Failed to request");
1243 int code = ewk_error_code_get(pErrorData);
1244 const char* pDescription = ewk_error_description_get(pErrorData);
1246 SysLog(NID_WEB_CTRL, "The current value of code is %d, description is %s", code, pDescription);
1250 case EWK_ERROR_CODE_FRAMELOADINTERRUPTEDBYPOLICYCHANGE:
1251 pImpl->SetLoadingErrorOccurred(true);
1254 case EWK_ERROR_CODE_PLUGINWILLHANDLELOAD:
1255 evas_object_smart_callback_call(pView, "load,finished", NULL);
1258 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
1259 pImpl->SetLoadingErrorOccurred(true);
1260 evas_object_smart_callback_call(pView, "load,stop", NULL);
1264 pImpl->SetLoadingErrorOccurred(true);
1265 if (pImpl->GetLoadingListener())
1267 result r = E_SUCCESS;
1269 r = FireLoadingErrorOccurredEvent(pImpl, code, pDescription);
1270 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1278 OnLoadingCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
1280 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1281 SysAssertf(pImpl, "Failed to request");
1283 if (pImpl->GetLoadingListener())
1285 result r = E_SUCCESS;
1287 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_CANCELED));
1288 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1290 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1291 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1292 pEventArg.release();
1299 OnLoadingCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1301 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1302 SysAssertf(pImpl, "Failed to request");
1304 if (pImpl->GetLoadingListener())
1306 result r = E_SUCCESS;
1308 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_COMPLETED));
1309 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1311 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1312 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1313 pEventArg.release();
1320 OnLoadingCommitted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1322 evas_object_focus_set(pView, EINA_FALSE);
1327 OnFaviconReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1329 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1330 SysAssertf(pImpl, "Failed to request");
1332 if (pImpl->GetLoadingListener())
1334 result r = E_SUCCESS;
1336 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED));
1337 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1339 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1340 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1341 pEventArg.release();
1348 OnDidStartDownloadCallback(const char* pUrl, void* pUserData)
1350 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1351 SysAssertf(pUrl && pImpl != null, "Failed to request");
1353 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s", pUrl);
1358 FireWebPageShowRequestedEvent(_WebImpl* pImpl, int event)
1360 result r = E_SUCCESS;
1362 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1363 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1365 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1366 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1367 pEventArg.release();
1374 OnWebPageShowRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1376 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1377 SysAssertf(pImpl, "Failed to request");
1379 if (pImpl->GetUiEventListener())
1381 result r = E_SUCCESS;
1383 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED);
1384 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1386 if (pImpl->GetUiEventListenerF())
1388 result r = E_SUCCESS;
1390 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT);
1391 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1397 OnWebWindowCreateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1399 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(pUserData);
1400 Evas_Object** pChildView = reinterpret_cast< Evas_Object** >(pEventInfo);
1401 SysAssertf(pParentImpl && pChildView, "Failed to request");
1403 IWebUiEventListener* pUserUiListener = pParentImpl->GetUiEventListener();
1404 IWebUiEventListenerF* pUserUiListenerF = pParentImpl->GetUiEventListenerF();
1405 if (pUserUiListener)
1407 Web* pWeb = pUserUiListener->OnWebWindowCreateRequested();
1410 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1411 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1413 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1414 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1417 if (pUserUiListenerF)
1419 Web* pWeb = pUserUiListenerF->OnWebWindowCreateRequested();
1422 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1423 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1425 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1426 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1433 FireWebWindowClosedRequestedEvent(_WebImpl* pImpl, int event)
1435 result r = E_SUCCESS;
1437 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1438 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1440 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1441 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1442 pEventArg.release();
1449 OnWebWindowClosedRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1451 _WebImpl* pChildImpl = reinterpret_cast< _WebImpl* >(pUserData);
1452 SysAssertf(pChildImpl, "Failed to request");
1454 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, PARENT_WEB_CTRL));
1455 if (pParentImpl == null)
1460 if (pParentImpl->GetUiEventListener())
1462 result r = E_SUCCESS;
1464 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED);
1465 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1467 if (pParentImpl->GetUiEventListenerF())
1469 result r = E_SUCCESS;
1471 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT);
1472 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1478 FireWebPreventDefaultTriggeredEvent(_WebImpl* pImpl, int event, bool trigger)
1480 result r = E_SUCCESS;
1482 std::unique_ptr<Boolean> pPreventTrigger(new (std::nothrow) Boolean(trigger));
1483 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1484 SysTryReturnResult(NID_WEB_CTRL, pPreventTrigger.get() && pEventArg.get(), E_OUT_OF_MEMORY, " Memory allocation failed." );
1486 r = pEventArg->SetEventInfo(_WebUiEventArg::PREVENT_DEFAULT, *pPreventTrigger.get());
1487 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1488 pPreventTrigger.release();
1490 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1491 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1492 pEventArg.release();
1499 OnWebPreventDefaultTriggered(void* pUserData, Evas_Object* pView, void* pEventInfo)
1501 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1502 Eina_Bool* pTrigger = reinterpret_cast< Eina_Bool* >(pEventInfo);
1503 SysAssertf(pImpl && pTrigger, "Failed to request");
1505 if (pImpl->GetUiEventListener())
1507 result r = E_SUCCESS;
1509 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED, static_cast< bool >(*pTrigger));
1510 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1512 if (pImpl->GetUiEventListenerF())
1514 result r = E_SUCCESS;
1516 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT, static_cast< bool >(*pTrigger));
1517 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1523 FireWebPageBlockSelectedEvent(_WebImpl* pImpl)
1525 result r = E_SUCCESS;
1527 std::unique_ptr<Point> startPoint(new (std::nothrow) Point());
1528 std::unique_ptr<Point> endPoint(new (std::nothrow) Point());
1529 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1531 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1533 if ((endPoint->x != 0) && (endPoint->y != 0))
1535 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED));
1536 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1538 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1539 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1540 startPoint.release();
1542 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1543 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1546 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1547 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1548 pEventArg.release();
1556 FireWebPageBlockSelectedEventF(_WebImpl* pImpl)
1558 result r = E_SUCCESS;
1560 std::unique_ptr<FloatPoint> startPoint(new (std::nothrow) FloatPoint());
1561 std::unique_ptr<FloatPoint> endPoint(new (std::nothrow) FloatPoint());
1563 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1565 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1566 if ((endPoint->x != 0.0f) && (endPoint->y != 0.0f))
1568 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT));
1569 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1571 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1572 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1573 startPoint.release();
1575 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1576 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1579 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1580 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1581 pEventArg.release();
1589 OnWebPageBlockSelected(void* pUserData, Evas_Object* pView, void* pEventInfo)
1591 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1592 SysAssertf(pImpl, "Failed to request");
1594 if (pImpl->GetUiEventListener())
1596 result r = E_SUCCESS;
1598 r = FireWebPageBlockSelectedEvent(pImpl);
1599 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1601 if (pImpl->GetUiEventListenerF())
1603 result r = E_SUCCESS;
1605 r = FireWebPageBlockSelectedEventF(pImpl);
1606 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1612 OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo)
1614 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1615 char* pJsonText = reinterpret_cast< char* >(pEventInfo);
1616 SysAssertf(pImpl && pJsonText, "Failed to request");
1618 result r = E_SUCCESS;
1620 SysLog(NID_WEB_CTRL, "The current value of jsontext is %s", pJsonText);
1622 std::unique_ptr<_JsBridgeArg> pEventArg(new (std::nothrow) _JsBridgeArg());
1623 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1625 r = pEventArg->Construct(pJsonText);
1626 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1628 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1629 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1630 pEventArg.release();
1635 OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo)
1637 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1638 Eina_Rectangle* pEinaRect = reinterpret_cast< Eina_Rectangle* >(pEventInfo);
1639 SysAssertf(pImpl && pEinaRect, "Failed to request");
1641 if (pImpl->GetSetting().GetInputStyle() == INPUT_STYLE_OVERLAY)
1643 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1644 SysAssertf(pXformer, "Failed to get CoordinateTransformer");
1646 Rectangle rect(pEinaRect->x, pEinaRect->y, pEinaRect->w, pEinaRect->h);
1648 if (rect.height == 0)
1653 _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl));
1656 pFormImpl->DeflateClientRectHeight(pXformer->TransformVertical(rect.height));
1659 if (pImpl->GetWebKeypadEventListener())
1661 if (pImpl->IsKeypadVisible() == true)
1663 if ((pImpl->GetPreviousKeypadBounds().width == rect.width) && (pImpl->GetPreviousKeypadBounds().height != rect.height))
1665 pImpl->GetWebKeypadEventListener()->OnWebKeypadBoundsChanged(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1670 pImpl->GetWebKeypadEventListener()->OnWebKeypadWillOpen(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1674 pImpl->SetPreviousKeypadBounds(rect);
1678 result r = pImpl->SetFullScreenKeypad();
1679 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1685 OnWebKeypadOpened(void* pUserData, Evas_Object* pView, void* pEventInfo)
1687 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1688 SysAssertf(pImpl, "Failed to request");
1690 pImpl->SetKeypadVisibleState(true);
1692 _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl));
1695 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1696 SysAssertf(pXformer, "Failed to get CoordinateTransformer");
1698 pFormImpl->DeflateClientRectHeight(pXformer->TransformVertical(pImpl->GetPreviousKeypadBounds().height));
1700 if (pFormImpl->HasFooter())
1702 pFormImpl->GetCore().SetKeypadShowState(true);
1707 if (pImpl->GetWebKeypadEventListener())
1709 pImpl->GetWebKeypadEventListener()->OnWebKeypadOpened(*static_cast< Web* >(&pImpl->GetPublic()));
1715 OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo)
1717 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1718 SysAssertf(pImpl, "Failed to request");
1720 _FormImpl* pFormImpl = pImpl->GetParentFormImpl(dynamic_cast< _ControlImpl* >(pImpl));
1723 pFormImpl->DeflateClientRectHeight(0);
1725 if (pFormImpl->HasFooter())
1727 pFormImpl->GetCore().SetKeypadShowState(false);
1732 if (pImpl->GetWebKeypadEventListener())
1734 pImpl->GetWebKeypadEventListener()->OnWebKeypadClosed(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1737 pImpl->SetKeypadVisibleState(false);
1742 OnWindowObjectFocusLost(void* pUserData, Evas_Object* pWin, void* pEvent_info)
1744 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1745 SysAssertf(pImpl, "Failed to request");
1747 pImpl->SetWinFocusLost(true);
1752 OnWindowObjectFocusGained(void* pUserData, Evas_Object* pWin, void* pEvent_info)
1754 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1755 SysAssertf(pImpl, "Failed to request");
1757 if (pImpl->IsVisible() == true && pImpl->IsFocused() == true)
1759 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
1760 SysAssertf(pWebCore, "Failed to get Web core object");
1762 if (pImpl->IsWinFocusLost() == true)
1764 Ewk_Settings* pSettings = ewk_view_settings_get(pWebCore->GetWebNativeNode());
1765 SysAssertf(pSettings, "Failed to get settings instance.");
1767 if (ewk_settings_clear_text_selection_automatically_get(pSettings) == EINA_FALSE)
1769 ewk_settings_clear_text_selection_automatically_set(pSettings, EINA_TRUE);
1771 evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE);
1773 else if (pImpl->IsKeypadOpened() == true)
1775 evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE);
1780 pImpl->SetWinFocusLost(false);
1785 OnWebNativeNodeFocusGained(void* pUserData, Evas* pCanvas, Evas_Object* pView, void* pEventInfo)
1787 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1788 SysAssertf(pImpl, "Failed to request");
1790 if (pImpl->IsKeypadOpened() == true)
1792 pImpl->SetKeypadOpened(false);
1798 OnWebNativeNodeFocusLost(void* pUserData, Evas* pCanvas, Evas_Object* pView, void* pEventInfo)
1800 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1801 SysAssertf(pImpl, "Failed to request");
1803 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
1804 SysAssertf(pWebCore, "Failed to get Web core object");
1806 Eina_Rectangle leftHandle;
1807 Eina_Rectangle rightHandle;
1809 EINA_RECTANGLE_SET(&leftHandle, 0, 0, 0, 0);
1810 EINA_RECTANGLE_SET(&rightHandle, 0, 0, 0, 0);
1812 if (pImpl->IsWinFocusLost() == true && ewk_view_text_selection_range_get(pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle))
1814 Ewk_Settings* pSettings = ewk_view_settings_get(pWebCore->GetWebNativeNode());
1815 SysAssertf(pSettings, "Failed to get settings instance.");
1817 ewk_settings_clear_text_selection_automatically_set(pSettings, EINA_FALSE);
1823 OnColorPickerProviderRequested(Ewk_View_Smart_Data* pSmartData, int red, int green, int blue, int alpha)
1825 SysAssertf(pSmartData, "invalid smartdata");
1826 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1827 SysAssertf(pWebImpl, "Failed to get Impl");
1829 result r = E_SUCCESS;
1831 if (pWebImpl->GetColorpicker())
1838 r = pWebImpl->ShowColorPicker(red, green, blue, alpha, color);
1839 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1841 byte r1, g1, b1, a1;
1842 color.GetColorComponents(r1, g1, b1, a1);
1843 ewk_view_color_picker_color_set(pSmartData->self, r1, g1, b1, a1);
1850 OnColorPickerProviderDismissed(Ewk_View_Smart_Data* pSmartData)
1852 SysAssertf(pSmartData, "invalid smartdata");
1854 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1855 SysAssertf(pWebImpl, "Failed to get Impl");
1857 return pWebImpl->HideColorPicker();
1862 OnDatePickerProviderRequested(Ewk_View_Smart_Data* pSmartData, Ewk_Input_Type inputType, const char* inputValue)
1864 SysAssertf(pSmartData, "Failed to request");
1865 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1866 SysAssertf(pWebImpl, "Failed to get Impl");
1868 result r = E_SUCCESS;
1870 if (pWebImpl->GetDatepicker())
1872 ewk_view_focused_input_element_value_set(pSmartData->self, inputValue);
1879 r = pWebImpl->ShowDatePicker(inputType, inputValue, dateStr);
1880 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1882 std::unique_ptr<char[]> pDateStr(_StringConverter::CopyToCharArrayN(dateStr));
1883 SysTryReturn(NID_WEB_CTRL, pDateStr.get(), EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1885 ewk_view_focused_input_element_value_set(pSmartData->self, pDateStr.get());
1892 OnSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex)
1894 SysAssertf(pSmartData, "Failed to request");
1896 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1897 SysAssertf(pWebImpl, "Failed to get Impl");
1899 result r = pWebImpl->ShowSelectBoxPopup(false, L"", pItems, pSmartData->self, selectedIndex);
1900 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1907 OnMultiSelectBoxRequested(Ewk_View_Smart_Data* pSmartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* pItems)
1909 SysAssertf(pSmartData, "Failed to request");
1911 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1912 SysAssertf(pWebImpl, "Failed to get Impl");
1914 result r = pWebImpl->ShowSelectBoxPopup(true, L"", pItems, pSmartData->self, 0);
1915 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1922 OnSelectBoxClosed(Ewk_View_Smart_Data* pSmartData)
1924 SysAssertf(pSmartData, "invalid smartdata");
1926 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1927 SysAssertf(pWebImpl, "Failed to get Impl");
1929 result r = pWebImpl->ClearSelectBoxPopup();
1930 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1937 OnSelectBoxUpdateRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, Eina_List* pItems, int selectedIndex)
1939 SysAssertf(pSmartData, "invalid smartdata");
1941 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1942 SysAssertf(pWebImpl, "Failed to get Impl");
1944 result r = pWebImpl->UpdateSelectBoxPopup(pItems, selectedIndex, false);
1945 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1952 OnFormDataCandidateShow(Ewk_View_Smart_Data *pSmartData, int x, int y, int w, int h)
1954 SysAssertf(pSmartData, "Failed to request");
1956 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1957 SysAssertf(pWebImpl, "Failed to get Impl");
1959 Rectangle windowRect(x, y, w, h);
1960 result r = pWebImpl->ShowFormDataWindow(windowRect, pSmartData->self);
1961 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1968 OnFormDataCandidateHide(Ewk_View_Smart_Data *pSmartData)
1970 SysAssertf(pSmartData, "Failed to request");
1972 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1973 SysAssertf(pWebImpl, "Failed to get Impl");
1975 if (pWebImpl->IsFormDataWindowVisible())
1977 pWebImpl->HideFormDataWindow();
1985 OnFormDataCandidateUpdate(Ewk_View_Smart_Data *pSmartData, Eina_List *pDataList)
1987 SysAssertf(pSmartData, "Failed to request");
1989 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1990 SysAssertf(pWebImpl, "Failed to get Impl");
1992 pWebImpl->SetFormDataList(pDataList);
1999 OnFormDataCandidateIsShowing(Ewk_View_Smart_Data *pSmartData)
2001 SysAssertf(pSmartData, "Failed to request");
2003 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
2004 SysAssertf(pWebImpl, "Failed to get Impl");
2006 if (pWebImpl->IsFormDataWindowVisible())
2018 OnCookiesPolicyGot(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *pError, void *pUserData)
2020 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
2021 SysAssertf(pPresenter && !pError, "Failed to request");
2023 bool ret = EINA_TRUE;
2027 case EWK_COOKIE_ACCEPT_POLICY_ALWAYS:
2029 case EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY:
2033 case EWK_COOKIE_ACCEPT_POLICY_NEVER:
2042 SysLog(NID_WEB_CTRL, "The current value of policy is %d", ret);
2044 pPresenter->EndAsyncProcess(ret);
2049 OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData)
2051 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
2052 SysAssertf(pPresenter, "Failed to request");
2054 String result(pResult);
2055 SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer());
2057 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, WEB_CTRL));
2058 _WebManager* pWebManager = _WebManager::GetInstance();
2059 if (pWebManager->IsValidCallback(reinterpret_cast< int >(pImpl), reinterpret_cast< int >(pPresenter)))
2061 pPresenter->EndAsyncProcess(result);
2067 OnTextFound(void* pUserData, Evas_Object* pView, void* pEventInfo)
2069 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2070 SysAssertf(pImpl, "Failed to request");
2072 int* pTotalCount = reinterpret_cast< int* >(pEventInfo);
2073 SysLog(NID_WEB_CTRL, "The current value of totalCount is %d", *pTotalCount);
2075 _WebPresenter* pWebPresenter = pImpl->GetSearchPresenter();
2079 pWebPresenter->EndAsyncProcess(*pTotalCount);
2083 if (pImpl->GetTextSearchListener())
2085 result r = E_SUCCESS;
2089 if (*pTotalCount > 0)
2091 ordinal = pImpl->GetAsyncSearchOrdinal();
2092 pImpl->SetAsyncSearchResult(*pTotalCount);
2095 if (pImpl->GetPendingAsyncSearchCount() > 0)
2100 std::unique_ptr<Integer> pCount(new (std::nothrow) Integer(*pTotalCount));
2101 std::unique_ptr<Integer> pOrdinal(new (std::nothrow) Integer(ordinal));
2102 std::unique_ptr<_TextSearchEventArg> pEventArg(new (std::nothrow) _TextSearchEventArg(WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND));
2103 SysTryReturnVoidResult(NID_WEB_CTRL, pCount.get() && pOrdinal.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2105 r = pEventArg->SetEventInfo(_TextSearchEventArg::TOTAL_COUNT, *pCount.get());
2106 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2109 r = pEventArg->SetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL, *pOrdinal.get());
2110 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2113 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
2114 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2115 pEventArg.release();
2121 class _JsBridgeHashCodeProvider
2122 : public Tizen::Base::Collection::IHashCodeProviderT< Tizen::Base::String >
2125 _JsBridgeHashCodeProvider(){}
2126 virtual ~_JsBridgeHashCodeProvider(void) {}
2129 int GetHashCode(const Tizen::Base::String& obj) const
2131 return obj.GetHashCode();
2137 //Comparer implementation
2138 class _JsBridgeComparer
2139 : public Tizen::Base::Collection::IComparerT< Tizen::Base::String >
2142 _JsBridgeComparer(){}
2143 virtual ~_JsBridgeComparer(void) {}
2146 result Compare(const Tizen::Base::String& obj1, const Tizen::Base::String& obj2, int& cmp) const
2163 _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
2164 : _ContainerImpl(pWeb, pCore)
2165 , __isFooterVisible(false)
2166 , __isKeypadVisible(false)
2167 , __isKeypadOpened(false)
2168 , __isWinFocusLost(false)
2169 , __isLoadingErrorOccurred(false)
2170 , __isRedirectRequested(false)
2171 , __isCertificateRequested(false)
2172 , __isCertificateConfirmed(false)
2173 , __isFormDataVisible(false)
2174 , __keypadBounds(0, 0, 0, 0)
2176 , __pUserLoadingListener(null)
2177 , __pUserUiListener(null)
2178 , __pUserUiListenerF(null)
2179 , __pUserKeypadEventListener(null)
2180 , __pTextSearchListener(null)
2182 , __pJsBridgeList(null)
2183 , __pJsProvider(null)
2184 , __pJsComparer(null)
2185 , __pWebDownloadHandler(null)
2187 , __pAuthChallenge(null)
2188 , __pAuthPopup(null)
2189 , __pUserMediaConfirmPopup(null)
2190 , __pContentHandlerConfirmPopup(null)
2191 , __pProtocolHandlerConfirmPopup(null)
2192 , __pGeolocationConfirmPopup(null)
2193 , __pNotificationConfirmPopup(null)
2194 , __pScriptAlertConfirmPopup(null)
2195 , __pScriptConfirmPopup(null)
2196 , __pAppCacheConfirmPopup(null)
2197 , __pDbQuotaConfirmPopup(null)
2198 , __pLocalFsQuotaConfirmPopup(null)
2199 , __pIndexedDbQuotaConfirmPopup(null)
2200 , __pPromptPopup(null)
2201 , __pCertConfirmPopup(null)
2202 , __pSelectBox(null)
2203 , __pDatePicker(null)
2204 , __pColorPicker(null)
2205 , __pFormDataWindow(null)
2207 , __policy(WEB_DECISION_CONTINUE)
2208 , __defaultUserAgent(L"")
2209 , __pFormDataList(null)
2210 , __popupClosed(false)
2212 __textSearch.__searchAll = false;
2213 __textSearch.__searchForward = true;
2214 __textSearch.__caseSensitive = false;
2215 __textSearch.__pending = 0;
2216 __textSearch.__currentIndex = 1;
2217 __textSearch.__totalCount = -1;
2218 __textSearch.__text = L"";
2222 _WebImpl::~_WebImpl()
2224 _WebManager* pWebManager = _WebManager::GetInstance();
2225 SysTryCatch(NID_WEB_CTRL, pWebManager, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2227 pWebManager->RemoveWeb(reinterpret_cast< int >(this));
2228 pWebManager->RemoveActiveWeb(this);
2231 RemoveEventListenerCallback();
2233 ClearCertificateDb();
2238 _WebImpl::CreateWebImplN(Web* pControl, const Rectangle& bounds)
2240 result r = E_SUCCESS;
2242 r = GET_SIZE_INFO(Web).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2243 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2245 _Web* pCore = _Web::CreateWebN();
2246 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2248 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2250 r = CheckConstruction(pCore, pImpl);
2251 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2253 r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2254 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2256 r = pImpl->Construct();
2257 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2269 _WebImpl::CreateWebImplN(Web* pControl, const FloatRectangle& bounds)
2271 result r = E_SUCCESS;
2273 r = GET_SIZE_INFO(Web).CheckInitialSizeValidF(FloatDimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2274 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2276 _Web* pCore = _Web::CreateWebN();
2277 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2279 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2281 r = CheckConstruction(pCore, pImpl);
2282 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2284 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2285 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2287 r = pImpl->Construct();
2288 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2300 _WebImpl::Construct(void)
2302 result r = E_SUCCESS;
2304 r = __mutex.Create();
2305 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2307 r = __textSearch.__searchQueue.Construct();
2308 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2310 r = __webNotificationList.Construct();
2311 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2313 r = InitJsBridgeList();
2314 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2317 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2319 __pWebCore = dynamic_cast< _Web* >(&(GetCore()));
2320 SysTryReturnResult(NID_WEB_CTRL, __pWebCore, E_SYSTEM, "A system error has been occurred. Failed to get web control");
2327 _WebImpl::InitializeSetting(void)
2329 result r = E_SUCCESS;
2331 WebSetting* pWebSetting = __pWebCore->GetSetting();
2332 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(pWebSetting);
2334 SetCookieEnabled(pWebSettingImpl->IsCookieEnabled());
2335 SetPrivateBrowsingEnabled(pWebSettingImpl->IsPrivateBrowsingEnabled());
2337 __defaultUserAgent = pWebSettingImpl->GetUserAgent();
2339 r = SetSetting(*pWebSetting);
2340 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2342 SetEventListenerCallback();
2349 _WebImpl::IsLayoutable(void) const
2356 _WebImpl::InitWebEvent(void)
2358 __pWebEvent = std::unique_ptr<_WebEvent>(new (std::nothrow) _WebEvent());
2359 SysTryReturnResult(NID_WEB_CTRL, __pWebEvent.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2361 return __pWebEvent->Construct(*this);
2366 _WebImpl::GetWebEvent(void) const
2368 return __pWebEvent.get();
2373 _WebImpl::ConvertToSlpHeaderN(const HttpHeader& header) const
2375 Eina_Hash* pHttpHeader = null;
2377 std::unique_ptr<IList> pFieldNameList(header.GetFieldNamesN());
2378 if (pFieldNameList.get())
2380 pHttpHeader = eina_hash_string_small_new(FreeCharArray);
2381 SysTryReturn(NID_WEB_CTRL, pHttpHeader, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2383 int count = pFieldNameList->GetCount();
2385 for (int i = 0; i < count; i++)
2387 String* pFieldName = dynamic_cast< String* >(pFieldNameList->GetAt(i));
2388 SysTryCatch(NID_WEB_CTRL, pFieldName, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2390 std::unique_ptr<char[]> pKey(_StringConverter::CopyToCharArrayN(*pFieldName));
2391 SysTryCatch(NID_WEB_CTRL, pKey.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2393 std::unique_ptr<IEnumerator> pFieldValueEnum(header.GetFieldValuesN(*pFieldName));
2394 SysTryCatch(NID_WEB_CTRL, pFieldValueEnum.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2396 while (pFieldValueEnum->MoveNext() == E_SUCCESS)
2398 Eina_Bool ret = false;
2400 String* pFieldValue = dynamic_cast< String* >(pFieldValueEnum->GetCurrent());
2401 SysTryCatch(NID_WEB_CTRL, pFieldValue, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2403 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(*pFieldValue));
2404 SysTryCatch(NID_WEB_CTRL, pValue.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2406 ret = eina_hash_add(pHttpHeader, pKey.get(), pValue.release());
2407 SysTryCatch(NID_WEB_CTRL, ret == EINA_TRUE, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2414 eina_hash_free(pHttpHeader);
2421 _WebImpl::LoadUrl(const String& url) const
2423 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2424 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2426 ewk_view_url_set(__pWebCore->GetWebNativeNode(), pUrl.get());
2433 _WebImpl::LoadUrl(const String& url, const HttpHeader& header)
2435 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2436 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2438 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2440 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_GET, pHttpHeader, null);
2442 eina_hash_free(pHttpHeader);
2449 _WebImpl::LoadUrlWithPostRequest(const String& url, const HttpHeader& header, const ByteBuffer& body) const
2451 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2452 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2454 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2456 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_POST, pHttpHeader, reinterpret_cast< const char* >(body.GetPointer()));
2458 eina_hash_free(pHttpHeader);
2465 _WebImpl::LoadData(const String& baseUrl, const ByteBuffer& content, const String& mime, const String& encoding) const
2467 SysTryReturnResult(NID_WEB_CTRL, content.GetLimit() > 0, E_INVALID_ARG, "The content buffer is empty.");
2469 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(baseUrl));
2470 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
2471 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(encoding));
2472 SysTryReturn(NID_WEB_CTRL, pUrl.get() && pMime.get() && pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2474 ewk_view_contents_set(__pWebCore->GetWebNativeNode(), reinterpret_cast< const char* >(content.GetPointer()), content.GetLimit(), pMime.get(), pEncoding.get(), pUrl.get());
2481 _WebImpl::Pause(void)
2483 ewk_view_suspend(__pWebCore->GetWebNativeNode());
2488 _WebImpl::Resume(void)
2490 ewk_view_resume(__pWebCore->GetWebNativeNode());
2495 _WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List* pItems, Evas_Object* pWebView, int selectedIndex)
2497 __pSelectBox.reset();
2499 SysTryReturnResult(NID_WEB_CTRL, eina_list_count(pItems) > 0, E_SYSTEM, "ItemCount is invalid.");
2501 result r = E_SUCCESS;
2503 std::unique_ptr<_SelectBox> pSelectBox(new (std::nothrow) _SelectBox());
2504 SysTryReturnResult(NID_WEB_CTRL, pSelectBox.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2506 r = pSelectBox->Construct(isMultiSelect, title, DEFAULT_LIST_ITEM_COUNT, pWebView);
2507 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2509 r = pSelectBox->UpdateList(pItems, selectedIndex, false, false);
2510 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2512 __pSelectBox = std::move(pSelectBox);
2514 return __pSelectBox->ShowPopup();
2519 _WebImpl::UpdateSelectBoxPopup(Eina_List* pItems, int selectedIndex, bool isGroupedList)
2521 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2523 return __pSelectBox->UpdateList(pItems, selectedIndex, true, isGroupedList);
2528 _WebImpl::ClearSelectBoxPopup(void)
2530 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2532 __pSelectBox.reset();
2541 _WebImpl::GetDatepicker(void)
2543 _InputPickerPopup* pInputPicker =null;
2546 pInputPicker = __pDatePicker.get();
2548 return pInputPicker;
2553 _WebImpl::GetColorpicker(void)
2555 _InputPickerPopup* pInputPicker =null;
2558 pInputPicker = __pColorPicker.get();
2560 return pInputPicker;
2565 _WebImpl::CanGoBack(void) const
2567 return static_cast< bool >(ewk_view_back_possible(__pWebCore->GetWebNativeNode()));
2572 _WebImpl::CanGoForward(void) const
2574 return static_cast< bool >(ewk_view_forward_possible(__pWebCore->GetWebNativeNode()));
2579 _WebImpl::GoBack(void) const
2581 ewk_view_back(__pWebCore->GetWebNativeNode());
2586 _WebImpl::GoForward(void) const
2588 ewk_view_forward(__pWebCore->GetWebNativeNode());
2593 _WebImpl::GetUrl(void) const
2595 return ewk_view_url_get(__pWebCore->GetWebNativeNode());
2600 _WebImpl::GetTitle(void) const
2602 return ewk_view_title_get(__pWebCore->GetWebNativeNode());
2607 _WebImpl::StopLoading(void) const
2609 ewk_view_stop(__pWebCore->GetWebNativeNode());
2614 _WebImpl::Reload(void) const
2616 ewk_view_reload(__pWebCore->GetWebNativeNode());
2621 _WebImpl::EvaluateJavascriptN(const String& scriptCode)
2623 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2629 std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(scriptCode));
2630 SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2632 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
2633 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2635 ewk_view_script_execute(pView, pScript.get(), OnScriptExecuted, pPresenter.get());
2637 String* pResult = new (std::nothrow) String(L"");
2638 SysTryReturn(NID_WEB_CTRL, pResult, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2640 pPresenter->WaitAsyncProcess(*pResult);
2647 _WebImpl::SetZoomLevel(float level)
2649 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);
2651 ewk_view_scale_set(__pWebCore->GetWebNativeNode(), static_cast< double >(level), 0, 0);
2658 _WebImpl::GetZoomLevel(void) const
2660 return static_cast< float >(ewk_view_scale_get(__pWebCore->GetWebNativeNode()));
2664 const PageNavigationList*
2665 _WebImpl::GetBackForwardListN(void) const
2667 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2673 result r = E_SUCCESS;
2675 _PageNavigationListImpl* pNavigationListImpl = null;
2676 _HistoryItemImpl* pHistoryItemImpl = null;
2678 std::unique_ptr<PageNavigationList> pNavigationList;
2679 std::unique_ptr<ArrayList, AllElementsDeleter> pHistoryList;
2682 int forwardCount = 0;
2687 Ewk_History* pEwkHistoryList = ewk_view_history_get(pView);
2688 SysTryReturn(NID_WEB_CTRL, pEwkHistoryList, null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get full history.", GetErrorMessage(E_SYSTEM));
2690 Ewk_History_Item* pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, 0);
2691 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_DATA_NOT_FOUND, "[%s] There is no history.", GetErrorMessage(E_DATA_NOT_FOUND));
2693 pNavigationList = std::unique_ptr<PageNavigationList>(new (std::nothrow) PageNavigationList());
2694 SysTryCatch(NID_WEB_CTRL, pNavigationList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2696 pNavigationListImpl = _PageNavigationListImpl::GetInstance(pNavigationList.get());
2697 SysTryCatch(NID_WEB_CTRL, pNavigationListImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2699 pHistoryList = std::unique_ptr<ArrayList, AllElementsDeleter>(new (std::nothrow) ArrayList());
2700 SysTryCatch(NID_WEB_CTRL, pHistoryList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2702 r = pHistoryList->Construct();
2703 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2705 backCount = ewk_history_back_list_length_get(pEwkHistoryList);
2706 forwardCount = ewk_history_forward_list_length_get(pEwkHistoryList);
2707 SysLog(NID_WEB_CTRL, "The current value of backCount is %d, forwardCount is %d", backCount, forwardCount);
2709 for (int i = -backCount; i < forwardCount + 1; i++)
2711 std::unique_ptr<HistoryItem> pHistoryItem(new (std::nothrow) HistoryItem());
2712 SysTryCatch(NID_WEB_CTRL, pHistoryItem.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2714 pHistoryItemImpl = _HistoryItemImpl::GetInstance(pHistoryItem.get());
2715 SysTryCatch(NID_WEB_CTRL, pHistoryItemImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2717 pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, i);
2718 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2720 url = ewk_history_item_uri_get(pEwkItem);
2721 title = ewk_history_item_title_get(pEwkItem);
2722 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s, title is %s", url.GetPointer(), title.GetPointer());
2724 pHistoryItemImpl->SetHistoryItem(url, title);
2726 r = pHistoryList->Add(*pHistoryItem.get());
2727 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2728 pHistoryItem.release();
2731 pNavigationListImpl->SetPageNavigationList(pHistoryList.release(), backCount);
2733 ewk_history_free(pEwkHistoryList);
2735 return pNavigationList.release();
2738 ewk_history_free(pEwkHistoryList);
2745 _WebImpl::SearchText(const String& text, bool searchForward)
2747 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2753 result r = E_SUCCESS;
2755 Ewk_Find_Options condition = static_cast< Ewk_Find_Options >(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2759 condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS);
2762 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
2763 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2765 r = SynchronizeSearch(SEARCH_SYNC, pView, condition, text, searchForward, false, pPresenter.get());
2766 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
2769 pPresenter->WaitAsyncProcess(result);
2771 return static_cast < bool >(result);
2776 _WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive)
2778 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2784 result r = E_SUCCESS;
2786 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2790 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2793 r = SynchronizeSearch(SEARCH_ALL_ASYNC, pView, condition, text, true, caseSensitive);
2794 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2801 _WebImpl::SearchNextAsync(bool searchForward)
2803 Evas_Object* pView = __pWebCore->GetWebNativeNode();
2809 SysTryReturnResult(NID_WEB_CTRL, __textSearch.__searchAll && __textSearch.__totalCount > -1, E_INVALID_OPERATION, "The SearchTextAllAsync() method is not called or completed.");
2810 SysTryReturnResult(NID_WEB_CTRL, (searchForward && __textSearch.__currentIndex < __textSearch.__totalCount) || (!searchForward && __textSearch.__currentIndex > 1)
2811 , E_OBJ_NOT_FOUND, "The Next instance is not available.");
2813 result r = E_SUCCESS;
2815 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2817 if (!__textSearch.__caseSensitive)
2819 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2824 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_BACKWARDS);
2827 r = SynchronizeSearch(SEARCH_NEXT_ASYNC, pView, condition, __textSearch.__text, searchForward);
2828 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2835 _WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text, bool searchForward, bool caseSensitive, _WebPresenter* pWebPresenter)
2837 MutexGuard lock(__mutex);
2839 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(text));
2840 SysTryReturn(NID_WEB_CTRL, pText.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2845 if (__textSearch.__searchAll)
2847 DisableAsyncSearch();
2849 __textSearch.__searchQueue.Enqueue(this);
2850 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2852 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2853 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2857 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2859 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2863 case SEARCH_ALL_ASYNC:
2864 __textSearch.__searchAll = true;
2865 __textSearch.__text = text;
2866 __textSearch.__searchForward = true;
2867 __textSearch.__caseSensitive = caseSensitive;
2868 __textSearch.__totalCount = -1;
2869 __textSearch.__currentIndex = 1;
2871 __textSearch.__searchQueue.Enqueue(this);
2872 __textSearch.__searchQueue.Enqueue(this);
2874 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2875 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2878 case SEARCH_NEXT_ASYNC:
2879 __textSearch.__searchForward = searchForward;
2881 CalculateAsyncSearchOrdinal();
2883 __textSearch.__searchQueue.Enqueue(this);
2885 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2897 _WebImpl::SetAsyncSearchResult(int totalCount)
2899 __textSearch.__totalCount = totalCount;
2904 _WebImpl::GetSearchPresenter(void)
2906 MutexGuard lock(__mutex);
2908 return dynamic_cast< _WebPresenter* >(__textSearch.__searchQueue.Dequeue());
2913 _WebImpl::GetPendingAsyncSearchCount(void) const
2915 return __textSearch.__searchQueue.GetCount();
2920 _WebImpl::CalculateAsyncSearchOrdinal(void)
2922 if (__textSearch.__searchForward)
2924 __textSearch.__currentIndex++;
2928 __textSearch.__currentIndex--;
2934 _WebImpl::GetAsyncSearchOrdinal(void) const
2936 return __textSearch.__currentIndex;
2941 _WebImpl::DisableAsyncSearch(void)
2943 __textSearch.__searchAll = false;
2948 _WebImpl::SetSetting(const WebSetting& setting)
2950 if (__pWebCore->GetWebNativeNode())
2952 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2953 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2954 SysAssertf(pContext && pSettings, "Failed to get webkit instance.");
2956 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(setting.GetDefaultTextEncoding()));
2957 SysTryReturn(NID_WEB_CTRL, pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2959 ewk_settings_default_encoding_set(pSettings, pEncoding.get());
2961 switch (setting.GetCacheControl())
2963 case WEB_CACHE_VALIDATED:
2964 ewk_context_cache_disabled_set(pContext, EINA_FALSE);
2967 case WEB_CACHE_IGNORE:
2968 ewk_context_cache_disabled_set(pContext, EINA_TRUE);
2975 if (setting.GetInputStyle() == INPUT_STYLE_OVERLAY)
2977 ewk_settings_default_keypad_enabled_set(pSettings, EINA_TRUE);
2981 ewk_settings_default_keypad_enabled_set(pSettings, EINA_FALSE);
2984 ewk_settings_font_default_size_set(pSettings, static_cast< Eina_Bool >(setting.GetFontSize()));
2986 ewk_settings_javascript_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsJavascriptEnabled()));
2988 ewk_settings_loads_images_automatically_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoImageLoadEnabled()));
2990 if (__defaultUserAgent != setting.GetUserAgent())
2992 std::unique_ptr<char[]> pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent()));
2993 SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2995 ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get());
2998 ewk_settings_auto_fitting_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFittingEnabled()));
3000 ewk_settings_scripts_window_open_set(pSettings, static_cast< Eina_Bool >(setting.IsJavaScriptPopupEnabled()));
3002 ewk_settings_form_candidate_data_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFormDataShowEnabled()));
3004 ewk_settings_autofill_password_form_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoLoginFormFillEnabled()));
3007 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting());
3009 pWebSettingImpl->SetCertificateErrorHandlingMode(setting.GetCertificateErrorHandlingMode());
3010 pWebSettingImpl->SetDefaultTextEncoding(setting.GetDefaultTextEncoding());
3011 pWebSettingImpl->SetCacheControl(setting.GetCacheControl());
3012 pWebSettingImpl->SetFontSize(setting.GetFontSize());
3013 pWebSettingImpl->SetJavascriptEnabled(setting.IsJavascriptEnabled());
3014 pWebSettingImpl->SetAutoImageLoadEnabled(setting.IsAutoImageLoadEnabled());
3015 pWebSettingImpl->SetInputStyle(setting.GetInputStyle());
3016 pWebSettingImpl->SetUserAgent(setting.GetUserAgent());
3017 pWebSettingImpl->SetAutoFittingEnabled(setting.IsAutoFittingEnabled());
3018 pWebSettingImpl->SetJavaScriptPopupEnabled(setting.IsJavaScriptPopupEnabled());
3019 pWebSettingImpl->SetGeolocationEnabled(setting.IsGeolocationEnabled());
3020 pWebSettingImpl->SetAutoFormDataShowEnabled(setting.IsAutoFormDataShowEnabled());
3021 pWebSettingImpl->SetAutoLoginFormFillEnabled(setting.IsAutoLoginFormFillEnabled());
3028 _WebImpl::GetSetting(void) const
3030 return *__pWebCore->GetSetting();
3034 const HitElementResult*
3035 _WebImpl::GetElementByPointN(const Point& point) const
3037 return GetElementByPointN(_CoordinateSystemUtils::ConvertToFloat(point));
3041 const HitElementResult*
3042 _WebImpl::GetElementByPointN(const FloatPoint& point) const
3044 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3050 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));
3052 result r = E_SUCCESS;
3054 _HitElementResultImpl* pHitElementResultImpl = null;
3056 std::unique_ptr<HitElementResult> pHitElementResult;
3057 std::unique_ptr<Bitmap> pImage;
3058 std::unique_ptr<HashMap, AllElementsDeleter> pAttributeMap;
3060 Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(point)));
3062 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3063 SysTryReturn(NID_WEB_CTRL, pEwkHitTest, null, E_SYSTEM, "[%s] Failed to get hit test.", GetErrorMessage(E_SYSTEM));
3065 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
3066 Ewk_Hit_Test_Result_Context context = ewk_hit_test_result_context_get(pEwkHitTest);
3067 String url(ewk_hit_test_link_uri_get(pEwkHitTest));
3068 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3069 String nodeValue(ewk_hit_test_node_value_get(pEwkHitTest));
3071 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls, tag is %ls, value is %ls", url.GetPointer(), tagName.GetPointer(), nodeValue.GetPointer());
3073 pHitElementResult = std::unique_ptr<HitElementResult>(new (std::nothrow) HitElementResult());
3074 SysTryCatch(NID_WEB_CTRL, pHitElementResult.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3076 pHitElementResultImpl = _HitElementResultImpl::GetInstance(pHitElementResult.get());
3077 SysTryCatch(NID_WEB_CTRL, pHitElementResultImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3079 if (context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE)
3085 int imageLength = ewk_hit_test_image_buffer_length_get(pEwkHitTest);
3086 void* pImageBuffer = ewk_hit_test_image_buffer_get(pEwkHitTest);
3087 const char* pExtension = ewk_hit_test_image_file_name_extension_get(pEwkHitTest);
3088 SysLog(NID_WEB_CTRL, "The current value of imageBuffer is %u, bufferLength is %d, extension is %s", pImageBuffer, imageLength, pExtension);
3090 r = buf.Construct(imageLength);
3091 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3093 r = buf.SetArray(reinterpret_cast< byte* >(pImageBuffer), 0, imageLength);
3094 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3098 // ToDo : webkit doesn't support types such as IMG_FORMAT_WBMP and IMG_FORMAT_TIFF
3099 // webkit support types such as ico and vp8 additionally
3100 if (strcmp(pExtension, "gif") == 0)
3102 format = IMG_FORMAT_GIF;
3104 else if (strcmp(pExtension, "jpg") == 0)
3106 format = IMG_FORMAT_JPG;
3108 else if (strcmp(pExtension, "png") == 0)
3110 format = IMG_FORMAT_PNG;
3112 else if (strcmp(pExtension, "bmp") == 0)
3114 format = IMG_FORMAT_BMP;
3118 SysLogException(NID_WEB_CTRL, E_UNSUPPORTED_FORMAT, "[%s] The %s format is not supported", GetErrorMessage(E_UNSUPPORTED_FORMAT), pExtension);
3122 r = image.Construct();
3123 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3125 pImage = std::unique_ptr<Bitmap>(image.DecodeN(buf, format, BITMAP_PIXEL_FORMAT_RGB565));
3126 SysTryCatch(NID_WEB_CTRL, pImage.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3131 pAttributeMap = std::unique_ptr<HashMap, AllElementsDeleter>(new (std::nothrow) HashMap());
3132 SysTryCatch(NID_WEB_CTRL, pAttributeMap.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3134 r = pAttributeMap->Construct(eina_hash_population(pAttrHash));
3135 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3137 eina_hash_foreach(pAttrHash, AddHttpAttributeData, pAttributeMap.get());
3138 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3141 pHitElementResultImpl->SetHitElementResult(pAttributeMap.release(), pImage.release(), tagName, nodeValue, url);
3143 ewk_hit_test_free(pEwkHitTest);
3145 return pHitElementResult.release();
3148 ewk_hit_test_free(pEwkHitTest);
3155 _WebImpl::IsLoading(void) const
3157 double percent = ewk_view_load_progress_get(__pWebCore->GetWebNativeNode());
3159 if (Double::Compare(percent, 0.0) > 0 && Double::Compare(percent, 1.0) < 0)
3171 _WebImpl::GetTextFromBlock(void) const
3173 return ewk_view_text_selection_text_get(__pWebCore->GetWebNativeNode());
3178 _WebImpl::IsPrivateBrowsingEnabled(void) const
3180 if (__pWebCore->GetWebNativeNode() == null)
3182 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsPrivateBrowsingEnabled();
3185 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3186 SysAssertf(pSettings, "Failed to get webkit instance.");
3188 return static_cast< bool >(ewk_settings_private_browsing_enabled_get(pSettings));
3193 _WebImpl::SetPrivateBrowsingEnabled(bool enable)
3195 if (__pWebCore->GetWebNativeNode() == null)
3197 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetPrivateBrowsingEnabled(enable);
3201 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3202 SysAssertf(pSettings, "Failed to get webkit instance.");
3204 ewk_settings_private_browsing_enabled_set(pSettings, static_cast< Eina_Bool >(enable));
3209 _WebImpl::ClearHistory(void)
3211 ewk_view_back_forward_list_clear(__pWebCore->GetWebNativeNode());
3216 _WebImpl::ClearCache(void)
3218 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3220 ewk_context_cache_clear(pContext);
3225 _WebImpl::ClearCookie(void)
3227 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3228 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3230 ewk_cookie_manager_cookies_clear(pCookieManager);
3235 _WebImpl::ClearFormData(void)
3237 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3239 ewk_context_form_candidate_data_clear(pContext);
3244 _WebImpl::ClearLoginFormData(void)
3246 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3248 ewk_context_form_password_data_clear(pContext);
3253 _WebImpl::IsCookieEnabled(void) const
3255 if (__pWebCore->GetWebNativeNode() == null)
3257 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsCookieEnabled();
3260 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3261 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3262 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3264 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter(this));
3265 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3267 ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, pPresenter.get());
3269 bool result = false;
3270 pPresenter->WaitAsyncProcess(result);
3277 _WebImpl::SetCookieEnabled(bool enable)
3279 if (__pWebCore->GetWebNativeNode() == null)
3281 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetCookiEnabled(enable);
3286 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3287 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3288 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3292 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
3296 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER);
3297 ewk_cookie_manager_cookies_clear(pCookieManager);
3303 _WebImpl::SavePageAsPdf(const String& filePath, const Dimension* pSize) const
3305 result r = E_SUCCESS;
3307 std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
3308 SysTryReturn(NID_WEB_CTRL, pFilePath.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3311 String fileExtension = File::GetFileExtension(filePath);
3312 int pathLength = filePath.GetLength();
3315 SysTryReturnResult(NID_WEB_CTRL, fileExtension.Equals("pdf", false), E_INVALID_ARG, "Invalid argument(s) is used. File extension is not pdf.");
3317 r = filePath.LastIndexOf(L"/", pathLength - 1, index);
3318 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3319 r = filePath.SubString(0, index + 1, dirPath);
3320 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3322 std::unique_ptr<char[]> pDirPath(_StringConverter::CopyToCharArrayN(dirPath));
3323 SysTryReturnResult(NID_WEB_CTRL, access(pDirPath.get(), W_OK) == 0, E_INACCESSIBLE_PATH, "Directory permission is read-only.");
3327 SysTryReturnResult(NID_WEB_CTRL, pSize->width > 0 && pSize->height > 0, E_INVALID_ARG, "Invalid argument(s) is used. Size of pdf file is invalid.");
3329 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), pSize->width, pSize->height, pFilePath.get());
3333 Evas_Coord contentsWidth;
3334 Evas_Coord contentsHeight;
3336 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &contentsWidth, &contentsHeight);
3337 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), contentsWidth, contentsHeight, pFilePath.get());
3345 _WebImpl::IsMimeSupported(const String& mime) const
3347 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
3348 SysTryReturn(NID_WEB_CTRL, pMime.get(), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3350 return static_cast< bool >(ewk_frame_can_show_mime_type(ewk_view_main_frame_get(__pWebCore->GetWebNativeNode()), pMime.get()));
3355 _WebImpl::SetLoadingListener(ILoadingListener* pLoadingListener)
3357 __pUserLoadingListener = const_cast< ILoadingListener* >(pLoadingListener);
3362 _WebImpl::SetWebUiEventListener(IWebUiEventListener* pUiEventListener)
3364 __pUserUiListener = pUiEventListener;
3369 _WebImpl::SetWebUiEventListenerF(IWebUiEventListenerF* pUiEventListener)
3371 __pUserUiListenerF = pUiEventListener;
3376 _WebImpl::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener)
3378 __pUserKeypadEventListener = pKeypadEventListener;
3383 _WebImpl::SetDownloadListener(IWebDownloadListener* pDownLoadListener)
3385 if (__pWebDownloadHandler.get() == null)
3387 __pWebDownloadHandler = std::unique_ptr<_WebDataHandler>(new (std::nothrow) _WebDataHandler());
3388 SysTryReturnVoidResult(NID_WEB_CTRL, __pWebDownloadHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3391 __pWebDownloadHandler->SetDownloadListener(pDownLoadListener);
3392 __pWebDownloadHandler->SetWebEvent(__pWebEvent.get());
3397 _WebImpl::SetTextSearchListener(ITextSearchListener* pTextSearchListener)
3399 __pTextSearchListener = pTextSearchListener;
3404 _WebImpl::SetScrollEnabled(bool enable)
3406 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetScrollEnabled(enable);
3411 _WebImpl::IsScrollEnabled(void) const
3413 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled();
3418 _WebImpl::InitJsBridgeList(void)
3420 result r = E_SUCCESS;
3422 __pJsProvider = std::unique_ptr<_JsBridgeHashCodeProvider>(new (std::nothrow) _JsBridgeHashCodeProvider());
3423 SysTryReturnResult(NID_WEB_CTRL, __pJsProvider.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3425 __pJsComparer = std::unique_ptr<_JsBridgeComparer>(new (std::nothrow) _JsBridgeComparer());
3426 SysTryReturnResult(NID_WEB_CTRL, __pJsComparer.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3428 std::unique_ptr<HashMapT< String, IJavaScriptBridge* > > pJsBridgeList(new (std::nothrow) HashMapT< String, IJavaScriptBridge* >);
3429 SysTryReturnResult(NID_WEB_CTRL, pJsBridgeList.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3431 r = pJsBridgeList->Construct(0, 0, *__pJsProvider.get(), *__pJsComparer.get());
3432 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3434 __pJsBridgeList = std::move(pJsBridgeList);
3441 _WebImpl::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3443 result r = E_SUCCESS;
3445 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3446 String key(pJsBridge->GetName());
3448 r = __pJsBridgeList->Add(key, pJsBridge);
3449 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3456 _WebImpl::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3458 result r = E_SUCCESS;
3460 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3461 String key(pJsBridge->GetName());
3463 r = __pJsBridgeList->Remove(key);
3464 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3471 _WebImpl::FindJsInterface(const IJsonValue* pValue) const
3473 result r = E_SUCCESS;
3475 IJsonValue* pJsonValue = null;
3476 IJavaScriptBridge* pJsBridge = null;
3478 String key(L"name");
3480 const JsonObject* pJsonObject = dynamic_cast< const JsonObject* >(pValue);
3481 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));
3483 r = pJsonObject->GetValue(&key, pJsonValue);
3484 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS && pJsonValue, null, r, "[%s] Propagating.", GetErrorMessage(r));
3486 JsonString* pBridgeName = dynamic_cast< JsonString* >(pJsonValue);
3487 SysTryReturn(NID_WEB_CTRL, pBridgeName, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. name key is missing." , GetErrorMessage(E_INVALID_ARG));
3489 r = __pJsBridgeList->GetValue(static_cast< String >(*pBridgeName), pJsBridge);
3490 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3497 _WebImpl::GetLoadingListener(void) const
3499 return __pUserLoadingListener;
3503 IWebUiEventListener*
3504 _WebImpl::GetUiEventListener(void) const
3506 return __pUserUiListener;
3510 IWebUiEventListenerF*
3511 _WebImpl::GetUiEventListenerF(void) const
3513 return __pUserUiListenerF;
3517 IWebKeypadEventListener*
3518 _WebImpl::GetWebKeypadEventListener(void) const
3520 return __pUserKeypadEventListener;
3524 ITextSearchListener*
3525 _WebImpl::GetTextSearchListener(void) const
3527 return __pTextSearchListener;
3532 _WebImpl::SetEventListenerCallback(void) const
3534 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3537 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3538 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3540 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3541 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3543 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3544 SysAssertf(pSmartData, "Failed to request");
3546 Ewk_View_Smart_Class *pSmart = const_cast<Ewk_View_Smart_Class*>(pSmartData->api);
3547 SysAssertf(pSmart, "Failed to request");
3549 pSmart->popup_menu_show = OnSelectBoxRequested;
3550 pSmart->multiple_popup_menu_show = OnMultiSelectBoxRequested;
3551 pSmart->popup_menu_hide = OnSelectBoxClosed;
3552 pSmart->popup_menu_update = OnSelectBoxUpdateRequested;
3554 pSmart->input_picker_show = OnDatePickerProviderRequested;
3555 pSmart->input_picker_color_request = OnColorPickerProviderRequested;
3556 pSmart->input_picker_color_dismiss = OnColorPickerProviderDismissed;
3558 pSmart->formdata_candidate_show = OnFormDataCandidateShow;
3559 pSmart->formdata_candidate_hide = OnFormDataCandidateHide;
3560 pSmart->formdata_candidate_update_data = OnFormDataCandidateUpdate;
3561 pSmart->formdata_candidate_is_showing = OnFormDataCandidateIsShowing;
3563 evas_object_data_set(pWebNativeNode, WEB_CTRL, this);
3565 // add loading event callbacks for ILoadingListener
3566 evas_object_smart_callback_add(pWebNativeNode, "create,window", OnWebWindowCreateRequested, this);
3567 evas_object_smart_callback_add(pWebNativeNode, "close,window", OnWebWindowClosedRequested, this);
3569 evas_object_smart_callback_add(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested, this);
3570 evas_object_smart_callback_add(pWebNativeNode, "load,started", OnLoadingStarted, this);
3571 evas_object_smart_callback_add(pWebNativeNode, "load,finished", OnLoadingCompleted, this);
3572 evas_object_smart_callback_add(pWebNativeNode, "load,progress", OnEstimatedProgress, this);
3573 evas_object_smart_callback_add(pWebNativeNode, "load,progress,finished", OnProgressCompleted, this);
3574 evas_object_smart_callback_add(pWebNativeNode, "load,stop", OnLoadingCanceled, this);
3575 evas_object_smart_callback_add(pWebNativeNode, "load,error", OnLoadingErrorOccurred, this);
3576 evas_object_smart_callback_add(pWebNativeNode, "title,changed", OnPageTitleReceived, this);
3577 evas_object_smart_callback_add(pWebNativeNode, "load,committed", OnLoadingCommitted, this);
3579 evas_object_smart_callback_add(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest, this);
3581 evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3582 evas_object_smart_callback_add(pWinObject, "focus,out", OnWindowObjectFocusLost, this);
3584 evas_object_smart_callback_add(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged, this);
3585 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened, this);
3586 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed, this);
3588 evas_object_smart_callback_add(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested, this);
3589 evas_object_smart_callback_add(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled, this);
3591 evas_object_smart_callback_add(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested, this);
3593 ewk_view_javascript_alert_callback_set(pWebNativeNode, OnScriptAlertRequested, const_cast< _WebImpl* >(this));
3594 ewk_view_javascript_prompt_callback_set(pWebNativeNode, OnScriptPromptRequested, const_cast< _WebImpl* >(this));
3595 ewk_view_javascript_confirm_callback_set(pWebNativeNode, OnScriptConfirmRequested, const_cast< _WebImpl* >(this));
3597 evas_object_smart_callback_add(pWebNativeNode, "policy,response,decide", OnWebDataReceived, this);
3599 evas_object_smart_callback_add(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested, this);
3600 evas_object_smart_callback_add(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested, this);
3601 evas_object_smart_callback_add(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted, this);
3603 evas_object_smart_callback_add(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested, this);
3604 evas_object_smart_callback_add(pWebNativeNode, "notification,show", OnNotificationShow, this);
3605 evas_object_smart_callback_add(pWebNativeNode, "notification,cancel", OnNotificationCancel, this);
3607 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested, this);
3608 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered, this);
3609 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested, this);
3611 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested, this);
3612 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered, this);
3613 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested, this);
3614 evas_object_smart_callback_add(pWebNativeNode, "text,found", OnTextFound, this);
3616 evas_object_smart_callback_add(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered, this);
3617 evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this);
3619 evas_object_smart_callback_add(pWebNativeNode, "magnifier,hide", OnWebPageBlockSelected, this);
3621 evas_object_smart_callback_add(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered, this);
3622 evas_object_smart_callback_add(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited, this);
3624 evas_object_smart_callback_add(pWebNativeNode, "keyevent,down,not,handled", OnFocusDownRequested, this);
3625 evas_object_smart_callback_add(pWebNativeNode, "keyevent,up,not,handled", OnFocusUpRequested, this);
3627 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3628 SysAssertf(pContext, "Failed to get webkit instance.");
3629 ewk_context_did_start_download_callback_set(pContext, OnDidStartDownloadCallback, const_cast< _WebImpl* >(this));
3630 ewk_context_vibration_client_callbacks_set(pContext, OnVibrationRequested, OnVibrationCanceled, const_cast< _WebImpl* >(this));
3632 ewk_view_application_cache_permission_callback_set(pWebNativeNode, OnApplicationCachePermissionRequested, const_cast< _WebImpl* >(this));
3633 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, OnIndexedDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3634 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, OnDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3635 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, OnLocalFileSystemQuotaExceeded, const_cast< _WebImpl* >(this));
3637 evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this);
3638 evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_OUT, OnWebNativeNodeFocusLost, this);
3644 _WebImpl::RemoveEventListenerCallback(void) const
3646 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3649 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3650 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3652 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3653 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3655 evas_object_smart_callback_del(pWebNativeNode, "create,window", OnWebWindowCreateRequested);
3656 evas_object_smart_callback_del(pWebNativeNode, "close,window", OnWebWindowClosedRequested);
3658 evas_object_smart_callback_del(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested);
3659 evas_object_smart_callback_del(pWebNativeNode, "load,started", OnLoadingStarted);
3660 evas_object_smart_callback_del(pWebNativeNode, "load,finished", OnLoadingCompleted);
3661 evas_object_smart_callback_del(pWebNativeNode, "load,progress", OnEstimatedProgress);
3662 evas_object_smart_callback_del(pWebNativeNode, "load,progress,finished", OnProgressCompleted);
3663 evas_object_smart_callback_del(pWebNativeNode, "load,stop", OnLoadingCanceled);
3664 evas_object_smart_callback_del(pWebNativeNode, "load,error", OnLoadingErrorOccurred);
3665 evas_object_smart_callback_del(pWebNativeNode, "title,changed", OnPageTitleReceived);
3666 evas_object_smart_callback_del(pWebNativeNode, "load,committed", OnLoadingCommitted);
3668 evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest);
3670 evas_object_smart_callback_del_full(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3671 evas_object_smart_callback_del_full(pWinObject, "focus,out", OnWindowObjectFocusLost, this);
3673 evas_object_smart_callback_del(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged);
3674 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened);
3675 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed);
3677 evas_object_smart_callback_del(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested);
3678 evas_object_smart_callback_del(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled);
3680 evas_object_smart_callback_del(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested);
3682 ewk_view_javascript_alert_callback_set(pWebNativeNode, null, null);
3683 ewk_view_javascript_prompt_callback_set(pWebNativeNode, null, null);
3684 ewk_view_javascript_confirm_callback_set(pWebNativeNode, null, null);
3686 evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived);
3688 evas_object_smart_callback_del(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested);
3689 evas_object_smart_callback_del(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested);
3690 evas_object_smart_callback_del(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted);
3692 evas_object_smart_callback_del(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested);
3693 evas_object_smart_callback_del(pWebNativeNode, "notification,show", OnNotificationShow);
3694 evas_object_smart_callback_del(pWebNativeNode, "notification,cancel", OnNotificationCancel);
3695 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested);
3696 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered);
3697 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested);
3699 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested);
3700 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered);
3701 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested);
3703 evas_object_smart_callback_del(pWebNativeNode, "text,found", OnTextFound);
3705 evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered);
3706 evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived);
3708 evas_object_smart_callback_del(pWebNativeNode, "magnifier,hide", OnWebPageBlockSelected);
3710 evas_object_smart_callback_del(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered);
3711 evas_object_smart_callback_del(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited);
3713 evas_object_smart_callback_del(pWebNativeNode, "keyevent,down,not,handled", OnFocusDownRequested);
3714 evas_object_smart_callback_del(pWebNativeNode, "keyevent,up,not,handled", OnFocusUpRequested);
3716 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3717 SysAssertf(pContext, "Failed to get webkit instance.");
3718 ewk_context_vibration_client_callbacks_set(pContext, null, null, null);
3720 ewk_view_application_cache_permission_callback_set(pWebNativeNode, null, null);
3721 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, null, null);
3722 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, null, null);
3723 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, null, null);
3725 evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained);
3726 evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_OUT, OnWebNativeNodeFocusLost);
3732 _WebImpl::ClearCertificateDb(void)
3734 result r = E_SUCCESS;
3736 String certificatePath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
3737 String table(CERTIFICATE_TABLE_NAME);
3740 r = db.Construct(certificatePath, "r+", null);
3741 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3743 db.BeginTransaction();
3745 r = db.ExecuteSql(L"Delete From " + table, true);
3746 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3748 db.CommitTransaction();
3753 db.RollbackTransaction();
3758 _WebImpl::SetBlockSelectionPosition(const Point& startPoint)
3760 return SetBlockSelectionPosition(_CoordinateSystemUtils::ConvertToFloat(startPoint));
3765 _WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint)
3767 Evas_Object* pWebview = __pWebCore->GetWebNativeNode();
3773 Ewk_View_Smart_Data* pSmartData = reinterpret_cast< Ewk_View_Smart_Data* >(evas_object_smart_data_get(pWebview));
3774 SysAssertf(pSmartData && pSmartData->api, "Failed to get webkit instance.");
3775 Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(startPoint)));
3777 Eina_Bool ret = pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y);
3780 pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y);
3782 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pWebview, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3783 SysTryReturnResult(NID_WEB_CTRL, pEwkHitTest, E_SYSTEM, "Failed to get hit test.");
3785 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3787 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
3788 char* pValue = reinterpret_cast< char* >(eina_hash_find(pAttrHash, "contenteditable"));
3789 if (tagName.Equals(L"INPUT", false) || tagName.Equals(L"TEXTAREA", false) || pValue)
3791 ewk_view_command_execute(pWebview, "SelectWord", 0);
3792 evas_object_smart_callback_call(pWebview, "magnifier,hide", NULL);
3796 SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up.");
3803 _WebImpl::ReleaseBlock(void)
3805 ewk_view_text_selection_range_clear(__pWebCore->GetWebNativeNode());
3810 _WebImpl::GetBlockRange(Point& startPoint, Point& endPoint) const
3812 FloatPoint tempStartPoint;
3813 FloatPoint tempEndPoint;
3815 GetBlockRange(tempStartPoint, tempEndPoint);
3817 startPoint = _CoordinateSystemUtils::ConvertToInteger(tempStartPoint);
3818 endPoint = _CoordinateSystemUtils::ConvertToInteger(tempEndPoint);
3823 _WebImpl::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const
3825 Eina_Rectangle leftHandle;
3826 Eina_Rectangle rightHandle;
3828 EINA_RECTANGLE_SET(&leftHandle, 0, 0, 0, 0);
3829 EINA_RECTANGLE_SET(&rightHandle, 0, 0, 0, 0);
3831 ewk_view_text_selection_range_get(__pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle);
3833 startPoint.x = _CoordinateSystemUtils::ConvertToFloat(leftHandle.x);
3834 startPoint.y = _CoordinateSystemUtils::ConvertToFloat(leftHandle.y);
3835 endPoint.x = _CoordinateSystemUtils::ConvertToFloat(rightHandle.x + rightHandle.w);
3836 endPoint.y = _CoordinateSystemUtils::ConvertToFloat(rightHandle.y + rightHandle.h);
3838 if ((endPoint.x != 0.0f) && (endPoint.y != 0.0f))
3840 startPoint = __pWebCore->GetRelativeCoordinate(startPoint);
3841 endPoint = __pWebCore->GetRelativeCoordinate(endPoint);
3847 _WebImpl::GetFaviconN(void) const
3849 result r = E_SUCCESS;
3851 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3852 Ewk_Context* pContext = ewk_view_context_get(pView);
3853 const char* pUrl = ewk_view_url_get(pView);
3854 Evas* pEvas = evas_object_evas_get(pView);
3856 Evas_Object* pFavicon = ewk_context_icon_database_icon_object_add(pContext, pUrl, pEvas);
3862 Tizen::Graphics::BufferInfo bufferInfo;
3864 r = _Utility::GetPixelBufferFromEvasObject(pFavicon, bufferInfo);
3865 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3867 const Dimension dimension(bufferInfo.width, bufferInfo.height);
3868 Tizen::Base::ByteBuffer byteBuffer;
3870 r = byteBuffer.Construct((byte*)bufferInfo.pPixels, 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 );
3871 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3873 std::unique_ptr<Bitmap> pImage(new (std::nothrow) Bitmap());
3874 SysTryReturn(NID_WEB_CTRL, pImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3876 r = pImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888);
3877 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3879 return pImage.release();
3885 _WebImpl::ScrollBy(const Tizen::Graphics::Point& diff)
3887 ewk_view_scroll_by(__pWebCore->GetWebNativeNode(), diff.x, diff.y);
3892 _WebImpl::ScrollTo(const Tizen::Graphics::Point& dest)
3894 ewk_view_scroll_set(__pWebCore->GetWebNativeNode(), dest.x, dest.y);
3899 _WebImpl::GetScrollPosition(void) const
3903 ewk_view_scroll_pos_get(__pWebCore->GetWebNativeNode(), &position.x, &position.y);
3910 _WebImpl::GetPageSize(void) const
3912 Evas_Coord width = 0;
3913 Evas_Coord height = 0;
3915 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &width, &height);
3917 Dimension size(static_cast< int >(width), static_cast< int >(height));
3924 _WebImpl::AddHttpHeaderField(const String& name, const String& value)
3926 SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing.");
3928 std::unique_ptr<char[]> pName(_StringConverter::CopyToCharArrayN(name));
3929 SysTryReturn(NID_WEB_CTRL, pName.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3931 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(value));
3933 ewk_view_custom_header_add(__pWebCore->GetWebNativeNode(), pName.get(), pValue.get());
3940 _WebImpl::RemoveHttpHeaderField(const String& name)
3942 SysTryReturnResult(NID_WEB_CTRL, name.GetLength() > 0, E_INVALID_ARG, "Invalid argument(s) is used. name key is missing.");
3944 std::unique_ptr<char[]> pName(_StringConverter::CopyToCharArrayN(name));
3945 SysTryReturn(NID_WEB_CTRL, pName.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3947 ewk_view_custom_header_remove(__pWebCore->GetWebNativeNode(), pName.get());
3954 _WebImpl::SetLoadingErrorOccurred(bool arg)
3956 __isLoadingErrorOccurred = arg;
3961 _WebImpl::IsLoadingErrorOccurred(void) const
3963 return __isLoadingErrorOccurred;
3968 _WebImpl::SetRedirectRequested(bool arg)
3970 __isRedirectRequested = arg;
3975 _WebImpl::IsRedirectRequested(void) const
3977 return __isRedirectRequested;
3982 _WebImpl::SetPolicyDecision(DecisionPolicy policy)
3989 _WebImpl::GetPolicyDecision(void) const
3996 _WebImpl::SetCertificateRequested(bool arg)
3998 __isCertificateRequested = arg;
4003 _WebImpl::IsCertificateRequested(void) const
4005 return __isCertificateRequested;
4010 _WebImpl::SetCertificateConfirmed(bool arg)
4012 __isCertificateConfirmed = arg;
4017 _WebImpl::IsCertificateConfirmed(void) const
4019 return __isCertificateConfirmed;
4024 _WebImpl::SetFullScreenKeypad(void)
4026 result r = E_SUCCESS;
4028 std::unique_ptr<Keypad> pKeypad(new (std::nothrow) Keypad());
4029 SysTryReturnResult(NID_WEB_CTRL, pKeypad.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4031 r = pKeypad->Construct(KEYPAD_STYLE_NORMAL, 100);
4032 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4034 String text(ewk_view_focused_input_element_value_get(__pWebCore->GetWebNativeNode()));
4035 pKeypad->SetText(text);
4037 r = pKeypad->SetShowState(true);
4038 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4040 r = pKeypad->Show();
4041 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4043 pKeypad->AddTextEventListener(*this);
4045 __pKeypad = std::move(pKeypad);
4052 _WebImpl::RemoveFullScreenKeypad(void)
4054 __pKeypad->RemoveTextEventListener(*this);
4061 _WebImpl::IsFooterVisible(void) const
4063 return __isFooterVisible;
4068 _WebImpl::SetFooterVisibleState(bool isFooterVisible)
4070 __isFooterVisible = isFooterVisible;
4075 _WebImpl::IsKeypadVisible(void) const
4077 return __isKeypadVisible;
4082 _WebImpl::SetKeypadVisibleState(bool isKeypadVisible)
4084 __isKeypadVisible = isKeypadVisible;
4089 _WebImpl::IsKeypadOpened(void) const
4091 return __isKeypadOpened;
4095 _WebImpl::SetKeypadOpened(bool isKeypadOpened)
4097 __isKeypadOpened = isKeypadOpened;
4102 _WebImpl::IsWinFocusLost(void) const
4104 return __isWinFocusLost;
4109 _WebImpl::SetWinFocusLost(bool isWinFocusLost)
4111 __isWinFocusLost = isWinFocusLost;
4116 _WebImpl::GetPreviousKeypadBounds(void) const
4118 return __keypadBounds;
4123 _WebImpl::SetPreviousKeypadBounds(Rectangle& bounds)
4125 __keypadBounds = bounds;
4130 _WebImpl::OnTextValueChangeCanceled(const Control& source)
4132 RemoveFullScreenKeypad();
4137 _WebImpl::OnTextValueChanged(const Control& source)
4139 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(__pKeypad->GetText()));
4141 ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get());
4143 RemoveFullScreenKeypad();
4148 _WebImpl::OnHandleJavaScriptRequestByEventArg(const IEventArg& arg)
4150 const _JsBridgeArg* pEventArg = dynamic_cast< const _JsBridgeArg* >(&arg);
4151 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. arg is not _JsBridgeArg object.");
4153 std::unique_ptr<IJsonValue> pJsonValue(JsonParser::ParseN(*(pEventArg->GetJsonData())));
4154 SysTryReturn(NID_WEB_JSON, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4156 IJavaScriptBridge* pJsInterface = FindJsInterface(pJsonValue.get());
4157 SysTryReturnResult(NID_WEB_CTRL, pJsInterface, E_OBJ_NOT_FOUND, "JsInterface instance is not available.");
4159 pJsInterface->HandleJavaScriptRequestN(pJsonValue.release());
4166 _WebImpl::OnHandleLoadingEvent(const IEventArg& arg)
4168 result r = E_SUCCESS;
4170 const _LoadingEventArg* pEventArg = dynamic_cast< const _LoadingEventArg* >(&arg);
4171 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4173 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4175 ILoadingListener* pLoadingListner = GetLoadingListener();
4176 SysTryReturnResult(NID_WEB_CTRL, pLoadingListner, E_SYSTEM, "A system error has been occurred. Loading listener was not set or null.");
4178 switch (pEventArg->GetEventType())
4180 case WEB_EVENT_LOADINGLISTENER_STARTED:
4182 pLoadingListner->OnLoadingStarted();
4186 case WEB_EVENT_LOADINGLISTENER_PROGRESS:
4188 const Integer* pProgressPercentage = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS));
4189 SysTryReturn(NID_WEB_CTRL, pProgressPercentage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4191 pLoadingListner->OnEstimatedProgress(pProgressPercentage->ToInt());
4195 case WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED:
4197 const String* pPageTitle = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::PAGE_TITLE));
4198 SysTryReturn(NID_WEB_CTRL, pPageTitle, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4200 pLoadingListner->OnPageTitleReceived(*pPageTitle);
4204 case WEB_EVENT_LOADINGLISTENER_CANCELED:
4206 pLoadingListner->OnLoadingCanceled();
4210 case WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED:
4212 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_TYPE));
4213 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4215 const String* pErrorMessage = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_MESSAGE));
4216 SysTryReturn(NID_WEB_CTRL, pErrorMessage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4218 LoadingErrorType errorType = ConvertErrorCode(pErrorType->ToInt());
4220 pLoadingListner->OnLoadingErrorOccurred(errorType, *pErrorMessage);
4224 case WEB_EVENT_LOADINGLISTENER_COMPLETED:
4226 pLoadingListner->OnLoadingCompleted();
4230 case WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED:
4232 pLoadingListner->OnHttpAuthenticationCanceled();
4236 case WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED:
4238 std::unique_ptr<Bitmap> pFavicon(GetFaviconN());
4239 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4243 pLoadingListner->OnFaviconReceived(*pFavicon.get());
4259 _WebImpl::OnHandleWebDownloadEvent(const IEventArg& arg)
4261 result r = E_SUCCESS;
4263 const _WebDownloadEventArg* pEventArg = dynamic_cast< const _WebDownloadEventArg* >(&arg);
4264 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4266 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4268 IWebDownloadListener* pWebDownloadListener = __pWebDownloadHandler->GetDownloadListener();
4269 SysTryReturnResult(NID_WEB_CTRL, pWebDownloadListener, E_SYSTEM, "A system error has been occurred. Web Downloading listener was not set or null.");
4271 switch (pEventArg->GetEventType())
4273 case WEB_EVENT_WEBDOWNLOADLISTENER_DATA_RECEIVED:
4275 const ByteBuffer* pChunk = dynamic_cast< const ByteBuffer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::CHUNKED_DATA));
4276 SysTryReturn(NID_WEB_CTRL, pChunk, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4278 pWebDownloadListener->OnWebChunkedDataReceived(*pChunk);
4282 case WEB_EVENT_WEBDOWNLOADLISTENER_COMPLETED:
4284 pWebDownloadListener->OnWebDataDownloadCompleted();
4288 case WEB_EVENT_WEBDOWNLOADLISTENER_FAILED:
4290 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::ERROR_TYPE));
4291 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4293 LoadingErrorType errorType = static_cast < LoadingErrorType >(pErrorType->ToInt());
4295 pWebDownloadListener->OnWebDownloadFailed(errorType);
4310 _WebImpl::OnHandleWebUiEvent(const IEventArg& arg)
4312 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4313 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4315 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4317 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListener, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4319 switch (pEventArg->GetEventType())
4321 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED:
4323 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4325 Point* pStartPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4326 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4328 Point* pEndPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4329 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4331 __pUserUiListener->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4335 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED:
4337 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4339 __pUserUiListener->OnWebPageShowRequested(*pWeb);
4343 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED:
4345 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4347 __pUserUiListener->OnWebWindowCloseRequested(*pWeb);
4351 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED:
4353 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4355 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4356 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4358 __pUserUiListener->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4373 _WebImpl::OnHandleWebUiEventF(const IEventArg& arg)
4375 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4376 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4378 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4380 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListenerF, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4382 switch (pEventArg->GetEventType())
4384 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT:
4386 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4388 FloatPoint* pStartPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4389 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4391 FloatPoint* pEndPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4392 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4394 __pUserUiListenerF->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4398 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT:
4400 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4402 __pUserUiListenerF->OnWebPageShowRequested(*pWeb);
4406 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT:
4408 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4410 __pUserUiListenerF->OnWebWindowCloseRequested(*pWeb);
4414 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT:
4416 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4418 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4419 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4421 __pUserUiListenerF->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4436 _WebImpl::OnHandleTextSearchEvent(const IEventArg& arg)
4438 result r = E_SUCCESS;
4440 const _TextSearchEventArg* pEventArg = dynamic_cast< const _TextSearchEventArg* >(&arg);
4441 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4443 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4445 ITextSearchListener* pTextSearchListner = GetTextSearchListener();
4446 SysTryReturnResult(NID_WEB_CTRL, pTextSearchListner, E_SYSTEM, "A system error has been occurred. Web text search listener was not set or null.");
4448 switch (pEventArg->GetEventType())
4450 case WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND:
4452 Integer* pTotalCount= dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::TOTAL_COUNT)));
4453 SysTryReturn(NID_WEB_CTRL, pTotalCount, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4455 Integer* pCurrentOrdinal = dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL)));
4456 SysTryReturn(NID_WEB_CTRL, pCurrentOrdinal, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4458 pTextSearchListner->OnTextFound(pTotalCount->ToInt(), pCurrentOrdinal->ToInt());
4473 _WebImpl::VibrationRequested(uint64_t duration)
4475 result r = E_SUCCESS;
4477 __pVibrator.reset();
4479 std::unique_ptr<_VibratorImpl> pVibrator(new (std::nothrow) _VibratorImpl);
4480 SysTryReturnResult(NID_WEB_CTRL, pVibrator.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4482 r = pVibrator->Construct();
4483 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4485 __pVibrator = std::move(pVibrator);
4487 IntensityDurationVibrationPattern pattern = {static_cast< int >(duration), -1};
4489 r = __pVibrator->Start(&pattern, 1, 1);
4490 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4497 _WebImpl::VibrationCanceled(void)
4499 __pVibrator.reset();
4504 _WebImpl::HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge)
4506 result r = E_SUCCESS;
4508 String host(ewk_auth_challenge_url_get(pChallenge));
4509 String realm(ewk_auth_challenge_realm_get(pChallenge));
4511 __pAuthChallenge.reset();
4513 std::unique_ptr<AuthenticationChallenge> pAuthChallenge(new (std::nothrow) AuthenticationChallenge());
4514 SysTryReturnResult(NID_WEB_CTRL, pAuthChallenge, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4516 _AuthenticationChallengeImpl* pAuthImpl = _AuthenticationChallengeImpl::GetInstance(pAuthChallenge.get());
4517 SysTryReturn(NID_WEB_CTRL, pAuthImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4519 pAuthImpl->SetAuthenticationChallengeHandler(pChallenge);
4520 pAuthImpl->SetWebEvasObject(__pWebCore->GetWebNativeNode());
4522 __pAuthChallenge = std::move(pAuthChallenge);
4524 ewk_auth_challenge_suspend(pChallenge);
4525 if (__pUserLoadingListener && __pUserLoadingListener->OnHttpAuthenticationRequestedN(host, realm, *__pAuthChallenge.get()))
4527 __pAuthChallenge.release();
4531 r = ShowAuthenticationPopup(host, realm, __pAuthChallenge.get());
4532 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4540 _WebImpl::ShowAuthenticationPopup(const String& host, const String& realm, AuthenticationChallenge* pAuthChallenge)
4542 result r = E_SUCCESS;
4544 std::unique_ptr<_AuthConfirmPopup> pAuthPopup(new (std::nothrow) _AuthConfirmPopup());
4545 SysTryReturnResult(NID_WEB_CTRL, pAuthPopup, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4547 r = pAuthPopup->Construct(host, realm, pAuthChallenge);
4548 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4550 __pAuthPopup = std::move(pAuthPopup);
4552 int modalResult = 0;
4554 r = __pAuthPopup->ShowAndWait(modalResult);
4555 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4560 __pAuthPopup.reset();
4568 _WebImpl::ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk_Certificate_Policy_Decision* pPolicy)
4570 result r = E_SUCCESS;
4572 std::unique_ptr<_CertificateConfirmPopup> pCertConfirmPopup(new (std::nothrow) _CertificateConfirmPopup());
4573 SysTryReturnResult(NID_WEB_CTRL, pCertConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4575 r = pCertConfirmPopup->Construct(userConfirmMode, pPolicy);
4576 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4578 __pCertConfirmPopup = std::move(pCertConfirmPopup);
4580 int modalResult = 0;
4582 r = __pCertConfirmPopup->ShowAndWait(modalResult);
4583 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4585 if (__pCertConfirmPopup.get() && userConfirmMode == CERTIFICATE_POPUP_MODE_USER_CONFIRM)
4587 __isCertificateConfirmed = __pCertConfirmPopup->GetConfirmResult();
4591 if (__pCertConfirmPopup.get())
4593 __pCertConfirmPopup.reset();
4601 _WebImpl::ShowPromptPopup(String msg, String defVal)
4603 result r = E_SUCCESS;
4605 std::unique_ptr< _PromptPopup > pPromptPopup(new (std::nothrow) _PromptPopup());
4606 SysTryReturnResult(NID_WEB_CTRL, pPromptPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4608 r = pPromptPopup->Construct(msg, defVal, __pWebCore->GetWebNativeNode(), this);
4609 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4611 __pPromptPopup = std::move(pPromptPopup);
4613 r = __pPromptPopup->ShowPopup();
4614 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4619 __pPromptPopup.reset();
4627 _WebImpl::ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4629 result r = E_SUCCESS;
4631 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4632 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4634 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, this, true, msg);
4635 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4637 int modalResult = 0;
4639 switch(userConfirmMode)
4641 case USER_CONTENT_HANDLER:
4643 __pContentHandlerConfirmPopup = std::move(pUserConfirmPopup);
4645 r = __pContentHandlerConfirmPopup->ShowAndWait(modalResult);
4646 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pContentHandlerConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4648 __pContentHandlerConfirmPopup.reset();
4650 ewk_view_resume(__pWebCore->GetWebNativeNode());
4654 case USER_PROTOCOL_HANDLER:
4656 __pProtocolHandlerConfirmPopup = std::move(pUserConfirmPopup);
4658 r = __pProtocolHandlerConfirmPopup->ShowAndWait(modalResult);
4659 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pProtocolHandlerConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4661 __pProtocolHandlerConfirmPopup.reset();
4663 ewk_view_resume(__pWebCore->GetWebNativeNode());
4667 case USER_CONFIRM_APP_CACHE:
4669 __pAppCacheConfirmPopup = std::move(pUserConfirmPopup);
4671 r = __pAppCacheConfirmPopup->ShowAndWait(modalResult);
4672 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pAppCacheConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4674 __pAppCacheConfirmPopup.reset();
4676 ewk_view_resume(__pWebCore->GetWebNativeNode());
4680 case USER_CONFIRM_DB_QUOTA_EXCEDED:
4682 __pDbQuotaConfirmPopup = std::move(pUserConfirmPopup);
4684 r = __pDbQuotaConfirmPopup->ShowAndWait(modalResult);
4685 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pDbQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4687 __pDbQuotaConfirmPopup.reset();
4689 ewk_view_resume(__pWebCore->GetWebNativeNode());
4693 case USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED:
4695 __pLocalFsQuotaConfirmPopup = std::move(pUserConfirmPopup);
4697 r = __pLocalFsQuotaConfirmPopup->ShowAndWait(modalResult);
4698 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pLocalFsQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4700 __pLocalFsQuotaConfirmPopup.reset();
4702 ewk_view_resume(__pWebCore->GetWebNativeNode());
4706 case USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED:
4708 __pIndexedDbQuotaConfirmPopup = std::move(pUserConfirmPopup);
4710 r = __pIndexedDbQuotaConfirmPopup->ShowAndWait(modalResult);
4711 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pIndexedDbQuotaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4713 __pIndexedDbQuotaConfirmPopup.reset();
4715 ewk_view_resume(__pWebCore->GetWebNativeNode());
4728 _WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4730 result r = E_SUCCESS;
4732 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4733 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4735 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, this, false, msg);
4736 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4738 switch(userConfirmMode)
4740 case USER_CONFIRM_USERMEDIA:
4742 __pUserMediaConfirmPopup.reset();
4744 __pUserMediaConfirmPopup = std::move(pUserConfirmPopup);
4746 r = __pUserMediaConfirmPopup->ShowPopup();
4747 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pUserMediaConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4751 case USER_CONFIRM_GEOLOCATION:
4753 __pGeolocationConfirmPopup.reset();
4755 __pGeolocationConfirmPopup = std::move(pUserConfirmPopup);
4757 r = __pGeolocationConfirmPopup->ShowPopup();
4758 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pGeolocationConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4762 case USER_CONFIRM_NOTIFICATION:
4764 __pNotificationConfirmPopup.reset();
4766 __pNotificationConfirmPopup = std::move(pUserConfirmPopup);
4768 r = __pNotificationConfirmPopup->ShowPopup();
4769 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pNotificationConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4773 case USER_SCRIPT_ALERT:
4775 __pScriptAlertConfirmPopup.reset();
4777 __pScriptAlertConfirmPopup = std::move(pUserConfirmPopup);
4779 r = __pScriptAlertConfirmPopup->ShowPopup();
4780 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pScriptAlertConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4784 case USER_SCRIPT_CONFIRM:
4786 __pScriptConfirmPopup.reset();
4788 __pScriptConfirmPopup = std::move(pUserConfirmPopup);
4790 r = __pScriptConfirmPopup->ShowPopup();
4791 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, __pScriptConfirmPopup.reset(), r, "[%s] Propagating.", GetErrorMessage(r));
4807 _WebImpl::GetParentFormImpl(_ControlImpl* pControlImpl)
4810 _FormImpl* pFormImpl = null;
4812 _ControlImpl* pParentControlImpl = dynamic_cast< _ControlImpl* >(pControlImpl->GetParent());
4813 if (!pParentControlImpl)
4818 pFormImpl = dynamic_cast< _FormImpl* >(pParentControlImpl);
4824 return GetParentFormImpl(pParentControlImpl);
4829 _WebImpl::OnFocusGained(const _ControlImpl& source)
4836 _WebImpl::OnFocusLost(const _ControlImpl& source)
4838 Evas_Object* pWebview = __pWebCore->GetWebNativeNode();
4844 if(IsKeypadVisible() == true)
4846 SetKeypadOpened(true);
4854 _WebImpl::HasValidNativeNode(void) const
4856 if (__pWebCore && __pWebCore->GetWebNativeNode())
4866 _WebImpl::OnPreAttachedToMainTree(void)
4868 result r = E_SUCCESS;
4870 if (IsVisible() == true)
4872 _WebManager* pWebManager = _WebManager::GetInstance();
4873 pWebManager->SetActiveWeb(this);
4876 r = _ContainerImpl::OnPreAttachedToMainTree();
4877 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4879 if (!HasValidNativeNode())
4881 r = __pWebCore->InitializeWebNativeNode();
4882 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4884 _ControlManager* pControlManager = _ControlManager::GetInstance();
4885 SysTryReturnResult(NID_WEB_CTRL, pControlManager, E_SYSTEM, "Failed to get the ControlManager instance.");
4886 OnChangeLayout(pControlManager->GetScreenRotation());
4888 r = InitializeSetting();
4889 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4891 SettingInfo::AddSettingEventListener(*this);
4893 _WebManager* pWebManager = _WebManager::GetInstance();
4894 pWebManager->AddWeb(reinterpret_cast< int >(this));
4902 _WebImpl::OnDetachingFromMainTree(void)
4904 result r = E_SUCCESS;
4906 _WebManager* pWebManager = _WebManager::GetInstance();
4907 pWebManager->RemoveActiveWeb(this);
4909 r = _ContainerImpl::OnDetachingFromMainTree();
4910 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4917 _WebImpl::OnSettingChanged(String& key)
4919 Evas_Object* pWebview = __pWebCore->GetWebNativeNode();
4925 if (key == L"http://tizen.org/setting/font.type")
4927 ewk_view_use_settings_font(pWebview);
4933 _WebImpl::OnChangeLayout(_ControlRotation rotation)
4935 Evas_Object* pWebview = __pWebCore->GetWebNativeNode();
4945 case _CONTROL_ROTATION_0:
4948 case _CONTROL_ROTATION_90:
4951 case _CONTROL_ROTATION_180:
4954 case _CONTROL_ROTATION_270:
4960 ewk_view_orientation_send(pWebview, degree);
4965 _WebImpl::OnChangeLayout(_ControlOrientation orientation)
4967 _ContainerImpl::OnChangeLayout(orientation);
4969 if (__pColorPicker.get())
4971 __pColorPicker->ChangeLayout(orientation);
4974 HideFormDataWindow();
4976 std::unique_ptr< IEnumerator > pEnum(__webNotificationList.GetEnumeratorN());
4977 _WebNotification* pWebNotification = null;
4979 while (pEnum->MoveNext() == E_SUCCESS)
4981 pWebNotification = static_cast< _WebNotification* >(pEnum->GetCurrent());
4982 pWebNotification->OnChangeLayout();
4985 if (IsKeypadVisible())
4987 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
4988 SysAssertf(pXformer, "Failed to get CoordinateTransformer");
4990 _FormImpl* pFormImpl = GetParentFormImpl(dynamic_cast< _ControlImpl* >(this));
4991 pFormImpl->DeflateClientRectHeight(pXformer->TransformVertical(GetPreviousKeypadBounds().height));
4997 _WebImpl::OnAncestorVisibleStateChanged(const _Control& control)
4999 Evas_Object* pWebview = __pWebCore->GetWebNativeNode();
5005 _WebManager* pWebManager = _WebManager::GetInstance();
5006 if (IsVisible() == true)
5008 pWebManager->SetActiveWeb(this);
5009 ewk_view_page_visibility_state_set(pWebview, EWK_PAGE_VISIBILITY_STATE_VISIBLE, false);
5013 pWebManager->RemoveActiveWeb(this);
5014 ewk_view_page_visibility_state_set(pWebview, EWK_PAGE_VISIBILITY_STATE_HIDDEN, false);
5020 _WebImpl::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
5022 _ContainerImpl::OnUserEventReceivedN(requestId, pArgs);
5026 case ID_CERTIFICATE_CONFIRM_POPUP_CLOSE:
5027 __pCertConfirmPopup.reset();
5029 case ID_PROMPT_POPUP_CLOSE:
5030 __pPromptPopup.reset();
5032 case ID_USER_CONFIRM_USERMEDIA_CLOSE:
5033 __pUserMediaConfirmPopup.reset();
5035 case ID_USER_CONFIRM_GEOLOCATION_CLOSE:
5036 __pGeolocationConfirmPopup.reset();
5038 case ID_USER_CONFIRM_NOTIFICATION_CLOSE:
5039 __pNotificationConfirmPopup.reset();
5041 case ID_USER_SCRIPT_ALERT_CLOSE:
5042 __pScriptAlertConfirmPopup.reset();
5044 case ID_USER_SCRIPT_CONFIRM_CLOSE:
5045 __pScriptConfirmPopup.reset();
5056 _WebImpl::GetDownloadHandler(void) const
5058 return __pWebDownloadHandler.get();
5063 _WebImpl::HideColorPicker(void)
5065 __pColorPicker.reset();
5074 _WebImpl::ShowColorPicker(int red, int green, int blue, int alpha, Color& color)
5076 result r = E_SUCCESS;
5078 std::unique_ptr<_InputPickerPopup> pColorHadler(new (std::nothrow) _InputPickerPopup());
5079 SysTryReturnResult(NID_WEB_CTRL, pColorHadler.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
5081 Tizen::Graphics::Color colorVal(static_cast< byte >(red), static_cast< byte >(green), static_cast< byte >(blue), static_cast< byte >(alpha));
5083 r = pColorHadler->Construct(colorVal, this);
5084 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5086 __pColorPicker = std::move(pColorHadler);
5088 r = __pColorPicker->ShowPopup();
5089 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5093 color = __pColorPicker->GetColor();
5099 __pColorPicker.reset();
5108 _WebImpl::ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue, String& dateStr)
5110 result r = E_SUCCESS;
5112 std::unique_ptr<_InputPickerPopup> pInputPicker(new (std::nothrow) _InputPickerPopup());
5113 SysTryReturnResult(NID_WEB_CTRL, pInputPicker.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
5115 r = pInputPicker->Construct(String(inputValue), inputType, this);
5116 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5118 __pDatePicker = std::move(pInputPicker);
5120 r = __pDatePicker->ShowPopup();
5121 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5125 dateStr = __pDatePicker->GetDate();
5131 __pDatePicker.reset();
5140 _WebImpl::GetInstance(Web* pWeb)
5142 return dynamic_cast< _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
5147 _WebImpl::GetInstance(const Web* pWeb)
5149 return dynamic_cast< const _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
5154 _WebImpl::SearchHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
5156 int checkReturn = 0;
5158 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5161 if( checkmime == true)
5163 table = CUSTOM_CONTENT_TABLE_NAME;
5167 table = CUSTOM_PROTOCOL_TABLE_NAME;
5170 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
5171 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
5172 String target(ewk_custom_handlers_data_target_get(pHandlerData));
5174 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
5176 result r = db.Construct(handlerPath, "r+", null);
5177 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5179 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"'"));
5180 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5184 r = pEnum->MoveNext();
5185 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5186 r = pEnum->GetIntAt(0, checkReturn);
5187 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
5199 _WebImpl::UnregistrationHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
5203 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5206 if( checkmime == true)
5208 table = CUSTOM_CONTENT_TABLE_NAME;
5212 table = CUSTOM_PROTOCOL_TABLE_NAME;
5215 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
5216 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
5217 String target(ewk_custom_handlers_data_target_get(pHandlerData));
5219 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
5221 result r = db.Construct(handlerPath, "r+", null);
5222 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5224 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"'"));
5225 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5229 r = pEnum->MoveNext();
5230 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5231 r = pEnum->GetIntAt(0, checkId);
5232 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5234 std::unique_ptr<DbStatement> pDeleteStmt(db.CreateStatementN(L"Delete From " + table + L" Where id = (?)"));
5235 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
5237 r = pDeleteStmt->BindInt(0, checkId);
5238 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5240 db.BeginTransaction();
5242 std::unique_ptr<DbEnumerator> pEnum(db.ExecuteStatementN(*pDeleteStmt));
5244 db.CommitTransaction();
5251 const Tizen::Base::String
5252 _WebImpl::GetProtocolFromUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri)
5254 if (originUri == L"" || currentUri == L"")
5259 result r = E_SUCCESS;
5262 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5263 String originReplace(originUri);
5264 String table(CUSTOM_PROTOCOL_TABLE_NAME);
5268 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
5269 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5271 r = currentUri.SubString(0, found + 1, baseUri);
5272 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5274 r = db.Construct(handlerPath, "r+", null);
5275 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5277 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select mime, url, allow From " + table + L" Where baseUrl = '" + baseUri + "'"));
5278 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, L"", GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
5282 while (pEnum->MoveNext() == E_SUCCESS)
5287 String originScheme;
5289 r = pEnum->GetStringAt(0, protocol);
5290 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5292 r = pEnum->GetStringAt(1, queryUrl);
5293 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5295 r = pEnum->GetIntAt(2, allow);
5296 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5303 String protocolScheme(protocol + L":");
5305 r = originReplace.SubString(0, protocolScheme.GetLength(), originScheme);
5306 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5308 if ((originReplace.GetLength() >= protocolScheme.GetLength()) && originScheme.Equals(protocolScheme, false))
5310 if (queryUrl.IndexOf(L"%s", 0, foundQuery) == E_SUCCESS)
5312 r = originReplace.Replace(originScheme, "");
5313 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5315 queryUrl.Replace("%s", originReplace, 0);
5316 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5328 const Tizen::Base::String
5329 _WebImpl::GetRedirectUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri, const Tizen::Base::String& mime)
5331 if (originUri == L"" || currentUri == L"" || mime == L"")
5336 result r = E_SUCCESS;
5339 String originUrlStr = originUri;
5340 const String replaceStr = L"%s";
5342 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
5343 String table(CUSTOM_CONTENT_TABLE_NAME);
5347 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
5348 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5350 r = currentUri.SubString(0, found + 1, baseUri);
5351 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5353 r = db.Construct(handlerPath, "r+", null);
5354 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5356 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select allow, url From " + table + L" Where baseUrl = '" + baseUri + "' AND mime = '" + mime + L"'"));
5360 r = pEnum->MoveNext();
5361 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5362 r = pEnum->GetIntAt(0, allow);
5363 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5364 r = pEnum->GetStringAt(1, contentUrl);
5365 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5373 if (contentUrl != L"")
5375 r = contentUrl.Replace(replaceStr, originUrlStr, 0);
5376 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
5388 _WebImpl::SetFormDataList(Eina_List* pFormDataList)
5390 __pFormDataList = pFormDataList;
5395 _WebImpl::IsFormDataWindowVisible(void) const
5397 return __isFormDataVisible;
5402 _WebImpl::ShowFormDataWindow(const Rectangle& windowRect, Evas_Object* pWebView)
5404 Rectangle rect(_CoordinateSystemUtils::InverseTransform(Rectangle(windowRect.x, windowRect.y + windowRect.height, windowRect.width, windowRect.height)));
5406 if (__isFormDataVisible)
5408 result r = __pFormDataWindow->UpdateList(__pFormDataList, rect);
5409 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5413 __pFormDataWindow.reset();
5415 std::unique_ptr<_FormDataWindow> pFormDataWindow( new (std::nothrow) _FormDataWindow());
5416 SysTryReturnResult(NID_WEB_CTRL, pFormDataWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
5418 result r = pFormDataWindow->Construct(rect, this, pWebView);
5419 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5421 r = pFormDataWindow->UpdateList(__pFormDataList, rect);
5422 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5424 r = pFormDataWindow->LaunchFormDataWindow();
5425 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5427 __pFormDataWindow = std::move(pFormDataWindow);
5428 __isFormDataVisible = true;
5436 _WebImpl::HideFormDataWindow(bool delWindow)
5440 __pFormDataWindow.reset();
5443 __isFormDataVisible = false;
5448 _WebImpl::ClearWebNotification(_WebNotification* pWebNotification)
5450 __webNotificationList.Remove(*pWebNotification);
5455 _WebImpl::SetWebNotification(_WebNotification* pWebNotification)
5457 __webNotificationList.Add(pWebNotification);
5461 }}} // Tizen::Web::Controls