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 std::unique_ptr<_WebPresenter> pPresenter(new (std::nothrow) _WebPresenter());
2452 SysTryReturn(NID_WEB_CTRL, pPresenter.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2453 pPresenter->InitAsyncProcess();
2455 ewk_view_script_execute(__pWebCore->GetWebNativeNode(), pScript.get(), OnScriptExecuted, pPresenter.get());
2457 std::unique_ptr<String> pResult(new (std::nothrow) String(L""));
2458 SysTryReturn(NID_WEB_CTRL, pResult.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2459 pPresenter->WaitAsyncProcess(*pResult.get());
2461 return pResult.release();
2469 _WebImpl::SetZoomLevel(float level)
2471 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);
2473 ewk_view_scale_set(__pWebCore->GetWebNativeNode(), static_cast< double >(level), 0, 0);
2480 _WebImpl::GetZoomLevel(void) const
2482 return static_cast< float >(ewk_view_scale_get(__pWebCore->GetWebNativeNode()));
2486 const PageNavigationList*
2487 _WebImpl::GetBackForwardListN(void) const
2489 result r = E_SUCCESS;
2491 _PageNavigationListImpl* pNavigationListImpl = null;
2492 _HistoryItemImpl* pHistoryItemImpl = null;
2494 std::unique_ptr<PageNavigationList> pNavigationList;
2495 std::unique_ptr<ArrayList, AllElementsDeleter> pHistoryList;
2498 int forwardCount = 0;
2503 Ewk_History* pEwkHistoryList = ewk_view_history_get(__pWebCore->GetWebNativeNode());
2504 SysTryReturn(NID_WEB_CTRL, pEwkHistoryList, null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get full history.", GetErrorMessage(E_SYSTEM));
2506 Ewk_History_Item* pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, 0);
2507 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_DATA_NOT_FOUND, "[%s] There is no history.", GetErrorMessage(E_DATA_NOT_FOUND));
2509 pNavigationList = std::unique_ptr<PageNavigationList>(new (std::nothrow) PageNavigationList());
2510 SysTryCatch(NID_WEB_CTRL, pNavigationList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2512 pNavigationListImpl = _PageNavigationListImpl::GetInstance(pNavigationList.get());
2513 SysTryCatch(NID_WEB_CTRL, pNavigationListImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2515 pHistoryList = std::unique_ptr<ArrayList, AllElementsDeleter>(new (std::nothrow) ArrayList());
2516 SysTryCatch(NID_WEB_CTRL, pHistoryList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2518 r = pHistoryList->Construct();
2519 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2521 backCount = ewk_history_back_list_length_get(pEwkHistoryList);
2522 forwardCount = ewk_history_forward_list_length_get(pEwkHistoryList);
2523 SysLog(NID_WEB_CTRL, "The current value of backCount is %d, forwardCount is %d", backCount, forwardCount);
2525 for (int i = -backCount; i < forwardCount + 1; i++)
2527 std::unique_ptr<HistoryItem> pHistoryItem(new (std::nothrow) HistoryItem());
2528 SysTryCatch(NID_WEB_CTRL, pHistoryItem.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2530 pHistoryItemImpl = _HistoryItemImpl::GetInstance(pHistoryItem.get());
2531 SysTryCatch(NID_WEB_CTRL, pHistoryItemImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2533 pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, i);
2534 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2536 url = ewk_history_item_uri_get(pEwkItem);
2537 title = ewk_history_item_title_get(pEwkItem);
2538 SysLog(NID_WEB_CTRL, "The current value of url is %s, title is %s", url.GetPointer(), title.GetPointer());
2540 pHistoryItemImpl->SetHistoryItem(url, title);
2542 r = pHistoryList->Add(*pHistoryItem.get());
2543 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2544 pHistoryItem.release();
2547 pNavigationListImpl->SetPageNavigationList(pHistoryList.release(), backCount);
2549 ewk_history_free(pEwkHistoryList);
2551 return pNavigationList.release();
2554 ewk_history_free(pEwkHistoryList);
2561 _WebImpl::SearchText(const String& text, bool searchForward)
2563 result r = E_SUCCESS;
2565 Ewk_Find_Options condition = static_cast< Ewk_Find_Options >(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2569 condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS);
2572 _WebPresenter presenter;
2573 presenter.InitAsyncProcess();
2575 r = SynchronizeSearch(SEARCH_SYNC, __pWebCore->GetWebNativeNode(), condition, text, searchForward, false, &presenter);
2576 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2579 presenter.WaitAsyncProcess(result);
2581 return static_cast < bool >(result);
2586 _WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive)
2588 result r = E_SUCCESS;
2590 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2594 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2597 r = SynchronizeSearch(SEARCH_ALL_ASYNC, __pWebCore->GetWebNativeNode(), condition, text, true, caseSensitive);
2598 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2605 _WebImpl::SearchNextAsync(bool searchForward)
2607 SysTryReturnResult(NID_WEB_CTRL, __textSearch.__searchAll && __textSearch.__totalCount > -1, E_INVALID_OPERATION, "The SearchTextAllAsync() method is not called or completed.");
2608 SysTryReturnResult(NID_WEB_CTRL, (searchForward && __textSearch.__currentIndex < __textSearch.__totalCount) || (!searchForward && __textSearch.__currentIndex > 1)
2609 , E_OBJ_NOT_FOUND, "The Next instance is not available.");
2611 result r = E_SUCCESS;
2613 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2615 if (__textSearch.__caseSensitive)
2617 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2622 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_BACKWARDS);
2625 r = SynchronizeSearch(SEARCH_NEXT_ASYNC, __pWebCore->GetWebNativeNode(), condition, __textSearch.__text, searchForward);
2626 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2633 _WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text, bool searchForward, bool caseSensitive, _WebPresenter* pWebPresenter)
2635 MutexGuard lock(__mutex);
2637 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(text));
2638 SysTryReturn(NID_WEB_CTRL, pText.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2643 if (__textSearch.__searchAll)
2645 DisableAsyncSearch();
2647 __textSearch.__searchQueue.Enqueue(this);
2648 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2650 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2651 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2655 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2657 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2661 case SEARCH_ALL_ASYNC:
2662 __textSearch.__searchAll = true;
2663 __textSearch.__text = text;
2664 __textSearch.__searchForward = true;
2665 __textSearch.__caseSensitive = caseSensitive;
2666 __textSearch.__totalCount = -1;
2667 __textSearch.__currentIndex = 1;
2669 __textSearch.__searchQueue.Enqueue(this);
2670 __textSearch.__searchQueue.Enqueue(this);
2672 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2673 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2676 case SEARCH_NEXT_ASYNC:
2677 __textSearch.__searchForward = searchForward;
2679 CalculateAsyncSearchOrdinal();
2681 __textSearch.__searchQueue.Enqueue(this);
2683 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2695 _WebImpl::SetAsyncSearchResult(int totalCount)
2697 __textSearch.__totalCount = totalCount;
2702 _WebImpl::GetSearchPresenter(void)
2704 MutexGuard lock(__mutex);
2706 return dynamic_cast< _WebPresenter* >(__textSearch.__searchQueue.Dequeue());
2711 _WebImpl::GetPendingAsyncSearchCount(void) const
2713 return __textSearch.__searchQueue.GetCount();
2718 _WebImpl::CalculateAsyncSearchOrdinal(void)
2720 if (__textSearch.__searchForward)
2722 __textSearch.__currentIndex++;
2726 __textSearch.__currentIndex--;
2732 _WebImpl::GetAsyncSearchOrdinal(void) const
2734 return __textSearch.__currentIndex;
2739 _WebImpl::DisableAsyncSearch(void)
2741 __textSearch.__searchAll = false;
2746 _WebImpl::SetSetting(const WebSetting& setting)
2748 if (__pWebCore->GetWebNativeNode())
2750 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2751 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2752 SysAssertf(pContext && pSettings, "Failed to get webkit instance.");
2754 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(setting.GetDefaultTextEncoding()));
2755 SysTryReturn(NID_WEB_CTRL, pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2757 ewk_settings_default_encoding_set(pSettings, pEncoding.get());
2759 switch (setting.GetCacheControl())
2761 case WEB_CACHE_VALIDATED:
2762 ewk_context_cache_disabled_set(pContext, EINA_FALSE);
2765 case WEB_CACHE_IGNORE:
2766 ewk_context_cache_disabled_set(pContext, EINA_TRUE);
2773 if (setting.GetInputStyle() == INPUT_STYLE_OVERLAY)
2775 ewk_settings_default_keypad_enabled_set(pSettings, EINA_TRUE);
2779 ewk_settings_default_keypad_enabled_set(pSettings, EINA_FALSE);
2782 ewk_settings_font_default_size_set(pSettings, static_cast< Eina_Bool >(setting.GetFontSize()));
2784 ewk_settings_javascript_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsJavascriptEnabled()));
2786 ewk_settings_loads_images_automatically_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoImageLoadEnabled()));
2788 std::unique_ptr<char[]> pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent()));
2789 SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2791 ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get());
2793 ewk_settings_auto_fitting_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFittingEnabled()));
2795 ewk_settings_scripts_window_open_set(pSettings, static_cast< Eina_Bool >(setting.IsJavaScriptPopupEnabled()));
2797 ewk_settings_form_candidate_data_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFormDataShowEnabled()));
2799 ewk_settings_autofill_password_form_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoLoginFormFillEnabled()));
2802 _WebSettingImpl* pWebSettingImpl = _WebSettingImpl::GetInstance(__pWebCore->GetSetting());
2804 pWebSettingImpl->SetCertificateErrorHandlingMode(setting.GetCertificateErrorHandlingMode());
2805 pWebSettingImpl->SetDefaultTextEncoding(setting.GetDefaultTextEncoding());
2806 pWebSettingImpl->SetCacheControl(setting.GetCacheControl());
2807 pWebSettingImpl->SetFontSize(setting.GetFontSize());
2808 pWebSettingImpl->SetJavascriptEnabled(setting.IsJavascriptEnabled());
2809 pWebSettingImpl->SetAutoImageLoadEnabled(setting.IsAutoImageLoadEnabled());
2810 pWebSettingImpl->SetInputStyle(setting.GetInputStyle());
2811 pWebSettingImpl->SetUserAgent(setting.GetUserAgent());
2812 pWebSettingImpl->SetAutoFittingEnabled(setting.IsAutoFittingEnabled());
2813 pWebSettingImpl->SetJavaScriptPopupEnabled(setting.IsJavaScriptPopupEnabled());
2814 pWebSettingImpl->SetGeolocationEnabled(setting.IsGeolocationEnabled());
2815 pWebSettingImpl->SetAutoFormDataShowEnabled(setting.IsAutoFormDataShowEnabled());
2816 pWebSettingImpl->SetAutoLoginFormFillEnabled(setting.IsAutoLoginFormFillEnabled());
2823 _WebImpl::GetSetting(void) const
2825 return *__pWebCore->GetSetting();
2829 const HitElementResult*
2830 _WebImpl::GetElementByPointN(const Point& point) const
2832 result r = E_SUCCESS;
2834 _HitElementResultImpl* pHitElementResultImpl = null;
2836 std::unique_ptr<HitElementResult> pHitElementResult;
2837 std::unique_ptr<Bitmap> pImage;
2838 std::unique_ptr<HashMap, AllElementsDeleter> pAttributeMap;
2840 Point absPoint(__pWebCore->GetAbsoluteCoordinate(point));
2842 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(__pWebCore->GetWebNativeNode(), absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
2843 SysTryReturn(NID_WEB_CTRL, pEwkHitTest, null, E_SYSTEM, "[%s] Failed to get hit test.", GetErrorMessage(E_SYSTEM));
2845 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
2846 Ewk_Hit_Test_Result_Context context = ewk_hit_test_result_context_get(pEwkHitTest);
2847 String url(ewk_hit_test_link_uri_get(pEwkHitTest));
2848 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
2849 String nodeValue(ewk_hit_test_node_value_get(pEwkHitTest));
2851 SysLog(NID_WEB_CTRL, "The current value of url is %ls, tag is %ls, value is %ls", url.GetPointer(), tagName.GetPointer(), nodeValue.GetPointer());
2853 pHitElementResult = std::unique_ptr<HitElementResult>(new (std::nothrow) HitElementResult());
2854 SysTryCatch(NID_WEB_CTRL, pHitElementResult.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2856 pHitElementResultImpl = _HitElementResultImpl::GetInstance(pHitElementResult.get());
2857 SysTryCatch(NID_WEB_CTRL, pHitElementResultImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2859 if (context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE)
2865 int imageLength = ewk_hit_test_image_buffer_length_get(pEwkHitTest);
2866 void* pImageBuffer = ewk_hit_test_image_buffer_get(pEwkHitTest);
2867 const char* pExtension = ewk_hit_test_image_file_name_extension_get(pEwkHitTest);
2868 SysLog(NID_WEB_CTRL, "The current value of imageBuffer is %u, bufferLength is %d, extension is %s", pImageBuffer, imageLength, pExtension);
2870 r = buf.Construct(imageLength);
2871 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2873 r = buf.SetArray(reinterpret_cast< byte* >(pImageBuffer), 0, imageLength);
2874 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2878 // ToDo : webkit doesn't support types such as IMG_FORMAT_WBMP and IMG_FORMAT_TIFF
2879 // webkit support types such as ico and vp8 additionally
2880 if (strcmp(pExtension, "gif") == 0)
2882 format = IMG_FORMAT_GIF;
2884 else if (strcmp(pExtension, "jpg") == 0)
2886 format = IMG_FORMAT_JPG;
2888 else if (strcmp(pExtension, "png") == 0)
2890 format = IMG_FORMAT_PNG;
2892 else if (strcmp(pExtension, "bmp") == 0)
2894 format = IMG_FORMAT_BMP;
2898 SysLogException(NID_WEB_CTRL, E_UNSUPPORTED_FORMAT, "[%s] The %s format is not supported", GetErrorMessage(E_UNSUPPORTED_FORMAT), pExtension);
2902 r = image.Construct();
2903 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2905 pImage = std::unique_ptr<Bitmap>(image.DecodeN(buf, format, BITMAP_PIXEL_FORMAT_RGB565));
2906 SysTryCatch(NID_WEB_CTRL, pImage.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2911 pAttributeMap = std::unique_ptr<HashMap, AllElementsDeleter>(new (std::nothrow) HashMap());
2912 SysTryCatch(NID_WEB_CTRL, pAttributeMap.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2914 r = pAttributeMap->Construct(eina_hash_population(pAttrHash));
2915 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2917 eina_hash_foreach(pAttrHash, AddHttpAttributeData, pAttributeMap.get());
2918 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2921 pHitElementResultImpl->SetHitElementResult(pAttributeMap.release(), pImage.release(), tagName, nodeValue, url);
2923 ewk_hit_test_free(pEwkHitTest);
2925 return pHitElementResult.release();
2928 ewk_hit_test_free(pEwkHitTest);
2934 const HitElementResult*
2935 _WebImpl::GetElementByPointN(const FloatPoint& point) const
2937 const Point integerPoint(_CoordinateSystemUtils::ConvertToInteger(point));
2939 std::unique_ptr<const HitElementResult> pHitElementResult(GetElementByPointN(integerPoint));
2940 SysTryReturn(NID_WEB_CTRL, pHitElementResult.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2942 return pHitElementResult.release();
2947 _WebImpl::IsLoading(void) const
2949 double percent = ewk_view_load_progress_get(__pWebCore->GetWebNativeNode());
2951 if (Double::Compare(percent, 0.0) > 0 && Double::Compare(percent, 1.0) < 0)
2963 _WebImpl::GetTextFromBlock(void) const
2965 return ewk_view_text_selection_text_get(__pWebCore->GetWebNativeNode());
2970 _WebImpl::IsPrivateBrowsingEnabled(void) const
2972 if (__pWebCore->GetWebNativeNode() == null)
2974 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsPrivateBrowsingEnabled();
2977 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2978 SysAssertf(pSettings, "Failed to get webkit instance.");
2980 return static_cast< bool >(ewk_settings_private_browsing_enabled_get(pSettings));
2985 _WebImpl::SetPrivateBrowsingEnabled(bool enable)
2987 if (__pWebCore->GetWebNativeNode() == null)
2989 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetPrivateBrowsingEnabled(enable);
2993 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2994 SysAssertf(pSettings, "Failed to get webkit instance.");
2996 ewk_settings_private_browsing_enabled_set(pSettings, static_cast< Eina_Bool >(enable));
3001 _WebImpl::ClearHistory(void)
3003 ewk_view_back_forward_list_clear(__pWebCore->GetWebNativeNode());
3008 _WebImpl::ClearCache(void)
3010 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3011 SysAssertf(pContext, "Failed to get webkit instance.");
3013 ewk_context_cache_clear(pContext);
3018 _WebImpl::ClearCookie(void)
3020 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3021 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3022 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3024 ewk_cookie_manager_cookies_clear(pCookieManager);
3029 _WebImpl::ClearFormData(void)
3031 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3032 SysAssertf(pContext, "Failed to get webkit instance.");
3034 ewk_context_form_candidate_data_clear(pContext);
3039 _WebImpl::ClearLoginFormData(void)
3041 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3042 SysAssertf(pContext, "Failed to get webkit instance.");
3044 ewk_context_form_password_data_clear(pContext);
3049 _WebImpl::IsCookieEnabled(void) const
3051 if (__pWebCore->GetWebNativeNode() == null)
3053 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsCookieEnabled();
3056 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3057 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3058 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3060 _WebPresenter presenter;
3061 presenter.InitAsyncProcess();
3063 ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, &presenter);
3065 bool result = false;
3066 presenter.WaitAsyncProcess(result);
3073 _WebImpl::SetCookieEnabled(bool enable)
3075 if (__pWebCore->GetWebNativeNode() == null)
3077 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetCookiEnabled(enable);
3082 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
3083 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
3084 SysAssertf(pCookieManager, "Failed to get webkit instance.");
3088 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
3092 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER);
3093 ewk_cookie_manager_cookies_clear(pCookieManager);
3099 _WebImpl::SavePageAsPdf(const String& filePath, const Dimension* pSize) const
3101 result r = E_SUCCESS;
3103 std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
3104 SysTryReturn(NID_WEB_CTRL, pFilePath.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3107 String fileExtension = File::GetFileExtension(filePath);
3108 int pathLength = filePath.GetLength();
3111 SysTryReturnResult(NID_WEB_CTRL, fileExtension.Equals("pdf", false), E_INVALID_ARG, "Invalid argument(s) is used. File extension is not pdf.");
3113 r = filePath.LastIndexOf(L"/", pathLength - 1, index);
3114 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3115 r = filePath.SubString(0, index + 1, dirPath);
3116 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
3118 std::unique_ptr<char[]> pDirPath(_StringConverter::CopyToCharArrayN(dirPath));
3119 SysTryReturnResult(NID_WEB_CTRL, access(pDirPath.get(), W_OK) == 0, E_INACCESSIBLE_PATH, "Directory permission is read-only.");
3123 SysTryReturnResult(NID_WEB_CTRL, pSize->width > 0 && pSize->height > 0, E_INVALID_ARG, "Invalid argument(s) is used. Size of pdf file is invalid.");
3125 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), pSize->width, pSize->height, pFilePath.get());
3129 Evas_Coord contentsWidth;
3130 Evas_Coord contentsHeight;
3132 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &contentsWidth, &contentsHeight);
3133 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), contentsWidth, contentsHeight, pFilePath.get());
3141 _WebImpl::IsMimeSupported(const String& mime) const
3143 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
3144 SysTryReturn(NID_WEB_CTRL, pMime.get(), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3146 return static_cast< bool >(ewk_frame_can_show_mime_type(ewk_view_main_frame_get(__pWebCore->GetWebNativeNode()), pMime.get()));
3151 _WebImpl::SetLoadingListener(ILoadingListener* pLoadingListener)
3153 __pUserLoadingListener = const_cast< ILoadingListener* >(pLoadingListener);
3158 _WebImpl::SetWebUiEventListener(IWebUiEventListener* pUiEventListener)
3160 __pUserUiListener = pUiEventListener;
3165 _WebImpl::SetWebUiEventListenerF(IWebUiEventListenerF* pUiEventListener)
3167 __pUserUiListenerF = pUiEventListener;
3172 _WebImpl::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener)
3174 __pUserKeypadEventListener = pKeypadEventListener;
3179 _WebImpl::SetDownloadListener(IWebDownloadListener* pDownLoadListener)
3181 if (__pWebDownloadHandler.get() == null)
3183 __pWebDownloadHandler = std::unique_ptr<_WebDataHandler>(new (std::nothrow) _WebDataHandler());
3184 SysTryReturnVoidResult(NID_WEB_CTRL, __pWebDownloadHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3187 __pWebDownloadHandler->SetDownloadListener(pDownLoadListener);
3188 __pWebDownloadHandler->SetWebEvent(__pWebEvent.get());
3193 _WebImpl::SetTextSearchListener(ITextSearchListener* pTextSearchListener)
3195 __pTextSearchListener = pTextSearchListener;
3200 _WebImpl::SetScrollEnabled(bool enable)
3202 _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->SetScrollEnabled(enable);
3207 _WebImpl::IsScrollEnabled(void) const
3209 return _WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled();
3214 _WebImpl::InitJsBridgeList(void)
3216 result r = E_SUCCESS;
3218 __pJsProvider = std::unique_ptr<_JsBridgeHashCodeProvider>(new (std::nothrow) _JsBridgeHashCodeProvider());
3219 SysTryReturnResult(NID_WEB_CTRL, __pJsProvider.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3221 __pJsComparer = std::unique_ptr<_JsBridgeComparer>(new (std::nothrow) _JsBridgeComparer());
3222 SysTryReturnResult(NID_WEB_CTRL, __pJsComparer.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3224 std::unique_ptr<HashMapT< String, IJavaScriptBridge* > > pJsBridgeList(new (std::nothrow) HashMapT< String, IJavaScriptBridge* >);
3225 SysTryReturnResult(NID_WEB_CTRL, pJsBridgeList.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3227 r = pJsBridgeList->Construct(0, 0, *__pJsProvider.get(), *__pJsComparer.get());
3228 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3230 __pJsBridgeList = std::move(pJsBridgeList);
3237 _WebImpl::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3239 result r = E_SUCCESS;
3241 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3242 String key(pJsBridge->GetName());
3244 r = __pJsBridgeList->Add(key, pJsBridge);
3245 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3252 _WebImpl::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3254 result r = E_SUCCESS;
3256 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3257 String key(pJsBridge->GetName());
3259 r = __pJsBridgeList->Remove(key);
3260 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3267 _WebImpl::FindJsInterface(const IJsonValue* pValue) const
3269 result r = E_SUCCESS;
3271 IJsonValue* pJsonValue = null;
3272 IJavaScriptBridge* pJsBridge = null;
3274 String key(L"name");
3276 const JsonObject* pJsonObject = dynamic_cast< const JsonObject* >(pValue);
3277 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));
3279 r = pJsonObject->GetValue(&key, pJsonValue);
3280 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS && pJsonValue, null, r, "[%s] Propagating.", GetErrorMessage(r));
3282 JsonString* pBridgeName = dynamic_cast< JsonString* >(pJsonValue);
3283 SysTryReturn(NID_WEB_CTRL, pBridgeName, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. name key is missing." , GetErrorMessage(E_INVALID_ARG));
3285 r = __pJsBridgeList->GetValue(static_cast< String >(*pBridgeName), pJsBridge);
3286 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3293 _WebImpl::GetLoadingListener(void) const
3295 return __pUserLoadingListener;
3299 IWebUiEventListener*
3300 _WebImpl::GetUiEventListener(void) const
3302 return __pUserUiListener;
3306 IWebUiEventListenerF*
3307 _WebImpl::GetUiEventListenerF(void) const
3309 return __pUserUiListenerF;
3313 IWebKeypadEventListener*
3314 _WebImpl::GetWebKeypadEventListener(void) const
3316 return __pUserKeypadEventListener;
3320 ITextSearchListener*
3321 _WebImpl::GetTextSearchListener(void) const
3323 return __pTextSearchListener;
3328 _WebImpl::SetEventListenerCallback(void) const
3330 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3333 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3334 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3336 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3337 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3339 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3340 SysAssertf(pSmartData, "Failed to request");
3342 Ewk_View_Smart_Class *pSmart = const_cast<Ewk_View_Smart_Class*>(pSmartData->api);
3343 SysAssertf(pSmart, "Failed to request");
3345 pSmart->popup_menu_show = OnSelectBoxRequested;
3346 pSmart->popup_menu_hide = OnSelectBoxClosed;
3347 pSmart->popup_menu_update = OnSelectBoxUpdateRequested;
3349 pSmart->input_picker_show = OnDatePickerProviderRequested;
3350 pSmart->input_picker_color_request = OnColorPickerProviderRequested;
3351 pSmart->input_picker_color_dismiss = OnColorPickerProviderDismissed;
3353 evas_object_data_set(pWebNativeNode, WEB_CTRL, this);
3355 // add loading event callbacks for ILoadingListener
3356 evas_object_smart_callback_add(pWebNativeNode, "create,window", OnWebWindowCreateRequested, this);
3357 evas_object_smart_callback_add(pWebNativeNode, "close,window", OnWebWindowClosedRequested, this);
3359 evas_object_smart_callback_add(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested, this);
3360 evas_object_smart_callback_add(pWebNativeNode, "load,started", OnLoadingStarted, this);
3361 evas_object_smart_callback_add(pWebNativeNode, "load,finished", OnLoadingCompleted, this);
3362 evas_object_smart_callback_add(pWebNativeNode, "load,progress", OnEstimatedProgress, this);
3363 evas_object_smart_callback_add(pWebNativeNode, "load,progress,finished", OnProgressCompleted, this);
3364 evas_object_smart_callback_add(pWebNativeNode, "load,stop", OnLoadingCanceled, this);
3365 evas_object_smart_callback_add(pWebNativeNode, "load,error", OnLoadingErrorOccurred, this);
3366 evas_object_smart_callback_add(pWebNativeNode, "title,changed", OnPageTitleReceived, this);
3367 evas_object_smart_callback_add(pWebNativeNode, "load,committed", OnLoadingCommitted, this);
3369 evas_object_smart_callback_add(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest, this);
3371 evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3373 evas_object_smart_callback_add(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged, this);
3374 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened, this);
3375 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed, this);
3377 evas_object_smart_callback_add(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested, this);
3378 evas_object_smart_callback_add(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled, this);
3380 evas_object_smart_callback_add(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested, this);
3382 ewk_view_javascript_alert_callback_set(pWebNativeNode, OnScriptAlertRequested, const_cast< _WebImpl* >(this));
3383 ewk_view_javascript_prompt_callback_set(pWebNativeNode, OnScriptPromptRequested, const_cast< _WebImpl* >(this));
3384 ewk_view_javascript_confirm_callback_set(pWebNativeNode, OnScriptConfirmRequested, const_cast< _WebImpl* >(this));
3386 evas_object_smart_callback_add(pWebNativeNode, "policy,response,decide", OnWebDataReceived, this);
3388 evas_object_smart_callback_add(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested, this);
3389 evas_object_smart_callback_add(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested, this);
3390 evas_object_smart_callback_add(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted, this);
3392 evas_object_smart_callback_add(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested, this);
3393 evas_object_smart_callback_add(pWebNativeNode, "notification,show", OnNotificationShow, this);
3394 evas_object_smart_callback_add(pWebNativeNode, "notification,cancel", OnNotificationCancel, this);
3396 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested, this);
3397 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered, this);
3398 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested, this);
3400 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested, this);
3401 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered, this);
3402 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested, this);
3403 evas_object_smart_callback_add(pWebNativeNode, "text,found", OnTextFound, this);
3405 evas_object_smart_callback_add(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered, this);
3406 evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this);
3408 evas_object_smart_callback_add(pWebNativeNode, "text,style,state", OnWebPageBlockSelected, this);
3410 ewk_view_open_panel_callback_set(pWebNativeNode, OnSelectUploadFile, const_cast< _WebImpl* >(this));
3411 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3412 SysAssertf(pContext, "Failed to get webkit instance.");
3413 ewk_context_did_start_download_callback_set(pContext, OnDidStartDownloadCallback, const_cast< _WebImpl* >(this));
3414 ewk_context_vibration_client_callbacks_set(pContext, OnVibrationRequested, OnVibrationCanceled, const_cast< _WebImpl* >(this));
3415 ewk_view_application_cache_permission_callback_set(pWebNativeNode, OnApplicationCachePermissionRequested, const_cast< _WebImpl* >(this));
3417 evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this);
3423 _WebImpl::RemoveEventListenerCallback(void) const
3425 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3428 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3429 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3431 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3432 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3434 evas_object_smart_callback_del(pWebNativeNode, "create,window", OnWebWindowCreateRequested);
3435 evas_object_smart_callback_del(pWebNativeNode, "close,window", OnWebWindowClosedRequested);
3437 evas_object_smart_callback_del(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested);
3438 evas_object_smart_callback_del(pWebNativeNode, "load,started", OnLoadingStarted);
3439 evas_object_smart_callback_del(pWebNativeNode, "load,finished", OnLoadingCompleted);
3440 evas_object_smart_callback_del(pWebNativeNode, "load,progress", OnEstimatedProgress);
3441 evas_object_smart_callback_del(pWebNativeNode, "load,progress,finished", OnProgressCompleted);
3442 evas_object_smart_callback_del(pWebNativeNode, "load,stop", OnLoadingCanceled);
3443 evas_object_smart_callback_del(pWebNativeNode, "load,error", OnLoadingErrorOccurred);
3444 evas_object_smart_callback_del(pWebNativeNode, "title,changed", OnPageTitleReceived);
3446 evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest);
3448 evas_object_smart_callback_del_full(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3450 evas_object_smart_callback_del(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged);
3451 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened);
3452 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed);
3454 evas_object_smart_callback_del(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested);
3455 evas_object_smart_callback_del(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled);
3457 evas_object_smart_callback_del(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested);
3459 ewk_view_javascript_alert_callback_set(null, null, null);
3460 ewk_view_javascript_prompt_callback_set(null, null, null);
3461 ewk_view_javascript_confirm_callback_set(null, null, null);
3463 evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived);
3465 evas_object_smart_callback_del(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested);
3466 evas_object_smart_callback_del(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested);
3467 evas_object_smart_callback_del(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted);
3469 evas_object_smart_callback_del(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested);
3470 evas_object_smart_callback_del(pWebNativeNode, "notification,show", OnNotificationShow);
3471 evas_object_smart_callback_del(pWebNativeNode, "notification,cancel", OnNotificationCancel);
3472 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested);
3473 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered);
3474 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested);
3476 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested);
3477 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered);
3478 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested);
3480 evas_object_smart_callback_del(pWebNativeNode, "text,found", OnTextFound);
3482 evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered);
3483 evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived);
3485 evas_object_smart_callback_del(pWebNativeNode, "text,style,state", OnWebPageBlockSelected);
3487 ewk_view_open_panel_callback_set(null, null, null);
3488 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3489 SysAssertf(pContext, "Failed to get webkit instance.");
3490 ewk_context_vibration_client_callbacks_set(pContext, null, null, null);
3491 ewk_view_application_cache_permission_callback_set(pWebNativeNode, null, null);
3493 evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained);
3499 _WebImpl::SetBlockSelectionPosition(const Point& startPoint)
3501 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3503 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3504 SysAssertf(pSmartData, "Failed to request");
3506 Point absPoint(__pWebCore->GetAbsoluteCoordinate(startPoint));
3508 Eina_Bool ret = pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y);
3511 pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y);
3513 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(__pWebCore->GetWebNativeNode(), absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
3514 SysTryReturnResult(NID_WEB_CTRL, pEwkHitTest, E_SYSTEM, "Failed to get hit test.");
3516 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
3518 if (tagName.Equals(L"INPUT", false) || tagName.Equals(L"TEXTAREA", false))
3520 ewk_view_command_execute(pWebNativeNode, "SelectWord", 0);
3524 SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up.");
3531 _WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint)
3533 return SetBlockSelectionPosition(_CoordinateSystemUtils::ConvertToInteger(startPoint));
3538 _WebImpl::ReleaseBlock(void)
3540 ewk_view_command_execute(__pWebCore->GetWebNativeNode(), "Unselect", 0);
3545 _WebImpl::GetBlockRange(Point& startPoint, Point& endPoint) const
3547 FloatPoint tempStartPoint;
3548 FloatPoint tempEndPoint;
3550 GetBlockRange(tempStartPoint, tempEndPoint);
3552 startPoint = _CoordinateSystemUtils::ConvertToInteger(tempStartPoint);
3553 endPoint = _CoordinateSystemUtils::ConvertToInteger(tempEndPoint);
3558 _WebImpl::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const
3560 Eina_Rectangle leftHandle;
3561 Eina_Rectangle rightHandle;
3563 ewk_view_text_selection_range_get(__pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle);
3565 startPoint.x = _CoordinateSystemUtils::ConvertToFloat(leftHandle.x);
3566 startPoint.y = _CoordinateSystemUtils::ConvertToFloat(leftHandle.y);
3567 endPoint.x = _CoordinateSystemUtils::ConvertToFloat(rightHandle.x + rightHandle.w);
3568 endPoint.y = _CoordinateSystemUtils::ConvertToFloat(rightHandle.y + rightHandle.h);
3570 if ((endPoint.x != 0.0f) && (endPoint.y != 0.0f))
3572 startPoint = __pWebCore->GetRelativeCoordinate(startPoint);
3573 endPoint = __pWebCore->GetRelativeCoordinate(endPoint);
3579 _WebImpl::GetFaviconN(void) const
3581 result r = E_SUCCESS;
3583 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3585 Evas* pEvas = evas_object_evas_get(pView);
3586 Ewk_Context* pContext = ewk_view_context_get(pView);
3587 SysAssertf(pEvas && pContext, "Failed to request");
3589 const char* pUrl = ewk_view_url_get(pView);
3591 Tizen::Graphics::BufferInfo bufferInfo;
3592 Tizen::Base::ByteBuffer byteBuffer;
3594 std::unique_ptr<Bitmap> pBitmapImage(new (std::nothrow) Bitmap());
3595 SysTryReturn(NID_WEB_CTRL, pBitmapImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3597 Evas_Object* pFavicon = ewk_context_icon_database_icon_object_add(pContext, pUrl, pEvas);
3603 r = _Utility::GetPixelBufferFromEvasObject(pFavicon, bufferInfo);
3604 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3606 const Dimension dimension(bufferInfo.width, bufferInfo.height);
3608 r = byteBuffer.Construct((byte*)bufferInfo.pPixels, 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 );
3609 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3611 r = pBitmapImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888);
3612 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3614 return pBitmapImage.release();
3620 _WebImpl::ScrollBy(const Tizen::Graphics::Point& diff)
3622 ewk_view_scroll_by(__pWebCore->GetWebNativeNode(), diff.x, diff.y);
3627 _WebImpl::ScrollTo(const Tizen::Graphics::Point& dest)
3629 ewk_view_scroll_set(__pWebCore->GetWebNativeNode(), dest.x, dest.y);
3634 _WebImpl::GetScrollPosition(void) const
3638 ewk_view_scroll_pos_get(__pWebCore->GetWebNativeNode(), &position.x, &position.y);
3645 _WebImpl::GetPageSize(void) const
3647 Evas_Coord width = 0;
3648 Evas_Coord height = 0;
3650 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &width, &height);
3652 Dimension size(static_cast< int >(width), static_cast< int >(height));
3659 _WebImpl::SetLoadingErrorOccurred(bool arg)
3661 __isLoadingErrorOccurred = arg;
3666 _WebImpl::IsLoadingErrorOccurred(void) const
3668 return __isLoadingErrorOccurred;
3673 _WebImpl::SetRedirectRequested(bool arg)
3675 __isRedirectRequested = arg;
3680 _WebImpl::IsRedirectRequested(void) const
3682 return __isRedirectRequested;
3687 _WebImpl::SetPolicyDecision(DecisionPolicy policy)
3694 _WebImpl::GetPolicyDecision(void) const
3701 _WebImpl::SetCertificateRequested(bool arg)
3703 __isCertificateRequested = arg;
3708 _WebImpl::IsCertificateRequested(void) const
3710 return __isCertificateRequested;
3715 _WebImpl::IsCertificateConfirmed(void) const
3717 return __isCertificateConfirmed;
3722 _WebImpl::LaunchAppControl(const IEventArg& arg)
3724 result r = E_SUCCESS;
3726 IEventArg* pArg = const_cast< IEventArg* >(&arg);
3727 _WebEventArg* pWebEventArg = dynamic_cast< _WebEventArg* >(pArg);
3728 SysTryReturnResult(NID_WEB_CTRL, pWebEventArg, E_INVALID_ARG, "Type casting failed. argument must be IEventArg type.");
3730 String operationId(L"");
3731 String uriPattern(pWebEventArg->GetEventMessage());
3732 SysLog(NID_WEB_CTRL, "The current value of web event type is %d", pWebEventArg->GetEventType());
3734 switch (pWebEventArg->GetEventType())
3736 case WEB_EVENT_REQUEST_RTSP:
3740 int uriLength = uriPattern.GetLength();
3743 operationId = L"http://tizen.org/appcontrol/operation/view";
3745 r = uriPattern.LastIndexOf(L".", uriLength - 1, index);
3746 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3748 r = uriPattern.SubString(index + 1, ext);
3749 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3751 r = _AppControlManager::GetMimeFromExt(ext, mimeType);
3752 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3754 r = _AppControlImpl::FindAndStart(operationId, &uriPattern, &mimeType, null, null, null);
3755 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3759 case WEB_EVENT_REQUEST_TEL:
3761 operationId = L"http://tizen.org/appcontrol/operation/dial";
3764 case WEB_EVENT_REQUEST_EMAIL:
3766 case WEB_EVENT_REQUEST_SMS:
3768 case WEB_EVENT_REQUEST_MMS:
3770 operationId = L"http://tizen.org/appcontrol/operation/compose";
3773 case WEB_EVENT_REQUEST_UNKNOWN:
3775 operationId = L"http://tizen.org/appcontrol/operation/view";
3783 r = _AppControlImpl::FindAndStart(operationId, &uriPattern, null, null, null, null);
3784 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3791 _WebImpl::SetFullScreenKeypad(void)
3793 result r = E_SUCCESS;
3795 std::unique_ptr<Keypad> pKeypad(new (std::nothrow) Keypad());
3796 SysTryReturnResult(NID_WEB_CTRL, pKeypad.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
3798 r = pKeypad->Construct(KEYPAD_STYLE_NORMAL, 100);
3799 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3801 String text(ewk_view_focused_input_element_value_get(__pWebCore->GetWebNativeNode()));
3802 pKeypad->SetText(text);
3804 r = pKeypad->SetShowState(true);
3805 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3807 r = pKeypad->Show();
3808 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3810 pKeypad->AddTextEventListener(*this);
3812 __pKeypad = std::move(pKeypad);
3819 _WebImpl::RemoveFullScreenKeypad(void)
3821 __pKeypad->RemoveTextEventListener(*this);
3828 _WebImpl::IsFooterVisible(void) const
3830 return __isFooterVisible;
3835 _WebImpl::SetFooterVisibleState(bool isFooterVisible)
3837 __isFooterVisible = isFooterVisible;
3842 _WebImpl::IsKeypadVisible(void) const
3844 return __isKeypadVisible;
3849 _WebImpl::SetKeypadVisibleState(bool isKeypadVisible)
3851 __isKeypadVisible = isKeypadVisible;
3856 _WebImpl::IsKeypadOpened(void) const
3858 return __isKeypadOpened;
3862 _WebImpl::SetKeypadOpened(bool isKeypadOpened)
3864 __isKeypadOpened = isKeypadOpened;
3869 _WebImpl::GetPreviousKeypadBounds(void) const
3871 return __keypadBounds;
3876 _WebImpl::SetPreviousKeypadBounds(Rectangle& bounds)
3878 __keypadBounds = bounds;
3883 _WebImpl::OnTextValueChangeCanceled(const Control& source)
3885 RemoveFullScreenKeypad();
3890 _WebImpl::OnTextValueChanged(const Control& source)
3892 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(__pKeypad->GetText()));
3894 ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get());
3896 RemoveFullScreenKeypad();
3901 _WebImpl::OnHandleJavaScriptRequestByEventArg(const IEventArg& arg)
3903 const _JsBridgeArg* pEventArg = dynamic_cast< const _JsBridgeArg* >(&arg);
3904 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. arg is not _JsBridgeArg object.");
3906 std::unique_ptr<IJsonValue> pJsonValue(JsonParser::ParseN(*(pEventArg->GetJsonData())));
3907 SysTryReturn(NID_WEB_JSON, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3909 IJavaScriptBridge* pJsInterface = FindJsInterface(pJsonValue.get());
3910 SysTryReturnResult(NID_WEB_CTRL, pJsInterface, E_OBJ_NOT_FOUND, "JsInterface instance is not available.");
3912 pJsInterface->HandleJavaScriptRequestN(pJsonValue.release());
3919 _WebImpl::OnHandleLoadingEvent(const IEventArg& arg)
3921 result r = E_SUCCESS;
3923 const _LoadingEventArg* pEventArg = dynamic_cast< const _LoadingEventArg* >(&arg);
3924 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
3926 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
3928 ILoadingListener* pLoadingListner = GetLoadingListener();
3929 SysTryReturnResult(NID_WEB_CTRL, pLoadingListner, E_SYSTEM, "A system error has been occurred. Loading listener was not set or null.");
3931 switch (pEventArg->GetEventType())
3933 case WEB_EVENT_LOADINGLISTENER_STARTED:
3935 pLoadingListner->OnLoadingStarted();
3939 case WEB_EVENT_LOADINGLISTENER_PROGRESS:
3941 const Integer* pProgressPercentage = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS));
3942 SysTryReturn(NID_WEB_CTRL, pProgressPercentage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3944 pLoadingListner->OnEstimatedProgress(pProgressPercentage->ToInt());
3948 case WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED:
3950 const String* pPageTitle = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::PAGE_TITLE));
3951 SysTryReturn(NID_WEB_CTRL, pPageTitle, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3953 pLoadingListner->OnPageTitleReceived(*pPageTitle);
3957 case WEB_EVENT_LOADINGLISTENER_CANCELED:
3959 pLoadingListner->OnLoadingCanceled();
3963 case WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED:
3965 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_TYPE));
3966 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3968 const String* pErrorMessage = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_MESSAGE));
3969 SysTryReturn(NID_WEB_CTRL, pErrorMessage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3971 LoadingErrorType errorType = ConvertErrorCode(pErrorType->ToInt());
3973 pLoadingListner->OnLoadingErrorOccurred(errorType, *pErrorMessage);
3977 case WEB_EVENT_LOADINGLISTENER_COMPLETED:
3979 pLoadingListner->OnLoadingCompleted();
3983 case WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED:
3985 pLoadingListner->OnHttpAuthenticationCanceled();
3989 case WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED:
3991 std::unique_ptr<Bitmap> pFavicon(GetFaviconN());
3992 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3996 pLoadingListner->OnFaviconReceived(*pFavicon.get());
4012 _WebImpl::OnHandleWebDownloadEvent(const IEventArg& arg)
4014 result r = E_SUCCESS;
4016 const _WebDownloadEventArg* pEventArg = dynamic_cast< const _WebDownloadEventArg* >(&arg);
4017 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4019 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4021 IWebDownloadListener* pWebDownloadListener = __pWebDownloadHandler->GetDownloadListener();
4022 SysTryReturnResult(NID_WEB_CTRL, pWebDownloadListener, E_SYSTEM, "A system error has been occurred. Web Downloading listener was not set or null.");
4024 switch (pEventArg->GetEventType())
4026 case WEB_EVENT_WEBDOWNLOADLISTENER_DATA_RECEIVED:
4028 const ByteBuffer* pChunk = dynamic_cast< const ByteBuffer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::CHUNKED_DATA));
4029 SysTryReturn(NID_WEB_CTRL, pChunk, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4031 pWebDownloadListener->OnWebChunkedDataReceived(*pChunk);
4035 case WEB_EVENT_WEBDOWNLOADLISTENER_COMPLETED:
4037 pWebDownloadListener->OnWebDataDownloadCompleted();
4041 case WEB_EVENT_WEBDOWNLOADLISTENER_FAILED:
4043 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::ERROR_TYPE));
4044 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4046 LoadingErrorType errorType = static_cast < LoadingErrorType >(pErrorType->ToInt());
4048 pWebDownloadListener->OnWebDownloadFailed(errorType);
4063 _WebImpl::OnHandleWebUiEvent(const IEventArg& arg)
4065 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4066 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4068 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4070 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListener, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4072 switch (pEventArg->GetEventType())
4074 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED:
4076 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4078 Point* pStartPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4079 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4081 Point* pEndPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4082 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4084 __pUserUiListener->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4088 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED:
4090 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4092 __pUserUiListener->OnWebPageShowRequested(*pWeb);
4096 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED:
4098 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4100 __pUserUiListener->OnWebWindowCloseRequested(*pWeb);
4104 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED:
4106 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4108 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4109 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4111 __pUserUiListener->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4126 _WebImpl::OnHandleWebUiEventF(const IEventArg& arg)
4128 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4129 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4131 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4133 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListenerF, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4135 switch (pEventArg->GetEventType())
4137 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT:
4139 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4141 FloatPoint* pStartPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4142 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4144 FloatPoint* pEndPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4145 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4147 __pUserUiListenerF->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4151 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT:
4153 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4155 __pUserUiListenerF->OnWebPageShowRequested(*pWeb);
4159 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT:
4161 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4163 __pUserUiListenerF->OnWebWindowCloseRequested(*pWeb);
4167 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT:
4169 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4171 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4172 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4174 __pUserUiListenerF->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4189 _WebImpl::OnHandleTextSearchEvent(const IEventArg& arg)
4191 result r = E_SUCCESS;
4193 const _TextSearchEventArg* pEventArg = dynamic_cast< const _TextSearchEventArg* >(&arg);
4194 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4196 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4198 ITextSearchListener* pTextSearchListner = GetTextSearchListener();
4199 SysTryReturnResult(NID_WEB_CTRL, pTextSearchListner, E_SYSTEM, "A system error has been occurred. Web text search listener was not set or null.");
4201 switch (pEventArg->GetEventType())
4203 case WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND:
4205 Integer* pTotalCount= dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::TOTAL_COUNT)));
4206 SysTryReturn(NID_WEB_CTRL, pTotalCount, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4208 Integer* pCurrentOrdinal = dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL)));
4209 SysTryReturn(NID_WEB_CTRL, pCurrentOrdinal, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4211 pTextSearchListner->OnTextFound(pTotalCount->ToInt(), pCurrentOrdinal->ToInt());
4226 _WebImpl::VibrationRequested(uint64_t duration)
4228 result r = E_SUCCESS;
4230 __pVibrator.reset();
4232 std::unique_ptr<_VibratorImpl> pVibrator(new (std::nothrow) _VibratorImpl);
4233 SysTryReturnResult(NID_WEB_CTRL, pVibrator.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4235 r = pVibrator->Construct();
4236 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4238 __pVibrator = std::move(pVibrator);
4240 IntensityDurationVibrationPattern pattern = {static_cast< int >(duration), -1};
4242 r = __pVibrator->Start(&pattern, 1, 1);
4243 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4250 _WebImpl::VibrationCanceled(void)
4252 __pVibrator.reset();
4257 _WebImpl::HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge)
4259 result r = E_SUCCESS;
4261 String host(ewk_auth_challenge_url_get(pChallenge));
4262 String realm(ewk_auth_challenge_realm_get(pChallenge));
4264 __pAuthChallenge.reset();
4266 std::unique_ptr<AuthenticationChallenge> pAuthChallenge(new (std::nothrow) AuthenticationChallenge());
4267 SysTryReturnResult(NID_WEB_CTRL, pAuthChallenge, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4269 _AuthenticationChallengeImpl* pAuthImpl = _AuthenticationChallengeImpl::GetInstance(pAuthChallenge.get());
4270 SysTryReturn(NID_WEB_CTRL, pAuthImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4272 pAuthImpl->SetAuthenticationChallengeHandler(pChallenge);
4273 pAuthImpl->SetWebEvasObject(__pWebCore->GetWebNativeNode());
4275 __pAuthChallenge = std::move(pAuthChallenge);
4277 ewk_auth_challenge_suspend(pChallenge);
4278 if (__pUserLoadingListener && __pUserLoadingListener->OnHttpAuthenticationRequestedN(host, realm, *__pAuthChallenge.get()))
4280 __pAuthChallenge.release();
4284 r = ShowAuthenticationPopup(host, realm, __pAuthChallenge.get());
4285 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4293 _WebImpl::ShowAuthenticationPopup(const String& host, const String& realm, AuthenticationChallenge* pAuthChallenge)
4295 result r = E_SUCCESS;
4297 std::unique_ptr<_AuthConfirmPopup> pAuthPopup(new (std::nothrow) _AuthConfirmPopup());
4298 SysTryReturnResult(NID_WEB_CTRL, pAuthPopup, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4300 r = pAuthPopup->Construct(host, realm, pAuthChallenge);
4301 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4303 __pAuthPopup = std::move(pAuthPopup);
4305 int modalResult = 0;
4307 __pAuthPopup->SetOwner(&GetPublic());
4309 r = __pAuthPopup->ShowAndWait(modalResult);
4310 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4313 __pAuthPopup.reset();
4320 _WebImpl::ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk_Certificate_Policy_Decision* pPolicy)
4322 result r = E_SUCCESS;
4324 std::unique_ptr<_CertificateConfirmPopup> pCertConfirmPopup(new (std::nothrow) _CertificateConfirmPopup());
4325 SysTryReturnResult(NID_WEB_CTRL, pCertConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4327 r = pCertConfirmPopup->Construct(userConfirmMode, pPolicy);
4328 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4330 __pCertConfirmPopup = std::move(pCertConfirmPopup);
4332 int modalResult = 0;
4334 __pCertConfirmPopup->SetOwner(&GetPublic());
4336 r = __pCertConfirmPopup->ShowAndWait(modalResult);
4337 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4339 if (userConfirmMode == CERTIFICATE_POPUP_MODE_USER_CONFIRM)
4341 __isCertificateConfirmed = __pCertConfirmPopup->GetConfirmResult();
4345 __pCertConfirmPopup.reset();
4351 _WebImpl::ShowUserConfirmPopup(_UserConfirmMode userConfirmMode, void* pPolicy)
4353 result r = E_SUCCESS;
4355 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4356 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4358 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, true);
4359 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4361 __pUserConfirmPopup = std::move(pUserConfirmPopup);
4363 int modalResult = 0;
4365 __pUserConfirmPopup->SetOwner(&GetPublic());
4367 r = __pUserConfirmPopup->ShowAndWait(modalResult);
4368 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4371 __pUserConfirmPopup.reset();
4377 _WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy)
4379 result r = E_SUCCESS;
4381 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4382 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4384 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy, false);
4385 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4387 __pUserConfirmPopup = std::move(pUserConfirmPopup);
4389 __pUserConfirmPopup->SetOwner(&GetPublic());
4391 r = __pUserConfirmPopup->ShowPopup();
4392 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4394 __pUserConfirmPopup.release();
4399 __pUserConfirmPopup.reset();
4406 _WebImpl::GetParentFormCore(_Control* pControlCore)
4409 _Form* pFormCore = null;
4411 _Control* pParentControlCore = dynamic_cast< _Control* >(pControlCore->GetParent());
4412 if (!pParentControlCore)
4417 pFormCore = dynamic_cast< _Form* >(pParentControlCore);
4423 return GetParentFormCore(pParentControlCore);
4428 _WebImpl::OnFocusGained(const _ControlImpl& source)
4435 _WebImpl::OnFocusLost(const _ControlImpl& source)
4437 if(IsKeypadVisible() == true)
4439 SetKeypadOpened(true);
4441 SetKeypadVisibleState(false);
4444 evas_object_focus_set(__pWebCore->GetWebNativeNode(), EINA_FALSE);
4451 _WebImpl::HasValidNativeNode(void) const
4453 if (__pWebCore && __pWebCore->GetWebNativeNode())
4463 _WebImpl::OnPreAttachedToMainTree(void)
4465 result r = E_SUCCESS;
4467 r = __pWebCore->InitializeWebNativeNode();
4468 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4470 r = InitializeSetting();
4471 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4473 r = _ContainerImpl::OnPreAttachedToMainTree();
4474 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4481 _WebImpl::OnChangeLayout(_ControlOrientation orientation)
4483 _ContainerImpl::OnChangeLayout(orientation);
4485 if (__pColorPicker.get())
4487 __pColorPicker->ChangeLayout(orientation);
4493 _WebImpl::OnAncestorVisibleStateChanged(const _Control& control)
4495 if (IsVisible() == true)
4497 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_VISIBLE, false);
4501 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_HIDDEN, false);
4507 _WebImpl::GetDownloadHandler(void) const
4509 return __pWebDownloadHandler.get();
4514 _WebImpl::HideColorPicker(void)
4516 __pColorPicker.reset();
4523 _WebImpl::ShowColorPicker(int red, int green, int blue, int alpha, Color& color)
4525 result r = E_SUCCESS;
4527 std::unique_ptr<_InputPickerPopup> pColorHadler(new (std::nothrow) _InputPickerPopup());
4528 SysTryReturnResult(NID_WEB_CTRL, pColorHadler.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4530 Tizen::Graphics::Color colorVal(static_cast< byte >(red), static_cast< byte >(green), static_cast< byte >(blue), static_cast< byte >(alpha));
4532 r = pColorHadler->Construct(colorVal, this);
4533 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4535 __pColorPicker = std::move(pColorHadler);
4537 r = __pColorPicker->ShowPopup();
4538 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4540 color = __pColorPicker->GetColor();
4545 __pColorPicker.reset();
4552 _WebImpl::ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue, String& dateStr)
4554 result r = E_SUCCESS;
4556 std::unique_ptr<_InputPickerPopup> pInputPicker(new (std::nothrow) _InputPickerPopup());
4557 SysTryReturnResult(NID_WEB_CTRL, pInputPicker.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4559 r = pInputPicker->Construct(String(inputValue), inputType, this);
4560 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4562 __pDatePicker = std::move(pInputPicker);
4564 r = __pDatePicker->ShowPopup();
4565 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4567 dateStr = __pDatePicker->GetDate();
4570 __pDatePicker.reset();
4577 _WebImpl::GetInstance(Web* pWeb)
4579 return dynamic_cast< _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
4584 _WebImpl::GetInstance(const Web* pWeb)
4586 return dynamic_cast< const _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
4591 _WebImpl::SearchHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
4593 int checkReturn = 0;
4595 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4598 if( checkmime == true)
4600 table = CUSTOM_CONTENT_TABLE_NAME;
4604 table = CUSTOM_PROTOCOL_TABLE_NAME;
4607 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
4608 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
4609 String target(ewk_custom_handlers_data_target_get(pHandlerData));
4611 SysLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
4613 result r = db.Construct(handlerPath, "r+", null);
4614 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
4616 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"'"));
4617 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4621 r = pEnum->MoveNext();
4622 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
4623 r = pEnum->GetIntAt(0, checkReturn);
4624 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
4636 _WebImpl::UnregistrationHandler(Ewk_Custom_Handlers_Data* pHandlerData, bool checkmime)
4640 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4643 if( checkmime == true)
4645 table = CUSTOM_CONTENT_TABLE_NAME;
4649 table = CUSTOM_PROTOCOL_TABLE_NAME;
4652 String baseUri(ewk_custom_handlers_data_base_url_get(pHandlerData));
4653 String uri(ewk_custom_handlers_data_url_get(pHandlerData));
4654 String target(ewk_custom_handlers_data_target_get(pHandlerData));
4656 SysLog(NID_WEB_CTRL, "BaseUrl : %s, Url : %s, mime : %s", baseUri.GetPointer(), uri.GetPointer(), target.GetPointer());
4658 result r = db.Construct(handlerPath, "r+", null);
4659 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4661 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"'"));
4662 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4666 r = pEnum->MoveNext();
4667 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4668 r = pEnum->GetIntAt(0, checkId);
4669 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4671 std::unique_ptr<DbStatement> pDeleteStmt(db.CreateStatementN(L"Delete From " + table + L" Where id = (?)"));
4672 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4674 r = pDeleteStmt->BindInt(0, checkId);
4675 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4677 db.BeginTransaction();
4679 std::unique_ptr<DbEnumerator> pEnum(db.ExecuteStatementN(*pDeleteStmt));
4681 db.CommitTransaction();
4688 const Tizen::Base::String
4689 _WebImpl::GetProtocolFromUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri)
4691 if (originUri == L"" || currentUri == L"")
4696 result r = E_SUCCESS;
4699 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4700 String originReplace(originUri);
4701 String table(CUSTOM_PROTOCOL_TABLE_NAME);
4705 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
4706 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4708 r = currentUri.SubString(0, found + 1, baseUri);
4709 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4711 r = db.Construct(handlerPath, "r+", null);
4712 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4714 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select mime, url, allow From " + table + L" Where baseUrl = '" + baseUri + "'"));
4715 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, L"", GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
4719 while (pEnum->MoveNext() == E_SUCCESS)
4724 String originScheme;
4726 r = pEnum->GetStringAt(0, protocol);
4727 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4729 r = pEnum->GetStringAt(1, queryUrl);
4730 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4732 r = pEnum->GetIntAt(2, allow);
4733 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4740 String protocolScheme(protocol + L":");
4742 r = originReplace.SubString(0, protocolScheme.GetLength(), originScheme);
4743 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4745 if ((originReplace.GetLength() >= protocolScheme.GetLength()) && originScheme.Equals(protocolScheme, false))
4747 if (queryUrl.IndexOf(L"%s", 0, foundQuery) == E_SUCCESS)
4749 r = originReplace.Replace(originScheme, "");
4750 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4752 queryUrl.Replace("%s", originReplace, 0);
4753 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4765 const Tizen::Base::String
4766 _WebImpl::GetRedirectUri(const Tizen::Base::String& originUri, const Tizen::Base::String& currentUri, const Tizen::Base::String& mime)
4768 if (originUri == L"" || currentUri == L"" || mime == L"")
4773 result r = E_SUCCESS;
4776 String originUrlStr = originUri;
4777 const String replaceStr = L"%s";
4779 String handlerPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
4780 String table(CUSTOM_CONTENT_TABLE_NAME);
4784 r = currentUri.LastIndexOf(L"/", currentUri.GetLength()-1, found);
4785 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4787 r = currentUri.SubString(0, found + 1, baseUri);
4788 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4790 r = db.Construct(handlerPath, "r+", null);
4791 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4793 std::unique_ptr<DbEnumerator> pEnum(db.QueryN(L"Select allow, url From " + table + L" Where baseUrl = '" + baseUri + "' AND mime = '" + mime + L"'"));
4797 r = pEnum->MoveNext();
4798 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4799 r = pEnum->GetIntAt(0, allow);
4800 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4801 r = pEnum->GetStringAt(1, contentUrl);
4802 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4810 if (contentUrl != L"")
4812 r = contentUrl.Replace(replaceStr, originUrlStr, 0);
4813 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, L"", r, "[%s] Propagating.", GetErrorMessage(r));
4824 }}} // Tizen::Web::Controls