2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FWebCtrl_WebImpl.cpp
20 * @brief The file contains the definition of _WebImpl class.
22 * The file contains the definition of _WebImpl class.
24 #include <Ecore_IMF_Evas.h>
25 #include <Ecore_Evas.h>
26 #include <elm_config.h>
29 #include <ewk_popup_menu_item.h>
30 #include <libsoup/soup-status.h>
32 #include <FAppAppControl.h>
33 #include <FAppIAppControlListener.h>
34 #include <FBaseColAllElementsDeleter.h>
35 #include <FBaseColHashMapT.h>
36 #include <FBaseRtMutex.h>
37 #include <FBaseRtMutexGuard.h>
38 #include <FBaseSysLog.h>
39 #include <FBaseUtilUri.h>
40 #include <FCntDownloadRequest.h>
41 #include <FGrpColor.h>
42 #include <FGrpPoint.h>
43 #include <FGrpRectangle.h>
44 #include <FIoDbEnumerator.h>
45 #include <FIoDbStatement.h>
47 #include <FMediaImage.h>
48 #include <FMediaImageTypes.h>
49 #include <FNetHttpHttpHeader.h>
50 #include <FSysVibrator.h>
51 #include <FUiControl.h>
52 #include <FUiCtrlKeypad.h>
53 #include <FWebCtrlHitElementResult.h>
54 #include <FWebCtrlITextSearchListener.h>
55 #include <FWebCtrlIWebDownloadListener.h>
56 #include <FWebCtrlIWebUiEventListener.h>
57 #include <FWebCtrlIWebUiEventListenerF.h>
58 #include <FWebCtrlIWebKeypadEventListener.h>
59 #include <FWebCtrlIJavaScriptBridge.h>
60 #include <FWebCtrlPageNavigationList.h>
61 #include <FWebCtrlAuthenticationChallenge.h>
62 #include <FWebCtrlWeb.h>
63 #include <FWebCtrlWebSetting.h>
64 #include <FWebHistoryItem.h>
65 #include <FWebJsonJsonObject.h>
66 #include <FWebJsonJsonParser.h>
67 #include <FWebJsonJsonString.h>
68 #include <FApp_AppControlImpl.h>
69 #include <FApp_AppControlManager.h>
70 #include <FApp_AppInfo.h>
71 #include <FApp_AppManagerImpl.h>
72 #include <FBase_StringConverter.h>
73 #include <FCnt_DownloadManagerImpl.h>
74 #include <FGrp_CoordinateSystem.h>
75 #include <FGrp_Screen.h>
76 #include <FIo_DatabaseImpl.h>
77 #include <FIo_NormalFile.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_Form.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_GeolocationPermissionManagerImpl.h"
95 #include "FWebCtrl_HitElementResultImpl.h"
96 #include "FWebCtrl_InputPickerPopup.h"
97 #include "FWebCtrl_WebNotification.h"
98 #include "FWebCtrl_PageNavigationListImpl.h"
99 #include "FWebCtrl_PromptPopup.h"
100 #include "FWebCtrl_SelectBox.h"
101 #include "FWebCtrl_Utility.h"
102 #include "FWebCtrl_Web.h"
103 #include "FWebCtrl_WebDataHandler.h"
104 #include "FWebCtrl_WebEvent.h"
105 #include "FWebCtrl_WebEventArg.h"
106 #include "FWebCtrl_WebImpl.h"
107 #include "FWebCtrl_WebPresenter.h"
108 #include "FWebCtrl_WebSettingImpl.h"
111 using namespace Tizen::App;
112 using namespace Tizen::Base;
113 using namespace Tizen::Base::Collection;
114 using namespace Tizen::Base::Runtime;
115 using namespace Tizen::Base::Utility;
116 using namespace Tizen::Content;
117 using namespace Tizen::Graphics;
118 using namespace Tizen::Io;
119 using namespace Tizen::Media;
120 using namespace Tizen::Net::Http;
121 using namespace Tizen::System;
122 using namespace Tizen::Ui;
123 using namespace Tizen::Ui::Animations;
124 using namespace Tizen::Ui::Controls;
125 using namespace Tizen::Web::Json;
128 namespace Tizen { namespace Web { namespace Controls
132 static const char WEB_CTRL[] = "webcontrol";
133 static const char PARENT_WEB_CTRL[] = "parentwebcontrol";
136 static const float MIN_ZOOM_LEVEL = 0.3;
137 static const float MAX_ZOOM_LEVEL = 2;
140 static const int REDIRECTION_HEADER_GROUP = 300;
143 static const int MAX_TEXT_MATCH = pow(2, 31) - 1;
146 static const int PORTRAIT_KEYPAD_HEIGHT = 444;
147 static const int LANDSCAPE_KEYPAD_HEIGHT = 316;
148 static const int DEFAULT_LIST_ITEM_COUNT = 4;
152 AddHttpHeaderData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData)
154 result r = E_SUCCESS;
156 String key(reinterpret_cast< const char* >(pKey));
157 String value(reinterpret_cast< char* >(pValue));
159 SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", key.GetPointer(), value.GetPointer());
161 r = reinterpret_cast< HttpHeader* >(pUserData)->AddField(key, value);
162 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
169 AddHttpAttributeData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData)
171 result r = E_SUCCESS;
173 std::unique_ptr<String> pAttrKey(new (std::nothrow) String(reinterpret_cast< char* >(const_cast< void* >(pKey))));
174 std::unique_ptr<String> pAttrValue(new (std::nothrow) String(reinterpret_cast< char* >(pValue)));
175 SysTryReturn(NID_WEB_CTRL, pAttrKey.get() && pAttrValue.get(), EINA_FALSE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
177 SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", pAttrKey->GetPointer(), pAttrValue->GetPointer());
179 r = reinterpret_cast< HashMap* >(pUserData)->Add(*pAttrKey, *pAttrValue);
180 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
182 pAttrValue.release();
189 FreeCharArray(void* pData)
191 delete[] reinterpret_cast<char*>(pData);
196 ConvertErrorCode(int error)
198 LoadingErrorType errorCode = WEB_ERROR_UNKNOWN;
202 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
204 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE:
206 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE_PROXY:
208 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT:
210 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT_PROXY:
212 case EWK_ERROR_NETWORK_STATUS_IO_ERROR:
214 case EWK_ERROR_NETWORK_STATUS_MALFORMED:
216 case EWK_ERROR_NETWORK_STATUS_TRY_AGAIN:
218 case EWK_ERROR_NETWORK_STATUS_TOO_MANY_REDIRECTS:
220 case EWK_ERROR_NETWORK_STATUS_TLS_FAILED:
222 case EWK_ERROR_NETWORK_STATUS_INTERNAL_SERVER_ERROR:
224 case EWK_ERROR_NETWORK_STATUS_BAD_GATEWAY:
226 case EWK_ERROR_NETWORK_STATUS_SERVICE_UNAVAILABLE:
228 case EWK_ERROR_NETWORK_STATUS_GATEWAY_TIMEOUT:
229 errorCode = WEB_NO_CONNECTION;
232 case EWK_ERROR_NETWORK_STATUS_BAD_REQUEST:
234 case EWK_ERROR_NETWORK_STATUS_REQUEST_URI_TOO_LONG:
235 errorCode = WEB_BAD_URL;
238 case EWK_ERROR_NETWORK_STATUS_FORBIDDEN:
239 errorCode = WEB_FILE_ACCESS_FAILED;
242 case EWK_ERROR_NETWORK_STATUS_REQUEST_TIMEOUT:
243 errorCode = WEB_REQUEST_TIMEOUT;
246 case EWK_ERROR_NETWORK_STATUS_UNSUPPORTED_MEDIA_TYPE:
247 errorCode = WEB_MIME_NOT_SUPPORTED;
250 case EWK_ERROR_NETWORK_STATUS_INSUFFICIENT_STORAGE:
251 errorCode = WEB_OUT_OF_MEMORY;
254 case EWK_ERROR_NETWORK_STATUS_REQUEST_ENTITY_TOO_LARGE:
255 errorCode = WEB_REQUEST_MAX_EXCEEDED;
258 case EWK_ERROR_NETWORK_STATUS_CONTINUE:
260 case EWK_ERROR_NETWORK_STATUS_SWITCHING_PROTOCOLS:
262 case EWK_ERROR_NETWORK_STATUS_PROCESSING:
264 case EWK_ERROR_NETWORK_STATUS_OK:
266 case EWK_ERROR_NETWORK_STATUS_CREATED:
268 case EWK_ERROR_NETWORK_STATUS_ACCEPTED:
270 case EWK_ERROR_NETWORK_STATUS_NON_AUTHORITATIVE:
272 case EWK_ERROR_NETWORK_STATUS_NO_CONTENT:
274 case EWK_ERROR_NETWORK_STATUS_RESET_CONTENT:
276 case EWK_ERROR_NETWORK_STATUS_PARTIAL_CONTENT:
278 case EWK_ERROR_NETWORK_STATUS_MULTI_STATUS:
280 case EWK_ERROR_NETWORK_STATUS_MULTIPLE_CHOICES:
282 case EWK_ERROR_NETWORK_STATUS_MOVED_PERMANENTLY:
284 case EWK_ERROR_NETWORK_STATUS_FOUND:
286 case EWK_ERROR_NETWORK_STATUS_SEE_OTHER:
288 case EWK_ERROR_NETWORK_STATUS_NOT_MODIFIED:
290 case EWK_ERROR_NETWORK_STATUS_USE_PROXY:
292 case EWK_ERROR_NETWORK_STATUS_NOT_APPEARING_IN_THIS_PROTOCOL:
294 case EWK_ERROR_NETWORK_STATUS_TEMPORARY_REDIRECT:
295 errorCode = WEB_HTTP_RESPONSE;
298 case EWK_ERROR_NETWORK_STATUS_SSL_FAILED:
299 errorCode = WEB_INVALID_CERTIFICATE;
303 errorCode = WEB_ERROR_UNKNOWN;
312 FireLoadingErrorOccurredEvent(_WebImpl* pImpl, int code, const char* pDescription)
314 result r = E_SUCCESS;
316 std::unique_ptr<Integer> pErrorCode(new (std::nothrow) Integer(code));
317 std::unique_ptr<String> pErrorDescription(new (std::nothrow) String(pDescription));
318 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED));
319 SysTryReturnResult(NID_WEB_CTRL, pErrorCode.get() && pErrorDescription.get() && pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
321 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_TYPE, *pErrorCode.get());
322 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
323 pErrorCode.release();
325 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_MESSAGE, *pErrorDescription.get());
326 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
327 pErrorDescription.release();
329 r = pImpl->GetWebEvent()->FireAsync(*pEventArg);
330 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
338 OnScriptAlertRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
340 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
342 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
343 String msg(pMessage);
345 result r = pImpl->ShowUserConfirmPopupAsync(USER_SCRIPT_ALERT, pView, msg);
346 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
350 ewk_view_javascript_alert_reply(pView);
356 OnScriptConfirmRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
358 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
360 result r = E_SUCCESS;
361 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
362 String msg(pMessage);
364 MessageBox messageBox;
365 r = messageBox.Construct(L"", msg, MSGBOX_STYLE_OKCANCEL);
366 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
370 messageBox.SetOwner(&pImpl->GetPublic());
372 r = messageBox.ShowAndWait(modalResult);
373 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
375 if (modalResult == MSGBOX_RESULT_OK)
377 ewk_view_javascript_confirm_reply(pView, EINA_TRUE);
381 ewk_view_javascript_confirm_reply(pView, EINA_FALSE);
389 OnScriptPromptRequested(Evas_Object* pView, const char* pMessage, const char* pDefaultValue, void* pUserData)
391 SysLog(NID_WEB_CTRL, "The current value of message is %s, defaulValue is %s", pMessage, pDefaultValue);
393 result r = E_SUCCESS;
394 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
395 String msg(pMessage);
396 String defVal(pDefaultValue);
398 std::unique_ptr< _PromptPopup > pPromptPopup(new (std::nothrow) _PromptPopup());
399 SysTryCatch(NID_WEB_CTRL, pPromptPopup.get(), , E_OUT_OF_MEMORY, "Memory allocation failed.");
401 r = pPromptPopup->Construct(msg, defVal, pView);
402 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
404 pPromptPopup->SetOwner(&pImpl->GetPublic());
406 r = pPromptPopup->ShowPopup();
407 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
409 pPromptPopup.release();
414 ewk_view_javascript_prompt_reply(pView, null);
421 OnCertificateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
423 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
424 Ewk_Certificate_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Certificate_Policy_Decision* >(pEventInfo);
425 SysAssertf(pImpl && pPolicy, "Failed to request");
427 switch (pImpl->GetSetting().GetCertificateErrorHandlingMode())
429 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM:
431 if (pImpl->IsCertificateRequested())
433 ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast< Eina_Bool >(pImpl->IsCertificateConfirmed()));
437 result r = E_SUCCESS;
439 r = pImpl->ShowCertificateConfirmPopup(CERTIFICATE_POPUP_MODE_USER_CONFIRM, pPolicy);
440 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
442 pImpl->SetCertificateRequested(true);
445 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CANCEL:
447 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE);
449 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE :
450 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_TRUE);
459 OnHttpAuthenticationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
461 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
462 Ewk_Auth_Challenge* pChallenge = reinterpret_cast< Ewk_Auth_Challenge* >(pEventInfo);
463 SysAssertf(pImpl && pChallenge, "Failed to request");
465 result r = E_SUCCESS;
467 r = pImpl->HttpAuthenticationRequested(pChallenge);
468 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
472 ewk_auth_challenge_credential_cancel(pChallenge);
473 evas_object_smart_callback_call(pView, "authentication,canceled", NULL);
478 OnHttpAuthenticationCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
480 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
481 SysAssertf(pImpl , "Failed to request");
483 if (pImpl->GetLoadingListener())
485 result r = E_SUCCESS;
487 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED));
488 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
490 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
491 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
497 OnApplicationCachePermissionRequested(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, void* pUserData)
499 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
500 SysAssertf(pImpl , "Failed to request");
502 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
504 result r = msg.Format(256, L"Allow %s to use offline application cache?", pHostName);
505 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
507 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_APP_CACHE, pView, msg);
508 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
515 OnIndexedDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData)
517 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
518 SysAssertf(pImpl , "Failed to request");
520 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
522 result r = msg.Format(512, L"%s Used %lld of storage. Allow %s to use upto 2GB of indexed db?", pHostName, currentQuota, pHostName);
523 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
525 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_INDEXED_DB_QUOTA_EXCEDED, pView, msg);
526 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
533 OnDatabaseQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, const char* database_name, unsigned long long expectedQuota, void* pUserData)
535 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
536 SysAssertf(pImpl , "Failed to request");
538 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
540 result r = msg.Format(512, L"Allow %s to open %s use upto %lld of web database?", pHostName, database_name, expectedQuota);
541 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
543 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_DB_QUOTA_EXCEDED, pView, msg);
544 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
550 Eina_Bool OnLocalFileSystemQuotaExceeded(Evas_Object* pView, Ewk_Security_Origin* pSecOrigin, long long currentQuota, void* pUserData)
552 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
553 SysAssertf(pImpl , "Failed to request");
555 const char* pHostName = ewk_security_origin_host_get(pSecOrigin);
557 result r = msg.Format(512, L"%s Used %lld of storgae. Allow %s to use upto 2GB of file system?", pHostName, currentQuota, pHostName);
558 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
560 r = pImpl->ShowUserConfirmPopup(USER_CONFIRM_LOCAL_FS_QUOTA_EXCEDED, pView, msg);
561 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
568 OnGeolocationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
570 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
571 Ewk_Geolocation_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Geolocation_Permission_Request* >(pEventInfo);
572 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
574 if (pImpl->GetSetting().IsGeolocationEnabled())
576 result r = E_SUCCESS;
578 std::unique_ptr<DbEnumerator> pEnum;
580 String geolocationPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
581 String table(GEOLOCATION_TABLE_NAME);
584 const Ewk_Security_Origin* pSecurityOrigin = ewk_geolocation_permission_request_origin_get(pPermissionRequest);
585 String origin = _Utility::CreateOrigin(pSecurityOrigin);
587 r = db.Construct(geolocationPath, "r", null);
588 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
590 pEnum = std::unique_ptr<DbEnumerator>(db.QueryN(L"Select permission From " + table + L" Where origin = '" + origin + L"'"));
593 r = pEnum->MoveNext();
594 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
597 r = pEnum->GetIntAt(0, permission);
598 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
600 SysLog(NID_WEB_CTRL, "The current value of permission is %d", permission);
602 ewk_geolocation_permission_request_set(pPermissionRequest, static_cast < Eina_Bool >(permission));
606 ewk_geolocation_permission_request_suspend(pPermissionRequest);
608 r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_GEOLOCATION, pPermissionRequest);
609 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
616 ewk_geolocation_permission_request_set(pPermissionRequest, EINA_FALSE);
621 OnGetUserMediaPermissionRequsted(void* pUserData, Evas_Object* pView, void* pEventInfo)
623 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
624 Ewk_User_Media_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_User_Media_Permission_Request* >(pEventInfo);
625 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
627 result r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_USERMEDIA, pEventInfo);
628 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
632 ewk_user_media_permission_request_set(pPermissionRequest, EINA_FALSE);
637 OnNotificationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
639 result r = E_SUCCESS;
640 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
642 Ewk_Notification_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Notification_Permission_Request* >(pEventInfo);
643 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
645 ewk_notification_permission_request_suspend(pPermissionRequest);
647 r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_NOTIFICATION, pPermissionRequest);
648 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
652 ewk_notification_permission_request_set(pPermissionRequest, EINA_FALSE);
657 OnNotificationShow(void* pUserData, Evas_Object* pView, void* pEventInfo)
659 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
660 Ewk_Notification* pNotification = reinterpret_cast< Ewk_Notification* >(pEventInfo);
661 SysAssertf(pImpl && pNotification, "Failed to request");
663 result r = E_SUCCESS;
664 Ewk_Context* pContext = ewk_view_context_get(pView);
665 SysAssertf(pContext, "Failed to get webkit instance.");
666 uint64_t notificationId = ewk_notification_id_get(pNotification);
668 //ewk_notification_security_origin_get(pNotification)
670 const char* text = ewk_notification_body_get(pNotification);
671 SysSecureLog(NID_WEB_CTRL, "The current value of icon path is %s",ewk_notification_icon_url_get(pNotification));
673 std::unique_ptr<_WebNotification> pNotificationWindow( new (std::nothrow) _WebNotification());
674 SysTryReturnVoidResult(NID_WEB_CTRL, pNotificationWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
676 r = pNotificationWindow->Construct(pContext, notificationId, pImpl);
677 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Error propogated.", GetErrorMessage(r));
679 pNotificationWindow->SetText(String(text));
680 pNotificationWindow->LaunchNotification();
681 pNotificationWindow.release();
683 ewk_notification_showed(pContext, notificationId);
688 OnNotificationCancel(void* pUserData, Evas_Object* pView, void* pEventInfo)
690 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
691 uint64_t* pNotificationID = reinterpret_cast< uint64_t* >(pEventInfo);
692 SysAssertf(pImpl && pNotificationID, "Failed to request");
694 //ToDo : Where is ewk API for cancel operation?
699 OnProtocolHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
701 result r = E_SUCCESS;
702 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
703 SysAssertf(pImpl, "Failed to request");
705 r = pImpl->ShowUserConfirmPopup(USER_PROTOCOL_HANDLER, pEventInfo);
706 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
711 OnIsProtocolHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
713 int checkHandler = 0;
714 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
715 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
716 SysAssertf(pImpl && pHandlerData, "Failed to request");
718 checkHandler = pImpl->SearchHandler(pHandlerData, false);
719 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
720 switch (checkHandler)
725 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
728 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
731 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
739 OnProtocolHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
741 result r = E_SUCCESS;
742 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
743 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
744 SysAssertf(pImpl && pHandlerData, "Failed to request");
746 r = pImpl->UnregistrationHandler(pHandlerData, false);
747 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
752 OnContentHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
754 result r = E_SUCCESS;
755 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
756 SysAssertf(pImpl, "Failed to request");
758 r = pImpl->ShowUserConfirmPopup(USER_CONTENT_HANDLER, pEventInfo);
759 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
764 OnIsContentHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
766 int checkHandler = 0;
767 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
768 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
769 SysAssertf(pImpl && pHandlerData, "Failed to request");
771 checkHandler = pImpl->SearchHandler(pHandlerData, true);
772 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
774 switch (checkHandler)
779 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
782 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
785 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
794 OnContentHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
796 result r = E_SUCCESS;
797 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
798 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
799 SysAssertf(pImpl && pHandlerData, "Failed to request");
801 r = pImpl->UnregistrationHandler(pHandlerData, true);
802 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
807 OnVibrationRequested(uint64_t duration, void* pUserData)
809 result r = E_SUCCESS;
811 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
812 SysAssertf(pImpl, "Failed to request");
814 r = pImpl->VibrationRequested(duration);
815 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
820 OnVibrationCanceled(void* pUserData)
822 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
823 SysAssertf(pImpl, "Failed to request");
825 pImpl->VibrationCanceled();
830 OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
832 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
833 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
834 SysAssertf(pImpl && pPolicy, "Failed to request");
836 String url(ewk_policy_decision_url_get(pPolicy));
837 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls", url.GetPointer());
839 if (url == L"about:blank")
841 ewk_policy_decision_use(pPolicy);
845 if (pImpl->GetLoadingListener() && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy))
846 && !pImpl->IsRedirectRequested())
848 pImpl->SetCertificateRequested(false);
850 if (pImpl->GetTextSearchListener())
852 pImpl->DisableAsyncSearch();
855 WebNavigationType navigationType = WEB_NAVIGATION_OTHER;
856 Ewk_Policy_Navigation_Type ewkNavigationType = ewk_policy_decision_navigation_type_get(pPolicy);
858 switch (ewkNavigationType)
860 case EWK_POLICY_NAVIGATION_TYPE_LINK_CLICKED:
861 navigationType = WEB_NAVIGATION_LINK_CLICKED;
863 case EWK_POLICY_NAVIGATION_TYPE_FORM_SUBMITTED:
864 navigationType = WEB_NAVIGATION_FORM_SUBMITTED;
866 case EWK_POLICY_NAVIGATION_TYPE_BACK_FORWARD:
867 navigationType = WEB_NAVIGATION_BACKFORWARD;
869 case EWK_POLICY_NAVIGATION_TYPE_RELOAD:
870 navigationType = WEB_NAVIGATION_RELOAD;
872 case EWK_POLICY_NAVIGATION_TYPE_FORM_RESUBMITTED:
873 navigationType = WEB_NAVIGATION_FORM_RESUBMITTED;
875 case EWK_POLICY_NAVIGATION_TYPE_OTHER:
876 navigationType = WEB_NAVIGATION_OTHER;
882 if (pImpl->GetLoadingListener()->OnLoadingRequested(url, navigationType))
884 ewk_policy_decision_ignore(pPolicy);
890 String currentUrl(pImpl->GetUrl());
891 String redirectUrl(pImpl->GetProtocolFromUri(url, currentUrl));
892 if (redirectUrl != L"")
894 pImpl->LoadUrl(redirectUrl);
895 ewk_policy_decision_ignore(pPolicy);
903 String uriScheme(uri.GetScheme());
904 SysLog(NID_WEB_CTRL, "The current value of scheme is %ls", uriScheme.GetPointer());
906 if ((uriScheme != L"http") && (uriScheme != L"https") && (uriScheme != L"file"))
908 ewk_policy_decision_ignore(pPolicy);
910 if (uriScheme == L"")
915 result r = E_SUCCESS;
917 _WebEventType eventType = WEB_EVENT_REQUEST_UNKNOWN;
919 if (uriScheme == L"rtsp")
921 eventType = WEB_EVENT_REQUEST_RTSP;
923 else if (uriScheme == L"mailto")
925 eventType = WEB_EVENT_REQUEST_EMAIL;
927 else if (uriScheme == L"tel")
929 eventType = WEB_EVENT_REQUEST_TEL;
931 else if (uriScheme == L"sms" || uriScheme == L"smsto" )
933 eventType = WEB_EVENT_REQUEST_SMS;
935 else if (uriScheme == L"mms" || uriScheme == L"mmsto" )
937 eventType = WEB_EVENT_REQUEST_MMS;
940 std::unique_ptr<_WebEventArg> pEventArg(new _WebEventArg(eventType, url));
941 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
943 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
944 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
950 ewk_policy_decision_use(pPolicy);
955 OnLoadingStarted(void* pUserData, Evas_Object* pView, void* pEventInfo)
957 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
958 SysAssertf(pImpl, "Failed to request");
960 if (pImpl->GetLoadingListener())
962 result r = E_SUCCESS;
964 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_STARTED));
965 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
967 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
968 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
975 OnPageTitleReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
977 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
978 char* pTitle = reinterpret_cast< char* >(pEventInfo);
979 SysAssertf(pImpl, "Failed to request");
981 SysLog(NID_WEB_CTRL, "The current value of title is %s", pTitle);
983 if (pImpl->GetLoadingListener())
985 result r = E_SUCCESS;
987 std::unique_ptr<String> pPageTitle(new (std::nothrow) String(pTitle));
988 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED));
989 SysTryReturnVoidResult(NID_WEB_CTRL, pPageTitle.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
991 r = pEventArg->SetEventInfo(_LoadingEventArg::PAGE_TITLE, *pPageTitle.get());
992 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
993 pPageTitle.release();
995 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
996 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1003 OnEstimatedProgress(void* pUserData, Evas_Object* pView, void* pEventInfo)
1005 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1006 double* pProgress = reinterpret_cast< double* >(pEventInfo);
1007 SysAssertf(pImpl, "Failed to request");
1009 SysLog(NID_WEB_CTRL, "The current value of progress is %lf", *pProgress);
1011 if (pImpl->GetLoadingListener())
1013 result r = E_SUCCESS;
1015 std::unique_ptr<Integer> pProgressPercentage(new (std::nothrow) Integer(static_cast< int >(*pProgress * 100)));
1016 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PROGRESS));
1017 SysTryReturnVoidResult(NID_WEB_CTRL, pProgressPercentage.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1019 r = pEventArg->SetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS, *pProgressPercentage.get());
1020 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1021 pProgressPercentage.release();
1023 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1024 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1025 pEventArg.release();
1031 OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1033 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1034 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
1035 SysAssertf(pImpl && pPolicy, "Failed to request");
1037 result r = E_SUCCESS;
1039 const char* pUrl = ewk_policy_decision_url_get(pPolicy);
1040 int code = ewk_policy_decision_response_status_code_get(pPolicy);
1041 String mime(ewk_policy_decision_response_mime_get(pPolicy));
1042 SysSecureLog(NID_WEB_CTRL, "url : %s, mime : %ls, code : %d", pUrl, mime.GetPointer(), code);
1044 ILoadingListener* pLoadingListener = pImpl->GetLoadingListener();
1046 String url(ewk_policy_decision_url_get(pPolicy));
1049 if (pLoadingListener && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy)))
1051 const Eina_Hash* pHeader = ewk_policy_decision_response_headers_get(pPolicy);
1053 DecisionPolicy policy;
1054 HttpHeader httpHeader;
1056 if (code >= REDIRECTION_HEADER_GROUP && code < REDIRECTION_HEADER_GROUP + 100)
1058 pImpl->SetRedirectRequested(true);
1062 eina_hash_foreach(pHeader, AddHttpHeaderData, &httpHeader);
1063 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1065 policy = pLoadingListener->OnWebDataReceived(mime, httpHeader);
1066 pImpl->SetPolicyDecision(policy);
1069 switch (pImpl->GetPolicyDecision())
1071 case WEB_DECISION_CONTINUE:
1073 String currentUrl(pImpl->GetUrl());
1074 String redirectUrl(pImpl->GetRedirectUri(url, currentUrl, mime));
1075 if (redirectUrl != L"")
1077 pImpl->LoadUrl(redirectUrl);
1078 ewk_policy_decision_ignore(pPolicy);
1083 if (pImpl->IsMimeSupported(mime) || mime == L"")
1090 SysLog(NID_WEB_CTRL, "Launch native app to handle the mime");
1092 ewk_policy_decision_ignore(pPolicy);
1094 AppControl* pAppControl = null;
1095 _SelectBox selectBox;
1097 int selectedIndex = 0;
1099 std::unique_ptr<IList, AllElementsDeleter> pList(_AppManagerImpl::FindAppControlsN(NULL, NULL, &mime, NULL));
1103 appCount = pList->GetCount();
1106 r = selectBox.Construct(false, L"", appCount+1); //+1 for Downloader
1107 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1109 selectBox.AddListItem(L"Download", _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
1110 for (int i = 0; i < appCount; i++)
1112 pAppControl = dynamic_cast< AppControl* >(pList->GetAt(i));
1113 SysTryReturnVoidResult(NID_WEB_CTRL, pAppControl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1115 String text = pAppControl->GetAppName();
1116 SysLog(NID_WEB_CTRL, "AppName : %S", text.GetPointer());
1118 selectBox.AddListItem(text, _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
1120 r = selectBox.ShowAndWait(selectedIndex);
1121 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1123 if (selectedIndex == 0) //download
1125 RequestId reqId = 0;
1126 DownloadRequest request(pUrl);
1128 _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
1129 SysTryReturnVoidResult(NID_WEB_CTRL, pManagerImpl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1131 r = pManagerImpl->Start(request, reqId);
1132 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1134 else if (selectedIndex != -1) // -1 for cancel
1136 String path("path");
1137 String pathVal(pUrl);
1140 r = dataList.Construct();
1141 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1143 r = dataList.Add(path, pathVal);
1144 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1146 pAppControl = dynamic_cast< AppControl* >(pList->GetAt(selectedIndex));
1147 SysTryReturnVoidResult(NID_WEB_CTRL, pAppControl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1149 _AppControlImpl* pAcImpl = _AppControlImpl::GetInstance(*pAppControl);
1150 SysTryReturnVoidResult(NID_WEB_CTRL, pAcImpl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1152 r = pAcImpl->Start(null, null, &dataList, null);
1153 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1160 case WEB_DECISION_DOWNLOAD:
1162 ewk_policy_decision_ignore(pPolicy);
1164 _WebDataHandler* pDownloadHandler = pImpl->GetDownloadHandler();
1165 SysTryReturnVoidResult(NID_WEB_CTRL, pDownloadHandler, E_SYSTEM, "[%s] A system error has been occurred. Failed to get DownloadHandler.", GetErrorMessage(E_SYSTEM));
1167 Ewk_Context* pContext = ewk_view_context_get(pView);
1168 SysAssertf(pContext, "Failed to get webkit instance.");
1170 pDownloadHandler->StartDownload(pUrl);
1174 case WEB_DECISION_IGNORE:
1176 ewk_policy_decision_ignore(pPolicy);
1186 ewk_policy_decision_use(pPolicy);
1191 ewk_policy_decision_ignore(pPolicy);
1196 OnProgressCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1198 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1199 SysAssertf(pImpl, "Failed to request");
1201 if (pImpl->IsRedirectRequested())
1203 pImpl->SetRedirectRequested(false);
1206 if (pImpl->IsLoadingErrorOccurred())
1208 pImpl->SetLoadingErrorOccurred(false);
1209 evas_object_smart_callback_call(pView, "load,finished", NULL);
1215 OnLoadingErrorOccurred(void* pUserData, Evas_Object* pView, void* pEventInfo)
1217 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1218 Ewk_Error* pErrorData = reinterpret_cast< Ewk_Error* >(pEventInfo);
1219 SysAssertf(pImpl && pErrorData, "Failed to request");
1221 int code = ewk_error_code_get(pErrorData);
1222 const char* pDescription = ewk_error_description_get(pErrorData);
1224 SysLog(NID_WEB_CTRL, "The current value of code is %d, description is %s", code, pDescription);
1226 pImpl->SetLoadingErrorOccurred(true);
1229 case EWK_ERROR_CODE_FRAMELOADINTERRUPTEDBYPOLICYCHANGE:
1231 case EWK_ERROR_CODE_PLUGINWILLHANDLELOAD:
1234 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
1235 evas_object_smart_callback_call(pView, "load,stop", NULL);
1239 if (pImpl->GetLoadingListener())
1241 result r = E_SUCCESS;
1243 r = FireLoadingErrorOccurredEvent(pImpl, code, pDescription);
1244 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1252 OnLoadingCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
1254 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1255 SysAssertf(pImpl, "Failed to request");
1257 if (pImpl->GetLoadingListener())
1259 result r = E_SUCCESS;
1261 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_CANCELED));
1262 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1264 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1265 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1266 pEventArg.release();
1273 OnLoadingCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1275 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1276 SysAssertf(pImpl, "Failed to request");
1278 if (pImpl->GetLoadingListener())
1280 result r = E_SUCCESS;
1282 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_COMPLETED));
1283 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1285 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1286 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1287 pEventArg.release();
1294 OnLoadingCommitted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1296 evas_object_focus_set(pView, EINA_FALSE);
1301 OnFaviconReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1303 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1304 SysAssertf(pImpl, "Failed to request");
1306 if (pImpl->GetLoadingListener())
1308 result r = E_SUCCESS;
1310 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED));
1311 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1313 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1314 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1315 pEventArg.release();
1322 OnDidStartDownloadCallback(const char* pUrl, void* pUserData)
1324 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1325 SysAssertf(pUrl && pImpl != null, "Failed to request");
1327 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s", pUrl);
1332 FireWebPageShowRequestedEvent(_WebImpl* pImpl, int event)
1334 result r = E_SUCCESS;
1336 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1337 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1339 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1340 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1341 pEventArg.release();
1348 OnWebPageShowRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1350 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1351 SysAssertf(pImpl, "Failed to request");
1353 if (pImpl->GetUiEventListener())
1355 result r = E_SUCCESS;
1357 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED);
1358 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1360 if (pImpl->GetUiEventListenerF())
1362 result r = E_SUCCESS;
1364 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT);
1365 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1371 OnWebWindowCreateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1373 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(pUserData);
1374 Evas_Object** pChildView = reinterpret_cast< Evas_Object** >(pEventInfo);
1375 SysAssertf(pParentImpl && pChildView, "Failed to request");
1377 IWebUiEventListener* pUserUiListener = pParentImpl->GetUiEventListener();
1378 IWebUiEventListenerF* pUserUiListenerF = pParentImpl->GetUiEventListenerF();
1379 if (pUserUiListener)
1381 Web* pWeb = pUserUiListener->OnWebWindowCreateRequested();
1384 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1385 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1387 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1388 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1391 if (pUserUiListenerF)
1393 Web* pWeb = pUserUiListenerF->OnWebWindowCreateRequested();
1396 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1397 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1399 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1400 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1407 FireWebWindowClosedRequestedEvent(_WebImpl* pImpl, int event)
1409 result r = E_SUCCESS;
1411 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1412 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1414 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1415 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1416 pEventArg.release();
1423 OnWebWindowClosedRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1425 _WebImpl* pChildImpl = reinterpret_cast< _WebImpl* >(pUserData);
1426 SysAssertf(pChildImpl, "Failed to request");
1428 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, PARENT_WEB_CTRL));
1429 if (pParentImpl == null)
1434 if (pParentImpl->GetUiEventListener())
1436 result r = E_SUCCESS;
1438 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED);
1439 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1441 if (pParentImpl->GetUiEventListenerF())
1443 result r = E_SUCCESS;
1445 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT);
1446 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1452 FireWebPreventDefaultTriggeredEvent(_WebImpl* pImpl, int event, bool trigger)
1454 result r = E_SUCCESS;
1456 std::unique_ptr<Boolean> pPreventTrigger(new (std::nothrow) Boolean(trigger));
1457 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1458 SysTryReturnResult(NID_WEB_CTRL, pPreventTrigger.get() && pEventArg.get(), E_OUT_OF_MEMORY, " Memory allocation failed." );
1460 r = pEventArg->SetEventInfo(_WebUiEventArg::PREVENT_DEFAULT, *pPreventTrigger.get());
1461 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1462 pPreventTrigger.release();
1464 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1465 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1466 pEventArg.release();
1473 OnWebPreventDefaultTriggered(void* pUserData, Evas_Object* pView, void* pEventInfo)
1475 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1476 Eina_Bool* pTrigger = reinterpret_cast< Eina_Bool* >(pEventInfo);
1477 SysAssertf(pImpl && pTrigger, "Failed to request");
1479 if (pImpl->GetUiEventListener())
1481 result r = E_SUCCESS;
1483 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED, static_cast< bool >(*pTrigger));
1484 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1486 if (pImpl->GetUiEventListenerF())
1488 result r = E_SUCCESS;
1490 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT, static_cast< bool >(*pTrigger));
1491 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1497 FireWebPageBlockSelectedEvent(_WebImpl* pImpl)
1499 result r = E_SUCCESS;
1501 std::unique_ptr<Point> startPoint(new (std::nothrow) Point());
1502 std::unique_ptr<Point> endPoint(new (std::nothrow) Point());
1503 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1505 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1507 if ((endPoint->x != 0) && (endPoint->y != 0))
1509 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED));
1510 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1512 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1513 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1514 startPoint.release();
1516 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1517 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1520 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1521 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1522 pEventArg.release();
1530 FireWebPageBlockSelectedEventF(_WebImpl* pImpl)
1532 result r = E_SUCCESS;
1534 std::unique_ptr<FloatPoint> startPoint(new (std::nothrow) FloatPoint());
1535 std::unique_ptr<FloatPoint> endPoint(new (std::nothrow) FloatPoint());
1537 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1539 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1541 if ((endPoint->x != 0.0f) && (endPoint->y != 0.0f))
1543 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT));
1544 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1546 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1547 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1548 startPoint.release();
1550 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1551 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1554 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1555 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1556 pEventArg.release();
1564 OnWebPageBlockSelected(void* pUserData, Evas_Object* pView, void* pEventInfo)
1566 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1567 SysAssertf(pImpl, "Failed to request");
1569 if (pImpl->GetUiEventListener())
1571 result r = E_SUCCESS;
1573 r = FireWebPageBlockSelectedEvent(pImpl);
1574 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1576 if (pImpl->GetUiEventListenerF())
1578 result r = E_SUCCESS;
1580 r = FireWebPageBlockSelectedEventF(pImpl);
1581 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1587 OnWebPageBlockSelectedByOrientation(void* pUserData, Evas_Object* pView, void* pEventInfo)
1589 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1590 SysAssertf(pImpl, "Failed to request");
1592 if (!pImpl->IsOrientationChanged())
1597 pImpl->SetOrientationChanged(false);
1599 int orientation = 0;
1600 _ControlRotation rotation = _ControlManager::GetInstance()->GetOrientationStatus();
1603 case _CONTROL_ROTATION_0:
1606 case _CONTROL_ROTATION_90:
1609 case _CONTROL_ROTATION_180:
1612 case _CONTROL_ROTATION_270:
1616 ewk_view_orientation_send(pView, orientation);
1618 OnWebPageBlockSelected(pUserData, pView, pEventInfo);
1623 OnSelectUploadFile(Evas_Object* pView, Eina_Bool multipleFile, Eina_List* pAcceptTypes, const char* pCapture, void* pUserData)
1625 String isMultipleSelection(L"single");
1626 result r = E_SUCCESS;
1629 String mode(L"selectionType");
1630 String type(L"type");
1631 _AppControlImpl* pMediaAppControlImpl = null;
1634 String fileType = L"all";
1638 isMultipleSelection.Append(L"multiple");
1641 std::unique_ptr<AppControl> pMediaAppControl(_AppManagerImpl::FindAppControlN(L"tizen.filemanager", L"http://tizen.org/appcontrol/operation/pick"));
1642 SysTryReturn(NID_WEB_CTRL, pMediaAppControl.get(), EINA_TRUE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1644 std::unique_ptr<_MediaSelectionListener> pMediaListener(new (std::nothrow) _MediaSelectionListener());
1645 SysTryReturn(NID_WEB_CTRL, pMediaListener.get(), EINA_TRUE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1647 pMediaListener->Construct(pView, pMediaAppControl.get());
1649 itemCount = eina_list_count(pAcceptTypes);
1653 String item((char*)eina_list_nth(pAcceptTypes, 0));
1654 if (item.StartsWith("image/",0))
1656 fileType = L"image";
1658 else if (item.StartsWith("audio/",0))
1660 fileType = L"audio";
1662 else if (item.StartsWith("video/",0))
1664 fileType = L"video";
1668 r = dataList.Construct();
1669 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1671 r = dataList.Add(mode, isMultipleSelection);
1672 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1674 r = dataList.Add(type, fileType);
1675 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1677 pMediaAppControlImpl = _AppControlImpl::GetInstance(*pMediaAppControl.get());
1678 r = pMediaAppControlImpl->Start(null, null, &dataList, pMediaListener.get());
1679 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1681 pMediaListener.release();
1682 pMediaAppControl.release();
1687 ewk_view_open_panel_reply(pView, null, EINA_FALSE);
1693 OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo)
1695 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1696 char* pJsonText = reinterpret_cast< char* >(pEventInfo);
1697 SysAssertf(pImpl && pJsonText, "Failed to request");
1699 result r = E_SUCCESS;
1701 SysLog(NID_WEB_CTRL, "The current value of jsontext is %s", pJsonText);
1703 std::unique_ptr<_JsBridgeArg> pEventArg(new (std::nothrow) _JsBridgeArg());
1704 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1706 r = pEventArg->Construct(pJsonText);
1707 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1709 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1710 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1711 pEventArg.release();
1716 OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo)
1718 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1719 Eina_Rectangle* pEinaRect = reinterpret_cast< Eina_Rectangle* >(pEventInfo);
1720 SysAssertf(pImpl && pEinaRect, "Failed to request");
1722 if (pImpl->GetSetting().GetInputStyle() == INPUT_STYLE_OVERLAY)
1724 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1725 SysAssertf(pXformer, "Failed to get CoordinateTransformer");
1727 Rectangle rect(pEinaRect->x, pEinaRect->y, pEinaRect->w, pEinaRect->h);
1729 if (rect.height == 0)
1734 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1737 if (pFormCore->HasFooter() && pFormCore->IsFooterVisible())
1739 pImpl->SetFooterVisibleState(true);
1740 pFormCore->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, false);
1743 pFormCore->DeflateClientRectHeight(pXformer->TransformVertical(rect.height));
1746 if (pImpl->GetWebKeypadEventListener())
1748 if (pImpl->IsKeypadVisible() == true)
1750 if ((pImpl->GetPreviousKeypadBounds().width == rect.width) && (pImpl->GetPreviousKeypadBounds().height != rect.height))
1752 pImpl->GetWebKeypadEventListener()->OnWebKeypadBoundsChanged(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1757 pImpl->GetWebKeypadEventListener()->OnWebKeypadWillOpen(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1760 pImpl->SetKeypadVisibleState(true);
1761 pImpl->SetPreviousKeypadBounds(rect);
1765 result r = pImpl->SetFullScreenKeypad();
1766 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1772 OnWebKeypadOpened(void* pUserData, Evas_Object* pView, void* pEventInfo)
1774 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1775 SysAssertf(pImpl, "Failed to request");
1777 if (pImpl->GetWebKeypadEventListener())
1779 pImpl->GetWebKeypadEventListener()->OnWebKeypadOpened(*static_cast< Web* >(&pImpl->GetPublic()));
1785 OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo)
1787 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1788 SysAssertf(pImpl, "Failed to request");
1790 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1793 if (pFormCore->HasFooter() && pImpl->IsFooterVisible())
1795 pImpl->SetFooterVisibleState(false);
1796 pFormCore->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1799 pFormCore->DeflateClientRectHeight(0);
1802 if (pImpl->GetWebKeypadEventListener())
1804 pImpl->GetWebKeypadEventListener()->OnWebKeypadClosed(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1807 pImpl->SetKeypadVisibleState(false);
1812 OnWindowObjectFocusGained(void *pUserData, Evas_Object *pWin, void *pEvent_info)
1814 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1815 SysAssertf(pImpl, "Failed to request");
1817 if (pImpl->IsKeypadOpened() == true)
1819 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
1820 SysAssertf(pWebCore, "Failed to get Web core object");
1822 evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE);
1824 pImpl->SetKeypadOpened(false);
1830 OnWebNativeNodeFocusGained(void *pUserData, Evas *pCanvas, Evas_Object* pView, void* pEventInfo)
1832 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1833 SysAssertf(pImpl, "Failed to request");
1835 if (pImpl->IsKeypadOpened() == true)
1837 pImpl->SetKeypadOpened(false);
1843 OnColorPickerProviderRequested(Ewk_View_Smart_Data *pSmartData, int red, int green, int blue, int alpha)
1845 SysAssertf(pSmartData, "invalid smartdata");
1846 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1847 SysAssertf(pWebImpl, "Failed to get Impl");
1849 result r = E_SUCCESS;
1851 if (pWebImpl->GetColorpicker())
1858 r = pWebImpl->ShowColorPicker(red, green, blue, alpha, color);
1859 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1861 byte r1, g1, b1, a1;
1862 color.GetColorComponents(r1, g1, b1, a1);
1863 ewk_view_color_picker_color_set(pSmartData->self, r1, g1, b1, a1);
1870 OnColorPickerProviderDismissed(Ewk_View_Smart_Data *pSmartData)
1872 SysAssertf(pSmartData, "invalid smartdata");
1874 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1875 SysAssertf(pWebImpl, "Failed to get Impl");
1877 return pWebImpl->HideColorPicker();
1882 OnDatePickerProviderRequested(Ewk_View_Smart_Data *pSmartData, Ewk_Input_Type inputType, const char* inputValue)
1884 SysAssertf(pSmartData, "Failed to request");
1885 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1886 SysAssertf(pWebImpl, "Failed to get Impl");
1888 result r = E_SUCCESS;
1890 if (pWebImpl->GetDatepicker())
1892 ewk_view_focused_input_element_value_set(pSmartData->self, inputValue);
1899 r = pWebImpl->ShowDatePicker(inputType, inputValue, dateStr);
1900 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1902 std::unique_ptr<char[]> pDateStr(_StringConverter::CopyToCharArrayN(dateStr));
1903 SysTryReturn(NID_WEB_CTRL, pDateStr.get(), EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1905 ewk_view_focused_input_element_value_set(pSmartData->self, pDateStr.get());
1912 OnSelectBoxRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex)
1914 SysAssertf(pSmartData, "Failed to request");
1916 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1917 SysAssertf(pWebImpl, "Failed to get Impl");
1919 result r = pWebImpl->ShowSelectBoxPopup(false, L"", pItems, pSmartData->self, selectedIndex);
1920 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1927 OnSelectBoxClosed(Ewk_View_Smart_Data *pSmartData)
1929 SysAssertf(pSmartData, "invalid smartdata");
1931 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1932 SysAssertf(pWebImpl, "Failed to get Impl");
1934 result r = pWebImpl->ClearSelectBoxPopup();
1935 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1942 OnSelectBoxUpdateRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, Eina_List* pItems, int selectedIndex)
1944 SysAssertf(pSmartData, "invalid smartdata");
1946 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1947 SysAssertf(pWebImpl, "Failed to get Impl");
1949 result r = pWebImpl->UpdateSelectBoxPopup(pItems, selectedIndex, false);
1950 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1957 OnCookiesPolicyGot(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *pError, void *pUserData)
1959 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
1960 SysAssertf(pPresenter && !pError, "Failed to request");
1962 bool ret = EINA_TRUE;
1966 case EWK_COOKIE_ACCEPT_POLICY_ALWAYS:
1968 case EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY:
1972 case EWK_COOKIE_ACCEPT_POLICY_NEVER:
1981 SysLog(NID_WEB_CTRL, "The current value of policy is %d", ret);
1983 pPresenter->EndAsyncProcess(ret);
1988 OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData)
1990 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
1991 SysAssertf(pPresenter, "Failed to request");
1993 String result(pResult);
1994 SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer());
1996 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, WEB_CTRL));
1997 if (pImpl && pImpl->IsPresenterAlived(pPresenter))
1999 pPresenter->EndAsyncProcess(result);
2005 OnTextFound(void* pUserData, Evas_Object* pView, void* pEventInfo)
2007 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
2008 SysAssertf(pImpl, "Failed to request");
2010 int* pTotalCount = reinterpret_cast< int* >(pEventInfo);
2011 SysLog(NID_WEB_CTRL, "The current value of totalCount is %d", *pTotalCount);
2013 _WebPresenter* pWebPresenter = pImpl->GetSearchPresenter();
2017 pWebPresenter->EndAsyncProcess(*pTotalCount);
2021 if (pImpl->GetTextSearchListener())
2023 result r = E_SUCCESS;
2027 if (*pTotalCount > 0)
2029 ordinal = pImpl->GetAsyncSearchOrdinal();
2030 pImpl->SetAsyncSearchResult(*pTotalCount);
2033 if (pImpl->GetPendingAsyncSearchCount() > 0)
2038 std::unique_ptr<Integer> pCount(new (std::nothrow) Integer(*pTotalCount));
2039 std::unique_ptr<Integer> pOrdinal(new (std::nothrow) Integer(ordinal));
2040 std::unique_ptr<_TextSearchEventArg> pEventArg(new (std::nothrow) _TextSearchEventArg(WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND));
2041 SysTryReturnVoidResult(NID_WEB_CTRL, pCount.get() && pOrdinal.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2043 r = pEventArg->SetEventInfo(_TextSearchEventArg::TOTAL_COUNT, *pCount.get());
2044 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2047 r = pEventArg->SetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL, *pOrdinal.get());
2048 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2051 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
2052 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2053 pEventArg.release();
2059 class _JsBridgeHashCodeProvider
2060 : public Tizen::Base::Collection::IHashCodeProviderT< Tizen::Base::String >
2063 _JsBridgeHashCodeProvider(){}
2064 virtual ~_JsBridgeHashCodeProvider(void) {}
2067 int GetHashCode(const Tizen::Base::String& obj) const
2069 return obj.GetHashCode();
2075 //Comparer implementation
2076 class _JsBridgeComparer
2077 : public Tizen::Base::Collection::IComparerT< Tizen::Base::String >
2080 _JsBridgeComparer(){}
2081 virtual ~_JsBridgeComparer(void) {}
2084 result Compare(const Tizen::Base::String& obj1, const Tizen::Base::String& obj2, int& cmp) const
2101 _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
2102 : _ContainerImpl(pWeb, pCore)
2103 , __isFooterVisible(false)
2104 , __isKeypadVisible(false)
2105 , __isKeypadOpened(false)
2106 , __isLoadingErrorOccurred(false)
2107 , __isRedirectRequested(false)
2108 , __isCertificateRequested(false)
2109 , __isCertificateConfirmed(false)
2110 , __isOrientationChanged(false)
2111 , __keypadBounds(0, 0, 0, 0)
2113 , __pUserLoadingListener(null)
2114 , __pUserUiListener(null)
2115 , __pUserUiListenerF(null)
2116 , __pUserKeypadEventListener(null)
2117 , __pTextSearchListener(null)
2119 , __pJsBridgeList(null)
2120 , __pJsProvider(null)
2121 , __pJsComparer(null)
2122 , __pWebDownloadHandler(null)
2124 , __pAuthChallenge(null)
2125 , __pAuthPopup(null)
2126 , __pUserConfirmPopup(null)
2127 , __pCertConfirmPopup(null)
2128 , __pSelectBox(null)
2129 , __pDatePicker(null)
2130 , __pColorPicker(null)
2132 , __policy(WEB_DECISION_CONTINUE)
2133 , __defaultUserAgent(L"")
2135 __textSearch.__searchAll = false;
2136 __textSearch.__searchForward = true;
2137 __textSearch.__caseSensitive = false;
2138 __textSearch.__pending = 0;
2139 __textSearch.__currentIndex = 1;
2140 __textSearch.__totalCount = -1;
2141 __textSearch.__text = L"";
2145 _WebImpl::~_WebImpl()
2147 RemoveEventListenerCallback();
2151 _WebImpl::CreateWebImplN(Web* pControl, const Rectangle& bounds)
2153 result r = E_SUCCESS;
2155 r = GET_SIZE_INFO(Web).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2156 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2158 _Web* pCore = _Web::CreateWebN();
2159 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2161 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2163 r = CheckConstruction(pCore, pImpl);
2164 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2166 r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2167 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2169 r = pImpl->Construct();
2170 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2182 _WebImpl::CreateWebImplN(Web* pControl, const FloatRectangle& bounds)
2184 result r = E_SUCCESS;
2186 r = GET_SIZE_INFO(Web).CheckInitialSizeValidF(FloatDimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2187 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2189 _Web* pCore = _Web::CreateWebN();
2190 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2192 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2194 r = CheckConstruction(pCore, pImpl);
2195 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2197 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2198 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2200 r = pImpl->Construct();
2201 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2213 _WebImpl::Construct(void)
2215 result r = E_SUCCESS;
2217 r = __mutex.Create();
2218 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2220 r = __textSearch.__searchQueue.Construct();
2221 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2223 r = __callbackList.Construct();
2224 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2226 r = InitJsBridgeList();
2227 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2230 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2232 __pWebCore = dynamic_cast< _Web* >(&(GetCore()));
2233 SysTryReturnResult(NID_WEB_CTRL, __pWebCore, E_SYSTEM, "A system error has been occurred. Failed to get web control");
2240 _WebImpl::InitializeSetting(void)
2242 result r = E_SUCCESS;
2244 WebSetting* pWebSetting = __pWebCore->GetSetting();
2245 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(pWebSetting);
2247 SetCookieEnabled(pWebSettingImpl->IsCookieEnabled());
2248 SetPrivateBrowsingEnabled(pWebSettingImpl->IsPrivateBrowsingEnabled());
2249 SetZoomLevel(pWebSettingImpl->GetZoomLevel());
2251 __defaultUserAgent = pWebSettingImpl->GetUserAgent();
2253 r = SetSetting(*pWebSetting);
2254 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2256 SetEventListenerCallback();
2263 _WebImpl::IsLayoutable(void) const
2270 _WebImpl::InitWebEvent(void)
2272 __pWebEvent = std::unique_ptr<_WebEvent>(new (std::nothrow) _WebEvent());
2273 SysTryReturnResult(NID_WEB_CTRL, __pWebEvent.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2275 return __pWebEvent->Construct(*this);
2280 _WebImpl::GetWebEvent(void) const
2282 return __pWebEvent.get();
2287 _WebImpl::ConvertToSlpHeaderN(const HttpHeader& header) const
2289 Eina_Hash* pHttpHeader = null;
2291 std::unique_ptr<IList> pFieldNameList(header.GetFieldNamesN());
2292 if (pFieldNameList.get())
2294 pHttpHeader = eina_hash_string_small_new(FreeCharArray);
2295 SysTryReturn(NID_WEB_CTRL, pHttpHeader, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2297 int count = pFieldNameList->GetCount();
2299 for (int i = 0; i < count; i++)
2301 String* pFieldName = dynamic_cast< String* >(pFieldNameList->GetAt(i));
2302 SysTryCatch(NID_WEB_CTRL, pFieldName, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2304 std::unique_ptr<char[]> pKey(_StringConverter::CopyToCharArrayN(*pFieldName));
2305 SysTryCatch(NID_WEB_CTRL, pKey.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2307 std::unique_ptr<IEnumerator> pFieldValueEnum(header.GetFieldValuesN(*pFieldName));
2308 SysTryCatch(NID_WEB_CTRL, pFieldValueEnum.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2310 while (pFieldValueEnum->MoveNext() == E_SUCCESS)
2312 Eina_Bool ret = false;
2314 String* pFieldValue = dynamic_cast< String* >(pFieldValueEnum->GetCurrent());
2315 SysTryCatch(NID_WEB_CTRL, pFieldValue, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2317 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(*pFieldValue));
2318 SysTryCatch(NID_WEB_CTRL, pValue.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2320 ret = eina_hash_add(pHttpHeader, pKey.get(), pValue.release());
2321 SysTryCatch(NID_WEB_CTRL, ret == EINA_TRUE, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2328 eina_hash_free(pHttpHeader);
2335 _WebImpl::LoadUrl(const String& url) const
2337 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2338 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2340 ewk_view_url_set(__pWebCore->GetWebNativeNode(), pUrl.get());
2347 _WebImpl::LoadUrl(const String& url, const HttpHeader& header)
2349 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2350 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2352 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2354 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_GET, pHttpHeader, null);
2356 eina_hash_free(pHttpHeader);
2363 _WebImpl::LoadUrlWithPostRequest(const String& url, const HttpHeader& header, const ByteBuffer& body) const
2365 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2366 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2368 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2370 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_POST, pHttpHeader, reinterpret_cast< const char* >(body.GetPointer()));
2372 eina_hash_free(pHttpHeader);
2379 _WebImpl::LoadData(const String& baseUrl, const ByteBuffer& content, const String& mime, const String& encoding) const
2381 SysTryReturnResult(NID_WEB_CTRL, content.GetLimit() > 0, E_INVALID_ARG, "The content buffer is empty.");
2383 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(baseUrl));
2384 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
2385 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(encoding));
2386 SysTryReturn(NID_WEB_CTRL, pUrl.get() && pMime.get() && pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2388 ewk_view_contents_set(__pWebCore->GetWebNativeNode(), reinterpret_cast< const char* >(content.GetPointer()), content.GetLimit(), pMime.get(), pEncoding.get(), pUrl.get());
2395 _WebImpl::Pause(void)
2397 ewk_view_suspend(__pWebCore->GetWebNativeNode());
2402 _WebImpl::Resume(void)
2404 ewk_view_resume(__pWebCore->GetWebNativeNode());
2409 _WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List* pItems, Evas_Object* pWebView, int selectedIndex)
2411 __pSelectBox.reset();
2413 SysTryReturnResult(NID_WEB_CTRL, eina_list_count(pItems) > 0, E_SYSTEM, "ItemCount is invalid.");
2415 result r = E_SUCCESS;
2417 std::unique_ptr<_SelectBox> pSelectBox(new (std::nothrow) _SelectBox());
2418 SysTryReturnResult(NID_WEB_CTRL, pSelectBox.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2420 r = pSelectBox->Construct(isMultiSelect, title, DEFAULT_LIST_ITEM_COUNT, pWebView);
2421 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2423 r = pSelectBox->UpdateList(pItems, selectedIndex, false, false);
2424 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2426 __pSelectBox = std::move(pSelectBox);
2428 __pSelectBox->SetOwner(&GetPublic());
2430 return __pSelectBox->ShowPopup();
2435 _WebImpl::UpdateSelectBoxPopup(Eina_List* pItems, int selectedIndex, bool isGroupedList)
2437 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2439 return __pSelectBox->UpdateList(pItems, selectedIndex, true, isGroupedList);
2444 _WebImpl::ClearSelectBoxPopup(void)
2446 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2448 __pSelectBox.reset();
2455 _WebImpl::GetDatepicker(void)
2457 _InputPickerPopup* pInputPicker =null;
2460 pInputPicker = __pDatePicker.get();
2462 return pInputPicker;
2467 _WebImpl::GetColorpicker(void)
2469 _InputPickerPopup* pInputPicker =null;
2472 pInputPicker = __pColorPicker.get();
2474 return pInputPicker;
2479 _WebImpl::CanGoBack(void) const
2481 return static_cast< bool >(ewk_view_back_possible(__pWebCore->GetWebNativeNode()));
2486 _WebImpl::CanGoForward(void) const
2488 return static_cast< bool >(ewk_view_forward_possible(__pWebCore->GetWebNativeNode()));
2493 _WebImpl::GoBack(void) const
2495 ewk_view_back(__pWebCore->GetWebNativeNode());
2500 _WebImpl::GoForward(void) const
2502 ewk_view_forward(__pWebCore->GetWebNativeNode());
2507 _WebImpl::GetUrl(void) const
2509 return ewk_view_url_get(__pWebCore->GetWebNativeNode());
2514 _WebImpl::GetTitle(void) const
2516 return ewk_view_title_get(__pWebCore->GetWebNativeNode());
2521 _WebImpl::StopLoading(void) const
2523 ewk_view_stop(__pWebCore->GetWebNativeNode());
2528 _WebImpl::Reload(void) const
2530 ewk_view_reload_bypass_cache(__pWebCore->GetWebNativeNode());
2535 _WebImpl::EvaluateJavascriptN(const String& scriptCode)
2537 if (scriptCode.GetLength() == 0)
2542 result r = E_SUCCESS;
2544 std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(scriptCode));
2545 SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2547 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter());
2548 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2550 r = __callbackList.Add(pPresenter.get());
2551 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2553 ewk_view_script_execute(__pWebCore->GetWebNativeNode(), pScript.get(), OnScriptExecuted, pPresenter.get());
2555 std::unique_ptr<String> pResult(new (std::nothrow) String(L""));
2556 SysTryReturn(NID_WEB_CTRL, pResult.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2557 pPresenter->WaitAsyncProcess(*pResult.get());
2559 r = __callbackList.Remove(*pPresenter.get());
2560 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2561 pPresenter.release();
2563 return pResult.release();
2568 _WebImpl::IsPresenterAlived(_WebPresenter* pPresenter) const
2570 return __callbackList.Contains(*pPresenter);
2575 _WebImpl::SetZoomLevel(float level)
2577 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);
2579 ewk_view_scale_set(__pWebCore->GetWebNativeNode(), static_cast< double >(level), 0, 0);
2586 _WebImpl::GetZoomLevel(void) const
2588 return static_cast< float >(ewk_view_scale_get(__pWebCore->GetWebNativeNode()));
2592 const PageNavigationList*
2593 _WebImpl::GetBackForwardListN(void) const
2595 result r = E_SUCCESS;
2597 _PageNavigationListImpl* pNavigationListImpl = null;
2598 _HistoryItemImpl* pHistoryItemImpl = null;
2600 std::unique_ptr<PageNavigationList> pNavigationList;
2601 std::unique_ptr<ArrayList, AllElementsDeleter> pHistoryList;
2604 int forwardCount = 0;
2609 Ewk_History* pEwkHistoryList = ewk_view_history_get(__pWebCore->GetWebNativeNode());
2610 SysTryReturn(NID_WEB_CTRL, pEwkHistoryList, null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get full history.", GetErrorMessage(E_SYSTEM));
2612 Ewk_History_Item* pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, 0);
2613 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_DATA_NOT_FOUND, "[%s] There is no history.", GetErrorMessage(E_DATA_NOT_FOUND));
2615 pNavigationList = std::unique_ptr<PageNavigationList>(new (std::nothrow) PageNavigationList());
2616 SysTryCatch(NID_WEB_CTRL, pNavigationList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2618 pNavigationListImpl = _PageNavigationListImpl::GetInstance(pNavigationList.get());
2619 SysTryCatch(NID_WEB_CTRL, pNavigationListImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2621 pHistoryList = std::unique_ptr<ArrayList, AllElementsDeleter>(new (std::nothrow) ArrayList());
2622 SysTryCatch(NID_WEB_CTRL, pHistoryList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2624 r = pHistoryList->Construct();
2625 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2627 backCount = ewk_history_back_list_length_get(pEwkHistoryList);
2628 forwardCount = ewk_history_forward_list_length_get(pEwkHistoryList);
2629 SysLog(NID_WEB_CTRL, "The current value of backCount is %d, forwardCount is %d", backCount, forwardCount);
2631 for (int i = -backCount; i < forwardCount + 1; i++)
2633 std::unique_ptr<HistoryItem> pHistoryItem(new (std::nothrow) HistoryItem());
2634 SysTryCatch(NID_WEB_CTRL, pHistoryItem.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2636 pHistoryItemImpl = _HistoryItemImpl::GetInstance(pHistoryItem.get());
2637 SysTryCatch(NID_WEB_CTRL, pHistoryItemImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2639 pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, i);
2640 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2642 url = ewk_history_item_uri_get(pEwkItem);
2643 title = ewk_history_item_title_get(pEwkItem);
2644 SysSecureLog(NID_WEB_CTRL, "The current value of url is %s, title is %s", url.GetPointer(), title.GetPointer());
2646 pHistoryItemImpl->SetHistoryItem(url, title);
2648 r = pHistoryList->Add(*pHistoryItem.get());
2649 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2650 pHistoryItem.release();
2653 pNavigationListImpl->SetPageNavigationList(pHistoryList.release(), backCount);
2655 ewk_history_free(pEwkHistoryList);
2657 return pNavigationList.release();
2660 ewk_history_free(pEwkHistoryList);
2667 _WebImpl::SearchText(const String& text, bool searchForward)
2669 result r = E_SUCCESS;
2671 Ewk_Find_Options condition = static_cast< Ewk_Find_Options >(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2675 condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS);
2678 _WebPresenter presenter;
2679 presenter.InitAsyncProcess();
2681 r = SynchronizeSearch(SEARCH_SYNC, __pWebCore->GetWebNativeNode(), condition, text, searchForward, false, &presenter);
2682 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2685 presenter.WaitAsyncProcess(result);
2687 return static_cast < bool >(result);
2692 _WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive)
2694 result r = E_SUCCESS;
2696 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2700 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2703 r = SynchronizeSearch(SEARCH_ALL_ASYNC, __pWebCore->GetWebNativeNode(), condition, text, true, caseSensitive);
2704 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2711 _WebImpl::SearchNextAsync(bool searchForward)
2713 SysTryReturnResult(NID_WEB_CTRL, __textSearch.__searchAll && __textSearch.__totalCount > -1, E_INVALID_OPERATION, "The SearchTextAllAsync() method is not called or completed.");
2714 SysTryReturnResult(NID_WEB_CTRL, (searchForward && __textSearch.__currentIndex < __textSearch.__totalCount) || (!searchForward && __textSearch.__currentIndex > 1)
2715 , E_OBJ_NOT_FOUND, "The Next instance is not available.");
2717 result r = E_SUCCESS;
2719 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2721 if (__textSearch.__caseSensitive)
2723 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2728 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_BACKWARDS);
2731 r = SynchronizeSearch(SEARCH_NEXT_ASYNC, __pWebCore->GetWebNativeNode(), condition, __textSearch.__text, searchForward);
2732 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2739 _WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text, bool searchForward, bool caseSensitive, _WebPresenter* pWebPresenter)
2741 MutexGuard lock(__mutex);
2743 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(text));
2744 SysTryReturn(NID_WEB_CTRL, pText.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2749 if (__textSearch.__searchAll)
2751 DisableAsyncSearch();
2753 __textSearch.__searchQueue.Enqueue(this);
2754 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2756 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2757 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2761 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2763 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2767 case SEARCH_ALL_ASYNC:
2768 __textSearch.__searchAll = true;
2769 __textSearch.__text = text;
2770 __textSearch.__searchForward = true;
2771 __textSearch.__caseSensitive = caseSensitive;
2772 __textSearch.__totalCount = -1;
2773 __textSearch.__currentIndex = 1;
2775 __textSearch.__searchQueue.Enqueue(this);
2776 __textSearch.__searchQueue.Enqueue(this);
2778 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2779 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2782 case SEARCH_NEXT_ASYNC:
2783 __textSearch.__searchForward = searchForward;
2785 CalculateAsyncSearchOrdinal();
2787 __textSearch.__searchQueue.Enqueue(this);
2789 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2801 _WebImpl::SetAsyncSearchResult(int totalCount)
2803 __textSearch.__totalCount = totalCount;
2808 _WebImpl::GetSearchPresenter(void)
2810 MutexGuard lock(__mutex);
2812 return dynamic_cast< _WebPresenter* >(__textSearch.__searchQueue.Dequeue());
2817 _WebImpl::GetPendingAsyncSearchCount(void) const
2819 return __textSearch.__searchQueue.GetCount();
2824 _WebImpl::CalculateAsyncSearchOrdinal(void)
2826 if (__textSearch.__searchForward)
2828 __textSearch.__currentIndex++;
2832 __textSearch.__currentIndex--;
2838 _WebImpl::GetAsyncSearchOrdinal(void) const
2840 return __textSearch.__currentIndex;
2845 _WebImpl::DisableAsyncSearch(void)
2847 __textSearch.__searchAll = false;
2852 _WebImpl::SetSetting(const WebSetting& setting)
2854 if (__pWebCore->GetWebNativeNode())
2856 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2857 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2858 SysAssertf(pContext && pSettings, "Failed to get webkit instance.");
2860 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(setting.GetDefaultTextEncoding()));
2861 SysTryReturn(NID_WEB_CTRL, pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2863 ewk_settings_default_encoding_set(pSettings, pEncoding.get());
2865 switch (setting.GetCacheControl())
2867 case WEB_CACHE_VALIDATED:
2868 ewk_context_cache_disabled_set(pContext, EINA_FALSE);
2871 case WEB_CACHE_IGNORE:
2872 ewk_context_cache_disabled_set(pContext, EINA_TRUE);
2879 if (setting.GetInputStyle() == INPUT_STYLE_OVERLAY)
2881 ewk_settings_default_keypad_enabled_set(pSettings, EINA_TRUE);
2885 ewk_settings_default_keypad_enabled_set(pSettings, EINA_FALSE);
2888 ewk_settings_font_default_size_set(pSettings, static_cast< Eina_Bool >(setting.GetFontSize()));
2890 ewk_settings_javascript_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsJavascriptEnabled()));
2892 ewk_settings_loads_images_automatically_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoImageLoadEnabled()));
2894 if (__defaultUserAgent != setting.GetUserAgent())
2896 std::unique_ptr<char[]> pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent()));
2897 SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2899 ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get());
2902 ewk_settings_auto_fitting_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFittingEnabled()));
2904 ewk_settings_scripts_window_open_set(pSettings, static_cast< Eina_Bool >(setting.IsJavaScriptPopupEnabled()));
2906 ewk_settings_form_candidate_data_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFormDataShowEnabled()));
2908 ewk_settings_autofill_password_form_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoLoginFormFillEnabled()));
2911 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting());
2913 pWebSettingImpl->SetCertificateErrorHandlingMode(setting.GetCertificateErrorHandlingMode());
2914 pWebSettingImpl->SetDefaultTextEncoding(setting.GetDefaultTextEncoding());
2915 pWebSettingImpl->SetCacheControl(setting.GetCacheControl());
2916 pWebSettingImpl->SetFontSize(setting.GetFontSize());
2917 pWebSettingImpl->SetJavascriptEnabled(setting.IsJavascriptEnabled());
2918 pWebSettingImpl->SetAutoImageLoadEnabled(setting.IsAutoImageLoadEnabled());
2919 pWebSettingImpl->SetInputStyle(setting.GetInputStyle());
2920 pWebSettingImpl->SetUserAgent(setting.GetUserAgent());
2921 pWebSettingImpl->SetAutoFittingEnabled(setting.IsAutoFittingEnabled());
2922 pWebSettingImpl->SetJavaScriptPopupEnabled(setting.IsJavaScriptPopupEnabled());
2923 pWebSettingImpl->SetGeolocationEnabled(setting.IsGeolocationEnabled());
2924 pWebSettingImpl->SetAutoFormDataShowEnabled(setting.IsAutoFormDataShowEnabled());
2925 pWebSettingImpl->SetAutoLoginFormFillEnabled(setting.IsAutoLoginFormFillEnabled());
2932 _WebImpl::GetSetting(void) const
2934 return *__pWebCore->GetSetting();
2938 const HitElementResult*
2939 _WebImpl::GetElementByPointN(const Point& point) const
2941 return GetElementByPointN(_CoordinateSystemUtils::ConvertToFloat(point));
2945 const HitElementResult*
2946 _WebImpl::GetElementByPointN(const FloatPoint& point) const
2948 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));
2950 result r = E_SUCCESS;
2952 _HitElementResultImpl* pHitElementResultImpl = null;
2954 std::unique_ptr<HitElementResult> pHitElementResult;
2955 std::unique_ptr<Bitmap> pImage;
2956 std::unique_ptr<HashMap, AllElementsDeleter> pAttributeMap;
2958 Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(point)));
2960 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(__pWebCore->GetWebNativeNode(), absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
2961 SysTryReturn(NID_WEB_CTRL, pEwkHitTest, null, E_SYSTEM, "[%s] Failed to get hit test.", GetErrorMessage(E_SYSTEM));
2963 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
2964 Ewk_Hit_Test_Result_Context context = ewk_hit_test_result_context_get(pEwkHitTest);
2965 String url(ewk_hit_test_link_uri_get(pEwkHitTest));
2966 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
2967 String nodeValue(ewk_hit_test_node_value_get(pEwkHitTest));
2969 SysSecureLog(NID_WEB_CTRL, "The current value of url is %ls, tag is %ls, value is %ls", url.GetPointer(), tagName.GetPointer(), nodeValue.GetPointer());
2971 pHitElementResult = std::unique_ptr<HitElementResult>(new (std::nothrow) HitElementResult());
2972 SysTryCatch(NID_WEB_CTRL, pHitElementResult.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2974 pHitElementResultImpl = _HitElementResultImpl::GetInstance(pHitElementResult.get());
2975 SysTryCatch(NID_WEB_CTRL, pHitElementResultImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2977 if (context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE)
2983 int imageLength = ewk_hit_test_image_buffer_length_get(pEwkHitTest);
2984 void* pImageBuffer = ewk_hit_test_image_buffer_get(pEwkHitTest);
2985 const char* pExtension = ewk_hit_test_image_file_name_extension_get(pEwkHitTest);
2986 SysLog(NID_WEB_CTRL, "The current value of imageBuffer is %u, bufferLength is %d, extension is %s", pImageBuffer, imageLength, pExtension);
2988 r = buf.Construct(imageLength);
2989 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2991 r = buf.SetArray(reinterpret_cast< byte* >(pImageBuffer), 0, imageLength);
2992 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2996 // ToDo : webkit doesn't support types such as IMG_FORMAT_WBMP and IMG_FORMAT_TIFF
2997 // webkit support types such as ico and vp8 additionally
2998 if (strcmp(pExtension, "gif") == 0)
3000 format = IMG_FORMAT_GIF;
3002 else if (strcmp(pExtension, "jpg") == 0)
3004 format = IMG_FORMAT_JPG;
3006 else if (strcmp(pExtension, "png") == 0)
3008 format = IMG_FORMAT_PNG;
3010 else if (strcmp(pExtension, "bmp") == 0)
3012 format = IMG_FORMAT_BMP;
3016 SysLogException(NID_WEB_CTRL, E_UNSUPPORTED_FORMAT, "[%s] The %s format is not supported", GetErrorMessage(E_UNSUPPORTED_FORMAT), pExtension);
3020 r = image.Construct();
3021 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3023 pImage = std::unique_ptr<Bitmap>(image.DecodeN(buf, format, BITMAP_PIXEL_FORMAT_RGB565));
3024 SysTryCatch(NID_WEB_CTRL, pImage.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3029 pAttributeMap = std::unique_ptr<HashMap, AllElementsDeleter>(new (std::nothrow) HashMap());
3030 SysTryCatch(NID_WEB_CTRL, pAttributeMap.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3032 r = pAttributeMap->Construct(eina_hash_population(pAttrHash));
3033 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3035 eina_hash_foreach(pAttrHash, AddHttpAttributeData, pAttributeMap.get());
3036 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3039 pHitElementResultImpl->SetHitElementResult(pAttributeMap.release(), pImage.release(), tagName, nodeValue, url);
3041 ewk_hit_test_free(pEwkHitTest);
3043 return pHitElementResult.release();
3046 ewk_hit_test_free(pEwkHitTest);
3053 _WebImpl::IsLoading(void) const
3055 double percent = ewk_view_load_progress_get(__pWebCore->GetWebNativeNode());
3057 if (Double::Compare(percent, 0.0) > 0 && Double::Compare(percent, 1.0) < 0)
3069 _WebImpl::GetTextFromBlock(void) const
3071 return ewk_view_text_selection_text_get(__pWebCore->GetWebNativeNode());
3076 _WebImpl::IsPrivateBrowsingEnabled(void) const
3078 if (__pWebCore->GetWebNativeNode() == null)
3080 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsPrivateBrowsingEnabled();
3083 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3084 SysAssertf(pSettings, "Failed to get webkit instance.");
3086 return static_cast< bool >(ewk_settings_private_browsing_enabled_get(pSettings));
3091 _WebImpl::SetPrivateBrowsingEnabled(bool enable)
3093 if (__pWebCore->GetWebNativeNode() == null)
3095 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetPrivateBrowsingEnabled(enable);
3099 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
3100 SysAssertf(pSettings, "Failed to get webkit instance.");
3102 ewk_settings_private_browsing_enabled_set(pSettings, static_cast< Eina_Bool >(enable));
3107 _WebImpl::ClearHistory(void)
3109 ewk_view_back_forward_list_clear(__pWebCore->GetWebNativeNode());
3114 _WebImpl::ClearCache(void)
3116 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3117 SysAssertf(pContext, "Failed to get webkit instance.");
3119 ewk_context_cache_clear(pContext);
3124 _WebImpl::ClearCookie(void)
3126 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3127 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3128 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3130 ewk_cookie_manager_cookies_clear(pCookieManager);
3135 _WebImpl::ClearFormData(void)
3137 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3138 SysAssertf(pContext, "Failed to get webkit instance.");
3140 ewk_context_form_candidate_data_clear(pContext);
3145 _WebImpl::ClearLoginFormData(void)
3147 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3148 SysAssertf(pContext, "Failed to get webkit instance.");
3150 ewk_context_form_password_data_clear(pContext);
3155 _WebImpl::IsCookieEnabled(void) const
3157 if (__pWebCore->GetWebNativeNode() == null)
3159 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsCookieEnabled();
3162 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3163 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3164 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3166 _WebPresenter presenter;
3167 presenter.InitAsyncProcess();
3169 ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, &presenter);
3171 bool result = false;
3172 presenter.WaitAsyncProcess(result);
3179 _WebImpl::SetCookieEnabled(bool enable)
3181 if (__pWebCore->GetWebNativeNode() == null)
3183 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetCookiEnabled(enable);
3188 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3189 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3190 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3194 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
3198 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER);
3199 ewk_cookie_manager_cookies_clear(pCookieManager);
3205 _WebImpl::SavePageAsPdf(const String& filePath, const Dimension* pSize) const
3207 result r = E_SUCCESS;
3209 std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
3210 SysTryReturn(NID_WEB_CTRL, pFilePath.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3213 String fileExtension = File::GetFileExtension(filePath);
3214 int pathLength = filePath.GetLength();
3217 SysTryReturnResult(NID_WEB_CTRL, fileExtension.Equals("pdf", false), E_INVALID_ARG, "Invalid argument(s) is used. File extension is not pdf.");
3219 r = filePath.LastIndexOf(L"/", pathLength - 1, index);
3220 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3221 r = filePath.SubString(0, index + 1, dirPath);
3222 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3224 std::unique_ptr<char[]> pDirPath(_StringConverter::CopyToCharArrayN(dirPath));
3225 SysTryReturnResult(NID_WEB_CTRL, access(pDirPath.get(), W_OK) == 0, E_INACCESSIBLE_PATH, "Directory permission is read-only.");
3229 SysTryReturnResult(NID_WEB_CTRL, pSize->width > 0 && pSize->height > 0, E_INVALID_ARG, "Invalid argument(s) is used. Size of pdf file is invalid.");
3231 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), pSize->width, pSize->height, pFilePath.get());
3235 Evas_Coord contentsWidth;
3236 Evas_Coord contentsHeight;
3238 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &contentsWidth, &contentsHeight);
3239 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), contentsWidth, contentsHeight, pFilePath.get());
3247 _WebImpl::IsMimeSupported(const String& mime) const
3249 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
3250 SysTryReturn(NID_WEB_CTRL, pMime.get(), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3252 return static_cast< bool >(ewk_frame_can_show_mime_type(ewk_view_main_frame_get(__pWebCore->GetWebNativeNode()), pMime.get()));
3257 _WebImpl::SetLoadingListener(ILoadingListener* pLoadingListener)
3259 __pUserLoadingListener = const_cast< ILoadingListener* >(pLoadingListener);
3264 _WebImpl::SetWebUiEventListener(IWebUiEventListener* pUiEventListener)
3266 __pUserUiListener = pUiEventListener;
3271 _WebImpl::SetWebUiEventListenerF(IWebUiEventListenerF* pUiEventListener)
3273 __pUserUiListenerF = pUiEventListener;
3278 _WebImpl::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener)
3280 __pUserKeypadEventListener = pKeypadEventListener;
3285 _WebImpl::SetDownloadListener(IWebDownloadListener* pDownLoadListener)
3287 if (__pWebDownloadHandler.get() == null)
3289 __pWebDownloadHandler = std::unique_ptr<_WebDataHandler>(new (std::nothrow) _WebDataHandler());
3290 SysTryReturnVoidResult(NID_WEB_CTRL, __pWebDownloadHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3293 __pWebDownloadHandler->SetDownloadListener(pDownLoadListener);
3294 __pWebDownloadHandler->SetWebEvent(__pWebEvent.get());
3299 _WebImpl::SetTextSearchListener(ITextSearchListener* pTextSearchListener)
3301 __pTextSearchListener = pTextSearchListener;
3306 _WebImpl::SetScrollEnabled(bool enable)
3308 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetScrollEnabled(enable);
3313 _WebImpl::IsScrollEnabled(void) const
3315 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled();
3320 _WebImpl::InitJsBridgeList(void)
3322 result r = E_SUCCESS;
3324 __pJsProvider = std::unique_ptr<_JsBridgeHashCodeProvider>(new (std::nothrow) _JsBridgeHashCodeProvider());
3325 SysTryReturnResult(NID_WEB_CTRL, __pJsProvider.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3327 __pJsComparer = std::unique_ptr<_JsBridgeComparer>(new (std::nothrow) _JsBridgeComparer());
3328 SysTryReturnResult(NID_WEB_CTRL, __pJsComparer.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3330 std::unique_ptr<HashMapT< String, IJavaScriptBridge* > > pJsBridgeList(new (std::nothrow) HashMapT< String, IJavaScriptBridge* >);
3331 SysTryReturnResult(NID_WEB_CTRL, pJsBridgeList.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3333 r = pJsBridgeList->Construct(0, 0, *__pJsProvider.get(), *__pJsComparer.get());
3334 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3336 __pJsBridgeList = std::move(pJsBridgeList);
3343 _WebImpl::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3345 result r = E_SUCCESS;
3347 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3348 String key(pJsBridge->GetName());
3350 r = __pJsBridgeList->Add(key, pJsBridge);
3351 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3358 _WebImpl::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3360 result r = E_SUCCESS;
3362 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3363 String key(pJsBridge->GetName());
3365 r = __pJsBridgeList->Remove(key);
3366 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3373 _WebImpl::FindJsInterface(const IJsonValue* pValue) const
3375 result r = E_SUCCESS;
3377 IJsonValue* pJsonValue = null;
3378 IJavaScriptBridge* pJsBridge = null;
3380 String key(L"name");
3382 const JsonObject* pJsonObject = dynamic_cast< const JsonObject* >(pValue);
3383 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));
3385 r = pJsonObject->GetValue(&key, pJsonValue);
3386 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS && pJsonValue, null, r, "[%s] Propagating.", GetErrorMessage(r));
3388 JsonString* pBridgeName = dynamic_cast< JsonString* >(pJsonValue);
3389 SysTryReturn(NID_WEB_CTRL, pBridgeName, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. name key is missing." , GetErrorMessage(E_INVALID_ARG));
3391 r = __pJsBridgeList->GetValue(static_cast< String >(*pBridgeName), pJsBridge);
3392 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3399 _WebImpl::GetLoadingListener(void) const
3401 return __pUserLoadingListener;
3405 IWebUiEventListener*
3406 _WebImpl::GetUiEventListener(void) const
3408 return __pUserUiListener;
3412 IWebUiEventListenerF*
3413 _WebImpl::GetUiEventListenerF(void) const
3415 return __pUserUiListenerF;
3419 IWebKeypadEventListener*
3420 _WebImpl::GetWebKeypadEventListener(void) const
3422 return __pUserKeypadEventListener;
3426 ITextSearchListener*
3427 _WebImpl::GetTextSearchListener(void) const
3429 return __pTextSearchListener;
3434 _WebImpl::SetEventListenerCallback(void) const
3436 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3439 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3440 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3442 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3443 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3445 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3446 SysAssertf(pSmartData, "Failed to request");
3448 Ewk_View_Smart_Class *pSmart = const_cast<Ewk_View_Smart_Class*>(pSmartData->api);
3449 SysAssertf(pSmart, "Failed to request");
3451 pSmart->popup_menu_show = OnSelectBoxRequested;
3452 pSmart->popup_menu_hide = OnSelectBoxClosed;
3453 pSmart->popup_menu_update = OnSelectBoxUpdateRequested;
3455 pSmart->input_picker_show = OnDatePickerProviderRequested;
3456 pSmart->input_picker_color_request = OnColorPickerProviderRequested;
3457 pSmart->input_picker_color_dismiss = OnColorPickerProviderDismissed;
3459 evas_object_data_set(pWebNativeNode, WEB_CTRL, this);
3461 // add loading event callbacks for ILoadingListener
3462 evas_object_smart_callback_add(pWebNativeNode, "create,window", OnWebWindowCreateRequested, this);
3463 evas_object_smart_callback_add(pWebNativeNode, "close,window", OnWebWindowClosedRequested, this);
3465 evas_object_smart_callback_add(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested, this);
3466 evas_object_smart_callback_add(pWebNativeNode, "load,started", OnLoadingStarted, this);
3467 evas_object_smart_callback_add(pWebNativeNode, "load,finished", OnLoadingCompleted, this);
3468 evas_object_smart_callback_add(pWebNativeNode, "load,progress", OnEstimatedProgress, this);
3469 evas_object_smart_callback_add(pWebNativeNode, "load,progress,finished", OnProgressCompleted, this);
3470 evas_object_smart_callback_add(pWebNativeNode, "load,stop", OnLoadingCanceled, this);
3471 evas_object_smart_callback_add(pWebNativeNode, "load,error", OnLoadingErrorOccurred, this);
3472 evas_object_smart_callback_add(pWebNativeNode, "title,changed", OnPageTitleReceived, this);
3473 evas_object_smart_callback_add(pWebNativeNode, "load,committed", OnLoadingCommitted, this);
3475 evas_object_smart_callback_add(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest, this);
3477 evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3479 evas_object_smart_callback_add(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged, this);
3480 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened, this);
3481 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed, this);
3483 evas_object_smart_callback_add(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested, this);
3484 evas_object_smart_callback_add(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled, this);
3486 evas_object_smart_callback_add(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested, this);
3488 ewk_view_javascript_alert_callback_set(pWebNativeNode, OnScriptAlertRequested, const_cast< _WebImpl* >(this));
3489 ewk_view_javascript_prompt_callback_set(pWebNativeNode, OnScriptPromptRequested, const_cast< _WebImpl* >(this));
3490 ewk_view_javascript_confirm_callback_set(pWebNativeNode, OnScriptConfirmRequested, const_cast< _WebImpl* >(this));
3492 evas_object_smart_callback_add(pWebNativeNode, "policy,response,decide", OnWebDataReceived, this);
3494 evas_object_smart_callback_add(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested, this);
3495 evas_object_smart_callback_add(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested, this);
3496 evas_object_smart_callback_add(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted, this);
3498 evas_object_smart_callback_add(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested, this);
3499 evas_object_smart_callback_add(pWebNativeNode, "notification,show", OnNotificationShow, this);
3500 evas_object_smart_callback_add(pWebNativeNode, "notification,cancel", OnNotificationCancel, this);
3502 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested, this);
3503 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered, this);
3504 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested, this);
3506 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested, this);
3507 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered, this);
3508 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested, this);
3509 evas_object_smart_callback_add(pWebNativeNode, "text,found", OnTextFound, this);
3511 evas_object_smart_callback_add(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered, this);
3512 evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this);
3514 evas_object_smart_callback_add(pWebNativeNode, "text,style,state", OnWebPageBlockSelected, this);
3515 evas_object_smart_callback_add(pWebNativeNode, "frame,rendered", OnWebPageBlockSelectedByOrientation, this);
3517 ewk_view_open_panel_callback_set(pWebNativeNode, OnSelectUploadFile, const_cast< _WebImpl* >(this));
3518 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3519 SysAssertf(pContext, "Failed to get webkit instance.");
3520 ewk_context_did_start_download_callback_set(pContext, OnDidStartDownloadCallback, const_cast< _WebImpl* >(this));
3521 ewk_context_vibration_client_callbacks_set(pContext, OnVibrationRequested, OnVibrationCanceled, const_cast< _WebImpl* >(this));
3523 ewk_view_application_cache_permission_callback_set(pWebNativeNode, OnApplicationCachePermissionRequested, const_cast< _WebImpl* >(this));
3524 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, OnIndexedDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3525 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, OnDatabaseQuotaExceeded, const_cast< _WebImpl* >(this));
3526 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, OnLocalFileSystemQuotaExceeded, const_cast< _WebImpl* >(this));
3528 evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this);
3534 _WebImpl::RemoveEventListenerCallback(void) const
3536 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3539 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3540 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3542 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3543 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3545 evas_object_smart_callback_del(pWebNativeNode, "create,window", OnWebWindowCreateRequested);
3546 evas_object_smart_callback_del(pWebNativeNode, "close,window", OnWebWindowClosedRequested);
3548 evas_object_smart_callback_del(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested);
3549 evas_object_smart_callback_del(pWebNativeNode, "load,started", OnLoadingStarted);
3550 evas_object_smart_callback_del(pWebNativeNode, "load,finished", OnLoadingCompleted);
3551 evas_object_smart_callback_del(pWebNativeNode, "load,progress", OnEstimatedProgress);
3552 evas_object_smart_callback_del(pWebNativeNode, "load,progress,finished", OnProgressCompleted);
3553 evas_object_smart_callback_del(pWebNativeNode, "load,stop", OnLoadingCanceled);
3554 evas_object_smart_callback_del(pWebNativeNode, "load,error", OnLoadingErrorOccurred);
3555 evas_object_smart_callback_del(pWebNativeNode, "title,changed", OnPageTitleReceived);
3557 evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest);
3559 evas_object_smart_callback_del_full(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3561 evas_object_smart_callback_del(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged);
3562 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened);
3563 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed);
3565 evas_object_smart_callback_del(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested);
3566 evas_object_smart_callback_del(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled);
3568 evas_object_smart_callback_del(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested);
3570 ewk_view_javascript_alert_callback_set(null, null, null);
3571 ewk_view_javascript_prompt_callback_set(null, null, null);
3572 ewk_view_javascript_confirm_callback_set(null, null, null);
3574 evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived);
3576 evas_object_smart_callback_del(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested);
3577 evas_object_smart_callback_del(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested);
3578 evas_object_smart_callback_del(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted);
3580 evas_object_smart_callback_del(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested);
3581 evas_object_smart_callback_del(pWebNativeNode, "notification,show", OnNotificationShow);
3582 evas_object_smart_callback_del(pWebNativeNode, "notification,cancel", OnNotificationCancel);
3583 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested);
3584 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered);
3585 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested);
3587 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested);
3588 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered);
3589 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested);
3591 evas_object_smart_callback_del(pWebNativeNode, "text,found", OnTextFound);
3593 evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered);
3594 evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived);
3596 evas_object_smart_callback_del(pWebNativeNode, "text,style,state", OnWebPageBlockSelected);
3597 evas_object_smart_callback_del(pWebNativeNode, "frame,rendered", OnWebPageBlockSelectedByOrientation);
3599 ewk_view_open_panel_callback_set(null, null, null);
3600 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3601 SysAssertf(pContext, "Failed to get webkit instance.");
3602 ewk_context_vibration_client_callbacks_set(pContext, null, null, null);
3604 ewk_view_application_cache_permission_callback_set(pWebNativeNode, null, null);
3605 ewk_view_exceeded_indexed_database_quota_callback_set(pWebNativeNode, null, null);
3606 ewk_view_exceeded_database_quota_callback_set(pWebNativeNode, null, null);
3607 ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, null, null);
3609 evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained);
3615 _WebImpl::SetBlockSelectionPosition(const Point& startPoint)
3617 return SetBlockSelectionPosition(_CoordinateSystemUtils::ConvertToFloat(startPoint));
3622 _WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint)
3624 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3626 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3627 SysAssertf(pSmartData, "Failed to request");
3629 Point absPoint( _CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(startPoint)));
3631 Eina_Bool ret = pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y);
3634 pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y);
3636 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(__pWebCore->GetWebNativeNode(), absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3637 SysTryReturnResult(NID_WEB_CTRL, pEwkHitTest, E_SYSTEM, "Failed to get hit test.");
3639 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3641 if (tagName.Equals(L"INPUT", false) || tagName.Equals(L"TEXTAREA", false))
3643 ewk_view_command_execute(pWebNativeNode, "SelectWord", 0);
3647 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
3648 char* pValue = reinterpret_cast< char* >(eina_hash_find(pAttrHash, "contenteditable"));
3651 ewk_view_command_execute(pWebNativeNode, "SelectWord", 0);
3656 SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up.");
3663 _WebImpl::ReleaseBlock(void)
3665 ewk_view_text_selection_range_clear(__pWebCore->GetWebNativeNode());
3670 _WebImpl::GetBlockRange(Point& startPoint, Point& endPoint) const
3672 FloatPoint tempStartPoint;
3673 FloatPoint tempEndPoint;
3675 GetBlockRange(tempStartPoint, tempEndPoint);
3677 startPoint = _CoordinateSystemUtils::ConvertToInteger(tempStartPoint);
3678 endPoint = _CoordinateSystemUtils::ConvertToInteger(tempEndPoint);
3683 _WebImpl::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const
3685 Eina_Rectangle leftHandle;
3686 Eina_Rectangle rightHandle;
3688 ewk_view_text_selection_range_get(__pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle);
3690 startPoint.x = _CoordinateSystemUtils::ConvertToFloat(leftHandle.x);
3691 startPoint.y = _CoordinateSystemUtils::ConvertToFloat(leftHandle.y);
3692 endPoint.x = _CoordinateSystemUtils::ConvertToFloat(rightHandle.x + rightHandle.w);
3693 endPoint.y = _CoordinateSystemUtils::ConvertToFloat(rightHandle.y + rightHandle.h);
3695 if ((endPoint.x != 0.0f) && (endPoint.y != 0.0f))
3697 startPoint = __pWebCore->GetRelativeCoordinate(startPoint);
3698 endPoint = __pWebCore->GetRelativeCoordinate(endPoint);
3704 _WebImpl::GetFaviconN(void) const
3706 result r = E_SUCCESS;
3708 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3710 Evas* pEvas = evas_object_evas_get(pView);
3711 Ewk_Context* pContext = ewk_view_context_get(pView);
3712 SysAssertf(pEvas && pContext, "Failed to request");
3714 const char* pUrl = ewk_view_url_get(pView);
3716 Tizen::Graphics::BufferInfo bufferInfo;
3717 Tizen::Base::ByteBuffer byteBuffer;
3719 std::unique_ptr<Bitmap> pBitmapImage(new (std::nothrow) Bitmap());
3720 SysTryReturn(NID_WEB_CTRL, pBitmapImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3722 Evas_Object* pFavicon = ewk_context_icon_database_icon_object_add(pContext, pUrl, pEvas);
3728 r = _Utility::GetPixelBufferFromEvasObject(pFavicon, bufferInfo);
3729 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3731 const Dimension dimension(bufferInfo.width, bufferInfo.height);
3733 r = byteBuffer.Construct((byte*)bufferInfo.pPixels, 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 );
3734 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3736 r = pBitmapImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888);
3737 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3739 return pBitmapImage.release();
3745 _WebImpl::ScrollBy(const Tizen::Graphics::Point& diff)
3747 ewk_view_scroll_by(__pWebCore->GetWebNativeNode(), diff.x, diff.y);
3752 _WebImpl::ScrollTo(const Tizen::Graphics::Point& dest)
3754 ewk_view_scroll_set(__pWebCore->GetWebNativeNode(), dest.x, dest.y);
3759 _WebImpl::GetScrollPosition(void) const
3763 ewk_view_scroll_pos_get(__pWebCore->GetWebNativeNode(), &position.x, &position.y);
3770 _WebImpl::GetPageSize(void) const
3772 Evas_Coord width = 0;
3773 Evas_Coord height = 0;
3775 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &width, &height);
3777 Dimension size(static_cast< int >(width), static_cast< int >(height));
3784 _WebImpl::SetLoadingErrorOccurred(bool arg)
3786 __isLoadingErrorOccurred = arg;
3791 _WebImpl::IsLoadingErrorOccurred(void) const
3793 return __isLoadingErrorOccurred;
3798 _WebImpl::SetRedirectRequested(bool arg)
3800 __isRedirectRequested = arg;
3805 _WebImpl::IsRedirectRequested(void) const
3807 return __isRedirectRequested;
3812 _WebImpl::SetPolicyDecision(DecisionPolicy policy)
3819 _WebImpl::GetPolicyDecision(void) const
3826 _WebImpl::SetCertificateRequested(bool arg)
3828 __isCertificateRequested = arg;
3833 _WebImpl::IsCertificateRequested(void) const
3835 return __isCertificateRequested;
3840 _WebImpl::IsCertificateConfirmed(void) const
3842 return __isCertificateConfirmed;
3847 _WebImpl::SetOrientationChanged(bool arg)
3849 __isOrientationChanged = arg;
3854 _WebImpl::IsOrientationChanged(void) const
3856 return __isOrientationChanged;
3861 _WebImpl::LaunchAppControl(const IEventArg& arg)
3863 result r = E_SUCCESS;
3865 IEventArg* pArg = const_cast< IEventArg* >(&arg);
3866 _WebEventArg* pWebEventArg = dynamic_cast< _WebEventArg* >(pArg);
3867 SysTryReturnResult(NID_WEB_CTRL, pWebEventArg, E_INVALID_ARG, "Type casting failed. argument must be IEventArg type.");
3869 String operationId(L"");
3870 String uriPattern(pWebEventArg->GetEventMessage());
3871 SysLog(NID_WEB_CTRL, "The current value of web event type is %d", pWebEventArg->GetEventType());
3873 switch (pWebEventArg->GetEventType())
3875 case WEB_EVENT_REQUEST_RTSP:
3879 int uriLength = uriPattern.GetLength();
3882 operationId = L"http://tizen.org/appcontrol/operation/view";
3884 r = uriPattern.LastIndexOf(L".", uriLength - 1, index);
3885 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3887 r = uriPattern.SubString(index + 1, ext);
3888 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3890 r = _AppControlManager::GetMimeFromExt(ext, mimeType);
3891 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3893 r = _AppControlImpl::FindAndStart(operationId, &uriPattern, &mimeType, null, null, null);
3894 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3898 case WEB_EVENT_REQUEST_TEL:
3900 operationId = L"http://tizen.org/appcontrol/operation/dial";
3903 case WEB_EVENT_REQUEST_EMAIL:
3905 case WEB_EVENT_REQUEST_SMS:
3907 case WEB_EVENT_REQUEST_MMS:
3909 operationId = L"http://tizen.org/appcontrol/operation/compose";
3912 case WEB_EVENT_REQUEST_UNKNOWN:
3914 operationId = L"http://tizen.org/appcontrol/operation/view";
3922 r = _AppControlImpl::FindAndStart(operationId, &uriPattern, null, null, null, null);
3923 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3930 _WebImpl::SetFullScreenKeypad(void)
3932 result r = E_SUCCESS;
3934 std::unique_ptr<Keypad> pKeypad(new (std::nothrow) Keypad());
3935 SysTryReturnResult(NID_WEB_CTRL, pKeypad.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
3937 r = pKeypad->Construct(KEYPAD_STYLE_NORMAL, 100);
3938 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3940 String text(ewk_view_focused_input_element_value_get(__pWebCore->GetWebNativeNode()));
3941 pKeypad->SetText(text);
3943 r = pKeypad->SetShowState(true);
3944 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3946 r = pKeypad->Show();
3947 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3949 pKeypad->AddTextEventListener(*this);
3951 __pKeypad = std::move(pKeypad);
3958 _WebImpl::RemoveFullScreenKeypad(void)
3960 __pKeypad->RemoveTextEventListener(*this);
3967 _WebImpl::IsFooterVisible(void) const
3969 return __isFooterVisible;
3974 _WebImpl::SetFooterVisibleState(bool isFooterVisible)
3976 __isFooterVisible = isFooterVisible;
3981 _WebImpl::IsKeypadVisible(void) const
3983 return __isKeypadVisible;
3988 _WebImpl::SetKeypadVisibleState(bool isKeypadVisible)
3990 __isKeypadVisible = isKeypadVisible;
3995 _WebImpl::IsKeypadOpened(void) const
3997 return __isKeypadOpened;
4001 _WebImpl::SetKeypadOpened(bool isKeypadOpened)
4003 __isKeypadOpened = isKeypadOpened;
4008 _WebImpl::GetPreviousKeypadBounds(void) const
4010 return __keypadBounds;
4015 _WebImpl::SetPreviousKeypadBounds(Rectangle& bounds)
4017 __keypadBounds = bounds;
4022 _WebImpl::OnTextValueChangeCanceled(const Control& source)
4024 RemoveFullScreenKeypad();
4029 _WebImpl::OnTextValueChanged(const Control& source)
4031 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(__pKeypad->GetText()));
4033 ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get());
4035 RemoveFullScreenKeypad();
4040 _WebImpl::OnHandleJavaScriptRequestByEventArg(const IEventArg& arg)
4042 const _JsBridgeArg* pEventArg = dynamic_cast< const _JsBridgeArg* >(&arg);
4043 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. arg is not _JsBridgeArg object.");
4045 std::unique_ptr<IJsonValue> pJsonValue(JsonParser::ParseN(*(pEventArg->GetJsonData())));
4046 SysTryReturn(NID_WEB_JSON, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4048 IJavaScriptBridge* pJsInterface = FindJsInterface(pJsonValue.get());
4049 SysTryReturnResult(NID_WEB_CTRL, pJsInterface, E_OBJ_NOT_FOUND, "JsInterface instance is not available.");
4051 pJsInterface->HandleJavaScriptRequestN(pJsonValue.release());
4058 _WebImpl::OnHandleLoadingEvent(const IEventArg& arg)
4060 result r = E_SUCCESS;
4062 const _LoadingEventArg* pEventArg = dynamic_cast< const _LoadingEventArg* >(&arg);
4063 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4065 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4067 ILoadingListener* pLoadingListner = GetLoadingListener();
4068 SysTryReturnResult(NID_WEB_CTRL, pLoadingListner, E_SYSTEM, "A system error has been occurred. Loading listener was not set or null.");
4070 switch (pEventArg->GetEventType())
4072 case WEB_EVENT_LOADINGLISTENER_STARTED:
4074 pLoadingListner->OnLoadingStarted();
4078 case WEB_EVENT_LOADINGLISTENER_PROGRESS:
4080 const Integer* pProgressPercentage = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS));
4081 SysTryReturn(NID_WEB_CTRL, pProgressPercentage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4083 pLoadingListner->OnEstimatedProgress(pProgressPercentage->ToInt());
4087 case WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED:
4089 const String* pPageTitle = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::PAGE_TITLE));
4090 SysTryReturn(NID_WEB_CTRL, pPageTitle, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4092 pLoadingListner->OnPageTitleReceived(*pPageTitle);
4096 case WEB_EVENT_LOADINGLISTENER_CANCELED:
4098 pLoadingListner->OnLoadingCanceled();
4102 case WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED:
4104 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_TYPE));
4105 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4107 const String* pErrorMessage = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_MESSAGE));
4108 SysTryReturn(NID_WEB_CTRL, pErrorMessage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4110 LoadingErrorType errorType = ConvertErrorCode(pErrorType->ToInt());
4112 pLoadingListner->OnLoadingErrorOccurred(errorType, *pErrorMessage);
4116 case WEB_EVENT_LOADINGLISTENER_COMPLETED:
4118 pLoadingListner->OnLoadingCompleted();
4122 case WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED:
4124 pLoadingListner->OnHttpAuthenticationCanceled();
4128 case WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED:
4130 std::unique_ptr<Bitmap> pFavicon(GetFaviconN());
4131 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4135 pLoadingListner->OnFaviconReceived(*pFavicon.get());
4151 _WebImpl::OnHandleWebDownloadEvent(const IEventArg& arg)
4153 result r = E_SUCCESS;
4155 const _WebDownloadEventArg* pEventArg = dynamic_cast< const _WebDownloadEventArg* >(&arg);
4156 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4158 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4160 IWebDownloadListener* pWebDownloadListener = __pWebDownloadHandler->GetDownloadListener();
4161 SysTryReturnResult(NID_WEB_CTRL, pWebDownloadListener, E_SYSTEM, "A system error has been occurred. Web Downloading listener was not set or null.");
4163 switch (pEventArg->GetEventType())
4165 case WEB_EVENT_WEBDOWNLOADLISTENER_DATA_RECEIVED:
4167 const ByteBuffer* pChunk = dynamic_cast< const ByteBuffer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::CHUNKED_DATA));
4168 SysTryReturn(NID_WEB_CTRL, pChunk, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4170 pWebDownloadListener->OnWebChunkedDataReceived(*pChunk);
4174 case WEB_EVENT_WEBDOWNLOADLISTENER_COMPLETED:
4176 pWebDownloadListener->OnWebDataDownloadCompleted();
4180 case WEB_EVENT_WEBDOWNLOADLISTENER_FAILED:
4182 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::ERROR_TYPE));
4183 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4185 LoadingErrorType errorType = static_cast < LoadingErrorType >(pErrorType->ToInt());
4187 pWebDownloadListener->OnWebDownloadFailed(errorType);
4202 _WebImpl::OnHandleWebUiEvent(const IEventArg& arg)
4204 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4205 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4207 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4209 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListener, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4211 switch (pEventArg->GetEventType())
4213 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED:
4215 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4217 Point* pStartPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4218 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4220 Point* pEndPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4221 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4223 __pUserUiListener->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4227 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED:
4229 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4231 __pUserUiListener->OnWebPageShowRequested(*pWeb);
4235 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED:
4237 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4239 __pUserUiListener->OnWebWindowCloseRequested(*pWeb);
4243 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED:
4245 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4247 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4248 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4250 __pUserUiListener->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4265 _WebImpl::OnHandleWebUiEventF(const IEventArg& arg)
4267 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4268 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4270 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4272 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListenerF, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4274 switch (pEventArg->GetEventType())
4276 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT:
4278 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4280 FloatPoint* pStartPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4281 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4283 FloatPoint* pEndPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4284 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4286 __pUserUiListenerF->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4290 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT:
4292 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4294 __pUserUiListenerF->OnWebPageShowRequested(*pWeb);
4298 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT:
4300 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4302 __pUserUiListenerF->OnWebWindowCloseRequested(*pWeb);
4306 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT:
4308 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4310 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4311 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4313 __pUserUiListenerF->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4328 _WebImpl::OnHandleTextSearchEvent(const IEventArg& arg)
4330 result r = E_SUCCESS;
4332 const _TextSearchEventArg* pEventArg = dynamic_cast< const _TextSearchEventArg* >(&arg);
4333 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4335 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4337 ITextSearchListener* pTextSearchListner = GetTextSearchListener();
4338 SysTryReturnResult(NID_WEB_CTRL, pTextSearchListner, E_SYSTEM, "A system error has been occurred. Web text search listener was not set or null.");
4340 switch (pEventArg->GetEventType())
4342 case WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND:
4344 Integer* pTotalCount= dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::TOTAL_COUNT)));
4345 SysTryReturn(NID_WEB_CTRL, pTotalCount, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4347 Integer* pCurrentOrdinal = dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL)));
4348 SysTryReturn(NID_WEB_CTRL, pCurrentOrdinal, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4350 pTextSearchListner->OnTextFound(pTotalCount->ToInt(), pCurrentOrdinal->ToInt());
4365 _WebImpl::VibrationRequested(uint64_t duration)
4367 result r = E_SUCCESS;
4369 __pVibrator.reset();
4371 std::unique_ptr<_VibratorImpl> pVibrator(new (std::nothrow) _VibratorImpl);
4372 SysTryReturnResult(NID_WEB_CTRL, pVibrator.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4374 r = pVibrator->Construct();
4375 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4377 __pVibrator = std::move(pVibrator);
4379 IntensityDurationVibrationPattern pattern = {static_cast< int >(duration), -1};
4381 r = __pVibrator->Start(&pattern, 1, 1);
4382 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4389 _WebImpl::VibrationCanceled(void)
4391 __pVibrator.reset();
4396 _WebImpl::HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge)
4398 result r = E_SUCCESS;
4400 String host(ewk_auth_challenge_url_get(pChallenge));
4401 String realm(ewk_auth_challenge_realm_get(pChallenge));
4403 __pAuthChallenge.reset();
4405 std::unique_ptr<AuthenticationChallenge> pAuthChallenge(new (std::nothrow) AuthenticationChallenge());
4406 SysTryReturnResult(NID_WEB_CTRL, pAuthChallenge, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4408 _AuthenticationChallengeImpl* pAuthImpl = _AuthenticationChallengeImpl::GetInstance(pAuthChallenge.get());
4409 SysTryReturn(NID_WEB_CTRL, pAuthImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4411 pAuthImpl->SetAuthenticationChallengeHandler(pChallenge);
4412 pAuthImpl->SetWebEvasObject(__pWebCore->GetWebNativeNode());
4414 __pAuthChallenge = std::move(pAuthChallenge);
4416 ewk_auth_challenge_suspend(pChallenge);
4417 if (__pUserLoadingListener && __pUserLoadingListener->OnHttpAuthenticationRequestedN(host, realm, *__pAuthChallenge.get()))
4419 __pAuthChallenge.release();
4423 r = ShowAuthenticationPopup(host, realm, __pAuthChallenge.get());
4424 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4432 _WebImpl::ShowAuthenticationPopup(const String& host, const String& realm, AuthenticationChallenge* pAuthChallenge)
4434 result r = E_SUCCESS;
4436 std::unique_ptr<_AuthConfirmPopup> pAuthPopup(new (std::nothrow) _AuthConfirmPopup());
4437 SysTryReturnResult(NID_WEB_CTRL, pAuthPopup, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4439 r = pAuthPopup->Construct(host, realm, pAuthChallenge);
4440 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4442 __pAuthPopup = std::move(pAuthPopup);
4444 int modalResult = 0;
4446 __pAuthPopup->SetOwner(&GetPublic());
4448 r = __pAuthPopup->ShowAndWait(modalResult);
4449 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4452 __pAuthPopup.reset();
4459 _WebImpl::ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk_Certificate_Policy_Decision* pPolicy)
4461 result r = E_SUCCESS;
4463 std::unique_ptr<_CertificateConfirmPopup> pCertConfirmPopup(new (std::nothrow) _CertificateConfirmPopup());
4464 SysTryReturnResult(NID_WEB_CTRL, pCertConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4466 r = pCertConfirmPopup->Construct(userConfirmMode, pPolicy);
4467 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4469 __pCertConfirmPopup = std::move(pCertConfirmPopup);
4471 int modalResult = 0;
4473 __pCertConfirmPopup->SetOwner(&GetPublic());
4475 r = __pCertConfirmPopup->ShowAndWait(modalResult);
4476 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4478 if (userConfirmMode == CERTIFICATE_POPUP_MODE_USER_CONFIRM)
4480 __isCertificateConfirmed = __pCertConfirmPopup->GetConfirmResult();
4484 __pCertConfirmPopup.reset();
4490 _WebImpl::ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4492 result r = E_SUCCESS;
4494 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4495 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4497 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, true, msg);
4498 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4500 __pUserConfirmPopup = std::move(pUserConfirmPopup);
4502 int modalResult = 0;
4504 __pUserConfirmPopup->SetOwner(&GetPublic());
4506 r = __pUserConfirmPopup->ShowAndWait(modalResult);
4507 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4510 __pUserConfirmPopup.reset();
4516 _WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy, String msg)
4518 result r = E_SUCCESS;
4520 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4521 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4523 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, false, msg);
4524 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4526 __pUserConfirmPopup = std::move(pUserConfirmPopup);
4528 __pUserConfirmPopup->SetOwner(&GetPublic());
4530 r = __pUserConfirmPopup->ShowPopup();
4531 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4533 __pUserConfirmPopup.release();
4538 __pUserConfirmPopup.reset();
4545 _WebImpl::GetParentFormCore(_Control* pControlCore)
4548 _Form* pFormCore = null;
4550 _Control* pParentControlCore = dynamic_cast< _Control* >(pControlCore->GetParent());
4551 if (!pParentControlCore)
4556 pFormCore = dynamic_cast< _Form* >(pParentControlCore);
4562 return GetParentFormCore(pParentControlCore);
4567 _WebImpl::OnFocusGained(const _ControlImpl& source)
4574 _WebImpl::OnFocusLost(const _ControlImpl& source)
4576 if(IsKeypadVisible() == true)
4578 SetKeypadOpened(true);
4580 SetKeypadVisibleState(false);
4583 evas_object_focus_set(__pWebCore->GetWebNativeNode(), EINA_FALSE);
4590 _WebImpl::HasValidNativeNode(void) const
4592 if (__pWebCore && __pWebCore->GetWebNativeNode())
4602 _WebImpl::OnPreAttachedToMainTree(void)
4604 result r = E_SUCCESS;
4606 r = __pWebCore->InitializeWebNativeNode();
4607 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4609 r = InitializeSetting();
4610 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4612 r = _ContainerImpl::OnPreAttachedToMainTree();
4613 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4620 _WebImpl::OnChangeLayout(_ControlOrientation orientation)
4622 _ContainerImpl::OnChangeLayout(orientation);
4624 if (__pColorPicker.get())
4626 __pColorPicker->ChangeLayout(orientation);
4629 __isOrientationChanged = true;
4634 _WebImpl::OnAncestorVisibleStateChanged(const _Control& control)
4636 if (IsVisible() == true)
4638 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_VISIBLE, false);
4642 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_HIDDEN, false);
4648 _WebImpl::GetDownloadHandler(void) const
4650 return __pWebDownloadHandler.get();
4655 _WebImpl::HideColorPicker(void)
4657 __pColorPicker.reset();
4664 _WebImpl::ShowColorPicker(int red, int green, int blue, int alpha, Color& color)
4666 result r = E_SUCCESS;
4668 std::unique_ptr<_InputPickerPopup> pColorHadler(new (std::nothrow) _InputPickerPopup());
4669 SysTryReturnResult(NID_WEB_CTRL, pColorHadler.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4671 Tizen::Graphics::Color colorVal(static_cast< byte >(red), static_cast< byte >(green), static_cast< byte >(blue), static_cast< byte >(alpha));
4673 r = pColorHadler->Construct(colorVal, this);
4674 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4676 __pColorPicker = std::move(pColorHadler);
4678 r = __pColorPicker->ShowPopup();
4679 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4681 color = __pColorPicker->GetColor();
4686 __pColorPicker.reset();
4693 _WebImpl::ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue, String& dateStr)
4695 result r = E_SUCCESS;
4697 std::unique_ptr<_InputPickerPopup> pInputPicker(new (std::nothrow) _InputPickerPopup());
4698 SysTryReturnResult(NID_WEB_CTRL, pInputPicker.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4700 r = pInputPicker->Construct(String(inputValue), inputType, this);
4701 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4703 __pDatePicker = std::move(pInputPicker);
4705 r = __pDatePicker->ShowPopup();
4706 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4708 dateStr = __pDatePicker->GetDate();
4711 __pDatePicker.reset();
4718 _WebImpl::GetInstance(Web* pWeb)
4720 return dynamic_cast< _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
4725 _WebImpl::GetInstance(const Web* pWeb)
4727 return dynamic_cast< const _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
4732 _WebImpl::SearchHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
4734 int checkReturn = 0;
4736 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4739 if( checkmime == true)
4741 table = CUSTOM_CONTENT_TABLE_NAME;
4745 table = CUSTOM_PROTOCOL_TABLE_NAME;
4748 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
4749 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
4750 String target(ewk_custom_handlers_data_target_get(pHandlerData));
4752 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
4754 result r = db.Construct(handlerPath, "r+", null);
4755 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
4757 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"'"));
4758 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4762 r = pEnum->MoveNext();
4763 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
4764 r = pEnum->GetIntAt(0, checkReturn);
4765 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
4777 _WebImpl::UnregistrationHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
4781 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4784 if( checkmime == true)
4786 table = CUSTOM_CONTENT_TABLE_NAME;
4790 table = CUSTOM_PROTOCOL_TABLE_NAME;
4793 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
4794 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
4795 String target(ewk_custom_handlers_data_target_get(pHandlerData));
4797 SysSecureLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
4799 result r = db.Construct(handlerPath, "r+", null);
4800 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4802 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"'"));
4803 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4807 r = pEnum->MoveNext();
4808 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4809 r = pEnum->GetIntAt(0, checkId);
4810 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4812 std::unique_ptr<DbStatement> pDeleteStmt(db.CreateStatementN(L"Delete From " + table + L" Where id = (?)"));
4813 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4815 r = pDeleteStmt->BindInt(0, checkId);
4816 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4818 db.BeginTransaction();
4820 std::unique_ptr<DbEnumerator> pEnum(db.ExecuteStatementN(*pDeleteStmt));
4822 db.CommitTransaction();
4829 const Tizen::Base::String
4830 _WebImpl::GetProtocolFromUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri)
4832 if (originUri == L"" || currentUri == L"")
4837 result r = E_SUCCESS;
4840 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4841 String originReplace(originUri);
4842 String table(CUSTOM_PROTOCOL_TABLE_NAME);
4846 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
4847 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4849 r = currentUri.SubString(0, found + 1, baseUri);
4850 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4852 r = db.Construct(handlerPath, "r+", null);
4853 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4855 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select mime, url, allow From " + table + L" Where baseUrl = '" + baseUri + "'"));
4856 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, L"", GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
4860 while (pEnum->MoveNext() == E_SUCCESS)
4865 String originScheme;
4867 r = pEnum->GetStringAt(0, protocol);
4868 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4870 r = pEnum->GetStringAt(1, queryUrl);
4871 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4873 r = pEnum->GetIntAt(2, allow);
4874 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4881 String protocolScheme(protocol + L":");
4883 r = originReplace.SubString(0, protocolScheme.GetLength(), originScheme);
4884 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4886 if ((originReplace.GetLength() >= protocolScheme.GetLength()) && originScheme.Equals(protocolScheme, false))
4888 if (queryUrl.IndexOf(L"%s", 0, foundQuery) == E_SUCCESS)
4890 r = originReplace.Replace(originScheme, "");
4891 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4893 queryUrl.Replace("%s", originReplace, 0);
4894 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4906 const Tizen::Base::String
4907 _WebImpl::GetRedirectUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri, const Tizen::Base::String& mime)
4909 if (originUri == L"" || currentUri == L"" || mime == L"")
4914 result r = E_SUCCESS;
4917 String originUrlStr = originUri;
4918 const String replaceStr = L"%s";
4920 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4921 String table(CUSTOM_CONTENT_TABLE_NAME);
4925 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
4926 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4928 r = currentUri.SubString(0, found + 1, baseUri);
4929 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4931 r = db.Construct(handlerPath, "r+", null);
4932 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4934 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select allow, url From " + table + L" Where baseUrl = '" + baseUri + "' AND mime = '" + mime + L"'"));
4938 r = pEnum->MoveNext();
4939 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4940 r = pEnum->GetIntAt(0, allow);
4941 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4942 r = pEnum->GetStringAt(1, contentUrl);
4943 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4951 if (contentUrl != L"")
4953 r = contentUrl.Replace(replaceStr, originUrlStr, 0);
4954 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4965 }}} // Tizen::Web::Controls