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 <FIo_DatabaseImpl.h>
76 #include <FIo_NormalFile.h>
77 #include <FSys_VibratorImpl.h>
78 #include <FUi_Control.h>
79 #include <FUi_CoordinateSystemUtils.h>
80 #include <FUi_EcoreEvasMgr.h>
81 #include <FUi_EcoreEvas.h>
82 #include <FUi_ResourceSizeInfo.h>
83 #include <FUi_Window.h>
84 #include <FUiAnim_EflNode.h>
85 #include <FUiAnim_VisualElement.h>
86 #include <FUiCtrl_FooterImpl.h>
87 #include <FUiCtrl_Form.h>
88 #include "FWeb_HistoryItemImpl.h"
89 #include "FWebCtrl_AppControlListener.h"
90 #include "FWebCtrl_AuthConfirmPopup.h"
91 #include "FWebCtrl_AuthenticationChallengeImpl.h"
92 #include "FWebCtrl_EflWebkit.h"
93 #include "FWebCtrl_GeolocationPermissionManagerImpl.h"
94 #include "FWebCtrl_HitElementResultImpl.h"
95 #include "FWebCtrl_InputPickerPopup.h"
96 #include "FWebCtrl_WebNotification.h"
97 #include "FWebCtrl_PageNavigationListImpl.h"
98 #include "FWebCtrl_PromptPopup.h"
99 #include "FWebCtrl_SelectBox.h"
100 #include "FWebCtrl_Utility.h"
101 #include "FWebCtrl_Web.h"
102 #include "FWebCtrl_WebDataHandler.h"
103 #include "FWebCtrl_WebEvent.h"
104 #include "FWebCtrl_WebEventArg.h"
105 #include "FWebCtrl_WebImpl.h"
106 #include "FWebCtrl_WebPresenter.h"
107 #include "FWebCtrl_WebSettingImpl.h"
110 using namespace Tizen::App;
111 using namespace Tizen::Base;
112 using namespace Tizen::Base::Collection;
113 using namespace Tizen::Base::Runtime;
114 using namespace Tizen::Base::Utility;
115 using namespace Tizen::Content;
116 using namespace Tizen::Graphics;
117 using namespace Tizen::Io;
118 using namespace Tizen::Media;
119 using namespace Tizen::Net::Http;
120 using namespace Tizen::System;
121 using namespace Tizen::Ui;
122 using namespace Tizen::Ui::Animations;
123 using namespace Tizen::Ui::Controls;
124 using namespace Tizen::Web::Json;
127 namespace Tizen { namespace Web { namespace Controls
131 static const char WEB_CTRL[] = "webcontrol";
132 static const char PARENT_WEB_CTRL[] = "parentwebcontrol";
135 static const float MIN_ZOOM_LEVEL = 0.3;
136 static const float MAX_ZOOM_LEVEL = 2;
139 static const int REDIRECTION_HEADER_GROUP = 300;
142 static const int MAX_TEXT_MATCH = pow(2, 31) - 1;
145 static const int PORTRAIT_KEYPAD_HEIGHT = 444;
146 static const int LANDSCAPE_KEYPAD_HEIGHT = 316;
150 AddHttpHeaderData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData)
152 result r = E_SUCCESS;
154 String key(reinterpret_cast< const char* >(pKey));
155 String value(reinterpret_cast< char* >(pValue));
157 SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", key.GetPointer(), value.GetPointer());
159 r = reinterpret_cast< HttpHeader* >(pUserData)->AddField(key, value);
160 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
167 AddHttpAttributeData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData)
169 result r = E_SUCCESS;
171 std::unique_ptr<String> pAttrKey(new (std::nothrow) String(reinterpret_cast< char* >(const_cast< void* >(pKey))));
172 std::unique_ptr<String> pAttrValue(new (std::nothrow) String(reinterpret_cast< char* >(pValue)));
173 SysTryReturn(NID_WEB_CTRL, pAttrKey.get() && pAttrValue.get(), EINA_FALSE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
175 SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", pAttrKey->GetPointer(), pAttrValue->GetPointer());
177 r = reinterpret_cast< HashMap* >(pUserData)->Add(*pAttrKey, *pAttrValue);
178 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
180 pAttrValue.release();
187 FreeCharArray(void* pData)
189 delete[] reinterpret_cast<char*>(pData);
194 ConvertErrorCode(int error)
196 LoadingErrorType errorCode = WEB_ERROR_UNKNOWN;
200 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
202 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE:
204 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE_PROXY:
206 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT:
208 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT_PROXY:
210 case EWK_ERROR_NETWORK_STATUS_IO_ERROR:
212 case EWK_ERROR_NETWORK_STATUS_MALFORMED:
214 case EWK_ERROR_NETWORK_STATUS_TRY_AGAIN:
216 case EWK_ERROR_NETWORK_STATUS_TOO_MANY_REDIRECTS:
218 case EWK_ERROR_NETWORK_STATUS_TLS_FAILED:
220 case EWK_ERROR_NETWORK_STATUS_INTERNAL_SERVER_ERROR:
222 case EWK_ERROR_NETWORK_STATUS_BAD_GATEWAY:
224 case EWK_ERROR_NETWORK_STATUS_SERVICE_UNAVAILABLE:
226 case EWK_ERROR_NETWORK_STATUS_GATEWAY_TIMEOUT:
227 errorCode = WEB_NO_CONNECTION;
230 case EWK_ERROR_NETWORK_STATUS_BAD_REQUEST:
232 case EWK_ERROR_NETWORK_STATUS_REQUEST_URI_TOO_LONG:
233 errorCode = WEB_BAD_URL;
236 case EWK_ERROR_NETWORK_STATUS_FORBIDDEN:
237 errorCode = WEB_FILE_ACCESS_FAILED;
240 case EWK_ERROR_NETWORK_STATUS_REQUEST_TIMEOUT:
241 errorCode = WEB_REQUEST_TIMEOUT;
244 case EWK_ERROR_NETWORK_STATUS_UNSUPPORTED_MEDIA_TYPE:
245 errorCode = WEB_MIME_NOT_SUPPORTED;
248 case EWK_ERROR_NETWORK_STATUS_INSUFFICIENT_STORAGE:
249 errorCode = WEB_OUT_OF_MEMORY;
252 case EWK_ERROR_NETWORK_STATUS_REQUEST_ENTITY_TOO_LARGE:
253 errorCode = WEB_REQUEST_MAX_EXCEEDED;
256 case EWK_ERROR_NETWORK_STATUS_CONTINUE:
258 case EWK_ERROR_NETWORK_STATUS_SWITCHING_PROTOCOLS:
260 case EWK_ERROR_NETWORK_STATUS_PROCESSING:
262 case EWK_ERROR_NETWORK_STATUS_OK:
264 case EWK_ERROR_NETWORK_STATUS_CREATED:
266 case EWK_ERROR_NETWORK_STATUS_ACCEPTED:
268 case EWK_ERROR_NETWORK_STATUS_NON_AUTHORITATIVE:
270 case EWK_ERROR_NETWORK_STATUS_NO_CONTENT:
272 case EWK_ERROR_NETWORK_STATUS_RESET_CONTENT:
274 case EWK_ERROR_NETWORK_STATUS_PARTIAL_CONTENT:
276 case EWK_ERROR_NETWORK_STATUS_MULTI_STATUS:
278 case EWK_ERROR_NETWORK_STATUS_MULTIPLE_CHOICES:
280 case EWK_ERROR_NETWORK_STATUS_MOVED_PERMANENTLY:
282 case EWK_ERROR_NETWORK_STATUS_FOUND:
284 case EWK_ERROR_NETWORK_STATUS_SEE_OTHER:
286 case EWK_ERROR_NETWORK_STATUS_NOT_MODIFIED:
288 case EWK_ERROR_NETWORK_STATUS_USE_PROXY:
290 case EWK_ERROR_NETWORK_STATUS_NOT_APPEARING_IN_THIS_PROTOCOL:
292 case EWK_ERROR_NETWORK_STATUS_TEMPORARY_REDIRECT:
293 errorCode = WEB_HTTP_RESPONSE;
296 case EWK_ERROR_NETWORK_STATUS_SSL_FAILED:
297 errorCode = WEB_INVALID_CERTIFICATE;
301 errorCode = WEB_ERROR_UNKNOWN;
310 FireLoadingErrorOccurredEvent(_WebImpl* pImpl, int code, const char* pDescription)
312 result r = E_SUCCESS;
314 std::unique_ptr<Integer> pErrorCode(new (std::nothrow) Integer(code));
315 std::unique_ptr<String> pErrorDescription(new (std::nothrow) String(pDescription));
316 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED));
317 SysTryReturnResult(NID_WEB_CTRL, pErrorCode.get() && pErrorDescription.get() && pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
319 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_TYPE, *pErrorCode.get());
320 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
321 pErrorCode.release();
323 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_MESSAGE, *pErrorDescription.get());
324 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
325 pErrorDescription.release();
327 r = pImpl->GetWebEvent()->FireAsync(*pEventArg);
328 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
336 OnScriptAlertRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
338 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
340 result r = E_SUCCESS;
341 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
342 String msg(pMessage);
344 MessageBox messageBox;
345 r = messageBox.Construct(L"", msg, MSGBOX_STYLE_OK);
346 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
350 messageBox.SetOwner(&pImpl->GetPublic());
352 r = messageBox.ShowAndWait(modalResult);
353 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
355 ewk_view_javascript_alert_reply(pView);
362 OnScriptConfirmRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
364 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
366 result r = E_SUCCESS;
367 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
368 String msg(pMessage);
370 MessageBox messageBox;
371 r = messageBox.Construct(L"", msg, MSGBOX_STYLE_OKCANCEL);
372 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
376 messageBox.SetOwner(&pImpl->GetPublic());
378 r = messageBox.ShowAndWait(modalResult);
379 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
381 if (modalResult == MSGBOX_RESULT_OK)
383 ewk_view_javascript_confirm_reply(pView, EINA_TRUE);
387 ewk_view_javascript_confirm_reply(pView, EINA_FALSE);
395 OnScriptPromptRequested(Evas_Object* pView, const char* pMessage, const char* pDefaultValue, void* pUserData)
397 SysLog(NID_WEB_CTRL, "The current value of message is %s, defaulValue is %s", pMessage, pDefaultValue);
399 result r = E_SUCCESS;
400 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
401 String msg(pMessage);
402 String defVal(pDefaultValue);
404 std::unique_ptr< _PromptPopup > pPromptPopup(new (std::nothrow) _PromptPopup());
405 SysTryCatch(NID_WEB_CTRL, pPromptPopup.get(), , E_OUT_OF_MEMORY, "Memory allocation failed.");
407 r = pPromptPopup->Construct(msg, defVal, pView);
408 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
410 pPromptPopup->SetOwner(&pImpl->GetPublic());
412 r = pPromptPopup->ShowPopup();
413 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
415 pPromptPopup.release();
420 ewk_view_javascript_prompt_reply(pView, null);
427 OnCertificateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
429 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
430 Ewk_Certificate_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Certificate_Policy_Decision* >(pEventInfo);
431 SysAssertf(pImpl && pPolicy, "Failed to request");
433 switch (pImpl->GetSetting().GetCertificateErrorHandlingMode())
435 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM:
437 if (pImpl->IsCertificateRequested())
439 ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast< Eina_Bool >(pImpl->IsCertificateConfirmed()));
443 result r = E_SUCCESS;
445 r = pImpl->ShowCertificateConfirmPopup(CERTIFICATE_POPUP_MODE_USER_CONFIRM, pPolicy);
446 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
448 pImpl->SetCertificateRequested(true);
451 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CANCEL:
453 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE);
455 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE :
456 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_TRUE);
465 OnHttpAuthenticationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
467 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
468 Ewk_Auth_Challenge* pChallenge = reinterpret_cast< Ewk_Auth_Challenge* >(pEventInfo);
469 SysAssertf(pImpl && pChallenge, "Failed to request");
471 result r = E_SUCCESS;
473 r = pImpl->HttpAuthenticationRequested(pChallenge);
474 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
478 ewk_auth_challenge_credential_cancel(pChallenge);
479 evas_object_smart_callback_call(pView, "authentication,canceled", NULL);
484 OnHttpAuthenticationCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
486 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
487 SysAssertf(pImpl , "Failed to request");
489 if (pImpl->GetLoadingListener())
491 result r = E_SUCCESS;
493 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED));
494 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
496 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
497 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
504 OnGeolocationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
506 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
507 Ewk_Geolocation_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Geolocation_Permission_Request* >(pEventInfo);
508 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
510 if (pImpl->GetSetting().IsGeolocationEnabled())
512 result r = E_SUCCESS;
514 std::unique_ptr<DbEnumerator> pEnum;
516 String geolocationPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
517 String table(GEOLOCATION_TABLE_NAME);
520 const Ewk_Security_Origin* pSecurityOrigin = ewk_geolocation_permission_request_origin_get(pPermissionRequest);
521 String origin = _Utility::CreateOrigin(pSecurityOrigin);
523 r = db.Construct(geolocationPath, "r", null);
524 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
526 pEnum = std::unique_ptr<DbEnumerator>(db.QueryN(L"Select permission From " + table + L" Where origin = '" + origin + L"'"));
529 r = pEnum->MoveNext();
530 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
533 r = pEnum->GetIntAt(0, permission);
534 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
536 SysLog(NID_WEB_CTRL, "The current value of permission is %d", permission);
538 ewk_geolocation_permission_request_set(pPermissionRequest, static_cast < Eina_Bool >(permission));
542 ewk_geolocation_permission_request_suspend(pPermissionRequest);
544 r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_GEOLOCATION, pPermissionRequest);
545 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
552 ewk_geolocation_permission_request_set(pPermissionRequest, EINA_FALSE);
557 OnGetUserMediaPermissionRequsted(void* pUserData, Evas_Object* pView, void* pEventInfo)
559 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
560 Ewk_User_Media_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_User_Media_Permission_Request* >(pEventInfo);
561 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
563 result r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_USERMEDIA, pEventInfo);
564 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
568 ewk_user_media_permission_request_set(pPermissionRequest, EINA_FALSE);
573 OnNotificationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
575 result r = E_SUCCESS;
576 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
577 Ewk_Notification_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Notification_Permission_Request* >(pEventInfo);
578 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
580 MessageBox messageBox;
581 r = messageBox.Construct(L"Notification request", L"Do you want to allow notifications from this site ?", MSGBOX_STYLE_OKCANCEL);
582 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
586 messageBox.SetOwner(&pImpl->GetPublic());
588 r = messageBox.ShowAndWait(modalResult);
589 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
591 if (modalResult == MSGBOX_RESULT_OK)
593 ewk_notification_permission_request_set(pPermissionRequest, EINA_TRUE);
597 ewk_notification_permission_request_set(pPermissionRequest, EINA_FALSE);
603 OnNotificationShow(void* pUserData, Evas_Object* pView, void* pEventInfo)
605 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
606 Ewk_Notification* pNotification = reinterpret_cast< Ewk_Notification* >(pEventInfo);
607 SysAssertf(pImpl && pNotification, "Failed to request");
609 result r = E_SUCCESS;
610 Ewk_Context* pContext = ewk_view_context_get(pView);
611 SysAssertf(pContext, "Failed to get webkit instance.");
612 uint64_t notificationId = ewk_notification_id_get(pNotification);
614 //ewk_notification_security_origin_get(pNotification)
616 const char* text = ewk_notification_body_get(pNotification);
617 SysLog(NID_WEB_CTRL, "The current value of icon path is %s",ewk_notification_icon_url_get(pNotification));
619 std::unique_ptr<_WebNotification> pNotificationWindow( new (std::nothrow) _WebNotification());
620 SysTryReturnVoidResult(NID_WEB_CTRL, pNotificationWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
622 r = pNotificationWindow->Construct(pContext, notificationId, pImpl);
623 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Error propogated.", GetErrorMessage(r));
625 pNotificationWindow->SetText(String(text));
626 pNotificationWindow->LaunchNotification();
627 pNotificationWindow.release();
629 ewk_notification_showed(pContext, notificationId);
634 OnNotificationCancel(void* pUserData, Evas_Object* pView, void* pEventInfo)
636 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
637 uint64_t* pNotificationID = reinterpret_cast< uint64_t* >(pEventInfo);
638 SysAssertf(pImpl && pNotificationID, "Failed to request");
640 //ToDo : Where is ewk API for cancel operation?
645 OnProtocolHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
647 result r = E_SUCCESS;
648 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
649 SysAssertf(pImpl, "Failed to request");
651 r = pImpl->ShowUserConfirmPopup(USER_PROTOCOL_HANDLER, pEventInfo);
652 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
657 OnIsProtocolHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
659 int checkHandler = 0;
660 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
661 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
662 SysAssertf(pImpl && pHandlerData, "Failed to request");
664 checkHandler = pImpl->SearchHandler(pHandlerData, false);
665 SysTryReturnVoidResult(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
666 switch (checkHandler)
671 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_DECLINED);
674 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
677 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_NEW);
685 OnProtocolHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
687 result r = E_SUCCESS;
688 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
689 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
690 SysAssertf(pImpl && pHandlerData, "Failed to request");
692 r = pImpl->UnregistrationHandler(pHandlerData, false);
693 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
698 OnContentHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
700 result r = E_SUCCESS;
701 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
702 SysAssertf(pImpl, "Failed to request");
704 r = pImpl->ShowUserConfirmPopup(USER_CONTENT_HANDLER, pEventInfo);
705 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
710 OnIsContentHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
712 int checkHandler = 0;
713 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
714 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
715 SysAssertf(pImpl && pHandlerData, "Failed to request");
717 checkHandler = pImpl->SearchHandler(pHandlerData, true);
718 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);
740 OnContentHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
742 result r = E_SUCCESS;
743 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
744 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
745 SysAssertf(pImpl && pHandlerData, "Failed to request");
747 r = pImpl->UnregistrationHandler(pHandlerData, true);
748 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
753 OnVibrationRequested(uint64_t duration, void* pUserData)
755 result r = E_SUCCESS;
757 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
758 SysAssertf(pImpl, "Failed to request");
760 r = pImpl->VibrationRequested(duration);
761 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
766 OnVibrationCanceled(void* pUserData)
768 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
769 SysAssertf(pImpl, "Failed to request");
771 pImpl->VibrationCanceled();
776 OnApplicationCachePermissionRequested(Evas_Object* pView, Ewk_Security_Origin* pOrigin, void* pUserData)
778 ewk_view_application_cache_permission_reply(pView, EINA_TRUE);
785 OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
787 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
788 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
789 SysAssertf(pImpl && pPolicy, "Failed to request");
791 String url(ewk_policy_decision_url_get(pPolicy));
792 SysLog(NID_WEB_CTRL, "The current value of url is %ls", url.GetPointer());
794 if (url == L"about:blank")
796 ewk_policy_decision_use(pPolicy);
800 if (pImpl->GetLoadingListener() && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy))
801 && !pImpl->IsRedirectRequested())
803 pImpl->SetCertificateRequested(false);
805 if (pImpl->GetTextSearchListener())
807 pImpl->DisableAsyncSearch();
810 WebNavigationType navigationType = WEB_NAVIGATION_OTHER;
811 Ewk_Policy_Navigation_Type ewkNavigationType = ewk_policy_decision_navigation_type_get(pPolicy);
813 switch (ewkNavigationType)
815 case EWK_POLICY_NAVIGATION_TYPE_LINK_CLICKED:
816 navigationType = WEB_NAVIGATION_LINK_CLICKED;
818 case EWK_POLICY_NAVIGATION_TYPE_FORM_SUBMITTED:
819 navigationType = WEB_NAVIGATION_FORM_SUBMITTED;
821 case EWK_POLICY_NAVIGATION_TYPE_BACK_FORWARD:
822 navigationType = WEB_NAVIGATION_BACKFORWARD;
824 case EWK_POLICY_NAVIGATION_TYPE_RELOAD:
825 navigationType = WEB_NAVIGATION_RELOAD;
827 case EWK_POLICY_NAVIGATION_TYPE_FORM_RESUBMITTED:
828 navigationType = WEB_NAVIGATION_FORM_RESUBMITTED;
830 case EWK_POLICY_NAVIGATION_TYPE_OTHER:
831 navigationType = WEB_NAVIGATION_OTHER;
837 if (pImpl->GetLoadingListener()->OnLoadingRequested(url, navigationType))
839 ewk_policy_decision_ignore(pPolicy);
845 String currentUrl(pImpl->GetUrl());
846 String redirectUrl(pImpl->GetProtocolFromUri(url, currentUrl));
847 if (redirectUrl != L"")
849 pImpl->LoadUrl(redirectUrl);
850 ewk_policy_decision_ignore(pPolicy);
858 String uriScheme(uri.GetScheme());
859 SysLog(NID_WEB_CTRL, "The current value of scheme is %ls", uriScheme.GetPointer());
861 if ((uriScheme != L"http") && (uriScheme != L"https") && (uriScheme != L"file"))
863 ewk_policy_decision_ignore(pPolicy);
865 if (uriScheme == L"")
870 result r = E_SUCCESS;
872 _WebEventType eventType = WEB_EVENT_REQUEST_UNKNOWN;
874 if (uriScheme == L"rtsp")
876 eventType = WEB_EVENT_REQUEST_RTSP;
878 else if (uriScheme == L"mailto")
880 eventType = WEB_EVENT_REQUEST_EMAIL;
882 else if (uriScheme == L"tel")
884 eventType = WEB_EVENT_REQUEST_TEL;
886 else if (uriScheme == L"sms" || uriScheme == L"smsto" )
888 eventType = WEB_EVENT_REQUEST_SMS;
890 else if (uriScheme == L"mms" || uriScheme == L"mmsto" )
892 eventType = WEB_EVENT_REQUEST_MMS;
895 std::unique_ptr<_WebEventArg> pEventArg(new _WebEventArg(eventType, url));
896 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
898 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
899 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
905 ewk_policy_decision_use(pPolicy);
910 OnLoadingStarted(void* pUserData, Evas_Object* pView, void* pEventInfo)
912 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
913 SysAssertf(pImpl, "Failed to request");
915 if (pImpl->GetLoadingListener())
917 result r = E_SUCCESS;
919 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_STARTED));
920 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
922 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
923 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
930 OnPageTitleReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
932 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
933 char* pTitle = reinterpret_cast< char* >(pEventInfo);
934 SysAssertf(pImpl, "Failed to request");
936 SysLog(NID_WEB_CTRL, "The current value of title is %s", pTitle);
938 if (pImpl->GetLoadingListener())
940 result r = E_SUCCESS;
942 std::unique_ptr<String> pPageTitle(new (std::nothrow) String(pTitle));
943 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED));
944 SysTryReturnVoidResult(NID_WEB_CTRL, pPageTitle.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
946 r = pEventArg->SetEventInfo(_LoadingEventArg::PAGE_TITLE, *pPageTitle.get());
947 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
948 pPageTitle.release();
950 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
951 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
958 OnEstimatedProgress(void* pUserData, Evas_Object* pView, void* pEventInfo)
960 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
961 double* pProgress = reinterpret_cast< double* >(pEventInfo);
962 SysAssertf(pImpl, "Failed to request");
964 SysLog(NID_WEB_CTRL, "The current value of progress is %lf", *pProgress);
966 if (pImpl->GetLoadingListener())
968 result r = E_SUCCESS;
970 std::unique_ptr<Integer> pProgressPercentage(new (std::nothrow) Integer(static_cast< int >(*pProgress * 100)));
971 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PROGRESS));
972 SysTryReturnVoidResult(NID_WEB_CTRL, pProgressPercentage.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
974 r = pEventArg->SetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS, *pProgressPercentage.get());
975 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
976 pProgressPercentage.release();
978 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
979 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
986 OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
988 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
989 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
990 SysAssertf(pImpl && pPolicy, "Failed to request");
992 result r = E_SUCCESS;
994 const char* pUrl = ewk_policy_decision_url_get(pPolicy);
995 int code = ewk_policy_decision_response_status_code_get(pPolicy);
996 String mime(ewk_policy_decision_response_mime_get(pPolicy));
997 SysLog(NID_WEB_CTRL, "url : %s, mime : %ls, code : %d", pUrl, mime.GetPointer(), code);
999 ILoadingListener* pLoadingListener = pImpl->GetLoadingListener();
1001 String url(ewk_policy_decision_url_get(pPolicy));
1004 if (pLoadingListener && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy)))
1006 const Eina_Hash* pHeader = ewk_policy_decision_response_headers_get(pPolicy);
1008 DecisionPolicy policy;
1009 HttpHeader httpHeader;
1011 if (code >= REDIRECTION_HEADER_GROUP && code < REDIRECTION_HEADER_GROUP + 100)
1013 pImpl->SetRedirectRequested(true);
1017 eina_hash_foreach(pHeader, AddHttpHeaderData, &httpHeader);
1018 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1020 policy = pLoadingListener->OnWebDataReceived(mime, httpHeader);
1021 pImpl->SetPolicyDecision(policy);
1024 switch (pImpl->GetPolicyDecision())
1026 case WEB_DECISION_CONTINUE:
1028 String currentUrl(pImpl->GetUrl());
1029 String redirectUrl(pImpl->GetRedirectUri(url, currentUrl, mime));
1030 if (redirectUrl != L"")
1032 pImpl->LoadUrl(redirectUrl);
1033 ewk_policy_decision_ignore(pPolicy);
1038 if (pImpl->IsMimeSupported(mime) || mime == L"")
1045 SysLog(NID_WEB_CTRL, "Launch native app to handle the mime");
1047 ewk_policy_decision_ignore(pPolicy);
1049 AppControl* pAppControl = null;
1050 _SelectBox selectBox;
1052 int selectedIndex = 0;
1054 std::unique_ptr<IList, AllElementsDeleter> pList(_AppManagerImpl::FindAppControlsN(NULL, NULL, &mime, NULL));
1058 appCount = pList->GetCount();
1061 r = selectBox.Construct(false, L"", appCount+1); //+1 for Downloader
1062 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1064 selectBox.AddListItem(L"Download", _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
1065 for (int i = 0; i < appCount; i++)
1067 pAppControl = dynamic_cast< AppControl* >(pList->GetAt(i));
1068 SysTryReturnVoidResult(NID_WEB_CTRL, pAppControl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1070 String text = pAppControl->GetAppName();
1071 SysLog(NID_WEB_CTRL, "AppName : %S", text.GetPointer());
1073 selectBox.AddListItem(text, _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
1075 r = selectBox.ShowAndWait(selectedIndex);
1076 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1078 if (selectedIndex == 0) //download
1080 RequestId reqId = 0;
1081 DownloadRequest request(pUrl);
1083 _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
1084 SysTryReturnVoidResult(NID_WEB_CTRL, pManagerImpl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1086 r = pManagerImpl->Start(request, reqId);
1087 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1089 else if (selectedIndex != -1) // -1 for cancel
1091 String path("path");
1092 String pathVal(pUrl);
1095 r = dataList.Construct();
1096 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1098 r = dataList.Add(path, pathVal);
1099 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1101 pAppControl = dynamic_cast< AppControl* >(pList->GetAt(selectedIndex));
1102 SysTryReturnVoidResult(NID_WEB_CTRL, pAppControl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1104 _AppControlImpl* pAcImpl = _AppControlImpl::GetInstance(*pAppControl);
1105 SysTryReturnVoidResult(NID_WEB_CTRL, pAcImpl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1107 r = pAcImpl->Start(null, null, &dataList, null);
1108 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1115 case WEB_DECISION_DOWNLOAD:
1117 ewk_policy_decision_ignore(pPolicy);
1119 _WebDataHandler* pDownloadHandler = pImpl->GetDownloadHandler();
1120 SysTryReturnVoidResult(NID_WEB_CTRL, pDownloadHandler, E_SYSTEM, "[%s] A system error has been occurred. Failed to get DownloadHandler.", GetErrorMessage(E_SYSTEM));
1122 Ewk_Context* pContext = ewk_view_context_get(pView);
1123 SysAssertf(pContext, "Failed to get webkit instance.");
1125 pDownloadHandler->StartDownload(pUrl);
1129 case WEB_DECISION_IGNORE:
1131 ewk_policy_decision_ignore(pPolicy);
1141 ewk_policy_decision_use(pPolicy);
1146 ewk_policy_decision_ignore(pPolicy);
1151 OnProgressCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1153 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1154 SysAssertf(pImpl, "Failed to request");
1156 if (pImpl->IsRedirectRequested())
1158 pImpl->SetRedirectRequested(false);
1161 if (pImpl->IsLoadingErrorOccurred())
1163 pImpl->SetLoadingErrorOccurred(false);
1164 evas_object_smart_callback_call(pView, "load,finished", NULL);
1170 OnLoadingErrorOccurred(void* pUserData, Evas_Object* pView, void* pEventInfo)
1172 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1173 Ewk_Error* pErrorData = reinterpret_cast< Ewk_Error* >(pEventInfo);
1174 SysAssertf(pImpl && pErrorData, "Failed to request");
1176 int code = ewk_error_code_get(pErrorData);
1177 const char* pDescription = ewk_error_description_get(pErrorData);
1179 SysLog(NID_WEB_CTRL, "The current value of code is %d, description is %s", code, pDescription);
1181 pImpl->SetLoadingErrorOccurred(true);
1184 case EWK_ERROR_CODE_FRAMELOADINTERRUPTEDBYPOLICYCHANGE:
1186 case EWK_ERROR_CODE_PLUGINWILLHANDLELOAD:
1189 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
1190 evas_object_smart_callback_call(pView, "load,stop", NULL);
1194 if (pImpl->GetLoadingListener())
1196 result r = E_SUCCESS;
1198 r = FireLoadingErrorOccurredEvent(pImpl, code, pDescription);
1199 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1207 OnLoadingCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
1209 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1210 SysAssertf(pImpl, "Failed to request");
1212 if (pImpl->GetLoadingListener())
1214 result r = E_SUCCESS;
1216 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_CANCELED));
1217 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1219 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1220 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1221 pEventArg.release();
1228 OnLoadingCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1230 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1231 SysAssertf(pImpl, "Failed to request");
1233 if (pImpl->GetLoadingListener())
1235 result r = E_SUCCESS;
1237 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_COMPLETED));
1238 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1240 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1241 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1242 pEventArg.release();
1249 OnLoadingCommitted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1251 evas_object_focus_set(pView, EINA_FALSE);
1256 OnFaviconReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1258 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1259 SysAssertf(pImpl, "Failed to request");
1261 if (pImpl->GetLoadingListener())
1263 result r = E_SUCCESS;
1265 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED));
1266 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1268 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1269 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1270 pEventArg.release();
1277 OnDidStartDownloadCallback(const char* pUrl, void* pUserData)
1279 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1280 SysAssertf(pUrl && pImpl != null, "Failed to request");
1282 SysLog(NID_WEB_CTRL, "The current value of url is %s", pUrl);
1287 FireWebPageShowRequestedEvent(_WebImpl* pImpl, int event)
1289 result r = E_SUCCESS;
1291 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1292 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1294 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1295 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1296 pEventArg.release();
1303 OnWebPageShowRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1305 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1306 SysAssertf(pImpl, "Failed to request");
1308 if (pImpl->GetUiEventListener())
1310 result r = E_SUCCESS;
1312 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED);
1313 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1315 if (pImpl->GetUiEventListenerF())
1317 result r = E_SUCCESS;
1319 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT);
1320 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1326 OnWebWindowCreateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1328 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(pUserData);
1329 Evas_Object** pChildView = reinterpret_cast< Evas_Object** >(pEventInfo);
1330 SysAssertf(pParentImpl && pChildView, "Failed to request");
1332 IWebUiEventListener* pUserUiListener = pParentImpl->GetUiEventListener();
1333 IWebUiEventListenerF* pUserUiListenerF = pParentImpl->GetUiEventListenerF();
1334 if (pUserUiListener)
1336 Web* pWeb = pUserUiListener->OnWebWindowCreateRequested();
1339 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1340 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1342 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1343 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1346 if (pUserUiListenerF)
1348 Web* pWeb = pUserUiListenerF->OnWebWindowCreateRequested();
1351 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1352 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1354 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1355 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1362 FireWebWindowClosedRequestedEvent(_WebImpl* pImpl, int event)
1364 result r = E_SUCCESS;
1366 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1367 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1369 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1370 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1371 pEventArg.release();
1378 OnWebWindowClosedRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1380 _WebImpl* pChildImpl = reinterpret_cast< _WebImpl* >(pUserData);
1381 SysAssertf(pChildImpl, "Failed to request");
1383 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, PARENT_WEB_CTRL));
1384 if (pParentImpl == null)
1389 if (pParentImpl->GetUiEventListener())
1391 result r = E_SUCCESS;
1393 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED);
1394 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1396 if (pParentImpl->GetUiEventListenerF())
1398 result r = E_SUCCESS;
1400 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT);
1401 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1407 FireWebPreventDefaultTriggeredEvent(_WebImpl* pImpl, int event, bool trigger)
1409 result r = E_SUCCESS;
1411 std::unique_ptr<Boolean> pPreventTrigger(new (std::nothrow) Boolean(trigger));
1412 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1413 SysTryReturnResult(NID_WEB_CTRL, pPreventTrigger.get() && pEventArg.get(), E_OUT_OF_MEMORY, " Memory allocation failed." );
1415 r = pEventArg->SetEventInfo(_WebUiEventArg::PREVENT_DEFAULT, *pPreventTrigger.get());
1416 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1417 pPreventTrigger.release();
1419 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1420 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1421 pEventArg.release();
1428 OnWebPreventDefaultTriggered(void* pUserData, Evas_Object* pView, void* pEventInfo)
1430 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1431 Eina_Bool* pTrigger = reinterpret_cast< Eina_Bool* >(pEventInfo);
1432 SysAssertf(pImpl && pTrigger, "Failed to request");
1434 if (pImpl->GetUiEventListener())
1436 result r = E_SUCCESS;
1438 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED, static_cast< bool >(*pTrigger));
1439 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1441 if (pImpl->GetUiEventListenerF())
1443 result r = E_SUCCESS;
1445 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT, static_cast< bool >(*pTrigger));
1446 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1452 FireWebPageBlockSelectedEvent(_WebImpl* pImpl)
1454 result r = E_SUCCESS;
1456 std::unique_ptr<Point> startPoint(new (std::nothrow) Point());
1457 std::unique_ptr<Point> endPoint(new (std::nothrow) Point());
1458 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1460 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1462 if ((endPoint->x != 0) && (endPoint->y != 0))
1464 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED));
1465 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1467 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1468 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1469 startPoint.release();
1471 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1472 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1475 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1476 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1477 pEventArg.release();
1485 FireWebPageBlockSelectedEventF(_WebImpl* pImpl)
1487 result r = E_SUCCESS;
1489 std::unique_ptr<FloatPoint> startPoint(new (std::nothrow) FloatPoint());
1490 std::unique_ptr<FloatPoint> endPoint(new (std::nothrow) FloatPoint());
1492 SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1494 pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
1496 if ((endPoint->x != 0.0f) && (endPoint->y != 0.0f))
1498 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT));
1499 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
1501 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
1502 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1503 startPoint.release();
1505 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
1506 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1509 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1510 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1511 pEventArg.release();
1519 OnWebPageBlockSelected(void* pUserData, Evas_Object* pView, void* pEventInfo)
1521 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1522 Ewk_Text_Style* pStyle = reinterpret_cast< Ewk_Text_Style* >(pEventInfo);
1523 SysAssertf(pImpl && pStyle, "Failed to request");
1525 if (pImpl->GetUiEventListener())
1527 result r = E_SUCCESS;
1529 r = FireWebPageBlockSelectedEvent(pImpl);
1530 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1532 if (pImpl->GetUiEventListenerF())
1534 result r = E_SUCCESS;
1536 r = FireWebPageBlockSelectedEventF(pImpl);
1537 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1543 OnSelectUploadFile(Evas_Object* pView, Eina_Bool multipleFile, Eina_List* pAcceptTypes, const char* pCapture, void* pUserData)
1545 String isMultipleSelection(L"single");
1546 result r = E_SUCCESS;
1549 String mode(L"selectionType");
1550 String type(L"type");
1551 _AppControlImpl* pMediaAppControlImpl = null;
1554 String fileType = L"all";
1558 isMultipleSelection.Append(L"multiple");
1561 std::unique_ptr<AppControl> pMediaAppControl(_AppManagerImpl::FindAppControlN(L"tizen.filemanager", L"http://tizen.org/appcontrol/operation/pick"));
1562 SysTryReturn(NID_WEB_CTRL, pMediaAppControl.get(), EINA_TRUE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1564 std::unique_ptr<_MediaSelectionListener> pMediaListener(new (std::nothrow) _MediaSelectionListener());
1565 SysTryReturn(NID_WEB_CTRL, pMediaListener.get(), EINA_TRUE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1567 pMediaListener->Construct(pView, pMediaAppControl.get());
1569 itemCount = eina_list_count(pAcceptTypes);
1573 String item((char*)eina_list_nth(pAcceptTypes, 0));
1574 if (item.StartsWith("image/",0))
1576 fileType = L"image";
1578 else if (item.StartsWith("audio/",0))
1580 fileType = L"audio";
1582 else if (item.StartsWith("video/",0))
1584 fileType = L"video";
1588 r = dataList.Construct();
1589 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1591 r = dataList.Add(mode, isMultipleSelection);
1592 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1594 r = dataList.Add(type, fileType);
1595 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1597 pMediaAppControlImpl = _AppControlImpl::GetInstance(*pMediaAppControl.get());
1598 r = pMediaAppControlImpl->Start(null, null, &dataList, pMediaListener.get());
1599 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1601 pMediaListener.release();
1602 pMediaAppControl.release();
1607 ewk_view_open_panel_reply(pView, null, EINA_FALSE);
1613 OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo)
1615 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1616 char* pJsonText = reinterpret_cast< char* >(pEventInfo);
1617 SysAssertf(pImpl && pJsonText, "Failed to request");
1619 result r = E_SUCCESS;
1621 SysLog(NID_WEB_CTRL, "The current value of jsontext is %s", pJsonText);
1623 std::unique_ptr<_JsBridgeArg> pEventArg(new (std::nothrow) _JsBridgeArg());
1624 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1626 r = pEventArg->Construct(pJsonText);
1627 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1629 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1630 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1631 pEventArg.release();
1636 OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo)
1638 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1639 Eina_Rectangle* pEinaRect = reinterpret_cast< Eina_Rectangle* >(pEventInfo);
1640 SysAssertf(pImpl && pEinaRect, "Failed to request");
1642 if (pImpl->GetSetting().GetInputStyle() == INPUT_STYLE_OVERLAY)
1644 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1645 SysAssertf(pXformer, "Failed to get CoordinateTransformer");
1647 Rectangle rect(pEinaRect->x, pEinaRect->y, pEinaRect->w, pEinaRect->h);
1649 if (rect.height == 0)
1654 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1657 if (pFormCore->HasFooter() && pFormCore->IsFooterVisible())
1659 pImpl->SetFooterVisibleState(true);
1660 pFormCore->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, false);
1663 pFormCore->DeflateClientRectHeight(pXformer->TransformVertical(rect.height));
1666 if (pImpl->GetWebKeypadEventListener())
1668 if (pImpl->IsKeypadVisible() == true)
1670 if ((pImpl->GetPreviousKeypadBounds().width == rect.width) && (pImpl->GetPreviousKeypadBounds().height != rect.height))
1672 pImpl->GetWebKeypadEventListener()->OnWebKeypadBoundsChanged(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1677 pImpl->GetWebKeypadEventListener()->OnWebKeypadWillOpen(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1680 pImpl->SetKeypadVisibleState(true);
1681 pImpl->SetPreviousKeypadBounds(rect);
1685 result r = pImpl->SetFullScreenKeypad();
1686 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1692 OnWebKeypadOpened(void* pUserData, Evas_Object* pView, void* pEventInfo)
1694 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1695 SysAssertf(pImpl, "Failed to request");
1697 if (pImpl->GetWebKeypadEventListener())
1699 pImpl->GetWebKeypadEventListener()->OnWebKeypadOpened(*static_cast< Web* >(&pImpl->GetPublic()));
1705 OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo)
1707 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1708 SysAssertf(pImpl, "Failed to request");
1710 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1713 if (pFormCore->HasFooter() && pImpl->IsFooterVisible())
1715 pImpl->SetFooterVisibleState(false);
1716 pFormCore->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1719 pFormCore->DeflateClientRectHeight(0);
1722 if (pImpl->GetWebKeypadEventListener())
1724 pImpl->GetWebKeypadEventListener()->OnWebKeypadClosed(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1727 pImpl->SetKeypadVisibleState(false);
1732 OnWindowObjectFocusGained(void *pUserData, Evas_Object *pWin, void *pEvent_info)
1734 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1735 SysAssertf(pImpl, "Failed to request");
1737 if (pImpl->IsKeypadOpened() == true)
1739 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
1740 SysAssertf(pWebCore, "Failed to get Web core object");
1742 evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE);
1744 pImpl->SetKeypadOpened(false);
1750 OnWebNativeNodeFocusGained(void *pUserData, Evas *pCanvas, Evas_Object* pView, void* pEventInfo)
1752 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1753 SysAssertf(pImpl, "Failed to request");
1755 if (pImpl->IsKeypadOpened() == true)
1757 pImpl->SetKeypadOpened(false);
1763 OnColorPickerProviderRequested(Ewk_View_Smart_Data *pSmartData, int red, int green, int blue, int alpha)
1765 SysAssertf(pSmartData, "invalid smartdata");
1766 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1767 SysAssertf(pWebImpl, "Failed to get Impl");
1769 result r = E_SUCCESS;
1771 if (pWebImpl->GetColorpicker())
1778 r = pWebImpl->ShowColorPicker(red, green, blue, alpha, color);
1779 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1781 byte r1, g1, b1, a1;
1782 color.GetColorComponents(r1, g1, b1, a1);
1783 ewk_view_color_picker_color_set(pSmartData->self, r1, g1, b1, a1);
1790 OnColorPickerProviderDismissed(Ewk_View_Smart_Data *pSmartData)
1792 SysAssertf(pSmartData, "invalid smartdata");
1794 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1795 SysAssertf(pWebImpl, "Failed to get Impl");
1797 return pWebImpl->HideColorPicker();
1802 OnDatePickerProviderRequested(Ewk_View_Smart_Data *pSmartData, Ewk_Input_Type inputType, const char* inputValue)
1804 SysAssertf(pSmartData, "Failed to request");
1805 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1806 SysAssertf(pWebImpl, "Failed to get Impl");
1808 result r = E_SUCCESS;
1810 if (pWebImpl->GetDatepicker())
1812 ewk_view_focused_input_element_value_set(pSmartData->self, inputValue);
1819 r = pWebImpl->ShowDatePicker(inputType, inputValue, dateStr);
1820 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1822 std::unique_ptr<char[]> pDateStr(_StringConverter::CopyToCharArrayN(dateStr));
1823 SysTryReturn(NID_WEB_CTRL, pDateStr.get(), EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1825 ewk_view_focused_input_element_value_set(pSmartData->self, pDateStr.get());
1832 OnSelectBoxRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex)
1834 SysAssertf(pSmartData, "Failed to request");
1836 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1837 SysAssertf(pWebImpl, "Failed to get Impl");
1839 result r = pWebImpl->ShowSelectBoxPopup(false, L"", pItems, pSmartData->self, selectedIndex);
1840 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1847 OnSelectBoxClosed(Ewk_View_Smart_Data *pSmartData)
1849 SysAssertf(pSmartData, "invalid smartdata");
1851 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1852 SysAssertf(pWebImpl, "Failed to get Impl");
1854 result r = pWebImpl->ClearSelectBoxPopup();
1855 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1862 OnSelectBoxUpdateRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, Eina_List* pItems, int selectedIndex)
1864 SysAssertf(pSmartData, "invalid smartdata");
1866 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1867 SysAssertf(pWebImpl, "Failed to get Impl");
1869 result r = pWebImpl->UpdateSelectBoxPopup(pItems, selectedIndex, false);
1870 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1877 OnCookiesPolicyGot(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *pError, void *pUserData)
1879 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
1880 SysAssertf(pPresenter && !pError, "Failed to request");
1882 bool ret = EINA_TRUE;
1886 case EWK_COOKIE_ACCEPT_POLICY_ALWAYS:
1888 case EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY:
1892 case EWK_COOKIE_ACCEPT_POLICY_NEVER:
1901 SysLog(NID_WEB_CTRL, "The current value of policy is %d", ret);
1903 pPresenter->EndAsyncProcess(ret);
1908 OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData)
1910 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
1911 SysAssertf(pPresenter, "Failed to request");
1913 String result(pResult);
1914 SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer());
1916 pPresenter->EndAsyncProcess(result);
1921 OnTextFound(void* pUserData, Evas_Object* pView, void* pEventInfo)
1923 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1924 SysAssertf(pImpl, "Failed to request");
1926 int* pTotalCount = reinterpret_cast< int* >(pEventInfo);
1927 SysLog(NID_WEB_CTRL, "The current value of totalCount is %d", *pTotalCount);
1929 _WebPresenter* pWebPresenter = pImpl->GetSearchPresenter();
1933 pWebPresenter->EndAsyncProcess(*pTotalCount);
1937 if (pImpl->GetTextSearchListener())
1939 result r = E_SUCCESS;
1943 if (*pTotalCount > 0)
1945 ordinal = pImpl->GetAsyncSearchOrdinal();
1946 pImpl->SetAsyncSearchResult(*pTotalCount);
1949 if (pImpl->GetPendingAsyncSearchCount() > 0)
1954 std::unique_ptr<Integer> pCount(new (std::nothrow) Integer(*pTotalCount));
1955 std::unique_ptr<Integer> pOrdinal(new (std::nothrow) Integer(ordinal));
1956 std::unique_ptr<_TextSearchEventArg> pEventArg(new (std::nothrow) _TextSearchEventArg(WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND));
1957 SysTryReturnVoidResult(NID_WEB_CTRL, pCount.get() && pOrdinal.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1959 r = pEventArg->SetEventInfo(_TextSearchEventArg::TOTAL_COUNT, *pCount.get());
1960 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1963 r = pEventArg->SetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL, *pOrdinal.get());
1964 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1967 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1968 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1969 pEventArg.release();
1975 class _JsBridgeHashCodeProvider
1976 : public Tizen::Base::Collection::IHashCodeProviderT< Tizen::Base::String >
1979 _JsBridgeHashCodeProvider(){}
1980 virtual ~_JsBridgeHashCodeProvider(void) {}
1983 int GetHashCode(const Tizen::Base::String& obj) const
1985 return obj.GetHashCode();
1991 //Comparer implementation
1992 class _JsBridgeComparer
1993 : public Tizen::Base::Collection::IComparerT< Tizen::Base::String >
1996 _JsBridgeComparer(){}
1997 virtual ~_JsBridgeComparer(void) {}
2000 result Compare(const Tizen::Base::String& obj1, const Tizen::Base::String& obj2, int& cmp) const
2017 _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
2018 : _ContainerImpl(pWeb, pCore)
2019 , __isFooterVisible(false)
2020 , __isKeypadVisible(false)
2021 , __isKeypadOpened(false)
2022 , __isLoadingErrorOccurred(false)
2023 , __isRedirectRequested(false)
2024 , __isCertificateRequested(false)
2025 , __isCertificateConfirmed(false)
2026 , __keypadBounds(0, 0, 0, 0)
2028 , __pUserLoadingListener(null)
2029 , __pUserUiListener(null)
2030 , __pUserUiListenerF(null)
2031 , __pUserKeypadEventListener(null)
2032 , __pTextSearchListener(null)
2034 , __pJsBridgeList(null)
2035 , __pJsProvider(null)
2036 , __pJsComparer(null)
2037 , __pWebDownloadHandler(null)
2039 , __pAuthChallenge(null)
2040 , __pAuthPopup(null)
2041 , __pUserConfirmPopup(null)
2042 , __pCertConfirmPopup(null)
2043 , __pSelectBox(null)
2044 , __pDatePicker(null)
2045 , __pColorPicker(null)
2047 , __policy(WEB_DECISION_CONTINUE)
2049 __textSearch.__searchAll = false;
2050 __textSearch.__searchForward = true;
2051 __textSearch.__caseSensitive = false;
2052 __textSearch.__pending = 0;
2053 __textSearch.__currentIndex = 1;
2054 __textSearch.__totalCount = -1;
2055 __textSearch.__text = L"";
2059 _WebImpl::~_WebImpl()
2061 RemoveEventListenerCallback();
2065 _WebImpl::CreateWebImplN(Web* pControl, const Rectangle& bounds)
2067 result r = E_SUCCESS;
2069 r = GET_SIZE_INFO(Web).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2070 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2072 _Web* pCore = _Web::CreateWebN();
2073 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2075 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2077 r = CheckConstruction(pCore, pImpl);
2078 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2080 r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2081 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2083 r = pImpl->Construct();
2084 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2096 _WebImpl::CreateWebImplN(Web* pControl, const FloatRectangle& bounds)
2098 result r = E_SUCCESS;
2100 r = GET_SIZE_INFO(Web).CheckInitialSizeValidF(FloatDimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
2101 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2103 _Web* pCore = _Web::CreateWebN();
2104 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2106 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
2108 r = CheckConstruction(pCore, pImpl);
2109 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2111 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
2112 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2114 r = pImpl->Construct();
2115 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2127 _WebImpl::Construct(void)
2129 result r = E_SUCCESS;
2131 r = __mutex.Create();
2132 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2134 r = __textSearch.__searchQueue.Construct();
2135 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2137 r = InitJsBridgeList();
2138 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2141 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2143 __pWebCore = dynamic_cast< _Web* >(&(GetCore()));
2144 SysTryReturnResult(NID_WEB_CTRL, __pWebCore, E_SYSTEM, "A system error has been occurred. Failed to get web control");
2151 _WebImpl::InitializeSetting(void)
2153 result r = E_SUCCESS;
2155 r = SetSetting(*__pWebCore->GetSetting());
2156 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2158 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting());
2160 SetCookieEnabled(pWebSettingImpl->IsCookieEnabled());
2161 SetPrivateBrowsingEnabled(pWebSettingImpl->IsPrivateBrowsingEnabled());
2162 SetZoomLevel(pWebSettingImpl->GetZoomLevel());
2164 SetEventListenerCallback();
2171 _WebImpl::IsLayoutable(void) const
2178 _WebImpl::InitWebEvent(void)
2180 __pWebEvent = std::unique_ptr<_WebEvent>(new (std::nothrow) _WebEvent());
2181 SysTryReturnResult(NID_WEB_CTRL, __pWebEvent.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2183 return __pWebEvent->Construct(*this);
2188 _WebImpl::GetWebEvent(void) const
2190 return __pWebEvent.get();
2195 _WebImpl::ConvertToSlpHeaderN(const HttpHeader& header) const
2197 Eina_Hash* pHttpHeader = null;
2199 std::unique_ptr<IList> pFieldNameList(header.GetFieldNamesN());
2200 if (pFieldNameList.get())
2202 pHttpHeader = eina_hash_string_small_new(FreeCharArray);
2203 SysTryReturn(NID_WEB_CTRL, pHttpHeader, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2205 int count = pFieldNameList->GetCount();
2207 for (int i = 0; i < count; i++)
2209 String* pFieldName = dynamic_cast< String* >(pFieldNameList->GetAt(i));
2210 SysTryCatch(NID_WEB_CTRL, pFieldName, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2212 std::unique_ptr<char[]> pKey(_StringConverter::CopyToCharArrayN(*pFieldName));
2213 SysTryCatch(NID_WEB_CTRL, pKey.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2215 std::unique_ptr<IEnumerator> pFieldValueEnum(header.GetFieldValuesN(*pFieldName));
2216 SysTryCatch(NID_WEB_CTRL, pFieldValueEnum.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2218 while (pFieldValueEnum->MoveNext() == E_SUCCESS)
2220 Eina_Bool ret = false;
2222 String* pFieldValue = dynamic_cast< String* >(pFieldValueEnum->GetCurrent());
2223 SysTryCatch(NID_WEB_CTRL, pFieldValue, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2225 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(*pFieldValue));
2226 SysTryCatch(NID_WEB_CTRL, pValue.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2228 ret = eina_hash_add(pHttpHeader, pKey.get(), pValue.release());
2229 SysTryCatch(NID_WEB_CTRL, ret == EINA_TRUE, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2236 eina_hash_free(pHttpHeader);
2243 _WebImpl::LoadUrl(const String& url) const
2245 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2246 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2248 ewk_view_url_set(__pWebCore->GetWebNativeNode(), pUrl.get());
2255 _WebImpl::LoadUrl(const String& url, const HttpHeader& header)
2257 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2258 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2260 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2262 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_GET, pHttpHeader, null);
2264 eina_hash_free(pHttpHeader);
2271 _WebImpl::LoadUrlWithPostRequest(const String& url, const HttpHeader& header, const ByteBuffer& body) const
2273 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2274 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2276 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2278 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_POST, pHttpHeader, reinterpret_cast< const char* >(body.GetPointer()));
2280 eina_hash_free(pHttpHeader);
2287 _WebImpl::LoadData(const String& baseUrl, const ByteBuffer& content, const String& mime, const String& encoding) const
2289 SysTryReturnResult(NID_WEB_CTRL, content.GetLimit() > 0, E_INVALID_ARG, "The content buffer is empty.");
2291 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(baseUrl));
2292 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
2293 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(encoding));
2294 SysTryReturn(NID_WEB_CTRL, pUrl.get() && pMime.get() && pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2296 ewk_view_contents_set(__pWebCore->GetWebNativeNode(), reinterpret_cast< const char* >(content.GetPointer()), content.GetLimit(), pMime.get(), pEncoding.get(), pUrl.get());
2303 _WebImpl::Pause(void)
2305 ewk_view_suspend(__pWebCore->GetWebNativeNode());
2310 _WebImpl::Resume(void)
2312 ewk_view_resume(__pWebCore->GetWebNativeNode());
2317 _WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List* pItems, Evas_Object* pWebView, int selectedIndex)
2319 __pSelectBox.reset();
2321 int itemCount = eina_list_count(pItems);
2322 SysTryReturnResult(NID_WEB_CTRL, itemCount > 0, E_SYSTEM, "ItemCount is invalid.");
2324 result r = E_SUCCESS;
2326 std::unique_ptr<_SelectBox> pSelectBox(new (std::nothrow) _SelectBox());
2327 SysTryReturnResult(NID_WEB_CTRL, pSelectBox.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2329 r = pSelectBox->Construct(isMultiSelect, title, itemCount, pWebView);
2330 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2332 r = pSelectBox->UpdateList(pItems, selectedIndex, false, false);
2333 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2335 __pSelectBox = std::move(pSelectBox);
2337 __pSelectBox->SetOwner(&GetPublic());
2339 return __pSelectBox->ShowPopup();
2344 _WebImpl::UpdateSelectBoxPopup(Eina_List* pItems, int selectedIndex, bool isGroupedList)
2346 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2348 return __pSelectBox->UpdateList(pItems, selectedIndex, true, isGroupedList);
2353 _WebImpl::ClearSelectBoxPopup(void)
2355 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2357 __pSelectBox.reset();
2364 _WebImpl::GetDatepicker(void)
2366 _InputPickerPopup* pInputPicker =null;
2369 pInputPicker = __pDatePicker.get();
2371 return pInputPicker;
2376 _WebImpl::GetColorpicker(void)
2378 _InputPickerPopup* pInputPicker =null;
2381 pInputPicker = __pColorPicker.get();
2383 return pInputPicker;
2388 _WebImpl::CanGoBack(void) const
2390 return static_cast< bool >(ewk_view_back_possible(__pWebCore->GetWebNativeNode()));
2395 _WebImpl::CanGoForward(void) const
2397 return static_cast< bool >(ewk_view_forward_possible(__pWebCore->GetWebNativeNode()));
2402 _WebImpl::GoBack(void) const
2404 ewk_view_back(__pWebCore->GetWebNativeNode());
2409 _WebImpl::GoForward(void) const
2411 ewk_view_forward(__pWebCore->GetWebNativeNode());
2416 _WebImpl::GetUrl(void) const
2418 return ewk_view_url_get(__pWebCore->GetWebNativeNode());
2423 _WebImpl::GetTitle(void) const
2425 return ewk_view_title_get(__pWebCore->GetWebNativeNode());
2430 _WebImpl::StopLoading(void) const
2432 ewk_view_stop(__pWebCore->GetWebNativeNode());
2437 _WebImpl::Reload(void) const
2439 ewk_view_reload_bypass_cache(__pWebCore->GetWebNativeNode());
2444 _WebImpl::EvaluateJavascriptN(const String& scriptCode) const
2446 if (scriptCode.GetLength())
2448 std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(scriptCode));
2449 SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2451 _WebPresenter presenter;
2452 presenter.InitAsyncProcess();
2454 ewk_view_script_execute(__pWebCore->GetWebNativeNode(), pScript.get(), OnScriptExecuted, &presenter);
2456 Tizen::Base::String* pResult = new (std::nothrow) Tizen::Base::String(L"");
2457 SysTryReturn(NID_WEB_CTRL, pResult, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2458 presenter.WaitAsyncProcess(*pResult);
2468 _WebImpl::SetZoomLevel(float level)
2470 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);
2472 ewk_view_scale_set(__pWebCore->GetWebNativeNode(), static_cast< double >(level), 0, 0);
2479 _WebImpl::GetZoomLevel(void) const
2481 return static_cast< float >(ewk_view_scale_get(__pWebCore->GetWebNativeNode()));
2485 const PageNavigationList*
2486 _WebImpl::GetBackForwardListN(void) const
2488 result r = E_SUCCESS;
2490 _PageNavigationListImpl* pNavigationListImpl = null;
2491 _HistoryItemImpl* pHistoryItemImpl = null;
2493 std::unique_ptr<PageNavigationList> pNavigationList;
2494 std::unique_ptr<ArrayList, AllElementsDeleter> pHistoryList;
2497 int forwardCount = 0;
2502 Ewk_History* pEwkHistoryList = ewk_view_history_get(__pWebCore->GetWebNativeNode());
2503 SysTryReturn(NID_WEB_CTRL, pEwkHistoryList, null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get full history.", GetErrorMessage(E_SYSTEM));
2505 Ewk_History_Item* pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, 0);
2506 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_DATA_NOT_FOUND, "[%s] There is no history.", GetErrorMessage(E_DATA_NOT_FOUND));
2508 pNavigationList = std::unique_ptr<PageNavigationList>(new (std::nothrow) PageNavigationList());
2509 SysTryCatch(NID_WEB_CTRL, pNavigationList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2511 pNavigationListImpl = _PageNavigationListImpl::GetInstance(pNavigationList.get());
2512 SysTryCatch(NID_WEB_CTRL, pNavigationListImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2514 pHistoryList = std::unique_ptr<ArrayList, AllElementsDeleter>(new (std::nothrow) ArrayList());
2515 SysTryCatch(NID_WEB_CTRL, pHistoryList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2517 r = pHistoryList->Construct();
2518 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2520 backCount = ewk_history_back_list_length_get(pEwkHistoryList);
2521 forwardCount = ewk_history_forward_list_length_get(pEwkHistoryList);
2522 SysLog(NID_WEB_CTRL, "The current value of backCount is %d, forwardCount is %d", backCount, forwardCount);
2524 for (int i = -backCount; i < forwardCount + 1; i++)
2526 std::unique_ptr<HistoryItem> pHistoryItem(new (std::nothrow) HistoryItem());
2527 SysTryCatch(NID_WEB_CTRL, pHistoryItem.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2529 pHistoryItemImpl = _HistoryItemImpl::GetInstance(pHistoryItem.get());
2530 SysTryCatch(NID_WEB_CTRL, pHistoryItemImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2532 pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, i);
2533 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2535 url = ewk_history_item_uri_get(pEwkItem);
2536 title = ewk_history_item_title_get(pEwkItem);
2537 SysLog(NID_WEB_CTRL, "The current value of url is %s, title is %s", url.GetPointer(), title.GetPointer());
2539 pHistoryItemImpl->SetHistoryItem(url, title);
2541 r = pHistoryList->Add(*pHistoryItem.get());
2542 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2543 pHistoryItem.release();
2546 pNavigationListImpl->SetPageNavigationList(pHistoryList.release(), backCount);
2548 ewk_history_free(pEwkHistoryList);
2550 return pNavigationList.release();
2553 ewk_history_free(pEwkHistoryList);
2560 _WebImpl::SearchText(const String& text, bool searchForward)
2562 result r = E_SUCCESS;
2564 Ewk_Find_Options condition = static_cast< Ewk_Find_Options >(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2568 condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS);
2571 _WebPresenter presenter;
2572 presenter.InitAsyncProcess();
2574 r = SynchronizeSearch(SEARCH_SYNC, __pWebCore->GetWebNativeNode(), condition, text, searchForward, false, &presenter);
2575 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2578 presenter.WaitAsyncProcess(result);
2580 return static_cast < bool >(result);
2585 _WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive)
2587 result r = E_SUCCESS;
2589 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2593 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2596 r = SynchronizeSearch(SEARCH_ALL_ASYNC, __pWebCore->GetWebNativeNode(), condition, text, true, caseSensitive);
2597 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2604 _WebImpl::SearchNextAsync(bool searchForward)
2606 SysTryReturnResult(NID_WEB_CTRL, __textSearch.__searchAll && __textSearch.__totalCount > -1, E_INVALID_OPERATION, "The SearchTextAllAsync() method is not called or completed.");
2607 SysTryReturnResult(NID_WEB_CTRL, (searchForward && __textSearch.__currentIndex < __textSearch.__totalCount) || (!searchForward && __textSearch.__currentIndex > 1)
2608 , E_OBJ_NOT_FOUND, "The Next instance is not available.");
2610 result r = E_SUCCESS;
2612 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2614 if (__textSearch.__caseSensitive)
2616 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2621 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_BACKWARDS);
2624 r = SynchronizeSearch(SEARCH_NEXT_ASYNC, __pWebCore->GetWebNativeNode(), condition, __textSearch.__text, searchForward);
2625 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2632 _WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text, bool searchForward, bool caseSensitive, _WebPresenter* pWebPresenter)
2634 MutexGuard lock(__mutex);
2636 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(text));
2637 SysTryReturn(NID_WEB_CTRL, pText.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2642 if (__textSearch.__searchAll)
2644 DisableAsyncSearch();
2646 __textSearch.__searchQueue.Enqueue(this);
2647 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2649 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2650 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2654 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2656 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2660 case SEARCH_ALL_ASYNC:
2661 __textSearch.__searchAll = true;
2662 __textSearch.__text = text;
2663 __textSearch.__searchForward = true;
2664 __textSearch.__caseSensitive = caseSensitive;
2665 __textSearch.__totalCount = -1;
2666 __textSearch.__currentIndex = 1;
2668 __textSearch.__searchQueue.Enqueue(this);
2669 __textSearch.__searchQueue.Enqueue(this);
2671 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2672 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2675 case SEARCH_NEXT_ASYNC:
2676 __textSearch.__searchForward = searchForward;
2678 CalculateAsyncSearchOrdinal();
2680 __textSearch.__searchQueue.Enqueue(this);
2682 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2694 _WebImpl::SetAsyncSearchResult(int totalCount)
2696 __textSearch.__totalCount = totalCount;
2701 _WebImpl::GetSearchPresenter(void)
2703 MutexGuard lock(__mutex);
2705 return dynamic_cast< _WebPresenter* >(__textSearch.__searchQueue.Dequeue());
2710 _WebImpl::GetPendingAsyncSearchCount(void) const
2712 return __textSearch.__searchQueue.GetCount();
2717 _WebImpl::CalculateAsyncSearchOrdinal(void)
2719 if (__textSearch.__searchForward)
2721 __textSearch.__currentIndex++;
2725 __textSearch.__currentIndex--;
2731 _WebImpl::GetAsyncSearchOrdinal(void) const
2733 return __textSearch.__currentIndex;
2738 _WebImpl::DisableAsyncSearch(void)
2740 __textSearch.__searchAll = false;
2745 _WebImpl::SetSetting(const WebSetting& setting)
2747 if (__pWebCore->GetWebNativeNode())
2749 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2750 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2751 SysAssertf(pContext && pSettings, "Failed to get webkit instance.");
2753 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(setting.GetDefaultTextEncoding()));
2754 SysTryReturn(NID_WEB_CTRL, pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2756 ewk_settings_default_encoding_set(pSettings, pEncoding.get());
2758 switch (setting.GetCacheControl())
2760 case WEB_CACHE_VALIDATED:
2761 ewk_context_cache_disabled_set(pContext, EINA_FALSE);
2764 case WEB_CACHE_IGNORE:
2765 ewk_context_cache_disabled_set(pContext, EINA_TRUE);
2772 if (setting.GetInputStyle() == INPUT_STYLE_OVERLAY)
2774 ewk_settings_default_keypad_enabled_set(pSettings, EINA_TRUE);
2778 ewk_settings_default_keypad_enabled_set(pSettings, EINA_FALSE);
2781 ewk_settings_font_default_size_set(pSettings, static_cast< Eina_Bool >(setting.GetFontSize()));
2783 ewk_settings_javascript_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsJavascriptEnabled()));
2785 ewk_settings_loads_images_automatically_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoImageLoadEnabled()));
2787 std::unique_ptr<char[]> pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent()));
2788 SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2790 ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get());
2792 ewk_settings_auto_fitting_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFittingEnabled()));
2794 ewk_settings_scripts_window_open_set(pSettings, static_cast< Eina_Bool >(setting.IsJavaScriptPopupEnabled()));
2796 ewk_settings_form_candidate_data_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFormDataShowEnabled()));
2798 ewk_settings_autofill_password_form_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoLoginFormFillEnabled()));
2801 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting());
2803 pWebSettingImpl->SetCertificateErrorHandlingMode(setting.GetCertificateErrorHandlingMode());
2804 pWebSettingImpl->SetDefaultTextEncoding(setting.GetDefaultTextEncoding());
2805 pWebSettingImpl->SetCacheControl(setting.GetCacheControl());
2806 pWebSettingImpl->SetFontSize(setting.GetFontSize());
2807 pWebSettingImpl->SetJavascriptEnabled(setting.IsJavascriptEnabled());
2808 pWebSettingImpl->SetAutoImageLoadEnabled(setting.IsAutoImageLoadEnabled());
2809 pWebSettingImpl->SetInputStyle(setting.GetInputStyle());
2810 pWebSettingImpl->SetUserAgent(setting.GetUserAgent());
2811 pWebSettingImpl->SetAutoFittingEnabled(setting.IsAutoFittingEnabled());
2812 pWebSettingImpl->SetJavaScriptPopupEnabled(setting.IsJavaScriptPopupEnabled());
2813 pWebSettingImpl->SetGeolocationEnabled(setting.IsGeolocationEnabled());
2814 pWebSettingImpl->SetAutoFormDataShowEnabled(setting.IsAutoFormDataShowEnabled());
2815 pWebSettingImpl->SetAutoLoginFormFillEnabled(setting.IsAutoLoginFormFillEnabled());
2822 _WebImpl::GetSetting(void) const
2824 return *__pWebCore->GetSetting();
2828 const HitElementResult*
2829 _WebImpl::GetElementByPointN(const Point& point) const
2831 result r = E_SUCCESS;
2833 _HitElementResultImpl* pHitElementResultImpl = null;
2835 std::unique_ptr<HitElementResult> pHitElementResult;
2836 std::unique_ptr<Bitmap> pImage;
2837 std::unique_ptr<HashMap, AllElementsDeleter> pAttributeMap;
2839 Point absPoint(__pWebCore->GetAbsoluteCoordinate(point));
2841 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(__pWebCore->GetWebNativeNode(), absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
2842 SysTryReturn(NID_WEB_CTRL, pEwkHitTest, null, E_SYSTEM, "[%s] Failed to get hit test.", GetErrorMessage(E_SYSTEM));
2844 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
2845 Ewk_Hit_Test_Result_Context context = ewk_hit_test_result_context_get(pEwkHitTest);
2846 String url(ewk_hit_test_link_uri_get(pEwkHitTest));
2847 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
2848 String nodeValue(ewk_hit_test_node_value_get(pEwkHitTest));
2850 SysLog(NID_WEB_CTRL, "The current value of url is %ls, tag is %ls, value is %ls", url.GetPointer(), tagName.GetPointer(), nodeValue.GetPointer());
2852 pHitElementResult = std::unique_ptr<HitElementResult>(new (std::nothrow) HitElementResult());
2853 SysTryCatch(NID_WEB_CTRL, pHitElementResult.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2855 pHitElementResultImpl = _HitElementResultImpl::GetInstance(pHitElementResult.get());
2856 SysTryCatch(NID_WEB_CTRL, pHitElementResultImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2858 if (context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE)
2864 int imageLength = ewk_hit_test_image_buffer_length_get(pEwkHitTest);
2865 void* pImageBuffer = ewk_hit_test_image_buffer_get(pEwkHitTest);
2866 const char* pExtension = ewk_hit_test_image_file_name_extension_get(pEwkHitTest);
2867 SysLog(NID_WEB_CTRL, "The current value of imageBuffer is %u, bufferLength is %d, extension is %s", pImageBuffer, imageLength, pExtension);
2869 r = buf.Construct(imageLength);
2870 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2872 r = buf.SetArray(reinterpret_cast< byte* >(pImageBuffer), 0, imageLength);
2873 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2877 // ToDo : webkit doesn't support types such as IMG_FORMAT_WBMP and IMG_FORMAT_TIFF
2878 // webkit support types such as ico and vp8 additionally
2879 if (strcmp(pExtension, "gif") == 0)
2881 format = IMG_FORMAT_GIF;
2883 else if (strcmp(pExtension, "jpg") == 0)
2885 format = IMG_FORMAT_JPG;
2887 else if (strcmp(pExtension, "png") == 0)
2889 format = IMG_FORMAT_PNG;
2891 else if (strcmp(pExtension, "bmp") == 0)
2893 format = IMG_FORMAT_BMP;
2897 SysLogException(NID_WEB_CTRL, E_UNSUPPORTED_FORMAT, "[%s] The %s format is not supported", GetErrorMessage(E_UNSUPPORTED_FORMAT), pExtension);
2901 r = image.Construct();
2902 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2904 pImage = std::unique_ptr<Bitmap>(image.DecodeN(buf, format, BITMAP_PIXEL_FORMAT_RGB565));
2905 SysTryCatch(NID_WEB_CTRL, pImage.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2910 pAttributeMap = std::unique_ptr<HashMap, AllElementsDeleter>(new (std::nothrow) HashMap());
2911 SysTryCatch(NID_WEB_CTRL, pAttributeMap.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2913 r = pAttributeMap->Construct(eina_hash_population(pAttrHash));
2914 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2916 eina_hash_foreach(pAttrHash, AddHttpAttributeData, pAttributeMap.get());
2917 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2920 pHitElementResultImpl->SetHitElementResult(pAttributeMap.release(), pImage.release(), tagName, nodeValue, url);
2922 ewk_hit_test_free(pEwkHitTest);
2924 return pHitElementResult.release();
2927 ewk_hit_test_free(pEwkHitTest);
2933 const HitElementResult*
2934 _WebImpl::GetElementByPointN(const FloatPoint& point) const
2936 const Point integerPoint(_CoordinateSystemUtils::ConvertToInteger(point));
2938 std::unique_ptr<const HitElementResult> pHitElementResult(GetElementByPointN(integerPoint));
2939 SysTryReturn(NID_WEB_CTRL, pHitElementResult.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2941 return pHitElementResult.release();
2946 _WebImpl::IsLoading(void) const
2948 double percent = ewk_view_load_progress_get(__pWebCore->GetWebNativeNode());
2950 if (Double::Compare(percent, 0.0) > 0 && Double::Compare(percent, 1.0) < 0)
2962 _WebImpl::GetTextFromBlock(void) const
2964 return ewk_view_text_selection_text_get(__pWebCore->GetWebNativeNode());
2969 _WebImpl::IsPrivateBrowsingEnabled(void) const
2971 if (__pWebCore->GetWebNativeNode() == null)
2973 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsPrivateBrowsingEnabled();
2976 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2977 SysAssertf(pSettings, "Failed to get webkit instance.");
2979 return static_cast< bool >(ewk_settings_private_browsing_enabled_get(pSettings));
2984 _WebImpl::SetPrivateBrowsingEnabled(bool enable)
2986 if (__pWebCore->GetWebNativeNode() == null)
2988 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetPrivateBrowsingEnabled(enable);
2992 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2993 SysAssertf(pSettings, "Failed to get webkit instance.");
2995 ewk_settings_private_browsing_enabled_set(pSettings, static_cast< Eina_Bool >(enable));
3000 _WebImpl::ClearHistory(void)
3002 ewk_view_back_forward_list_clear(__pWebCore->GetWebNativeNode());
3007 _WebImpl::ClearCache(void)
3009 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3010 SysAssertf(pContext, "Failed to get webkit instance.");
3012 ewk_context_cache_clear(pContext);
3017 _WebImpl::ClearCookie(void)
3019 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3020 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3021 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3023 ewk_cookie_manager_cookies_clear(pCookieManager);
3028 _WebImpl::ClearFormData(void)
3030 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3031 SysAssertf(pContext, "Failed to get webkit instance.");
3033 ewk_context_form_candidate_data_clear(pContext);
3038 _WebImpl::ClearLoginFormData(void)
3040 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3041 SysAssertf(pContext, "Failed to get webkit instance.");
3043 ewk_context_form_password_data_clear(pContext);
3048 _WebImpl::IsCookieEnabled(void) const
3050 if (__pWebCore->GetWebNativeNode() == null)
3052 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsCookieEnabled();
3055 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3056 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3057 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3059 _WebPresenter presenter;
3060 presenter.InitAsyncProcess();
3062 ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, &presenter);
3064 bool result = false;
3065 presenter.WaitAsyncProcess(result);
3072 _WebImpl::SetCookieEnabled(bool enable)
3074 if (__pWebCore->GetWebNativeNode() == null)
3076 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetCookiEnabled(enable);
3081 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3082 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3083 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3087 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
3091 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER);
3092 ewk_cookie_manager_cookies_clear(pCookieManager);
3098 _WebImpl::SavePageAsPdf(const String& filePath, const Dimension* pSize) const
3100 result r = E_SUCCESS;
3102 std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
3103 SysTryReturn(NID_WEB_CTRL, pFilePath.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3106 String fileExtension = File::GetFileExtension(filePath);
3107 int pathLength = filePath.GetLength();
3110 SysTryReturnResult(NID_WEB_CTRL, fileExtension.Equals("pdf", false), E_INVALID_ARG, "Invalid argument(s) is used. File extension is not pdf.");
3112 r = filePath.LastIndexOf(L"/", pathLength - 1, index);
3113 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3114 r = filePath.SubString(0, index + 1, dirPath);
3115 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3117 std::unique_ptr<char[]> pDirPath(_StringConverter::CopyToCharArrayN(dirPath));
3118 SysTryReturnResult(NID_WEB_CTRL, access(pDirPath.get(), W_OK) == 0, E_INACCESSIBLE_PATH, "Directory permission is read-only.");
3122 SysTryReturnResult(NID_WEB_CTRL, pSize->width > 0 && pSize->height > 0, E_INVALID_ARG, "Invalid argument(s) is used. Size of pdf file is invalid.");
3124 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), pSize->width, pSize->height, pFilePath.get());
3128 Evas_Coord contentsWidth;
3129 Evas_Coord contentsHeight;
3131 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &contentsWidth, &contentsHeight);
3132 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), contentsWidth, contentsHeight, pFilePath.get());
3140 _WebImpl::IsMimeSupported(const String& mime) const
3142 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
3143 SysTryReturn(NID_WEB_CTRL, pMime.get(), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3145 return static_cast< bool >(ewk_frame_can_show_mime_type(ewk_view_main_frame_get(__pWebCore->GetWebNativeNode()), pMime.get()));
3150 _WebImpl::SetLoadingListener(ILoadingListener* pLoadingListener)
3152 __pUserLoadingListener = const_cast< ILoadingListener* >(pLoadingListener);
3157 _WebImpl::SetWebUiEventListener(IWebUiEventListener* pUiEventListener)
3159 __pUserUiListener = pUiEventListener;
3164 _WebImpl::SetWebUiEventListenerF(IWebUiEventListenerF* pUiEventListener)
3166 __pUserUiListenerF = pUiEventListener;
3171 _WebImpl::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener)
3173 __pUserKeypadEventListener = pKeypadEventListener;
3178 _WebImpl::SetDownloadListener(IWebDownloadListener* pDownLoadListener)
3180 if (__pWebDownloadHandler.get() == null)
3182 __pWebDownloadHandler = std::unique_ptr<_WebDataHandler>(new (std::nothrow) _WebDataHandler());
3183 SysTryReturnVoidResult(NID_WEB_CTRL, __pWebDownloadHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3186 __pWebDownloadHandler->SetDownloadListener(pDownLoadListener);
3187 __pWebDownloadHandler->SetWebEvent(__pWebEvent.get());
3192 _WebImpl::SetTextSearchListener(ITextSearchListener* pTextSearchListener)
3194 __pTextSearchListener = pTextSearchListener;
3199 _WebImpl::SetScrollEnabled(bool enable)
3201 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetScrollEnabled(enable);
3206 _WebImpl::IsScrollEnabled(void) const
3208 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled();
3213 _WebImpl::InitJsBridgeList(void)
3215 result r = E_SUCCESS;
3217 __pJsProvider = std::unique_ptr<_JsBridgeHashCodeProvider>(new (std::nothrow) _JsBridgeHashCodeProvider());
3218 SysTryReturnResult(NID_WEB_CTRL, __pJsProvider.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3220 __pJsComparer = std::unique_ptr<_JsBridgeComparer>(new (std::nothrow) _JsBridgeComparer());
3221 SysTryReturnResult(NID_WEB_CTRL, __pJsComparer.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3223 std::unique_ptr<HashMapT< String, IJavaScriptBridge* > > pJsBridgeList(new (std::nothrow) HashMapT< String, IJavaScriptBridge* >);
3224 SysTryReturnResult(NID_WEB_CTRL, pJsBridgeList.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3226 r = pJsBridgeList->Construct(0, 0, *__pJsProvider.get(), *__pJsComparer.get());
3227 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3229 __pJsBridgeList = std::move(pJsBridgeList);
3236 _WebImpl::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3238 result r = E_SUCCESS;
3240 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3241 String key(pJsBridge->GetName());
3243 r = __pJsBridgeList->Add(key, pJsBridge);
3244 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3251 _WebImpl::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3253 result r = E_SUCCESS;
3255 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3256 String key(pJsBridge->GetName());
3258 r = __pJsBridgeList->Remove(key);
3259 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3266 _WebImpl::FindJsInterface(const IJsonValue* pValue) const
3268 result r = E_SUCCESS;
3270 IJsonValue* pJsonValue = null;
3271 IJavaScriptBridge* pJsBridge = null;
3273 String key(L"name");
3275 const JsonObject* pJsonObject = dynamic_cast< const JsonObject* >(pValue);
3276 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));
3278 r = pJsonObject->GetValue(&key, pJsonValue);
3279 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS && pJsonValue, null, r, "[%s] Propagating.", GetErrorMessage(r));
3281 JsonString* pBridgeName = dynamic_cast< JsonString* >(pJsonValue);
3282 SysTryReturn(NID_WEB_CTRL, pBridgeName, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. name key is missing." , GetErrorMessage(E_INVALID_ARG));
3284 r = __pJsBridgeList->GetValue(static_cast< String >(*pBridgeName), pJsBridge);
3285 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3292 _WebImpl::GetLoadingListener(void) const
3294 return __pUserLoadingListener;
3298 IWebUiEventListener*
3299 _WebImpl::GetUiEventListener(void) const
3301 return __pUserUiListener;
3305 IWebUiEventListenerF*
3306 _WebImpl::GetUiEventListenerF(void) const
3308 return __pUserUiListenerF;
3312 IWebKeypadEventListener*
3313 _WebImpl::GetWebKeypadEventListener(void) const
3315 return __pUserKeypadEventListener;
3319 ITextSearchListener*
3320 _WebImpl::GetTextSearchListener(void) const
3322 return __pTextSearchListener;
3327 _WebImpl::SetEventListenerCallback(void) const
3329 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3332 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3333 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3335 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3336 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3338 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3339 SysAssertf(pSmartData, "Failed to request");
3341 Ewk_View_Smart_Class *pSmart = const_cast<Ewk_View_Smart_Class*>(pSmartData->api);
3342 SysAssertf(pSmart, "Failed to request");
3344 pSmart->popup_menu_show = OnSelectBoxRequested;
3345 pSmart->popup_menu_hide = OnSelectBoxClosed;
3346 pSmart->popup_menu_update = OnSelectBoxUpdateRequested;
3348 pSmart->input_picker_show = OnDatePickerProviderRequested;
3349 pSmart->input_picker_color_request = OnColorPickerProviderRequested;
3350 pSmart->input_picker_color_dismiss = OnColorPickerProviderDismissed;
3352 evas_object_data_set(pWebNativeNode, WEB_CTRL, this);
3354 // add loading event callbacks for ILoadingListener
3355 evas_object_smart_callback_add(pWebNativeNode, "create,window", OnWebWindowCreateRequested, this);
3356 evas_object_smart_callback_add(pWebNativeNode, "close,window", OnWebWindowClosedRequested, this);
3358 evas_object_smart_callback_add(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested, this);
3359 evas_object_smart_callback_add(pWebNativeNode, "load,started", OnLoadingStarted, this);
3360 evas_object_smart_callback_add(pWebNativeNode, "load,finished", OnLoadingCompleted, this);
3361 evas_object_smart_callback_add(pWebNativeNode, "load,progress", OnEstimatedProgress, this);
3362 evas_object_smart_callback_add(pWebNativeNode, "load,progress,finished", OnProgressCompleted, this);
3363 evas_object_smart_callback_add(pWebNativeNode, "load,stop", OnLoadingCanceled, this);
3364 evas_object_smart_callback_add(pWebNativeNode, "load,error", OnLoadingErrorOccurred, this);
3365 evas_object_smart_callback_add(pWebNativeNode, "title,changed", OnPageTitleReceived, this);
3366 evas_object_smart_callback_add(pWebNativeNode, "load,committed", OnLoadingCommitted, this);
3368 evas_object_smart_callback_add(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest, this);
3370 evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3372 evas_object_smart_callback_add(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged, this);
3373 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened, this);
3374 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed, this);
3376 evas_object_smart_callback_add(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested, this);
3377 evas_object_smart_callback_add(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled, this);
3379 evas_object_smart_callback_add(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested, this);
3381 ewk_view_javascript_alert_callback_set(pWebNativeNode, OnScriptAlertRequested, const_cast< _WebImpl* >(this));
3382 ewk_view_javascript_prompt_callback_set(pWebNativeNode, OnScriptPromptRequested, const_cast< _WebImpl* >(this));
3383 ewk_view_javascript_confirm_callback_set(pWebNativeNode, OnScriptConfirmRequested, const_cast< _WebImpl* >(this));
3385 evas_object_smart_callback_add(pWebNativeNode, "policy,response,decide", OnWebDataReceived, this);
3387 evas_object_smart_callback_add(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested, this);
3388 evas_object_smart_callback_add(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested, this);
3389 evas_object_smart_callback_add(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted, this);
3391 evas_object_smart_callback_add(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested, this);
3392 evas_object_smart_callback_add(pWebNativeNode, "notification,show", OnNotificationShow, this);
3393 evas_object_smart_callback_add(pWebNativeNode, "notification,cancel", OnNotificationCancel, this);
3395 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested, this);
3396 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered, this);
3397 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested, this);
3399 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested, this);
3400 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered, this);
3401 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested, this);
3402 evas_object_smart_callback_add(pWebNativeNode, "text,found", OnTextFound, this);
3404 evas_object_smart_callback_add(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered, this);
3405 evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this);
3407 evas_object_smart_callback_add(pWebNativeNode, "text,style,state", OnWebPageBlockSelected, this);
3409 ewk_view_open_panel_callback_set(pWebNativeNode, OnSelectUploadFile, const_cast< _WebImpl* >(this));
3410 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3411 SysAssertf(pContext, "Failed to get webkit instance.");
3412 ewk_context_did_start_download_callback_set(pContext, OnDidStartDownloadCallback, const_cast< _WebImpl* >(this));
3413 ewk_context_vibration_client_callbacks_set(pContext, OnVibrationRequested, OnVibrationCanceled, const_cast< _WebImpl* >(this));
3414 ewk_view_application_cache_permission_callback_set(pWebNativeNode, OnApplicationCachePermissionRequested, const_cast< _WebImpl* >(this));
3416 evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this);
3422 _WebImpl::RemoveEventListenerCallback(void) const
3424 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3427 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3428 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3430 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3431 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3433 evas_object_smart_callback_del(pWebNativeNode, "create,window", OnWebWindowCreateRequested);
3434 evas_object_smart_callback_del(pWebNativeNode, "close,window", OnWebWindowClosedRequested);
3436 evas_object_smart_callback_del(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested);
3437 evas_object_smart_callback_del(pWebNativeNode, "load,started", OnLoadingStarted);
3438 evas_object_smart_callback_del(pWebNativeNode, "load,finished", OnLoadingCompleted);
3439 evas_object_smart_callback_del(pWebNativeNode, "load,progress", OnEstimatedProgress);
3440 evas_object_smart_callback_del(pWebNativeNode, "load,progress,finished", OnProgressCompleted);
3441 evas_object_smart_callback_del(pWebNativeNode, "load,stop", OnLoadingCanceled);
3442 evas_object_smart_callback_del(pWebNativeNode, "load,error", OnLoadingErrorOccurred);
3443 evas_object_smart_callback_del(pWebNativeNode, "title,changed", OnPageTitleReceived);
3445 evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest);
3447 evas_object_smart_callback_del_full(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3449 evas_object_smart_callback_del(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged);
3450 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened);
3451 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed);
3453 evas_object_smart_callback_del(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested);
3454 evas_object_smart_callback_del(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled);
3456 evas_object_smart_callback_del(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested);
3458 ewk_view_javascript_alert_callback_set(null, null, null);
3459 ewk_view_javascript_prompt_callback_set(null, null, null);
3460 ewk_view_javascript_confirm_callback_set(null, null, null);
3462 evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived);
3464 evas_object_smart_callback_del(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested);
3465 evas_object_smart_callback_del(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested);
3466 evas_object_smart_callback_del(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted);
3468 evas_object_smart_callback_del(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested);
3469 evas_object_smart_callback_del(pWebNativeNode, "notification,show", OnNotificationShow);
3470 evas_object_smart_callback_del(pWebNativeNode, "notification,cancel", OnNotificationCancel);
3471 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested);
3472 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered);
3473 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested);
3475 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested);
3476 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered);
3477 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested);
3479 evas_object_smart_callback_del(pWebNativeNode, "text,found", OnTextFound);
3481 evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered);
3482 evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived);
3484 evas_object_smart_callback_del(pWebNativeNode, "text,style,state", OnWebPageBlockSelected);
3486 ewk_view_open_panel_callback_set(null, null, null);
3487 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3488 SysAssertf(pContext, "Failed to get webkit instance.");
3489 ewk_context_vibration_client_callbacks_set(pContext, null, null, null);
3490 ewk_view_application_cache_permission_callback_set(pWebNativeNode, null, null);
3492 evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained);
3498 _WebImpl::SetBlockSelectionPosition(const Point& startPoint)
3500 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3502 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3503 SysAssertf(pSmartData, "Failed to request");
3505 Point absPoint(__pWebCore->GetAbsoluteCoordinate(startPoint));
3507 Eina_Bool ret = pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y);
3510 pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y);
3512 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(__pWebCore->GetWebNativeNode(), absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3513 SysTryReturnResult(NID_WEB_CTRL, pEwkHitTest, E_SYSTEM, "Failed to get hit test.");
3515 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3517 if (tagName.Equals(L"INPUT", false) || tagName.Equals(L"TEXTAREA", false))
3519 ewk_view_command_execute(pWebNativeNode, "SelectWord", 0);
3523 SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up.");
3530 _WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint)
3532 return SetBlockSelectionPosition(_CoordinateSystemUtils::ConvertToInteger(startPoint));
3537 _WebImpl::ReleaseBlock(void)
3539 ewk_view_command_execute(__pWebCore->GetWebNativeNode(), "Unselect", 0);
3544 _WebImpl::GetBlockRange(Point& startPoint, Point& endPoint) const
3546 FloatPoint tempStartPoint;
3547 FloatPoint tempEndPoint;
3549 GetBlockRange(tempStartPoint, tempEndPoint);
3551 startPoint = _CoordinateSystemUtils::ConvertToInteger(tempStartPoint);
3552 endPoint = _CoordinateSystemUtils::ConvertToInteger(tempEndPoint);
3557 _WebImpl::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const
3559 Eina_Rectangle leftHandle;
3560 Eina_Rectangle rightHandle;
3562 ewk_view_text_selection_range_get(__pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle);
3564 startPoint.x = _CoordinateSystemUtils::ConvertToFloat(leftHandle.x);
3565 startPoint.y = _CoordinateSystemUtils::ConvertToFloat(leftHandle.y);
3566 endPoint.x = _CoordinateSystemUtils::ConvertToFloat(rightHandle.x + rightHandle.w);
3567 endPoint.y = _CoordinateSystemUtils::ConvertToFloat(rightHandle.y + rightHandle.h);
3569 if ((endPoint.x != 0.0f) && (endPoint.y != 0.0f))
3571 startPoint = __pWebCore->GetRelativeCoordinate(startPoint);
3572 endPoint = __pWebCore->GetRelativeCoordinate(endPoint);
3578 _WebImpl::GetFaviconN(void) const
3580 result r = E_SUCCESS;
3582 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3584 Evas* pEvas = evas_object_evas_get(pView);
3585 Ewk_Context* pContext = ewk_view_context_get(pView);
3586 SysAssertf(pEvas && pContext, "Failed to request");
3588 const char* pUrl = ewk_view_url_get(pView);
3590 Tizen::Graphics::BufferInfo bufferInfo;
3591 Tizen::Base::ByteBuffer byteBuffer;
3593 std::unique_ptr<Bitmap> pBitmapImage(new (std::nothrow) Bitmap());
3594 SysTryReturn(NID_WEB_CTRL, pBitmapImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3596 Evas_Object* pFavicon = ewk_context_icon_database_icon_object_add(pContext, pUrl, pEvas);
3602 r = _Utility::GetPixelBufferFromEvasObject(pFavicon, bufferInfo);
3603 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3605 const Dimension dimension(bufferInfo.width, bufferInfo.height);
3607 r = byteBuffer.Construct((byte*)bufferInfo.pPixels, 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 );
3608 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3610 r = pBitmapImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888);
3611 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3613 return pBitmapImage.release();
3619 _WebImpl::ScrollBy(const Tizen::Graphics::Point& diff)
3621 ewk_view_scroll_by(__pWebCore->GetWebNativeNode(), diff.x, diff.y);
3626 _WebImpl::ScrollTo(const Tizen::Graphics::Point& dest)
3628 ewk_view_scroll_set(__pWebCore->GetWebNativeNode(), dest.x, dest.y);
3633 _WebImpl::GetScrollPosition(void) const
3637 ewk_view_scroll_pos_get(__pWebCore->GetWebNativeNode(), &position.x, &position.y);
3644 _WebImpl::GetPageSize(void) const
3646 Evas_Coord width = 0;
3647 Evas_Coord height = 0;
3649 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &width, &height);
3651 Dimension size(static_cast< int >(width), static_cast< int >(height));
3658 _WebImpl::SetLoadingErrorOccurred(bool arg)
3660 __isLoadingErrorOccurred = arg;
3665 _WebImpl::IsLoadingErrorOccurred(void) const
3667 return __isLoadingErrorOccurred;
3672 _WebImpl::SetRedirectRequested(bool arg)
3674 __isRedirectRequested = arg;
3679 _WebImpl::IsRedirectRequested(void) const
3681 return __isRedirectRequested;
3686 _WebImpl::SetPolicyDecision(DecisionPolicy policy)
3693 _WebImpl::GetPolicyDecision(void) const
3700 _WebImpl::SetCertificateRequested(bool arg)
3702 __isCertificateRequested = arg;
3707 _WebImpl::IsCertificateRequested(void) const
3709 return __isCertificateRequested;
3714 _WebImpl::IsCertificateConfirmed(void) const
3716 return __isCertificateConfirmed;
3721 _WebImpl::LaunchAppControl(const IEventArg& arg)
3723 result r = E_SUCCESS;
3725 IEventArg* pArg = const_cast< IEventArg* >(&arg);
3726 _WebEventArg* pWebEventArg = dynamic_cast< _WebEventArg* >(pArg);
3727 SysTryReturnResult(NID_WEB_CTRL, pWebEventArg, E_INVALID_ARG, "Type casting failed. argument must be IEventArg type.");
3729 String operationId(L"");
3730 String uriPattern(pWebEventArg->GetEventMessage());
3731 SysLog(NID_WEB_CTRL, "The current value of web event type is %d", pWebEventArg->GetEventType());
3733 switch (pWebEventArg->GetEventType())
3735 case WEB_EVENT_REQUEST_RTSP:
3739 int uriLength = uriPattern.GetLength();
3742 operationId = L"http://tizen.org/appcontrol/operation/view";
3744 r = uriPattern.LastIndexOf(L".", uriLength - 1, index);
3745 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3747 r = uriPattern.SubString(index + 1, ext);
3748 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3750 r = _AppControlManager::GetMimeFromExt(ext, mimeType);
3751 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3753 r = _AppControlImpl::FindAndStart(operationId, &uriPattern, &mimeType, null, null, null);
3754 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3758 case WEB_EVENT_REQUEST_TEL:
3760 operationId = L"http://tizen.org/appcontrol/operation/dial";
3763 case WEB_EVENT_REQUEST_EMAIL:
3765 case WEB_EVENT_REQUEST_SMS:
3767 case WEB_EVENT_REQUEST_MMS:
3769 operationId = L"http://tizen.org/appcontrol/operation/compose";
3772 case WEB_EVENT_REQUEST_UNKNOWN:
3774 operationId = L"http://tizen.org/appcontrol/operation/view";
3782 r = _AppControlImpl::FindAndStart(operationId, &uriPattern, null, null, null, null);
3783 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3790 _WebImpl::SetFullScreenKeypad(void)
3792 result r = E_SUCCESS;
3794 std::unique_ptr<Keypad> pKeypad(new (std::nothrow) Keypad());
3795 SysTryReturnResult(NID_WEB_CTRL, pKeypad.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
3797 r = pKeypad->Construct(KEYPAD_STYLE_NORMAL, 100);
3798 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3800 String text(ewk_view_focused_input_element_value_get(__pWebCore->GetWebNativeNode()));
3801 pKeypad->SetText(text);
3803 r = pKeypad->SetShowState(true);
3804 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3806 r = pKeypad->Show();
3807 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3809 pKeypad->AddTextEventListener(*this);
3811 __pKeypad = std::move(pKeypad);
3818 _WebImpl::RemoveFullScreenKeypad(void)
3820 __pKeypad->RemoveTextEventListener(*this);
3827 _WebImpl::IsFooterVisible(void) const
3829 return __isFooterVisible;
3834 _WebImpl::SetFooterVisibleState(bool isFooterVisible)
3836 __isFooterVisible = isFooterVisible;
3841 _WebImpl::IsKeypadVisible(void) const
3843 return __isKeypadVisible;
3848 _WebImpl::SetKeypadVisibleState(bool isKeypadVisible)
3850 __isKeypadVisible = isKeypadVisible;
3855 _WebImpl::IsKeypadOpened(void) const
3857 return __isKeypadOpened;
3861 _WebImpl::SetKeypadOpened(bool isKeypadOpened)
3863 __isKeypadOpened = isKeypadOpened;
3868 _WebImpl::GetPreviousKeypadBounds(void) const
3870 return __keypadBounds;
3875 _WebImpl::SetPreviousKeypadBounds(Rectangle& bounds)
3877 __keypadBounds = bounds;
3882 _WebImpl::OnTextValueChangeCanceled(const Control& source)
3884 RemoveFullScreenKeypad();
3889 _WebImpl::OnTextValueChanged(const Control& source)
3891 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(__pKeypad->GetText()));
3893 ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get());
3895 RemoveFullScreenKeypad();
3900 _WebImpl::OnHandleJavaScriptRequestByEventArg(const IEventArg& arg)
3902 const _JsBridgeArg* pEventArg = dynamic_cast< const _JsBridgeArg* >(&arg);
3903 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. arg is not _JsBridgeArg object.");
3905 std::unique_ptr<IJsonValue> pJsonValue(JsonParser::ParseN(*(pEventArg->GetJsonData())));
3906 SysTryReturn(NID_WEB_JSON, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3908 IJavaScriptBridge* pJsInterface = FindJsInterface(pJsonValue.get());
3909 SysTryReturnResult(NID_WEB_CTRL, pJsInterface, E_OBJ_NOT_FOUND, "JsInterface instance is not available.");
3911 pJsInterface->HandleJavaScriptRequestN(pJsonValue.release());
3918 _WebImpl::OnHandleLoadingEvent(const IEventArg& arg)
3920 result r = E_SUCCESS;
3922 const _LoadingEventArg* pEventArg = dynamic_cast< const _LoadingEventArg* >(&arg);
3923 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
3925 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
3927 ILoadingListener* pLoadingListner = GetLoadingListener();
3928 SysTryReturnResult(NID_WEB_CTRL, pLoadingListner, E_SYSTEM, "A system error has been occurred. Loading listener was not set or null.");
3930 switch (pEventArg->GetEventType())
3932 case WEB_EVENT_LOADINGLISTENER_STARTED:
3934 pLoadingListner->OnLoadingStarted();
3938 case WEB_EVENT_LOADINGLISTENER_PROGRESS:
3940 const Integer* pProgressPercentage = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS));
3941 SysTryReturn(NID_WEB_CTRL, pProgressPercentage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3943 pLoadingListner->OnEstimatedProgress(pProgressPercentage->ToInt());
3947 case WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED:
3949 const String* pPageTitle = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::PAGE_TITLE));
3950 SysTryReturn(NID_WEB_CTRL, pPageTitle, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3952 pLoadingListner->OnPageTitleReceived(*pPageTitle);
3956 case WEB_EVENT_LOADINGLISTENER_CANCELED:
3958 pLoadingListner->OnLoadingCanceled();
3962 case WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED:
3964 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_TYPE));
3965 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3967 const String* pErrorMessage = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_MESSAGE));
3968 SysTryReturn(NID_WEB_CTRL, pErrorMessage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3970 LoadingErrorType errorType = ConvertErrorCode(pErrorType->ToInt());
3972 pLoadingListner->OnLoadingErrorOccurred(errorType, *pErrorMessage);
3976 case WEB_EVENT_LOADINGLISTENER_COMPLETED:
3978 pLoadingListner->OnLoadingCompleted();
3982 case WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED:
3984 pLoadingListner->OnHttpAuthenticationCanceled();
3988 case WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED:
3990 std::unique_ptr<Bitmap> pFavicon(GetFaviconN());
3991 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3995 pLoadingListner->OnFaviconReceived(*pFavicon.get());
4011 _WebImpl::OnHandleWebDownloadEvent(const IEventArg& arg)
4013 result r = E_SUCCESS;
4015 const _WebDownloadEventArg* pEventArg = dynamic_cast< const _WebDownloadEventArg* >(&arg);
4016 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4018 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4020 IWebDownloadListener* pWebDownloadListener = __pWebDownloadHandler->GetDownloadListener();
4021 SysTryReturnResult(NID_WEB_CTRL, pWebDownloadListener, E_SYSTEM, "A system error has been occurred. Web Downloading listener was not set or null.");
4023 switch (pEventArg->GetEventType())
4025 case WEB_EVENT_WEBDOWNLOADLISTENER_DATA_RECEIVED:
4027 const ByteBuffer* pChunk = dynamic_cast< const ByteBuffer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::CHUNKED_DATA));
4028 SysTryReturn(NID_WEB_CTRL, pChunk, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4030 pWebDownloadListener->OnWebChunkedDataReceived(*pChunk);
4034 case WEB_EVENT_WEBDOWNLOADLISTENER_COMPLETED:
4036 pWebDownloadListener->OnWebDataDownloadCompleted();
4040 case WEB_EVENT_WEBDOWNLOADLISTENER_FAILED:
4042 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::ERROR_TYPE));
4043 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4045 LoadingErrorType errorType = static_cast < LoadingErrorType >(pErrorType->ToInt());
4047 pWebDownloadListener->OnWebDownloadFailed(errorType);
4062 _WebImpl::OnHandleWebUiEvent(const IEventArg& arg)
4064 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4065 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4067 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4069 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListener, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4071 switch (pEventArg->GetEventType())
4073 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED:
4075 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4077 Point* pStartPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4078 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4080 Point* pEndPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4081 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4083 __pUserUiListener->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4087 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED:
4089 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4091 __pUserUiListener->OnWebPageShowRequested(*pWeb);
4095 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED:
4097 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4099 __pUserUiListener->OnWebWindowCloseRequested(*pWeb);
4103 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED:
4105 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4107 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4108 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4110 __pUserUiListener->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4125 _WebImpl::OnHandleWebUiEventF(const IEventArg& arg)
4127 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4128 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4130 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4132 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListenerF, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4134 switch (pEventArg->GetEventType())
4136 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT:
4138 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4140 FloatPoint* pStartPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4141 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4143 FloatPoint* pEndPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4144 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4146 __pUserUiListenerF->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4150 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT:
4152 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4154 __pUserUiListenerF->OnWebPageShowRequested(*pWeb);
4158 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT:
4160 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4162 __pUserUiListenerF->OnWebWindowCloseRequested(*pWeb);
4166 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT:
4168 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4170 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4171 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4173 __pUserUiListenerF->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4188 _WebImpl::OnHandleTextSearchEvent(const IEventArg& arg)
4190 result r = E_SUCCESS;
4192 const _TextSearchEventArg* pEventArg = dynamic_cast< const _TextSearchEventArg* >(&arg);
4193 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4195 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4197 ITextSearchListener* pTextSearchListner = GetTextSearchListener();
4198 SysTryReturnResult(NID_WEB_CTRL, pTextSearchListner, E_SYSTEM, "A system error has been occurred. Web text search listener was not set or null.");
4200 switch (pEventArg->GetEventType())
4202 case WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND:
4204 Integer* pTotalCount= dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::TOTAL_COUNT)));
4205 SysTryReturn(NID_WEB_CTRL, pTotalCount, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4207 Integer* pCurrentOrdinal = dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL)));
4208 SysTryReturn(NID_WEB_CTRL, pCurrentOrdinal, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4210 pTextSearchListner->OnTextFound(pTotalCount->ToInt(), pCurrentOrdinal->ToInt());
4225 _WebImpl::VibrationRequested(uint64_t duration)
4227 result r = E_SUCCESS;
4229 __pVibrator.reset();
4231 std::unique_ptr<_VibratorImpl> pVibrator(new (std::nothrow) _VibratorImpl);
4232 SysTryReturnResult(NID_WEB_CTRL, pVibrator.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4234 r = pVibrator->Construct();
4235 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4237 __pVibrator = std::move(pVibrator);
4239 IntensityDurationVibrationPattern pattern = {static_cast< int >(duration), -1};
4241 r = __pVibrator->Start(&pattern, 1, 1);
4242 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4249 _WebImpl::VibrationCanceled(void)
4251 __pVibrator.reset();
4256 _WebImpl::HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge)
4258 result r = E_SUCCESS;
4260 String host(ewk_auth_challenge_url_get(pChallenge));
4261 String realm(ewk_auth_challenge_realm_get(pChallenge));
4263 __pAuthChallenge.reset();
4265 std::unique_ptr<AuthenticationChallenge> pAuthChallenge(new (std::nothrow) AuthenticationChallenge());
4266 SysTryReturnResult(NID_WEB_CTRL, pAuthChallenge, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4268 _AuthenticationChallengeImpl* pAuthImpl = _AuthenticationChallengeImpl::GetInstance(pAuthChallenge.get());
4269 SysTryReturn(NID_WEB_CTRL, pAuthImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4271 pAuthImpl->SetAuthenticationChallengeHandler(pChallenge);
4272 pAuthImpl->SetWebEvasObject(__pWebCore->GetWebNativeNode());
4274 __pAuthChallenge = std::move(pAuthChallenge);
4276 ewk_auth_challenge_suspend(pChallenge);
4277 if (__pUserLoadingListener && __pUserLoadingListener->OnHttpAuthenticationRequestedN(host, realm, *__pAuthChallenge.get()))
4279 __pAuthChallenge.release();
4283 r = ShowAuthenticationPopup(host, realm, __pAuthChallenge.get());
4284 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4292 _WebImpl::ShowAuthenticationPopup(const String& host, const String& realm, AuthenticationChallenge* pAuthChallenge)
4294 result r = E_SUCCESS;
4296 std::unique_ptr<_AuthConfirmPopup> pAuthPopup(new (std::nothrow) _AuthConfirmPopup());
4297 SysTryReturnResult(NID_WEB_CTRL, pAuthPopup, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4299 r = pAuthPopup->Construct(host, realm, pAuthChallenge);
4300 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4302 __pAuthPopup = std::move(pAuthPopup);
4304 int modalResult = 0;
4306 __pAuthPopup->SetOwner(&GetPublic());
4308 r = __pAuthPopup->ShowAndWait(modalResult);
4309 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4312 __pAuthPopup.reset();
4319 _WebImpl::ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk_Certificate_Policy_Decision* pPolicy)
4321 result r = E_SUCCESS;
4323 std::unique_ptr<_CertificateConfirmPopup> pCertConfirmPopup(new (std::nothrow) _CertificateConfirmPopup());
4324 SysTryReturnResult(NID_WEB_CTRL, pCertConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4326 r = pCertConfirmPopup->Construct(userConfirmMode, pPolicy);
4327 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4329 __pCertConfirmPopup = std::move(pCertConfirmPopup);
4331 int modalResult = 0;
4333 __pCertConfirmPopup->SetOwner(&GetPublic());
4335 r = __pCertConfirmPopup->ShowAndWait(modalResult);
4336 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4338 if (userConfirmMode == CERTIFICATE_POPUP_MODE_USER_CONFIRM)
4340 __isCertificateConfirmed = __pCertConfirmPopup->GetConfirmResult();
4344 __pCertConfirmPopup.reset();
4350 _WebImpl::ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy)
4352 result r = E_SUCCESS;
4354 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4355 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4357 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, true);
4358 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4360 __pUserConfirmPopup = std::move(pUserConfirmPopup);
4362 int modalResult = 0;
4364 __pUserConfirmPopup->SetOwner(&GetPublic());
4366 r = __pUserConfirmPopup->ShowAndWait(modalResult);
4367 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4370 __pUserConfirmPopup.reset();
4376 _WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy)
4378 result r = E_SUCCESS;
4380 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4381 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4383 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, false);
4384 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4386 __pUserConfirmPopup = std::move(pUserConfirmPopup);
4388 __pUserConfirmPopup->SetOwner(&GetPublic());
4390 r = __pUserConfirmPopup->ShowPopup();
4391 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4393 __pUserConfirmPopup.release();
4398 __pUserConfirmPopup.reset();
4405 _WebImpl::GetParentFormCore(_Control* pControlCore)
4408 _Form* pFormCore = null;
4410 _Control* pParentControlCore = dynamic_cast< _Control* >(pControlCore->GetParent());
4411 if (!pParentControlCore)
4416 pFormCore = dynamic_cast< _Form* >(pParentControlCore);
4422 return GetParentFormCore(pParentControlCore);
4427 _WebImpl::OnFocusGained(const _ControlImpl& source)
4434 _WebImpl::OnFocusLost(const _ControlImpl& source)
4436 if(IsKeypadVisible() == true)
4438 SetKeypadOpened(true);
4440 SetKeypadVisibleState(false);
4443 evas_object_focus_set(__pWebCore->GetWebNativeNode(), EINA_FALSE);
4450 _WebImpl::HasValidNativeNode(void) const
4452 if (__pWebCore && __pWebCore->GetWebNativeNode())
4462 _WebImpl::OnPreAttachedToMainTree(void)
4464 result r = E_SUCCESS;
4466 r = __pWebCore->InitializeWebNativeNode();
4467 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4469 r = InitializeSetting();
4470 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4472 r = _ContainerImpl::OnPreAttachedToMainTree();
4473 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4480 _WebImpl::OnChangeLayout(_ControlOrientation orientation)
4482 _ContainerImpl::OnChangeLayout(orientation);
4484 if (__pColorPicker.get())
4486 __pColorPicker->ChangeLayout(orientation);
4492 _WebImpl::OnAncestorVisibleStateChanged(const _Control& control)
4494 if (IsVisible() == true)
4496 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_VISIBLE, false);
4500 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_HIDDEN, false);
4506 _WebImpl::GetDownloadHandler(void) const
4508 return __pWebDownloadHandler.get();
4513 _WebImpl::HideColorPicker(void)
4515 __pColorPicker.reset();
4522 _WebImpl::ShowColorPicker(int red, int green, int blue, int alpha, Color& color)
4524 result r = E_SUCCESS;
4526 std::unique_ptr<_InputPickerPopup> pColorHadler(new (std::nothrow) _InputPickerPopup());
4527 SysTryReturnResult(NID_WEB_CTRL, pColorHadler.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4529 Tizen::Graphics::Color colorVal(static_cast< byte >(red), static_cast< byte >(green), static_cast< byte >(blue), static_cast< byte >(alpha));
4531 r = pColorHadler->Construct(colorVal, this);
4532 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4534 __pColorPicker = std::move(pColorHadler);
4536 r = __pColorPicker->ShowPopup();
4537 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4539 color = __pColorPicker->GetColor();
4544 __pColorPicker.reset();
4551 _WebImpl::ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue, String& dateStr)
4553 result r = E_SUCCESS;
4555 std::unique_ptr<_InputPickerPopup> pInputPicker(new (std::nothrow) _InputPickerPopup());
4556 SysTryReturnResult(NID_WEB_CTRL, pInputPicker.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4558 r = pInputPicker->Construct(String(inputValue), inputType, this);
4559 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4561 __pDatePicker = std::move(pInputPicker);
4563 r = __pDatePicker->ShowPopup();
4564 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4566 dateStr = __pDatePicker->GetDate();
4569 __pDatePicker.reset();
4576 _WebImpl::GetInstance(Web* pWeb)
4578 return dynamic_cast< _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
4583 _WebImpl::GetInstance(const Web* pWeb)
4585 return dynamic_cast< const _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
4590 _WebImpl::SearchHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
4592 int checkReturn = 0;
4594 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4597 if( checkmime == true)
4599 table = CUSTOM_CONTENT_TABLE_NAME;
4603 table = CUSTOM_PROTOCOL_TABLE_NAME;
4606 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
4607 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
4608 String target(ewk_custom_handlers_data_target_get(pHandlerData));
4610 SysLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
4612 result r = db.Construct(handlerPath, "r+", null);
4613 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
4615 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"'"));
4616 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4620 r = pEnum->MoveNext();
4621 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
4622 r = pEnum->GetIntAt(0, checkReturn);
4623 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
4635 _WebImpl::UnregistrationHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
4639 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4642 if( checkmime == true)
4644 table = CUSTOM_CONTENT_TABLE_NAME;
4648 table = CUSTOM_PROTOCOL_TABLE_NAME;
4651 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
4652 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
4653 String target(ewk_custom_handlers_data_target_get(pHandlerData));
4655 SysLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
4657 result r = db.Construct(handlerPath, "r+", null);
4658 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4660 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"'"));
4661 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4665 r = pEnum->MoveNext();
4666 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4667 r = pEnum->GetIntAt(0, checkId);
4668 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4670 std::unique_ptr<DbStatement> pDeleteStmt(db.CreateStatementN(L"Delete From " + table + L" Where id = (?)"));
4671 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4673 r = pDeleteStmt->BindInt(0, checkId);
4674 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4676 db.BeginTransaction();
4678 std::unique_ptr<DbEnumerator> pEnum(db.ExecuteStatementN(*pDeleteStmt));
4680 db.CommitTransaction();
4687 const Tizen::Base::String
4688 _WebImpl::GetProtocolFromUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri)
4690 if (originUri == L"" || currentUri == L"")
4695 result r = E_SUCCESS;
4698 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4699 String originReplace(originUri);
4700 String table(CUSTOM_PROTOCOL_TABLE_NAME);
4704 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
4705 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4707 r = currentUri.SubString(0, found + 1, baseUri);
4708 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4710 r = db.Construct(handlerPath, "r+", null);
4711 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4713 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select mime, url, allow From " + table + L" Where baseUrl = '" + baseUri + "'"));
4714 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, L"", GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
4718 while (pEnum->MoveNext() == E_SUCCESS)
4723 String originScheme;
4725 r = pEnum->GetStringAt(0, protocol);
4726 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4728 r = pEnum->GetStringAt(1, queryUrl);
4729 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4731 r = pEnum->GetIntAt(2, allow);
4732 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4739 String protocolScheme(protocol + L":");
4741 r = originReplace.SubString(0, protocolScheme.GetLength(), originScheme);
4742 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4744 if ((originReplace.GetLength() >= protocolScheme.GetLength()) && originScheme.Equals(protocolScheme, false))
4746 if (queryUrl.IndexOf(L"%s", 0, foundQuery) == E_SUCCESS)
4748 r = originReplace.Replace(originScheme, "");
4749 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4751 queryUrl.Replace("%s", originReplace, 0);
4752 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4764 const Tizen::Base::String
4765 _WebImpl::GetRedirectUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri, const Tizen::Base::String& mime)
4767 if (originUri == L"" || currentUri == L"" || mime == L"")
4772 result r = E_SUCCESS;
4775 String originUrlStr = originUri;
4776 const String replaceStr = L"%s";
4778 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4779 String table(CUSTOM_CONTENT_TABLE_NAME);
4783 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
4784 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4786 r = currentUri.SubString(0, found + 1, baseUri);
4787 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4789 r = db.Construct(handlerPath, "r+", null);
4790 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4792 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select allow, url From " + table + L" Where baseUrl = '" + baseUri + "' AND mime = '" + mime + L"'"));
4796 r = pEnum->MoveNext();
4797 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4798 r = pEnum->GetIntAt(0, allow);
4799 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4800 r = pEnum->GetStringAt(1, contentUrl);
4801 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4809 if (contentUrl != L"")
4811 r = contentUrl.Replace(replaceStr, originUrlStr, 0);
4812 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4823 }}} // Tizen::Web::Controls