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 <FUiControl.h>
51 #include <FUiCtrlKeypad.h>
52 #include <FWebCtrlHitElementResult.h>
53 #include <FWebCtrlITextSearchListener.h>
54 #include <FWebCtrlIWebDownloadListener.h>
55 #include <FWebCtrlIWebUiEventListener.h>
56 #include <FWebCtrlIWebUiEventListenerF.h>
57 #include <FWebCtrlIWebKeypadEventListener.h>
58 #include <FWebCtrlIJavaScriptBridge.h>
59 #include <FWebCtrlPageNavigationList.h>
60 #include <FWebCtrlAuthenticationChallenge.h>
61 #include <FWebCtrlWeb.h>
62 #include <FWebCtrlWebSetting.h>
63 #include <FWebHistoryItem.h>
64 #include <FWebJsonJsonObject.h>
65 #include <FWebJsonJsonParser.h>
66 #include <FWebJsonJsonString.h>
67 #include <FApp_AppControlImpl.h>
68 #include <FApp_AppControlManager.h>
69 #include <FApp_AppInfo.h>
70 #include <FApp_AppManagerImpl.h>
71 #include <FBase_StringConverter.h>
72 #include <FCnt_DownloadManagerImpl.h>
73 #include <FGrp_CoordinateSystem.h>
74 #include <FIo_DatabaseImpl.h>
75 #include <FIo_NormalFile.h>
76 #include <FUi_Control.h>
77 #include <FUi_CoordinateSystemUtils.h>
78 #include <FUi_EcoreEvasMgr.h>
79 #include <FUi_EcoreEvas.h>
80 #include <FUi_ResourceSizeInfo.h>
81 #include <FUi_Window.h>
82 #include <FUiAnim_EflNode.h>
83 #include <FUiAnim_VisualElement.h>
84 #include <FUiCtrl_FooterImpl.h>
85 #include <FUiCtrl_Form.h>
86 #include "FWeb_HistoryItemImpl.h"
87 #include "FWebCtrl_AppControlListener.h"
88 #include "FWebCtrl_AuthConfirmPopup.h"
89 #include "FWebCtrl_AuthenticationChallengeImpl.h"
90 #include "FWebCtrl_EflWebkit.h"
91 #include "FWebCtrl_GeolocationConfirmPopup.h"
92 #include "FWebCtrl_GeolocationPermissionManagerImpl.h"
93 #include "FWebCtrl_HitElementResultImpl.h"
94 #include "FWebCtrl_InputPickerPopup.h"
95 #include "FWebCtrl_PageNavigationListImpl.h"
96 #include "FWebCtrl_PromptPopup.h"
97 #include "FWebCtrl_SelectBox.h"
98 #include "FWebCtrl_Utility.h"
99 #include "FWebCtrl_Web.h"
100 #include "FWebCtrl_WebDataHandler.h"
101 #include "FWebCtrl_WebEvent.h"
102 #include "FWebCtrl_WebEventArg.h"
103 #include "FWebCtrl_WebImpl.h"
104 #include "FWebCtrl_WebPresenter.h"
105 #include "FWebCtrl_WebSettingImpl.h"
108 using namespace Tizen::App;
109 using namespace Tizen::Base;
110 using namespace Tizen::Base::Collection;
111 using namespace Tizen::Base::Runtime;
112 using namespace Tizen::Base::Utility;
113 using namespace Tizen::Content;
114 using namespace Tizen::Graphics;
115 using namespace Tizen::Io;
116 using namespace Tizen::Media;
117 using namespace Tizen::Net::Http;
118 using namespace Tizen::Ui;
119 using namespace Tizen::Ui::Animations;
120 using namespace Tizen::Ui::Controls;
121 using namespace Tizen::Web::Json;
124 namespace Tizen { namespace Web { namespace Controls
128 static const char WEB_CTRL[] = "webcontrol";
129 static const char PARENT_WEB_CTRL[] = "parentwebcontrol";
132 static const float MIN_ZOOM_LEVEL = 0.3;
133 static const float MAX_ZOOM_LEVEL = 2;
136 static const int REDIRECTION_HEADER_GROUP = 300;
139 static const int MAX_TEXT_MATCH = pow(2, 31) - 1;
142 static const int PORTRAIT_KEYPAD_HEIGHT = 444;
143 static const int LANDSCAPE_KEYPAD_HEIGHT = 316;
147 AddHttpHeaderData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData)
149 result r = E_SUCCESS;
151 String key(reinterpret_cast< const char* >(pKey));
152 String value(reinterpret_cast< char* >(pValue));
154 SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", key.GetPointer(), value.GetPointer());
156 r = reinterpret_cast< HttpHeader* >(pUserData)->AddField(key, value);
157 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
164 AddHttpAttributeData(const Eina_Hash* pHash, const void* pKey, void* pValue, void* pUserData)
166 result r = E_SUCCESS;
168 std::unique_ptr<String> pAttrKey(new (std::nothrow) String(reinterpret_cast< char* >(const_cast< void* >(pKey))));
169 std::unique_ptr<String> pAttrValue(new (std::nothrow) String(reinterpret_cast< char* >(pValue)));
170 SysTryReturn(NID_WEB_CTRL, pAttrKey.get() && pAttrValue.get(), EINA_FALSE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
172 SysLog(NID_WEB_CTRL, "The current value of key is %ls, value is %ls", pAttrKey->GetPointer(), pAttrValue->GetPointer());
174 r = reinterpret_cast< HashMap* >(pUserData)->Add(*pAttrKey, *pAttrValue);
175 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
177 pAttrValue.release();
184 FreeCharArray(void* pData)
186 delete[] reinterpret_cast<char*>(pData);
191 ConvertErrorCode(int error)
193 LoadingErrorType errorCode = WEB_ERROR_UNKNOWN;
197 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
199 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE:
201 case EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE_PROXY:
203 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT:
205 case EWK_ERROR_NETWORK_STATUS_CANT_CONNECT_PROXY:
207 case EWK_ERROR_NETWORK_STATUS_IO_ERROR:
209 case EWK_ERROR_NETWORK_STATUS_MALFORMED:
211 case EWK_ERROR_NETWORK_STATUS_TRY_AGAIN:
213 case EWK_ERROR_NETWORK_STATUS_TOO_MANY_REDIRECTS:
215 case EWK_ERROR_NETWORK_STATUS_TLS_FAILED:
217 case EWK_ERROR_NETWORK_STATUS_INTERNAL_SERVER_ERROR:
219 case EWK_ERROR_NETWORK_STATUS_BAD_GATEWAY:
221 case EWK_ERROR_NETWORK_STATUS_SERVICE_UNAVAILABLE:
223 case EWK_ERROR_NETWORK_STATUS_GATEWAY_TIMEOUT:
224 errorCode = WEB_NO_CONNECTION;
227 case EWK_ERROR_NETWORK_STATUS_BAD_REQUEST:
229 case EWK_ERROR_NETWORK_STATUS_REQUEST_URI_TOO_LONG:
230 errorCode = WEB_BAD_URL;
233 case EWK_ERROR_NETWORK_STATUS_FORBIDDEN:
234 errorCode = WEB_FILE_ACCESS_FAILED;
237 case EWK_ERROR_NETWORK_STATUS_REQUEST_TIMEOUT:
238 errorCode = WEB_REQUEST_TIMEOUT;
241 case EWK_ERROR_NETWORK_STATUS_UNSUPPORTED_MEDIA_TYPE:
242 errorCode = WEB_MIME_NOT_SUPPORTED;
245 case EWK_ERROR_NETWORK_STATUS_INSUFFICIENT_STORAGE:
246 errorCode = WEB_OUT_OF_MEMORY;
249 case EWK_ERROR_NETWORK_STATUS_REQUEST_ENTITY_TOO_LARGE:
250 errorCode = WEB_REQUEST_MAX_EXCEEDED;
253 case EWK_ERROR_NETWORK_STATUS_CONTINUE:
255 case EWK_ERROR_NETWORK_STATUS_SWITCHING_PROTOCOLS:
257 case EWK_ERROR_NETWORK_STATUS_PROCESSING:
259 case EWK_ERROR_NETWORK_STATUS_OK:
261 case EWK_ERROR_NETWORK_STATUS_CREATED:
263 case EWK_ERROR_NETWORK_STATUS_ACCEPTED:
265 case EWK_ERROR_NETWORK_STATUS_NON_AUTHORITATIVE:
267 case EWK_ERROR_NETWORK_STATUS_NO_CONTENT:
269 case EWK_ERROR_NETWORK_STATUS_RESET_CONTENT:
271 case EWK_ERROR_NETWORK_STATUS_PARTIAL_CONTENT:
273 case EWK_ERROR_NETWORK_STATUS_MULTI_STATUS:
275 case EWK_ERROR_NETWORK_STATUS_MULTIPLE_CHOICES:
277 case EWK_ERROR_NETWORK_STATUS_MOVED_PERMANENTLY:
279 case EWK_ERROR_NETWORK_STATUS_FOUND:
281 case EWK_ERROR_NETWORK_STATUS_SEE_OTHER:
283 case EWK_ERROR_NETWORK_STATUS_NOT_MODIFIED:
285 case EWK_ERROR_NETWORK_STATUS_USE_PROXY:
287 case EWK_ERROR_NETWORK_STATUS_NOT_APPEARING_IN_THIS_PROTOCOL:
289 case EWK_ERROR_NETWORK_STATUS_TEMPORARY_REDIRECT:
290 errorCode = WEB_HTTP_RESPONSE;
293 case EWK_ERROR_NETWORK_STATUS_SSL_FAILED:
294 errorCode = WEB_INVALID_CERTIFICATE;
298 errorCode = WEB_ERROR_UNKNOWN;
307 FireLoadingErrorOccurredEvent(_WebImpl* pImpl, int code, const char* pDescription)
309 result r = E_SUCCESS;
311 std::unique_ptr<Integer> pErrorCode(new (std::nothrow) Integer(code));
312 std::unique_ptr<String> pErrorDescription(new (std::nothrow) String(pDescription));
313 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED));
314 SysTryReturnResult(NID_WEB_CTRL, pErrorCode.get() && pErrorDescription.get() && pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
316 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_TYPE, *pErrorCode.get());
317 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
318 pErrorCode.release();
320 r = pEventArg->SetEventInfo(_LoadingEventArg::ERROR_MESSAGE, *pErrorDescription.get());
321 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
322 pErrorDescription.release();
324 r = pImpl->GetWebEvent()->FireAsync(*pEventArg);
325 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
333 OnScriptAlertRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
335 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
337 result r = E_SUCCESS;
339 String msg(pMessage);
341 MessageBox messageBox;
342 r = messageBox.Construct(L"", msg, MSGBOX_STYLE_OK);
343 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
346 r = messageBox.ShowAndWait(modalResult);
347 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
349 ewk_view_javascript_alert_reply(pView);
356 OnScriptConfirmRequested(Evas_Object* pView, const char* pMessage, void* pUserData)
358 SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
360 result r = E_SUCCESS;
362 String msg(pMessage);
364 MessageBox messageBox;
365 r = messageBox.Construct(L"", msg, MSGBOX_STYLE_OKCANCEL);
366 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
369 r = messageBox.ShowAndWait(modalResult);
370 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
372 if (modalResult == MSGBOX_RESULT_OK)
374 ewk_view_javascript_confirm_reply(pView, EINA_TRUE);
378 ewk_view_javascript_confirm_reply(pView, EINA_FALSE);
386 OnScriptPromptRequested(Evas_Object* pView, const char* pMessage, const char* pDefaultValue, void* pUserData)
388 SysLog(NID_WEB_CTRL, "The current value of message is %s, defaulValue is %s", pMessage, pDefaultValue);
390 result r = E_SUCCESS;
392 String msg(pMessage);
393 String defVal(pDefaultValue);
395 int modalResult = -1;
396 Eina_Bool returnValue = EINA_TRUE;
397 _PromptPopup pPromptPopup;
399 r = pPromptPopup.Construct(msg, defVal);
400 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, returnValue = EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
402 r = pPromptPopup.ShowAndWait(modalResult);
403 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, returnValue = EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
405 if (modalResult == ID_BUTTON_PROMPT_OK)
407 std::unique_ptr<char[]> pResult(_StringConverter::CopyToCharArrayN(pPromptPopup.GetPromptText()));
408 SysTryCatch(NID_WEB_CTRL, pResult.get(), returnValue = EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
410 ewk_view_javascript_prompt_reply(pView, pResult.get());
415 ewk_view_javascript_prompt_reply(pView, null);
421 OnCertificateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
423 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
424 Ewk_Certificate_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Certificate_Policy_Decision* >(pEventInfo);
425 SysAssertf(pImpl && pPolicy, "Failed to request");
427 switch (pImpl->GetSetting().GetCertificateErrorHandlingMode())
429 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM:
431 if (pImpl->IsCertificateRequested())
433 ewk_certificate_policy_decision_allowed_set(pPolicy, static_cast< Eina_Bool >(pImpl->IsCertificateConfirmed()));
437 result r = E_SUCCESS;
439 r = pImpl->ShowCertificateConfirmPopup(CERTIFICATE_POPUP_MODE_USER_CONFIRM, pPolicy);
440 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
442 pImpl->SetCertificateRequested(true);
445 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CANCEL:
447 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_FALSE);
449 case WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE :
450 ewk_certificate_policy_decision_allowed_set(pPolicy, EINA_TRUE);
459 OnHttpAuthenticationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
461 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
462 Ewk_Auth_Challenge* pChallenge = reinterpret_cast< Ewk_Auth_Challenge* >(pEventInfo);
463 SysAssertf(pImpl && pChallenge, "Failed to request");
465 result r = E_SUCCESS;
467 r = pImpl->HttpAuthenticationRequested(pChallenge);
468 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
472 ewk_auth_challenge_credential_cancel(pChallenge);
473 evas_object_smart_callback_call(pView, "authentication,canceled", NULL);
478 OnHttpAuthenticationCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
480 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
481 SysAssertf(pImpl , "Failed to request");
483 if (pImpl->GetLoadingListener())
485 result r = E_SUCCESS;
487 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED));
488 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
490 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
491 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
498 OnGeolocationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
500 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
501 Ewk_Geolocation_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Geolocation_Permission_Request* >(pEventInfo);
502 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
504 if (pImpl->GetSetting().IsGeolocationEnabled())
506 result r = E_SUCCESS;
508 std::unique_ptr<DbEnumerator> pEnum;
510 String geolocationPath(Tizen::App::App::GetInstance()->GetAppRootPath() + CUSTOM_DB_DIRECTORY_PATH + USER_CONFIRM_DB_NAME);
511 String table(GEOLOCATION_TABLE_NAME);
514 const Ewk_Security_Origin* pSecurityOrigin = ewk_geolocation_permission_request_origin_get(pPermissionRequest);
515 String origin = _Utility::CreateOrigin(pSecurityOrigin);
517 r = db.Construct(geolocationPath, "r", null);
518 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
520 pEnum = std::unique_ptr<DbEnumerator>(db.QueryN(L"Select permission From " + table + L" Where origin = '" + origin + L"'"));
523 r = pEnum->MoveNext();
524 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
527 r = pEnum->GetIntAt(0, permission);
528 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
530 SysLog(NID_WEB_CTRL, "The current value of permission is %d", permission);
532 ewk_geolocation_permission_request_set(pPermissionRequest, static_cast < Eina_Bool >(permission));
536 ewk_geolocation_permission_request_suspend(pPermissionRequest);
538 r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_GEOLOCATION, pPermissionRequest);
539 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
546 ewk_geolocation_permission_request_set(pPermissionRequest, EINA_FALSE);
551 OnGetUserMediaPermissionRequsted(void* pUserData, Evas_Object* pView, void* pEventInfo)
553 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
554 Ewk_User_Media_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_User_Media_Permission_Request* >(pEventInfo);
555 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
557 result r = pImpl->ShowUserConfirmPopupAsync(USER_CONFIRM_USERMEDIA, pEventInfo);
558 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
562 ewk_user_media_permission_request_set(pPermissionRequest, EINA_FALSE);
567 OnNotificationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
569 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
570 Ewk_Notification_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Notification_Permission_Request* >(pEventInfo);
571 SysAssertf(pImpl && pPermissionRequest, "Failed to request");
573 SysLog(NID_WEB_CTRL, "The permission popup has not Implemented yet. allow is the default value now.");
575 //ToDo : Show NotificationPermissionPopup
577 Ewk_Context* pContext = ewk_view_context_get(pView);
578 SysAssertf(pContext, "Failed to get webkit instance.");
580 //ewk_notification_permission_request_origin_get(pPermissionRequest);
582 ewk_notification_permission_request_set(pPermissionRequest, EINA_TRUE);
587 OnNotificationShow(void* pUserData, Evas_Object* pView, void* pEventInfo)
589 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
590 Ewk_Notification* pNotification = reinterpret_cast< Ewk_Notification* >(pEventInfo);
591 SysAssertf(pImpl && pNotification, "Failed to request");
593 Ewk_Context* pContext = ewk_view_context_get(pView);
594 SysAssertf(pContext, "Failed to get webkit instance.");
596 //ToDo : Show Notification
597 //Perform ewk_notification_clicked
598 //ewk_notification_security_origin_get(pNotification)
599 SysLog(NID_WEB_CTRL, "The current value of title is %s", ewk_notification_title_get(pNotification));
600 SysLog(NID_WEB_CTRL, "The current value of body is %s", ewk_notification_body_get(pNotification));
601 SysLog(NID_WEB_CTRL, "The current value of icon path is %s",ewk_notification_icon_url_get(pNotification));
603 uint64_t notificationId = ewk_notification_id_get(pNotification);
604 ewk_notification_showed(pContext, notificationId);
609 OnNotificationCancel(void* pUserData, Evas_Object* pView, void* pEventInfo)
611 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
612 uint64_t* pNotificationID = reinterpret_cast< uint64_t* >(pEventInfo);
613 SysAssertf(pImpl && pNotificationID, "Failed to request");
615 //ToDo : Where is ewk API for cancel operation?
620 OnProtocolHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
622 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
623 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
624 SysAssertf(pImpl && pHandlerData, "Failed to request");
626 ewk_custom_handlers_data_target_get(pHandlerData);
627 ewk_custom_handlers_data_base_url_get(pHandlerData);
628 ewk_custom_handlers_data_url_get(pHandlerData);
629 ewk_custom_handlers_data_title_get(pHandlerData);
634 OnIsProtocolHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
636 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
637 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
638 SysAssertf(pImpl && pHandlerData, "Failed to request");
640 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
645 OnProtocolHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
647 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
648 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
649 SysAssertf(pImpl && pHandlerData, "Failed to request");
654 OnContentHandlerRegistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
656 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
657 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
658 SysAssertf(pImpl && pHandlerData, "Failed to request");
663 OnIsContentHandlerRegistered(void* pUserData, Evas_Object* pView, void* pEventInfo)
665 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
666 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
667 SysAssertf(pImpl && pHandlerData, "Failed to request");
669 ewk_custom_handlers_data_result_set(pHandlerData, EWK_CUSTOM_HANDLERS_REGISTERED);
674 OnContentHandlerUnregistrationRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
676 _WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
677 Ewk_Custom_Handlers_Data* pHandlerData = reinterpret_cast< Ewk_Custom_Handlers_Data* >(pEventInfo);
678 SysAssertf(pImpl && pHandlerData, "Failed to request");
683 OnLoadingRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
685 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
686 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
687 SysAssertf(pImpl && pPolicy, "Failed to request");
689 String url(ewk_policy_decision_url_get(pPolicy));
690 SysLog(NID_WEB_CTRL, "The current value of url is %ls", url.GetPointer());
692 if (url == L"about:blank")
694 ewk_policy_decision_use(pPolicy);
698 if (pImpl->GetLoadingListener() && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy))
699 && !pImpl->IsRedirectRequested())
701 pImpl->SetCertificateRequested(false);
703 if (pImpl->GetTextSearchListener())
705 pImpl->DisableAsyncSearch();
708 WebNavigationType navigationType = WEB_NAVIGATION_OTHER;
709 Ewk_Policy_Navigation_Type ewkNavigationType = ewk_policy_decision_navigation_type_get(pPolicy);
711 switch (ewkNavigationType)
713 case EWK_POLICY_NAVIGATION_TYPE_LINK_CLICKED:
714 navigationType = WEB_NAVIGATION_LINK_CLICKED;
716 case EWK_POLICY_NAVIGATION_TYPE_FORM_SUBMITTED:
717 navigationType = WEB_NAVIGATION_FORM_SUBMITTED;
719 case EWK_POLICY_NAVIGATION_TYPE_BACK_FORWARD:
720 navigationType = WEB_NAVIGATION_BACKFORWARD;
722 case EWK_POLICY_NAVIGATION_TYPE_RELOAD:
723 navigationType = WEB_NAVIGATION_RELOAD;
725 case EWK_POLICY_NAVIGATION_TYPE_FORM_RESUBMITTED:
726 navigationType = WEB_NAVIGATION_FORM_RESUBMITTED;
728 case EWK_POLICY_NAVIGATION_TYPE_OTHER:
729 navigationType = WEB_NAVIGATION_OTHER;
735 if (pImpl->GetLoadingListener()->OnLoadingRequested(url, navigationType))
737 ewk_policy_decision_ignore(pPolicy);
746 String uriScheme(uri.GetScheme());
747 SysLog(NID_WEB_CTRL, "The current value of scheme is %ls", uriScheme.GetPointer());
749 if ((uriScheme != L"http") && (uriScheme != L"https") && (uriScheme != L"file"))
751 ewk_policy_decision_ignore(pPolicy);
753 if (uriScheme == L"")
758 result r = E_SUCCESS;
760 _WebEventType eventType = WEB_EVENT_REQUEST_UNKNOWN;
762 if (uriScheme == L"rtsp")
764 eventType = WEB_EVENT_REQUEST_RTSP;
766 else if (uriScheme == L"mailto")
768 eventType = WEB_EVENT_REQUEST_EMAIL;
770 else if (uriScheme == L"tel")
772 eventType = WEB_EVENT_REQUEST_TEL;
774 else if (uriScheme == L"sms" || uriScheme == L"smsto" )
776 eventType = WEB_EVENT_REQUEST_SMS;
778 else if (uriScheme == L"mms" || uriScheme == L"mmsto" )
780 eventType = WEB_EVENT_REQUEST_MMS;
783 std::unique_ptr<_WebEventArg> pEventArg(new _WebEventArg(eventType, url));
784 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
786 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
787 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
793 ewk_policy_decision_use(pPolicy);
798 OnLoadingStarted(void* pUserData, Evas_Object* pView, void* pEventInfo)
800 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
801 SysAssertf(pImpl, "Failed to request");
803 if (pImpl->GetLoadingListener())
805 result r = E_SUCCESS;
807 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_STARTED));
808 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
810 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
811 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
818 OnPageTitleReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
820 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
821 char* pTitle = reinterpret_cast< char* >(pEventInfo);
822 SysAssertf(pImpl, "Failed to request");
824 SysLog(NID_WEB_CTRL, "The current value of title is %s", pTitle);
826 if (pImpl->GetLoadingListener())
828 result r = E_SUCCESS;
830 std::unique_ptr<String> pPageTitle(new (std::nothrow) String(pTitle));
831 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED));
832 SysTryReturnVoidResult(NID_WEB_CTRL, pPageTitle.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
834 r = pEventArg->SetEventInfo(_LoadingEventArg::PAGE_TITLE, *pPageTitle.get());
835 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
836 pPageTitle.release();
838 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
839 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
846 OnEstimatedProgress(void* pUserData, Evas_Object* pView, void* pEventInfo)
848 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
849 double* pProgress = reinterpret_cast< double* >(pEventInfo);
850 SysAssertf(pImpl, "Failed to request");
852 SysLog(NID_WEB_CTRL, "The current value of progress is %lf", *pProgress);
854 if (pImpl->GetLoadingListener())
856 result r = E_SUCCESS;
858 std::unique_ptr<Integer> pProgressPercentage(new (std::nothrow) Integer(static_cast< int >(*pProgress * 100)));
859 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_PROGRESS));
860 SysTryReturnVoidResult(NID_WEB_CTRL, pProgressPercentage.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
862 r = pEventArg->SetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS, *pProgressPercentage.get());
863 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
864 pProgressPercentage.release();
866 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
867 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
874 OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
876 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
877 Ewk_Policy_Decision* pPolicy = reinterpret_cast< Ewk_Policy_Decision* >(pEventInfo);
878 SysAssertf(pImpl && pPolicy, "Failed to request");
880 result r = E_SUCCESS;
882 const char* pUrl = ewk_policy_decision_url_get(pPolicy);
883 int code = ewk_policy_decision_response_status_code_get(pPolicy);
884 String mime(ewk_policy_decision_response_mime_get(pPolicy));
885 SysLog(NID_WEB_CTRL, "url : %s, mime : %ls, code : %d", pUrl, mime.GetPointer(), code);
887 ILoadingListener* pLoadingListener = pImpl->GetLoadingListener();
888 if (pLoadingListener && ewk_frame_is_main_frame(ewk_policy_decision_frame_get(pPolicy)))
890 const Eina_Hash* pHeader = ewk_policy_decision_response_headers_get(pPolicy);
892 DecisionPolicy policy;
893 HttpHeader httpHeader;
895 if (code >= REDIRECTION_HEADER_GROUP && code < REDIRECTION_HEADER_GROUP + 100)
897 pImpl->SetRedirectRequested(true);
901 eina_hash_foreach(pHeader, AddHttpHeaderData, &httpHeader);
902 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
904 policy = pLoadingListener->OnWebDataReceived(mime, httpHeader);
905 pImpl->SetPolicyDecision(policy);
908 switch (pImpl->GetPolicyDecision())
910 case WEB_DECISION_CONTINUE:
912 if (pImpl->IsMimeSupported(mime) || mime == L"")
919 SysLog(NID_WEB_CTRL, "Lauch native app to handle the mime");
921 ewk_policy_decision_ignore(pPolicy);
923 AppControl* pAppControl = null;
924 _SelectBox selectBox;
926 int selectedIndex = 0;
928 std::unique_ptr<IList, AllElementsDeleter> pList(_AppManagerImpl::FindAppControlsN(NULL, NULL, &mime, NULL));
932 appCount = pList->GetCount();
935 r = selectBox.Construct(false, L"", appCount+1); //+1 for Downloader
936 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
938 selectBox.AddListItem(L"Download", _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
939 for (int i = 0; i < appCount; i++)
941 pAppControl = dynamic_cast< AppControl* >(pList->GetAt(i));
942 SysTryReturnVoidResult(NID_WEB_CTRL, pAppControl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
944 String text = pAppControl->GetAppName();
945 SysLog(NID_WEB_CTRL, "AppName : %S", text.GetPointer());
947 selectBox.AddListItem(text, _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
949 r = selectBox.ShowAndWait(selectedIndex);
950 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
952 if (selectedIndex == 0) //download
955 DownloadRequest request(pUrl);
957 _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
958 SysTryReturnVoidResult(NID_WEB_CTRL, pManagerImpl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
960 r = pManagerImpl->Start(request, reqId);
961 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
963 else if (selectedIndex != -1) // -1 for cancel
966 String pathVal(pUrl);
969 r = dataList.Construct();
970 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
972 r = dataList.Add(path, pathVal);
973 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
975 pAppControl = dynamic_cast< AppControl* >(pList->GetAt(selectedIndex));
976 SysTryReturnVoidResult(NID_WEB_CTRL, pAppControl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
978 _AppControlImpl* pAcImpl = _AppControlImpl::GetInstance(*pAppControl);
979 SysTryReturnVoidResult(NID_WEB_CTRL, pAcImpl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
981 r = pAcImpl->Start(null, null, &dataList, null);
982 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
989 case WEB_DECISION_DOWNLOAD:
991 ewk_policy_decision_ignore(pPolicy);
993 _WebDataHandler* pDownloadHandler = pImpl->GetDownloadHandler();
994 SysTryReturnVoidResult(NID_WEB_CTRL, pDownloadHandler, E_SYSTEM, "[%s] A system error has been occurred. Failed to get DownloadHandler.", GetErrorMessage(E_SYSTEM));
996 Ewk_Context* pContext = ewk_view_context_get(pView);
997 SysAssertf(pContext, "Failed to get webkit instance.");
999 pDownloadHandler->StartDownload(pUrl);
1003 case WEB_DECISION_IGNORE:
1005 ewk_policy_decision_ignore(pPolicy);
1015 ewk_policy_decision_use(pPolicy);
1020 ewk_policy_decision_ignore(pPolicy);
1025 OnProgressCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1027 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1028 SysAssertf(pImpl, "Failed to request");
1030 if (pImpl->IsRedirectRequested())
1032 pImpl->SetRedirectRequested(false);
1035 if (pImpl->IsLoadingErrorOccurred())
1037 pImpl->SetLoadingErrorOccurred(false);
1038 evas_object_smart_callback_call(pView, "load,finished", NULL);
1044 OnLoadingErrorOccurred(void* pUserData, Evas_Object* pView, void* pEventInfo)
1046 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1047 Ewk_Error* pErrorData = reinterpret_cast< Ewk_Error* >(pEventInfo);
1048 SysAssertf(pImpl && pErrorData, "Failed to request");
1050 int code = ewk_error_code_get(pErrorData);
1051 const char* pDescription = ewk_error_description_get(pErrorData);
1053 SysLog(NID_WEB_CTRL, "The current value of code is %d, description is %s", code, pDescription);
1055 pImpl->SetLoadingErrorOccurred(true);
1058 case EWK_ERROR_CODE_FRAMELOADINTERRUPTEDBYPOLICYCHANGE:
1060 case EWK_ERROR_CODE_PLUGINWILLHANDLELOAD:
1063 case EWK_ERROR_NETWORK_STATUS_CANCELLED:
1064 evas_object_smart_callback_call(pView, "load,stop", NULL);
1068 if (pImpl->GetLoadingListener())
1070 result r = E_SUCCESS;
1072 r = FireLoadingErrorOccurredEvent(pImpl, code, pDescription);
1073 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1081 OnLoadingCanceled(void* pUserData, Evas_Object* pView, void* pEventInfo)
1083 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1084 SysAssertf(pImpl, "Failed to request");
1086 if (pImpl->GetLoadingListener())
1088 result r = E_SUCCESS;
1090 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_CANCELED));
1091 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1093 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1094 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1095 pEventArg.release();
1102 OnLoadingCompleted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1104 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1105 SysAssertf(pImpl, "Failed to request");
1107 if (pImpl->GetLoadingListener())
1109 result r = E_SUCCESS;
1111 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_COMPLETED));
1112 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1114 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1115 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1116 pEventArg.release();
1123 OnLoadingCommitted(void* pUserData, Evas_Object* pView, void* pEventInfo)
1125 evas_object_focus_set(pView, EINA_FALSE);
1130 OnFaviconReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
1132 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1133 SysAssertf(pImpl, "Failed to request");
1135 if (pImpl->GetLoadingListener())
1137 result r = E_SUCCESS;
1139 std::unique_ptr<_LoadingEventArg> pEventArg(new (std::nothrow) _LoadingEventArg(WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED));
1140 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1142 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1143 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1144 pEventArg.release();
1151 OnDidStartDownloadCallback(const char* pUrl, void* pUserData)
1153 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1154 SysAssertf(pUrl && pImpl != null, "Failed to request");
1156 SysLog(NID_WEB_CTRL, "The current value of url is %s", pUrl);
1161 FireWebPageShowRequestedEvent(_WebImpl* pImpl, int event)
1163 result r = E_SUCCESS;
1165 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1166 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1168 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1169 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1170 pEventArg.release();
1177 OnWebPageShowRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1179 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1180 SysAssertf(pImpl, "Failed to request");
1182 if (pImpl->GetUiEventListener())
1184 result r = E_SUCCESS;
1186 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED);
1187 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1189 if (pImpl->GetUiEventListenerF())
1191 result r = E_SUCCESS;
1193 r = FireWebPageShowRequestedEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT);
1194 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1200 OnWebWindowCreateRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1202 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(pUserData);
1203 Evas_Object** pChildView = reinterpret_cast< Evas_Object** >(pEventInfo);
1204 SysAssertf(pParentImpl && pChildView, "Failed to request");
1206 IWebUiEventListener* pUserUiListener = pParentImpl->GetUiEventListener();
1207 IWebUiEventListenerF* pUserUiListenerF = pParentImpl->GetUiEventListenerF();
1208 if (pUserUiListener)
1210 Web* pWeb = pUserUiListener->OnWebWindowCreateRequested();
1213 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1214 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1216 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1217 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1220 if (pUserUiListenerF)
1222 Web* pWeb = pUserUiListenerF->OnWebWindowCreateRequested();
1225 _WebImpl* pChildImpl = _WebImpl::GetInstance(pWeb);
1226 SysTryReturnVoidResult(NID_WEB_CTRL, pChildImpl, E_SYSTEM, "[%s] A system error has been occurred. Failed to get ChildImpl object.", GetErrorMessage(E_SYSTEM));
1228 *pChildView = dynamic_cast< _Web* >(&pChildImpl->GetCore())->GetWebNativeNode();
1229 evas_object_data_set(*pChildView, PARENT_WEB_CTRL, pParentImpl);
1236 FireWebWindowClosedRequestedEvent(_WebImpl* pImpl, int event)
1238 result r = E_SUCCESS;
1240 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1241 SysTryReturnResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1243 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1244 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1245 pEventArg.release();
1252 OnWebWindowClosedRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
1254 _WebImpl* pChildImpl = reinterpret_cast< _WebImpl* >(pUserData);
1255 SysAssertf(pChildImpl, "Failed to request");
1257 _WebImpl* pParentImpl = reinterpret_cast< _WebImpl* >(evas_object_data_get(pView, PARENT_WEB_CTRL));
1258 if (pParentImpl == null)
1263 if (pParentImpl->GetUiEventListener())
1265 result r = E_SUCCESS;
1267 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED);
1268 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1270 if (pParentImpl->GetUiEventListenerF())
1272 result r = E_SUCCESS;
1274 r = FireWebWindowClosedRequestedEvent(pChildImpl, WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT);
1275 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1281 FireWebPreventDefaultTriggeredEvent(_WebImpl* pImpl, int event, bool trigger)
1283 result r = E_SUCCESS;
1285 std::unique_ptr<Boolean> pPreventTrigger(new (std::nothrow) Boolean(trigger));
1286 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(event));
1287 SysTryReturnResult(NID_WEB_CTRL, pPreventTrigger.get() && pEventArg.get(), E_OUT_OF_MEMORY, " Memory allocation failed." );
1289 r = pEventArg->SetEventInfo(_WebUiEventArg::PREVENT_DEFAULT, *pPreventTrigger.get());
1290 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1291 pPreventTrigger.release();
1293 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1294 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1295 pEventArg.release();
1302 OnWebPreventDefaultTriggered(void* pUserData, Evas_Object* pView, void* pEventInfo)
1304 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1305 Eina_Bool* pTrigger = reinterpret_cast< Eina_Bool* >(pEventInfo);
1306 SysAssertf(pImpl && pTrigger, "Failed to request");
1308 if (pImpl->GetUiEventListener())
1310 result r = E_SUCCESS;
1312 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED, static_cast< bool >(*pTrigger));
1313 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1315 if (pImpl->GetUiEventListenerF())
1317 result r = E_SUCCESS;
1319 r = FireWebPreventDefaultTriggeredEvent(pImpl, WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT, static_cast< bool >(*pTrigger));
1320 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1326 OnSelectUploadFile(Evas_Object* pView, Eina_Bool multipleFile, Eina_List* pAcceptTypes, const char* pCapture, void* pUserData)
1328 Eina_Bool ret = EINA_FALSE;
1329 Eina_List* pSelectedFileNames = null;
1330 String isMultipleSelection(L"single");
1334 isMultipleSelection.Append(L"multiple");
1337 std::unique_ptr<_MediaSelectionListener> pMediaListener(new (std::nothrow) _MediaSelectionListener());
1338 SysTryCatch(NID_WEB_CTRL, pMediaListener.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1341 int itemCount = eina_list_count(pAcceptTypes);
1342 String fileType = L"all";
1346 String item((char*)eina_list_nth(pAcceptTypes, 0));
1347 if (item.StartsWith("image/",0))
1349 fileType = L"image";
1351 else if (item.StartsWith("audio/",0))
1353 fileType = L"audio";
1355 else if (item.StartsWith("video/",0))
1357 fileType = L"video";
1362 result r = dataList.Construct();
1363 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1365 String mode(L"selectionType");
1366 r = dataList.Add(mode, isMultipleSelection);
1367 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1369 String type(L"type");
1370 r = dataList.Add(type, fileType);
1371 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1373 std::unique_ptr<AppControl> pMediaAppControl(_AppManagerImpl::FindAppControlN(L"tizen.filemanager", L"http://tizen.org/appcontrol/operation/pick"));
1374 SysTryCatch(NID_WEB_CTRL, pMediaAppControl.get(), r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
1376 _AppControlImpl* pMediaAppControlImpl = _AppControlImpl::GetInstance(*pMediaAppControl);
1377 r = pMediaAppControlImpl->Start(null, null, &dataList, pMediaListener.get());
1378 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1382 if (pMediaListener->IsSelectionCompleted())
1384 const ArrayList* pSelectedFiles = pMediaListener->GetSelectedFiles();
1385 SysTryCatch(NID_WEB_CTRL, pSelectedFiles, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
1387 int fileCount = pSelectedFiles->GetCount();
1389 for (int i = 0; i < fileCount; i++)
1391 String* pFile = (String*)pSelectedFiles->GetAt(i);
1392 SysTryCatch(NID_WEB_CTRL, pFile, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
1394 std::unique_ptr<ByteBuffer> pByteBuf(StringUtil::StringToUtf8N(*pFile));
1395 SysTryCatch(NID_WEB_CTRL, pByteBuf.get(), r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
1397 pSelectedFileNames = eina_list_append(pSelectedFileNames, strdup((const char*)pByteBuf->GetPointer()));
1404 ecore_main_loop_iterate();
1407 ewk_view_open_panel_reply(pView, pSelectedFileNames, ret);
1412 ewk_view_open_panel_reply(pView, null, ret);
1413 eina_list_free(pSelectedFileNames);
1419 OnHandleJavaScriptRequest(void* pUserData, Evas_Object* pView, void* pEventInfo)
1421 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1422 char* pJsonText = reinterpret_cast< char* >(pEventInfo);
1423 SysAssertf(pImpl && pJsonText, "Failed to request");
1425 result r = E_SUCCESS;
1427 SysLog(NID_WEB_CTRL, "The current value of jsontext is %s", pJsonText);
1429 std::unique_ptr<_JsBridgeArg> pEventArg(new (std::nothrow) _JsBridgeArg());
1430 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1432 r = pEventArg->Construct(pJsonText);
1433 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1435 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1436 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1437 pEventArg.release();
1442 OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo)
1444 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1445 Eina_Rectangle* pEinaRect = reinterpret_cast< Eina_Rectangle* >(pEventInfo);
1446 SysAssertf(pImpl && pEinaRect, "Failed to request");
1448 if (pImpl->GetSetting().GetInputStyle() == INPUT_STYLE_OVERLAY)
1450 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer();
1451 SysAssertf(pXformer, "Failed to get CoordinateTransformer");
1453 Rectangle rect(pEinaRect->x, pEinaRect->y, pEinaRect->w, pEinaRect->h);
1455 if (rect.height == 0)
1460 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1461 SysAssertf(pFormCore != null, "Failed to get FormCore");
1463 if (pFormCore->HasFooter() && pFormCore->IsFooterVisible())
1465 pImpl->SetFooterVisibleState(true);
1466 pFormCore->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, false);
1469 if (pImpl->GetWebKeypadEventListener())
1471 if (pImpl->IsKeypadVisible() == true)
1473 if ((pImpl->GetPreviousKeypadBounds().width == rect.width) && (pImpl->GetPreviousKeypadBounds().height != rect.height))
1475 pImpl->GetWebKeypadEventListener()->OnWebKeypadBoundsChanged(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1480 pFormCore->DeflateClientRectHeight(pXformer->TransformVertical(rect.height));
1481 pImpl->GetWebKeypadEventListener()->OnWebKeypadWillOpen(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1484 pImpl->SetKeypadVisibleState(true);
1485 pImpl->SetPreviousKeypadBounds(rect);
1489 result r = pImpl->SetFullScreenKeypad();
1490 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1496 OnWebKeypadOpened(void* pUserData, Evas_Object* pView, void* pEventInfo)
1498 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1499 SysAssertf(pImpl, "Failed to request");
1501 if (pImpl->GetWebKeypadEventListener())
1503 pImpl->GetWebKeypadEventListener()->OnWebKeypadOpened(*static_cast< Web* >(&pImpl->GetPublic()));
1509 OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo)
1511 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1512 SysAssertf(pImpl, "Failed to request");
1514 _Form* pFormCore = pImpl->GetParentFormCore(dynamic_cast< _Control* >(&pImpl->GetCore()));
1515 SysAssertf(pFormCore != null, "Failed to get FormCore");
1517 if (pFormCore->HasFooter() && pImpl->IsFooterVisible())
1519 pImpl->SetFooterVisibleState(false);
1520 pFormCore->SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true);
1523 pFormCore->DeflateClientRectHeight(0);
1525 if (pImpl->GetWebKeypadEventListener())
1527 pImpl->GetWebKeypadEventListener()->OnWebKeypadClosed(*dynamic_cast< Web* >(&pImpl->GetPublic()));
1530 pImpl->SetKeypadVisibleState(false);
1535 OnWindowObjectFocusGained(void *pUserData, Evas_Object *pWin, void *pEvent_info)
1537 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1538 SysAssertf(pImpl, "Failed to request");
1540 if (pImpl->IsKeypadOpened() == true)
1542 _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore()));
1543 SysAssertf(pWebCore, "Failed to get Web core object");
1545 evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE);
1547 pImpl->SetKeypadOpened(false);
1553 OnWebNativeNodeFocusGained(void *pUserData, Evas *pCanvas, Evas_Object* pView, void* pEventInfo)
1555 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1556 SysAssertf(pImpl, "Failed to request");
1558 if (pImpl->IsKeypadOpened() == true)
1560 pImpl->SetKeypadOpened(false);
1566 OnColorPickerProviderRequested(Ewk_View_Smart_Data *pSmartData, int red, int green, int blue, int alpha)
1568 SysAssertf(pSmartData, "invalid smartdata");
1569 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1570 SysAssertf(pWebImpl, "Failed to get Impl");
1572 result r = E_SUCCESS;
1574 if (pWebImpl->GetColorpicker())
1581 r = pWebImpl->ShowColorPicker(red, green, blue, alpha, color);
1582 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1584 byte r1, g1, b1, a1;
1585 color.GetColorComponents(r1, g1, b1, a1);
1586 ewk_view_color_picker_color_set(pSmartData->self, r1, g1, b1, a1);
1593 OnColorPickerProviderDismissed(Ewk_View_Smart_Data *pSmartData)
1595 SysAssertf(pSmartData, "invalid smartdata");
1597 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1598 SysAssertf(pWebImpl, "Failed to get Impl");
1600 return pWebImpl->HideColorPicker();
1605 OnDatePickerProviderRequested(Ewk_View_Smart_Data *pSmartData, Ewk_Input_Type inputType, const char* inputValue)
1607 SysAssertf(pSmartData, "Failed to request");
1608 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1609 SysAssertf(pWebImpl, "Failed to get Impl");
1611 result r = E_SUCCESS;
1613 if (pWebImpl->GetDatepicker())
1615 ewk_view_focused_input_element_value_set(pSmartData->self, inputValue);
1622 r = pWebImpl->ShowDatePicker(inputType, inputValue, dateStr);
1623 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
1625 std::unique_ptr<char[]> pDateStr(_StringConverter::CopyToCharArrayN(dateStr));
1626 SysTryReturn(NID_WEB_CTRL, pDateStr.get(), EINA_FALSE, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1628 ewk_view_focused_input_element_value_set(pSmartData->self, pDateStr.get());
1635 OnSelectBoxRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, double pageScaleFactor, Eina_List* pItems, int selectedIndex)
1637 SysAssertf(pSmartData, "Failed to request");
1639 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1640 SysAssertf(pWebImpl, "Failed to get Impl");
1642 result r = pWebImpl->ShowSelectBoxPopup(false, L"", pItems, pSmartData->self, selectedIndex);
1643 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1650 OnSelectBoxClosed(Ewk_View_Smart_Data *pSmartData)
1652 SysAssertf(pSmartData, "invalid smartdata");
1654 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1655 SysAssertf(pWebImpl, "Failed to get Impl");
1657 result r = pWebImpl->ClearSelectBoxPopup();
1658 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1665 OnSelectBoxUpdateRequested(Ewk_View_Smart_Data *pSmartData, Eina_Rectangle rect, Ewk_Text_Direction textDirection, Eina_List* pItems, int selectedIndex)
1667 SysAssertf(pSmartData, "invalid smartdata");
1669 _WebImpl* pWebImpl = reinterpret_cast<_WebImpl*>(evas_object_data_get(pSmartData->self, WEB_CTRL));
1670 SysAssertf(pWebImpl, "Failed to get Impl");
1672 result r = pWebImpl->UpdateSelectBoxPopup(pItems, selectedIndex, false);
1673 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, EINA_FALSE, r, "[%s] Propagating.", GetErrorMessage(r));
1680 OnCookiesPolicyGot(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *pError, void *pUserData)
1682 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
1683 SysAssertf(pPresenter && !pError, "Failed to request");
1685 bool ret = EINA_TRUE;
1689 case EWK_COOKIE_ACCEPT_POLICY_ALWAYS:
1691 case EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY:
1695 case EWK_COOKIE_ACCEPT_POLICY_NEVER:
1704 SysLog(NID_WEB_CTRL, "The current value of policy is %d", ret);
1706 pPresenter->EndAsyncProcess(ret);
1711 OnScriptExecuted(Evas_Object* pView, const char* pResult, void* pUserData)
1713 _WebPresenter* pPresenter = reinterpret_cast< _WebPresenter* >(pUserData);
1714 SysAssertf(pPresenter, "Failed to request");
1716 String result(pResult);
1717 SysLog(NID_WEB_CTRL, "result : %ls", result.GetPointer());
1719 pPresenter->EndAsyncProcess(result);
1724 OnTextFound(void* pUserData, Evas_Object* pView, void* pEventInfo)
1726 _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
1727 SysAssertf(pImpl, "Failed to request");
1729 int* pTotalCount = reinterpret_cast< int* >(pEventInfo);
1730 SysLog(NID_WEB_CTRL, "The current value of totalCount is %d", *pTotalCount);
1732 _WebPresenter* pWebPresenter = pImpl->GetSearchPresenter();
1736 pWebPresenter->EndAsyncProcess(*pTotalCount);
1740 if (pImpl->GetTextSearchListener())
1742 result r = E_SUCCESS;
1746 if (*pTotalCount > 0)
1748 ordinal = pImpl->GetAsyncSearchOrdinal();
1749 pImpl->SetAsyncSearchResult(*pTotalCount);
1752 if (pImpl->GetPendingAsyncSearchCount() > 0)
1757 std::unique_ptr<Integer> pCount(new (std::nothrow) Integer(*pTotalCount));
1758 std::unique_ptr<Integer> pOrdinal(new (std::nothrow) Integer(ordinal));
1759 std::unique_ptr<_TextSearchEventArg> pEventArg(new (std::nothrow) _TextSearchEventArg(WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND));
1760 SysTryReturnVoidResult(NID_WEB_CTRL, pCount.get() && pOrdinal.get() && pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1762 r = pEventArg->SetEventInfo(_TextSearchEventArg::TOTAL_COUNT, *pCount.get());
1763 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1766 r = pEventArg->SetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL, *pOrdinal.get());
1767 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1770 r = pImpl->GetWebEvent()->FireAsync(*pEventArg.get());
1771 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1772 pEventArg.release();
1778 class _JsBridgeHashCodeProvider
1779 : public Tizen::Base::Collection::IHashCodeProviderT< Tizen::Base::String >
1782 _JsBridgeHashCodeProvider(){}
1783 virtual ~_JsBridgeHashCodeProvider(void) {}
1786 int GetHashCode(const Tizen::Base::String& obj) const
1788 return obj.GetHashCode();
1794 //Comparer implementation
1795 class _JsBridgeComparer
1796 : public Tizen::Base::Collection::IComparerT< Tizen::Base::String >
1799 _JsBridgeComparer(){}
1800 virtual ~_JsBridgeComparer(void) {}
1803 result Compare(const Tizen::Base::String& obj1, const Tizen::Base::String& obj2, int& cmp) const
1820 _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore)
1821 : _ContainerImpl(pWeb, pCore)
1822 , __isFooterVisible(false)
1823 , __isKeypadVisible(false)
1824 , __isKeypadOpened(false)
1825 , __isLoadingErrorOccurred(false)
1826 , __isRedirectRequested(false)
1827 , __isCertificateRequested(false)
1828 , __isCertificateConfirmed(false)
1829 , __keypadBounds(0, 0, 0, 0)
1831 , __pUserLoadingListener(null)
1832 , __pUserUiListener(null)
1833 , __pUserUiListenerF(null)
1834 , __pUserKeypadEventListener(null)
1835 , __pTextSearchListener(null)
1837 , __pWebSetting(null)
1838 , __pJsBridgeList(null)
1839 , __pJsProvider(null)
1840 , __pJsComparer(null)
1841 , __pWebDownloadHandler(null)
1843 , __pAuthChallenge(null)
1844 , __pAuthPopup(null)
1845 , __pUserConfirmPopup(null)
1846 , __pCertConfirmPopup(null)
1847 , __pSelectBox(null)
1848 , __pDatePicker(null)
1849 , __pColorPicker(null)
1850 , __policy(WEB_DECISION_CONTINUE)
1852 __textSearch.__searchAll = false;
1853 __textSearch.__searchForward = true;
1854 __textSearch.__caseSensitive = false;
1855 __textSearch.__pending = 0;
1856 __textSearch.__currentIndex = 1;
1857 __textSearch.__totalCount = -1;
1858 __textSearch.__text = L"";
1862 _WebImpl::~_WebImpl()
1864 RemoveEventListenerCallback();
1868 _WebImpl::CreateWebImplN(Web* pControl, const Rectangle& bounds)
1870 result r = E_SUCCESS;
1872 r = GET_SIZE_INFO(Web).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
1873 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1875 _Web* pCore = _Web::CreateWebN();
1876 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1878 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
1880 r = CheckConstruction(pCore, pImpl);
1881 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1883 r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
1884 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1886 r = pImpl->Construct();
1887 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1899 _WebImpl::CreateWebImplN(Web* pControl, const FloatRectangle& bounds)
1901 result r = E_SUCCESS;
1903 r = GET_SIZE_INFO(Web).CheckInitialSizeValidF(FloatDimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
1904 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1906 _Web* pCore = _Web::CreateWebN();
1907 SysTryReturn(NID_WEB_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1909 _WebImpl* pImpl = new (std::nothrow) _WebImpl(pControl, pCore);
1911 r = CheckConstruction(pCore, pImpl);
1912 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1914 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Web), bounds, pCore->GetOrientation());
1915 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1917 r = pImpl->Construct();
1918 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1930 _WebImpl::Construct(void)
1932 result r = E_SUCCESS;
1934 r = __mutex.Create();
1935 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1937 r = __textSearch.__searchQueue.Construct();
1938 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1940 __pWebSetting = std::unique_ptr<WebSetting>(new (std::nothrow) WebSetting());
1941 SysTryReturn(NID_WEB_CTRL, __pWebSetting.get(), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1943 r = InitJsBridgeList();
1944 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1947 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1949 __pWebCore = dynamic_cast< _Web* >(&(GetCore()));
1950 SysTryReturnResult(NID_WEB_CTRL, __pWebCore, E_SYSTEM, "A system error has been occurred. Failed to get web control");
1952 __pWebCore->SetWebSettingImpl(_WebSettingImpl::GetInstance(__pWebSetting.get()));
1959 _WebImpl::InitializeSetting(void)
1961 result r = E_SUCCESS;
1963 r = SetSetting(*__pWebSetting.get());
1964 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1966 SetCookieEnabled(_WebSettingImpl::GetInstance(__pWebSetting.get())->IsCookieEnabled());
1967 SetPrivateBrowsingEnabled(_WebSettingImpl::GetInstance(__pWebSetting.get())->IsPrivateBrowsingEnabled());
1968 SetZoomLevel(_WebSettingImpl::GetInstance(__pWebSetting.get())->GetZoomLevel());
1970 SetEventListenerCallback();
1972 _Form* pFormCore = GetParentFormCore(dynamic_cast< _Control* >(&this->GetCore()));
1973 SysAssertf(pFormCore != null, "Failed to get FormCore");
1980 _WebImpl::IsLayoutable(void) const
1987 _WebImpl::InitWebEvent(void)
1989 __pWebEvent = std::unique_ptr<_WebEvent>(new (std::nothrow) _WebEvent());
1990 SysTryReturnResult(NID_WEB_CTRL, __pWebEvent.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
1992 return __pWebEvent->Construct(*this);
1997 _WebImpl::GetWebEvent(void) const
1999 return __pWebEvent.get();
2004 _WebImpl::ConvertToSlpHeaderN(const HttpHeader& header) const
2006 Eina_Hash* pHttpHeader = null;
2008 std::unique_ptr<IList> pFieldNameList(header.GetFieldNamesN());
2009 if (pFieldNameList.get())
2011 pHttpHeader = eina_hash_string_small_new(FreeCharArray);
2012 SysTryReturn(NID_WEB_CTRL, pHttpHeader, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2014 int count = pFieldNameList->GetCount();
2016 for (int i = 0; i < count; i++)
2018 String* pFieldName = dynamic_cast< String* >(pFieldNameList->GetAt(i));
2019 SysTryCatch(NID_WEB_CTRL, pFieldName, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2021 std::unique_ptr<char[]> pKey(_StringConverter::CopyToCharArrayN(*pFieldName));
2022 SysTryCatch(NID_WEB_CTRL, pKey.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2024 std::unique_ptr<IEnumerator> pFieldValueEnum(header.GetFieldValuesN(*pFieldName));
2025 SysTryCatch(NID_WEB_CTRL, pFieldValueEnum.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2027 while (pFieldValueEnum->MoveNext() == E_SUCCESS)
2029 Eina_Bool ret = false;
2031 String* pFieldValue = dynamic_cast< String* >(pFieldValueEnum->GetCurrent());
2032 SysTryCatch(NID_WEB_CTRL, pFieldValue, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2034 std::unique_ptr<char[]> pValue(_StringConverter::CopyToCharArrayN(*pFieldValue));
2035 SysTryCatch(NID_WEB_CTRL, pValue.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2037 ret = eina_hash_add(pHttpHeader, pKey.get(), pValue.release());
2038 SysTryCatch(NID_WEB_CTRL, ret == EINA_TRUE, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2045 eina_hash_free(pHttpHeader);
2052 _WebImpl::LoadUrl(const String& url) const
2054 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2055 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2057 ewk_view_url_set(__pWebCore->GetWebNativeNode(), pUrl.get());
2064 _WebImpl::LoadUrl(const String& url, const HttpHeader& header)
2066 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2067 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2069 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2071 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_GET, pHttpHeader, null);
2073 eina_hash_free(pHttpHeader);
2080 _WebImpl::LoadUrlWithPostRequest(const String& url, const HttpHeader& header, const ByteBuffer& body) const
2082 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(url));
2083 SysTryReturn(NID_WEB_CTRL, pUrl.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2085 Eina_Hash* pHttpHeader = ConvertToSlpHeaderN(header);
2087 ewk_view_url_request_set(__pWebCore->GetWebNativeNode(), pUrl.get(), EWK_HTTP_METHOD_POST, pHttpHeader, reinterpret_cast< const char* >(body.GetPointer()));
2089 eina_hash_free(pHttpHeader);
2096 _WebImpl::LoadData(const String& baseUrl, const ByteBuffer& content, const String& mime, const String& encoding) const
2098 SysTryReturnResult(NID_WEB_CTRL, content.GetLimit() > 0, E_INVALID_ARG, "The content buffer is empty.");
2100 std::unique_ptr<char[]> pUrl(_StringConverter::CopyToCharArrayN(baseUrl));
2101 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
2102 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(encoding));
2103 SysTryReturn(NID_WEB_CTRL, pUrl.get() && pMime.get() && pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2105 ewk_view_contents_set(__pWebCore->GetWebNativeNode(), reinterpret_cast< const char* >(content.GetPointer()), content.GetLimit(), pMime.get(), pEncoding.get(), pUrl.get());
2112 _WebImpl::Pause(void)
2114 ewk_view_suspend(__pWebCore->GetWebNativeNode());
2119 _WebImpl::Resume(void)
2121 ewk_view_resume(__pWebCore->GetWebNativeNode());
2126 _WebImpl::ShowSelectBoxPopup(bool isMultiSelect, const String& title, Eina_List* pItems, Evas_Object* pWebView, int selectedIndex)
2128 __pSelectBox.reset();
2130 int itemCount = eina_list_count(pItems);
2131 SysTryReturnResult(NID_WEB_CTRL, itemCount > 0, E_SYSTEM, "ItemCount is invalid.");
2133 result r = E_SUCCESS;
2135 std::unique_ptr<_SelectBox> pSelectBox(new (std::nothrow) _SelectBox());
2136 SysTryReturnResult(NID_WEB_CTRL, pSelectBox.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
2138 r = pSelectBox->Construct(isMultiSelect, title, itemCount, pWebView);
2139 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2141 r = pSelectBox->UpdateList(pItems, selectedIndex, false, false);
2142 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2144 __pSelectBox = std::move(pSelectBox);
2146 return __pSelectBox->ShowPopup();
2151 _WebImpl::UpdateSelectBoxPopup(Eina_List* pItems, int selectedIndex, bool isGroupedList)
2153 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2155 return __pSelectBox->UpdateList(pItems, selectedIndex, true, isGroupedList);
2160 _WebImpl::ClearSelectBoxPopup(void)
2162 SysTryReturnResult(NID_WEB_CTRL, __pSelectBox.get(), E_SYSTEM, "SlectBox instance does not exist.");
2164 __pSelectBox.reset();
2171 _WebImpl::GetDatepicker(void)
2173 _InputPickerPopup* pInputPicker =null;
2176 pInputPicker = __pDatePicker.get();
2178 return pInputPicker;
2183 _WebImpl::GetColorpicker(void)
2185 _InputPickerPopup* pInputPicker =null;
2188 pInputPicker = __pColorPicker.get();
2190 return pInputPicker;
2195 _WebImpl::CanGoBack(void) const
2197 return static_cast< bool >(ewk_view_back_possible(__pWebCore->GetWebNativeNode()));
2202 _WebImpl::CanGoForward(void) const
2204 return static_cast< bool >(ewk_view_forward_possible(__pWebCore->GetWebNativeNode()));
2209 _WebImpl::GoBack(void) const
2211 ewk_view_back(__pWebCore->GetWebNativeNode());
2216 _WebImpl::GoForward(void) const
2218 ewk_view_forward(__pWebCore->GetWebNativeNode());
2223 _WebImpl::GetUrl(void) const
2225 return ewk_view_url_get(__pWebCore->GetWebNativeNode());
2230 _WebImpl::GetTitle(void) const
2232 return ewk_view_title_get(__pWebCore->GetWebNativeNode());
2237 _WebImpl::StopLoading(void) const
2239 ewk_view_stop(__pWebCore->GetWebNativeNode());
2244 _WebImpl::Reload(void) const
2246 ewk_view_reload_bypass_cache(__pWebCore->GetWebNativeNode());
2251 _WebImpl::EvaluateJavascriptN(const String& scriptCode) const
2253 if (scriptCode.GetLength())
2255 std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(scriptCode));
2256 SysTryReturn(NID_WEB_CTRL, pScript.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2258 _WebPresenter presenter;
2259 presenter.InitAsyncProcess();
2261 ewk_view_script_execute(__pWebCore->GetWebNativeNode(), pScript.get(), OnScriptExecuted, &presenter);
2263 Tizen::Base::String* pResult = new (std::nothrow) Tizen::Base::String(L"");
2264 SysTryReturn(NID_WEB_CTRL, pResult, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2265 presenter.WaitAsyncProcess(*pResult);
2275 _WebImpl::SetZoomLevel(float level)
2277 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);
2279 ewk_view_scale_set(__pWebCore->GetWebNativeNode(), static_cast< double >(level), 0, 0);
2286 _WebImpl::GetZoomLevel(void) const
2288 return static_cast< float >(ewk_view_scale_get(__pWebCore->GetWebNativeNode()));
2292 const PageNavigationList*
2293 _WebImpl::GetBackForwardListN(void) const
2295 result r = E_SUCCESS;
2297 _PageNavigationListImpl* pNavigationListImpl = null;
2298 _HistoryItemImpl* pHistoryItemImpl = null;
2300 std::unique_ptr<PageNavigationList> pNavigationList;
2301 std::unique_ptr<ArrayList, AllElementsDeleter> pHistoryList;
2304 int forwardCount = 0;
2309 Ewk_History* pEwkHistoryList = ewk_view_history_get(__pWebCore->GetWebNativeNode());
2310 SysTryReturn(NID_WEB_CTRL, pEwkHistoryList, null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get full history.", GetErrorMessage(E_SYSTEM));
2312 Ewk_History_Item* pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, 0);
2313 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_DATA_NOT_FOUND, "[%s] There is no history.", GetErrorMessage(E_DATA_NOT_FOUND));
2315 pNavigationList = std::unique_ptr<PageNavigationList>(new (std::nothrow) PageNavigationList());
2316 SysTryCatch(NID_WEB_CTRL, pNavigationList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2318 pNavigationListImpl = _PageNavigationListImpl::GetInstance(pNavigationList.get());
2319 SysTryCatch(NID_WEB_CTRL, pNavigationListImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2321 pHistoryList = std::unique_ptr<ArrayList, AllElementsDeleter>(new (std::nothrow) ArrayList());
2322 SysTryCatch(NID_WEB_CTRL, pHistoryList.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2324 r = pHistoryList->Construct();
2325 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2327 backCount = ewk_history_back_list_length_get(pEwkHistoryList);
2328 forwardCount = ewk_history_forward_list_length_get(pEwkHistoryList);
2329 SysLog(NID_WEB_CTRL, "The current value of backCount is %d, forwardCount is %d", backCount, forwardCount);
2331 for (int i = -backCount; i < forwardCount + 1; i++)
2333 std::unique_ptr<HistoryItem> pHistoryItem(new (std::nothrow) HistoryItem());
2334 SysTryCatch(NID_WEB_CTRL, pHistoryItem.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2336 pHistoryItemImpl = _HistoryItemImpl::GetInstance(pHistoryItem.get());
2337 SysTryCatch(NID_WEB_CTRL, pHistoryItemImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2339 pEwkItem = ewk_history_nth_item_get(pEwkHistoryList, i);
2340 SysTryCatch(NID_WEB_CTRL, pEwkItem, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2342 url = ewk_history_item_uri_get(pEwkItem);
2343 title = ewk_history_item_title_get(pEwkItem);
2344 SysLog(NID_WEB_CTRL, "The current value of url is %s, title is %s", url.GetPointer(), title.GetPointer());
2346 pHistoryItemImpl->SetHistoryItem(url, title);
2348 r = pHistoryList->Add(*pHistoryItem.get());
2349 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2350 pHistoryItem.release();
2353 pNavigationListImpl->SetPageNavigationList(pHistoryList.release(), backCount);
2355 ewk_history_free(pEwkHistoryList);
2357 return pNavigationList.release();
2360 ewk_history_free(pEwkHistoryList);
2367 _WebImpl::SearchText(const String& text, bool searchForward)
2369 result r = E_SUCCESS;
2371 Ewk_Find_Options condition = static_cast< Ewk_Find_Options >(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2375 condition = static_cast < Ewk_Find_Options >(condition | EWK_FIND_OPTIONS_BACKWARDS);
2378 _WebPresenter presenter;
2379 presenter.InitAsyncProcess();
2381 r = SynchronizeSearch(SEARCH_SYNC, __pWebCore->GetWebNativeNode(), condition, text, searchForward, false, &presenter);
2382 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2385 presenter.WaitAsyncProcess(result);
2387 return static_cast < bool >(result);
2392 _WebImpl::SearchTextAllAsync(const Tizen::Base::String& text, bool caseSensitive)
2394 result r = E_SUCCESS;
2396 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2400 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2403 r = SynchronizeSearch(SEARCH_ALL_ASYNC, __pWebCore->GetWebNativeNode(), condition, text, true, caseSensitive);
2404 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2411 _WebImpl::SearchNextAsync(bool searchForward)
2413 SysTryReturnResult(NID_WEB_CTRL, __textSearch.__searchAll && __textSearch.__totalCount > -1, E_INVALID_OPERATION, "The SearchTextAllAsync() method is not called or completed.");
2414 SysTryReturnResult(NID_WEB_CTRL, (searchForward && __textSearch.__currentIndex < __textSearch.__totalCount) || (!searchForward && __textSearch.__currentIndex > 1)
2415 , E_OBJ_NOT_FOUND, "The Next instance is not available.");
2417 result r = E_SUCCESS;
2419 Ewk_Find_Options condition = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT;
2421 if (__textSearch.__caseSensitive)
2423 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_CASE_INSENSITIVE);
2428 condition = static_cast <Ewk_Find_Options>(condition | EWK_FIND_OPTIONS_BACKWARDS);
2431 r = SynchronizeSearch(SEARCH_NEXT_ASYNC, __pWebCore->GetWebNativeNode(), condition, __textSearch.__text, searchForward);
2432 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2439 _WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Options condition, const Tizen::Base::String& text, bool searchForward, bool caseSensitive, _WebPresenter* pWebPresenter)
2441 MutexGuard lock(__mutex);
2443 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(text));
2444 SysTryReturn(NID_WEB_CTRL, pText.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2449 if (__textSearch.__searchAll)
2451 DisableAsyncSearch();
2453 __textSearch.__searchQueue.Enqueue(this);
2454 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2456 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2457 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2461 __textSearch.__searchQueue.Enqueue(pWebPresenter);
2463 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2467 case SEARCH_ALL_ASYNC:
2468 __textSearch.__searchAll = true;
2469 __textSearch.__text = text;
2470 __textSearch.__searchForward = true;
2471 __textSearch.__caseSensitive = caseSensitive;
2472 __textSearch.__totalCount = -1;
2473 __textSearch.__currentIndex = 1;
2475 __textSearch.__searchQueue.Enqueue(this);
2476 __textSearch.__searchQueue.Enqueue(this);
2478 ewk_view_text_find(pView, "", condition, MAX_TEXT_MATCH);
2479 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2482 case SEARCH_NEXT_ASYNC:
2483 __textSearch.__searchForward = searchForward;
2485 CalculateAsyncSearchOrdinal();
2487 __textSearch.__searchQueue.Enqueue(this);
2489 ewk_view_text_find(pView, pText.get(), condition, MAX_TEXT_MATCH);
2501 _WebImpl::SetAsyncSearchResult(int totalCount)
2503 __textSearch.__totalCount = totalCount;
2508 _WebImpl::GetSearchPresenter(void)
2510 MutexGuard lock(__mutex);
2512 return dynamic_cast< _WebPresenter* >(__textSearch.__searchQueue.Dequeue());
2517 _WebImpl::GetPendingAsyncSearchCount(void) const
2519 return __textSearch.__searchQueue.GetCount();
2524 _WebImpl::CalculateAsyncSearchOrdinal(void)
2526 if (__textSearch.__searchForward)
2528 __textSearch.__currentIndex++;
2532 __textSearch.__currentIndex--;
2538 _WebImpl::GetAsyncSearchOrdinal(void) const
2540 return __textSearch.__currentIndex;
2545 _WebImpl::DisableAsyncSearch(void)
2547 __textSearch.__searchAll = false;
2552 _WebImpl::SetSetting(const WebSetting& setting)
2554 if (__pWebCore->GetWebNativeNode())
2556 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2557 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2558 SysAssertf(pContext && pSettings, "Failed to get webkit instance.");
2560 std::unique_ptr<char[]> pEncoding(_StringConverter::CopyToCharArrayN(setting.GetDefaultTextEncoding()));
2561 SysTryReturn(NID_WEB_CTRL, pEncoding.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2563 ewk_settings_default_encoding_set(pSettings, pEncoding.get());
2565 switch (setting.GetCacheControl())
2567 case WEB_CACHE_VALIDATED:
2568 ewk_context_cache_disabled_set(pContext, EINA_FALSE);
2571 case WEB_CACHE_IGNORE:
2572 ewk_context_cache_disabled_set(pContext, EINA_TRUE);
2579 if (setting.GetInputStyle() == INPUT_STYLE_OVERLAY)
2581 ewk_settings_default_keypad_enabled_set(pSettings, EINA_TRUE);
2585 ewk_settings_default_keypad_enabled_set(pSettings, EINA_FALSE);
2588 ewk_settings_font_default_size_set(pSettings, static_cast< Eina_Bool >(setting.GetFontSize()));
2590 ewk_settings_javascript_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsJavascriptEnabled()));
2592 ewk_settings_loads_images_automatically_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoImageLoadEnabled()));
2594 std::unique_ptr<char[]> pAgent(_StringConverter::CopyToCharArrayN(setting.GetUserAgent()));
2595 SysTryReturn(NID_WEB_CTRL, pAgent.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2597 ewk_view_user_agent_set(__pWebCore->GetWebNativeNode(), pAgent.get());
2599 ewk_settings_auto_fitting_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFittingEnabled()));
2601 ewk_settings_scripts_window_open_set(pSettings, static_cast< Eina_Bool >(setting.IsJavaScriptPopupEnabled()));
2603 ewk_settings_form_candidate_data_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoFormDataShowEnabled()));
2605 ewk_settings_autofill_password_form_enabled_set(pSettings, static_cast< Eina_Bool >(setting.IsAutoLoginFormFillEnabled()));
2608 __pWebSetting->SetCertificateErrorHandlingMode(setting.GetCertificateErrorHandlingMode());
2609 __pWebSetting->SetDefaultTextEncoding(setting.GetDefaultTextEncoding());
2610 __pWebSetting->SetCacheControl(setting.GetCacheControl());
2611 __pWebSetting->SetFontSize(setting.GetFontSize());
2612 __pWebSetting->SetJavascriptEnabled(setting.IsJavascriptEnabled());
2613 __pWebSetting->SetAutoImageLoadEnabled(setting.IsAutoImageLoadEnabled());
2614 __pWebSetting->SetInputStyle(setting.GetInputStyle());
2615 __pWebSetting->SetUserAgent(setting.GetUserAgent());
2616 __pWebSetting->SetAutoFittingEnabled(setting.IsAutoFittingEnabled());
2617 __pWebSetting->SetJavaScriptPopupEnabled(setting.IsJavaScriptPopupEnabled());
2618 __pWebSetting->SetGeolocationEnabled(setting.IsGeolocationEnabled());
2619 __pWebSetting->SetAutoFormDataShowEnabled(setting.IsAutoFormDataShowEnabled());
2620 __pWebSetting->SetAutoLoginFormFillEnabled(setting.IsAutoLoginFormFillEnabled());
2627 _WebImpl::GetSetting(void) const
2629 return *__pWebSetting;
2633 const HitElementResult*
2634 _WebImpl::GetElementByPointN(const Point& point) const
2636 result r = E_SUCCESS;
2638 _HitElementResultImpl* pHitElementResultImpl = null;
2640 std::unique_ptr<HitElementResult> pHitElementResult;
2641 std::unique_ptr<Bitmap> pImage;
2642 std::unique_ptr<HashMap, AllElementsDeleter> pAttributeMap;
2644 Point absPoint(__pWebCore->GetAbsoluteCoordinate(point));
2646 Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(__pWebCore->GetWebNativeNode(), absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
2647 SysTryReturn(NID_WEB_CTRL, pEwkHitTest, null, E_SYSTEM, "[%s] Failed to get hit test.", GetErrorMessage(E_SYSTEM));
2649 Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
2650 Ewk_Hit_Test_Result_Context context = ewk_hit_test_result_context_get(pEwkHitTest);
2651 String url(ewk_hit_test_link_uri_get(pEwkHitTest));
2652 String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
2653 String nodeValue(ewk_hit_test_node_value_get(pEwkHitTest));
2655 SysLog(NID_WEB_CTRL, "The current value of url is %ls, tag is %ls, value is %ls", url.GetPointer(), tagName.GetPointer(), nodeValue.GetPointer());
2657 pHitElementResult = std::unique_ptr<HitElementResult>(new (std::nothrow) HitElementResult());
2658 SysTryCatch(NID_WEB_CTRL, pHitElementResult.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2660 pHitElementResultImpl = _HitElementResultImpl::GetInstance(pHitElementResult.get());
2661 SysTryCatch(NID_WEB_CTRL, pHitElementResultImpl, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2663 if (context & EWK_HIT_TEST_RESULT_CONTEXT_IMAGE)
2669 int imageLength = ewk_hit_test_image_buffer_length_get(pEwkHitTest);
2670 void* pImageBuffer = ewk_hit_test_image_buffer_get(pEwkHitTest);
2671 const char* pExtension = ewk_hit_test_image_file_name_extension_get(pEwkHitTest);
2672 SysLog(NID_WEB_CTRL, "The current value of imageBuffer is %u, bufferLength is %d, extension is %s", pImageBuffer, imageLength, pExtension);
2674 r = buf.Construct(imageLength);
2675 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2677 r = buf.SetArray(reinterpret_cast< byte* >(pImageBuffer), 0, imageLength);
2678 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2682 // ToDo : webkit doesn't support types such as IMG_FORMAT_WBMP and IMG_FORMAT_TIFF
2683 // webkit support types such as ico and vp8 additionally
2684 if (strcmp(pExtension, "gif") == 0)
2686 format = IMG_FORMAT_GIF;
2688 else if (strcmp(pExtension, "jpg") == 0)
2690 format = IMG_FORMAT_JPG;
2692 else if (strcmp(pExtension, "png") == 0)
2694 format = IMG_FORMAT_PNG;
2696 else if (strcmp(pExtension, "bmp") == 0)
2698 format = IMG_FORMAT_BMP;
2702 SysLogException(NID_WEB_CTRL, E_UNSUPPORTED_FORMAT, "[%s] The %s format is not supported", GetErrorMessage(E_UNSUPPORTED_FORMAT), pExtension);
2706 r = image.Construct();
2707 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2709 pImage = std::unique_ptr<Bitmap>(image.DecodeN(buf, format, BITMAP_PIXEL_FORMAT_RGB565));
2710 SysTryCatch(NID_WEB_CTRL, pImage.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2715 pAttributeMap = std::unique_ptr<HashMap, AllElementsDeleter>(new (std::nothrow) HashMap());
2716 SysTryCatch(NID_WEB_CTRL, pAttributeMap.get(), , E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2718 r = pAttributeMap->Construct(eina_hash_population(pAttrHash));
2719 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2721 eina_hash_foreach(pAttrHash, AddHttpAttributeData, pAttributeMap.get());
2722 SysTryCatch(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2725 pHitElementResultImpl->SetHitElementResult(pAttributeMap.release(), pImage.release(), tagName, nodeValue, url);
2727 ewk_hit_test_free(pEwkHitTest);
2729 return pHitElementResult.release();
2732 ewk_hit_test_free(pEwkHitTest);
2738 const HitElementResult*
2739 _WebImpl::GetElementByPointN(const FloatPoint& point) const
2741 const Point integerPoint(_CoordinateSystemUtils::ConvertToInteger(point));
2743 std::unique_ptr<const HitElementResult> pHitElementResult(GetElementByPointN(integerPoint));
2744 SysTryReturn(NID_WEB_CTRL, pHitElementResult.get(), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2746 return pHitElementResult.release();
2751 _WebImpl::IsLoading(void) const
2753 double percent = ewk_view_load_progress_get(__pWebCore->GetWebNativeNode());
2755 if (Double::Compare(percent, 0.0) > 0 && Double::Compare(percent, 1.0) < 0)
2767 _WebImpl::GetTextFromBlock(void) const
2769 return ewk_view_text_selection_text_get(__pWebCore->GetWebNativeNode());
2774 _WebImpl::IsPrivateBrowsingEnabled(void) const
2776 if (__pWebCore->GetWebNativeNode() == null)
2778 return _WebSettingImpl::GetInstance(__pWebSetting.get())->IsPrivateBrowsingEnabled();
2781 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2782 SysAssertf(pSettings, "Failed to get webkit instance.");
2784 return static_cast< bool >(ewk_settings_private_browsing_enabled_get(pSettings));
2789 _WebImpl::SetPrivateBrowsingEnabled(bool enable)
2791 if (__pWebCore->GetWebNativeNode() == null)
2793 _WebSettingImpl::GetInstance(__pWebSetting.get())->SetPrivateBrowsingEnabled(enable);
2797 Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode());
2798 SysAssertf(pSettings, "Failed to get webkit instance.");
2800 ewk_settings_private_browsing_enabled_set(pSettings, static_cast< Eina_Bool >(enable));
2805 _WebImpl::ClearHistory(void)
2807 ewk_view_back_forward_list_clear(__pWebCore->GetWebNativeNode());
2812 _WebImpl::ClearCache(void)
2814 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2815 SysAssertf(pContext, "Failed to get webkit instance.");
2817 ewk_context_cache_clear(pContext);
2822 _WebImpl::ClearCookie(void)
2824 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2825 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
2826 SysAssertf(pCookieManager, "Failed to get webkit instance.");
2828 ewk_cookie_manager_cookies_clear(pCookieManager);
2833 _WebImpl::ClearFormData(void)
2835 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2836 SysAssertf(pContext, "Failed to get webkit instance.");
2838 ewk_context_form_candidate_data_clear(pContext);
2843 _WebImpl::ClearLoginFormData(void)
2845 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2846 SysAssertf(pContext, "Failed to get webkit instance.");
2848 ewk_context_form_password_data_clear(pContext);
2853 _WebImpl::IsCookieEnabled(void) const
2855 if (__pWebCore->GetWebNativeNode() == null)
2857 return _WebSettingImpl::GetInstance(__pWebSetting.get())->IsCookieEnabled();
2860 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2861 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
2862 SysAssertf(pCookieManager, "Failed to get webkit instance.");
2864 _WebPresenter presenter;
2865 presenter.InitAsyncProcess();
2867 ewk_cookie_manager_async_accept_policy_get(pCookieManager, OnCookiesPolicyGot, &presenter);
2869 bool result = false;
2870 presenter.WaitAsyncProcess(result);
2877 _WebImpl::SetCookieEnabled(bool enable)
2879 if (__pWebCore->GetWebNativeNode() == null)
2881 _WebSettingImpl::GetInstance(__pWebSetting.get())->SetCookiEnabled(enable);
2886 Ewk_Context* pContext = ewk_view_context_get(__pWebCore->GetWebNativeNode());
2887 Ewk_Cookie_Manager* pCookieManager = ewk_context_cookie_manager_get(pContext);
2888 SysAssertf(pCookieManager, "Failed to get webkit instance.");
2892 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY);
2896 ewk_cookie_manager_accept_policy_set(pCookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER);
2897 ewk_cookie_manager_cookies_clear(pCookieManager);
2903 _WebImpl::SavePageAsPdf(const String& filePath, const Dimension* pSize) const
2905 result r = E_SUCCESS;
2907 std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
2908 SysTryReturn(NID_WEB_CTRL, pFilePath.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2911 String fileExtension = File::GetFileExtension(filePath);
2912 int pathLength = filePath.GetLength();
2915 SysTryReturnResult(NID_WEB_CTRL, fileExtension.Equals("pdf", false), E_INVALID_ARG, "Invalid argument(s) is used. File extension is not pdf.");
2917 r = filePath.LastIndexOf(L"/", pathLength - 1, index);
2918 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
2919 r = filePath.SubString(0, index + 1, dirPath);
2920 SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument(s) is used. Directory path is invalid.");
2922 std::unique_ptr<char[]> pDirPath(_StringConverter::CopyToCharArrayN(dirPath));
2923 SysTryReturnResult(NID_WEB_CTRL, access(pDirPath.get(), W_OK) == 0, E_INACCESSIBLE_PATH, "Directory permission is read-only.");
2927 SysTryReturnResult(NID_WEB_CTRL, pSize->width > 0 && pSize->height > 0, E_INVALID_ARG, "Invalid argument(s) is used. Size of pdf file is invalid.");
2929 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), pSize->width, pSize->height, pFilePath.get());
2933 Evas_Coord contentsWidth;
2934 Evas_Coord contentsHeight;
2936 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &contentsWidth, &contentsHeight);
2937 ewk_view_contents_pdf_get(__pWebCore->GetWebNativeNode(), contentsWidth, contentsHeight, pFilePath.get());
2945 _WebImpl::IsMimeSupported(const String& mime) const
2947 std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(mime));
2948 SysTryReturn(NID_WEB_CTRL, pMime.get(), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2950 return static_cast< bool >(ewk_frame_can_show_mime_type(ewk_view_main_frame_get(__pWebCore->GetWebNativeNode()), pMime.get()));
2955 _WebImpl::SetLoadingListener(ILoadingListener* pLoadingListener)
2957 __pUserLoadingListener = const_cast< ILoadingListener* >(pLoadingListener);
2962 _WebImpl::SetWebUiEventListener(IWebUiEventListener* pUiEventListener)
2964 __pUserUiListener = pUiEventListener;
2969 _WebImpl::SetWebUiEventListenerF(IWebUiEventListenerF* pUiEventListener)
2971 __pUserUiListenerF = pUiEventListener;
2976 _WebImpl::SetWebKeypadEventListener(IWebKeypadEventListener* pKeypadEventListener)
2978 __pUserKeypadEventListener = pKeypadEventListener;
2983 _WebImpl::SetDownloadListener(IWebDownloadListener* pDownLoadListener)
2985 if (__pWebDownloadHandler.get() == null)
2987 __pWebDownloadHandler = std::unique_ptr<_WebDataHandler>(new (std::nothrow) _WebDataHandler());
2988 SysTryReturnVoidResult(NID_WEB_CTRL, __pWebDownloadHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2991 __pWebDownloadHandler->SetDownloadListener(pDownLoadListener);
2992 __pWebDownloadHandler->SetWebEvent(__pWebEvent.get());
2997 _WebImpl::SetTextSearchListener(ITextSearchListener* pTextSearchListener)
2999 __pTextSearchListener = pTextSearchListener;
3004 _WebImpl::SetScrollEnabled(bool enable)
3006 _WebSettingImpl::GetInstance(__pWebSetting.get())->SetScrollEnabled(enable);
3011 _WebImpl::IsScrollEnabled(void) const
3013 return _WebSettingImpl::GetInstance(__pWebSetting.get())->IsScrollEnabled();
3018 _WebImpl::InitJsBridgeList(void)
3020 result r = E_SUCCESS;
3022 __pJsProvider = std::unique_ptr<_JsBridgeHashCodeProvider>(new (std::nothrow) _JsBridgeHashCodeProvider());
3023 SysTryReturnResult(NID_WEB_CTRL, __pJsProvider.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3025 __pJsComparer = std::unique_ptr<_JsBridgeComparer>(new (std::nothrow) _JsBridgeComparer());
3026 SysTryReturnResult(NID_WEB_CTRL, __pJsComparer.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3028 std::unique_ptr<HashMapT< String, IJavaScriptBridge* > > pJsBridgeList(new (std::nothrow) HashMapT< String, IJavaScriptBridge* >);
3029 SysTryReturnResult(NID_WEB_CTRL, pJsBridgeList.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
3031 r = pJsBridgeList->Construct(0, 0, *__pJsProvider.get(), *__pJsComparer.get());
3032 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3034 __pJsBridgeList = std::move(pJsBridgeList);
3041 _WebImpl::AddJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3043 result r = E_SUCCESS;
3045 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3046 String key(pJsBridge->GetName());
3048 r = __pJsBridgeList->Add(key, pJsBridge);
3049 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3056 _WebImpl::RemoveJavaScriptBridge(const IJavaScriptBridge& jsBridge)
3058 result r = E_SUCCESS;
3060 IJavaScriptBridge* pJsBridge = const_cast< IJavaScriptBridge* >(&jsBridge);
3061 String key(pJsBridge->GetName());
3063 r = __pJsBridgeList->Remove(key);
3064 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3071 _WebImpl::FindJsInterface(const IJsonValue* pValue) const
3073 result r = E_SUCCESS;
3075 IJsonValue* pJsonValue = null;
3076 IJavaScriptBridge* pJsBridge = null;
3078 String key(L"name");
3080 const JsonObject* pJsonObject = dynamic_cast< const JsonObject* >(pValue);
3081 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));
3083 r = pJsonObject->GetValue(&key, pJsonValue);
3084 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS && pJsonValue, null, r, "[%s] Propagating.", GetErrorMessage(r));
3086 JsonString* pBridgeName = dynamic_cast< JsonString* >(pJsonValue);
3087 SysTryReturn(NID_WEB_CTRL, pBridgeName, null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. name key is missing." , GetErrorMessage(E_INVALID_ARG));
3089 r = __pJsBridgeList->GetValue(static_cast< String >(*pBridgeName), pJsBridge);
3090 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3097 _WebImpl::GetLoadingListener(void) const
3099 return __pUserLoadingListener;
3103 IWebUiEventListener*
3104 _WebImpl::GetUiEventListener(void) const
3106 return __pUserUiListener;
3110 IWebUiEventListenerF*
3111 _WebImpl::GetUiEventListenerF(void) const
3113 return __pUserUiListenerF;
3117 IWebKeypadEventListener*
3118 _WebImpl::GetWebKeypadEventListener(void) const
3120 return __pUserKeypadEventListener;
3124 ITextSearchListener*
3125 _WebImpl::GetTextSearchListener(void) const
3127 return __pTextSearchListener;
3132 _WebImpl::SetEventListenerCallback(void) const
3134 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3137 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3138 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3140 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3141 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3143 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3144 SysAssertf(pSmartData, "Failed to request");
3146 Ewk_View_Smart_Class *pSmart = const_cast<Ewk_View_Smart_Class*>(pSmartData->api);
3147 SysAssertf(pSmart, "Failed to request");
3149 pSmart->popup_menu_show = OnSelectBoxRequested;
3150 pSmart->popup_menu_hide = OnSelectBoxClosed;
3151 pSmart->popup_menu_update = OnSelectBoxUpdateRequested;
3153 pSmart->input_picker_show = OnDatePickerProviderRequested;
3154 pSmart->input_picker_color_request = OnColorPickerProviderRequested;
3155 pSmart->input_picker_color_dismiss = OnColorPickerProviderDismissed;
3157 evas_object_data_set(pWebNativeNode, WEB_CTRL, this);
3159 // add loading event callbacks for ILoadingListener
3160 evas_object_smart_callback_add(pWebNativeNode, "create,window", OnWebWindowCreateRequested, this);
3161 evas_object_smart_callback_add(pWebNativeNode, "close,window", OnWebWindowClosedRequested, this);
3163 evas_object_smart_callback_add(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested, this);
3164 evas_object_smart_callback_add(pWebNativeNode, "load,started", OnLoadingStarted, this);
3165 evas_object_smart_callback_add(pWebNativeNode, "load,finished", OnLoadingCompleted, this);
3166 evas_object_smart_callback_add(pWebNativeNode, "load,progress", OnEstimatedProgress, this);
3167 evas_object_smart_callback_add(pWebNativeNode, "load,progress,finished", OnProgressCompleted, this);
3168 evas_object_smart_callback_add(pWebNativeNode, "load,stop", OnLoadingCanceled, this);
3169 evas_object_smart_callback_add(pWebNativeNode, "load,error", OnLoadingErrorOccurred, this);
3170 evas_object_smart_callback_add(pWebNativeNode, "title,changed", OnPageTitleReceived, this);
3171 evas_object_smart_callback_add(pWebNativeNode, "load,committed", OnLoadingCommitted, this);
3173 evas_object_smart_callback_add(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest, this);
3175 evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, this);
3177 evas_object_smart_callback_add(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged, this);
3178 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened, this);
3179 evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed, this);
3181 evas_object_smart_callback_add(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested, this);
3182 evas_object_smart_callback_add(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled, this);
3184 evas_object_smart_callback_add(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested, this);
3186 ewk_view_javascript_alert_callback_set(pWebNativeNode, OnScriptAlertRequested, const_cast< _WebImpl* >(this));
3187 ewk_view_javascript_prompt_callback_set(pWebNativeNode, OnScriptPromptRequested, const_cast< _WebImpl* >(this));
3188 ewk_view_javascript_confirm_callback_set(pWebNativeNode, OnScriptConfirmRequested, const_cast< _WebImpl* >(this));
3190 evas_object_smart_callback_add(pWebNativeNode, "policy,response,decide", OnWebDataReceived, this);
3192 evas_object_smart_callback_add(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested, this);
3193 evas_object_smart_callback_add(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested, this);
3194 evas_object_smart_callback_add(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted, this);
3196 evas_object_smart_callback_add(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested, this);
3197 evas_object_smart_callback_add(pWebNativeNode, "notification,show", OnNotificationShow, this);
3198 evas_object_smart_callback_add(pWebNativeNode, "notification,cancel", OnNotificationCancel, this);
3200 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested, this);
3201 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered, this);
3202 evas_object_smart_callback_add(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested, this);
3204 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested, this);
3205 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered, this);
3206 evas_object_smart_callback_add(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested, this);
3207 evas_object_smart_callback_add(pWebNativeNode, "text,found", OnTextFound, this);
3209 evas_object_smart_callback_add(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered, this);
3210 evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this);
3212 Ewk_Context* pContext = ewk_view_context_get(pWebNativeNode);
3213 SysAssertf(pContext, "Failed to get webkit instance.");
3214 ewk_context_did_start_download_callback_set(pContext, OnDidStartDownloadCallback, const_cast< _WebImpl* >(this));
3215 ewk_view_open_panel_callback_set(pWebNativeNode, OnSelectUploadFile, const_cast< _WebImpl* >(this));
3217 evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this);
3223 _WebImpl::RemoveEventListenerCallback(void) const
3225 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3228 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
3229 SysAssertf(pEcoreEvas, "Failed to get Ui ecore evas");
3231 Evas_Object* pWinObject = pEcoreEvas->GetWindowObject();
3232 SysAssertf(pWinObject, "Failed to get Ui window evas object");
3234 evas_object_smart_callback_del(pWebNativeNode, "create,window", OnWebWindowCreateRequested);
3235 evas_object_smart_callback_del(pWebNativeNode, "close,window", OnWebWindowClosedRequested);
3237 evas_object_smart_callback_del(pWebNativeNode, "policy,navigation,decide", OnLoadingRequested);
3238 evas_object_smart_callback_del(pWebNativeNode, "load,started", OnLoadingStarted);
3239 evas_object_smart_callback_del(pWebNativeNode, "load,finished", OnLoadingCompleted);
3240 evas_object_smart_callback_del(pWebNativeNode, "load,progress", OnEstimatedProgress);
3241 evas_object_smart_callback_del(pWebNativeNode, "load,progress,finished", OnProgressCompleted);
3242 evas_object_smart_callback_del(pWebNativeNode, "load,stop", OnLoadingCanceled);
3243 evas_object_smart_callback_del(pWebNativeNode, "load,error", OnLoadingErrorOccurred);
3244 evas_object_smart_callback_del(pWebNativeNode, "title,changed", OnPageTitleReceived);
3246 evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest);
3248 evas_object_smart_callback_del(pWinObject, "focus,in", OnWindowObjectFocusGained);
3250 evas_object_smart_callback_del(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged);
3251 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened);
3252 evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,closed", OnWebKeypadClosed);
3254 evas_object_smart_callback_del(pWebNativeNode, "authentication,challenge", OnHttpAuthenticationRequested);
3255 evas_object_smart_callback_del(pWebNativeNode, "authentication,canceled", OnHttpAuthenticationCanceled);
3257 evas_object_smart_callback_del(pWebNativeNode, "geolocation,permission,request", OnGeolocationPermissionRequested);
3259 ewk_view_javascript_alert_callback_set(null, null, null);
3260 ewk_view_javascript_prompt_callback_set(null, null, null);
3261 ewk_view_javascript_confirm_callback_set(null, null, null);
3263 evas_object_smart_callback_del(pWebNativeNode, "policy,response,decide", OnWebDataReceived);
3265 evas_object_smart_callback_del(pWebNativeNode, "load,nonemptylayout,finished", OnWebPageShowRequested);
3266 evas_object_smart_callback_del(pWebNativeNode, "request,certificate,confirm", OnCertificateRequested);
3267 evas_object_smart_callback_del(pWebNativeNode, "usermedia,permission,request", OnGetUserMediaPermissionRequsted);
3269 evas_object_smart_callback_del(pWebNativeNode, "notification,permission,request", OnNotificationPermissionRequested);
3270 evas_object_smart_callback_del(pWebNativeNode, "notification,show", OnNotificationShow);
3271 evas_object_smart_callback_del(pWebNativeNode, "notification,cancel", OnNotificationCancel);
3272 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,registration,requested", OnProtocolHandlerRegistrationRequested);
3273 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,isregistered", OnIsProtocolHandlerRegistered);
3274 evas_object_smart_callback_del(pWebNativeNode, "protocolhandler,unregistration,requested", OnProtocolHandlerUnregistrationRequested);
3276 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,registration,requested", OnContentHandlerRegistrationRequested);
3277 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,isregistered", OnIsContentHandlerRegistered);
3278 evas_object_smart_callback_del(pWebNativeNode, "contenthandler,unregistration,requested", OnContentHandlerUnregistrationRequested);
3280 evas_object_smart_callback_del(pWebNativeNode, "text,found", OnTextFound);
3282 evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered);
3283 evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived);
3285 ewk_view_open_panel_callback_set(null, null, null);
3287 evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained);
3293 _WebImpl::SetBlockSelectionPosition(const Point& startPoint)
3295 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3297 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3298 SysAssertf(pSmartData, "Failed to request");
3300 Point absPoint(__pWebCore->GetAbsoluteCoordinate(startPoint));
3302 pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y);
3303 pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y);
3305 ewk_view_command_execute(pWebNativeNode, "SelectWord", 0);
3307 SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up.");
3309 if (__pUserUiListener)
3311 FireWebPageBlockSelectedEvent();
3319 _WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint)
3321 Evas_Object* pWebNativeNode = __pWebCore->GetWebNativeNode();
3323 Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pWebNativeNode);
3324 SysAssertf(pSmartData, "Failed to request");
3326 Point absPoint(__pWebCore->GetAbsoluteCoordinate(_CoordinateSystemUtils::ConvertToInteger(startPoint)));
3328 pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y);
3329 pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y);
3331 ewk_view_command_execute(pWebNativeNode, "SelectWord", 0);
3333 SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up.");
3335 if (__pUserUiListenerF)
3337 FireWebPageBlockSelectedEventF();
3345 _WebImpl::FireWebPageBlockSelectedEvent(void) const
3347 result r = E_SUCCESS;
3349 std::unique_ptr<Point> startPoint(new (std::nothrow) Point());
3350 std::unique_ptr<Point> endPoint(new (std::nothrow) Point());
3351 SysTryReturnVoidResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3353 GetBlockRange(*startPoint.get(), *endPoint.get());
3355 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED));
3356 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3358 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
3359 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3360 startPoint.release();
3362 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
3363 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3366 r = __pWebEvent->FireAsync(*pEventArg.get());
3367 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3368 pEventArg.release();
3373 _WebImpl::FireWebPageBlockSelectedEventF(void) const
3375 result r = E_SUCCESS;
3377 std::unique_ptr<FloatPoint> startPoint(new (std::nothrow) FloatPoint());
3378 std::unique_ptr<FloatPoint> endPoint(new (std::nothrow) FloatPoint());
3379 SysTryReturnVoidResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3381 GetBlockRange(*startPoint.get(), *endPoint.get());
3383 std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT));
3384 SysTryReturnVoidResult(NID_WEB_CTRL, pEventArg.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3386 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_START, *startPoint.get());
3387 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3388 startPoint.release();
3390 r = pEventArg->SetEventInfo(_WebUiEventArg::BLOCK_END, *endPoint.get());
3391 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3394 r = __pWebEvent->FireAsync(*pEventArg.get());
3395 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
3396 pEventArg.release();
3401 _WebImpl::ReleaseBlock(void)
3403 ewk_view_command_execute(__pWebCore->GetWebNativeNode(), "Unselect", 0);
3408 _WebImpl::GetBlockRange(Point& startPoint, Point& endPoint) const
3410 Eina_Rectangle leftHandle;
3411 Eina_Rectangle rightHandle;
3413 ewk_view_text_selection_range_get(__pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle);
3415 startPoint.x = leftHandle.x;
3416 startPoint.y = leftHandle.y;
3417 endPoint.x = rightHandle.x + rightHandle.w;
3418 endPoint.y = rightHandle.y + rightHandle.h;
3420 if ((endPoint.x != 0) && (endPoint.y != 0))
3422 startPoint = __pWebCore->GetRelativeCoordinate(startPoint);
3423 endPoint = __pWebCore->GetRelativeCoordinate(endPoint);
3429 _WebImpl::GetBlockRange(FloatPoint& startPoint, FloatPoint& endPoint) const
3431 Eina_Rectangle leftHandle;
3432 Eina_Rectangle rightHandle;
3434 ewk_view_text_selection_range_get(__pWebCore->GetWebNativeNode(), &leftHandle, &rightHandle);
3436 startPoint.x = _CoordinateSystemUtils::ConvertToFloat(leftHandle.x);
3437 startPoint.y = _CoordinateSystemUtils::ConvertToFloat(leftHandle.y);
3438 endPoint.x = _CoordinateSystemUtils::ConvertToFloat(rightHandle.x + rightHandle.w);
3439 endPoint.y = _CoordinateSystemUtils::ConvertToFloat(rightHandle.y + rightHandle.h);
3441 if ((endPoint.x != 0) && (endPoint.y != 0))
3443 startPoint = __pWebCore->GetRelativeCoordinate(startPoint);
3444 endPoint = __pWebCore->GetRelativeCoordinate(endPoint);
3450 _WebImpl::GetFaviconN(void) const
3452 result r = E_SUCCESS;
3454 Evas_Object* pView = __pWebCore->GetWebNativeNode();
3456 Evas* pEvas = evas_object_evas_get(pView);
3457 Ewk_Context* pContext = ewk_view_context_get(pView);
3458 SysAssertf(pEvas && pContext, "Failed to request");
3460 const char* pUrl = ewk_view_url_get(pView);
3462 Tizen::Graphics::BufferInfo bufferInfo;
3463 Tizen::Base::ByteBuffer byteBuffer;
3465 std::unique_ptr<Bitmap> pBitmapImage(new (std::nothrow) Bitmap());
3466 SysTryReturn(NID_WEB_CTRL, pBitmapImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3468 Evas_Object* pFavicon = ewk_context_icon_database_icon_object_add(pContext, pUrl, pEvas);
3474 r = _Utility::GetPixelBufferFromEvasObject(pFavicon, bufferInfo);
3475 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3477 const Dimension dimension(bufferInfo.width, bufferInfo.height);
3479 r = byteBuffer.Construct((byte*)bufferInfo.pPixels, 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 );
3480 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3482 r = pBitmapImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888);
3483 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3485 return pBitmapImage.release();
3491 _WebImpl::ScrollBy(const Tizen::Graphics::Point& diff)
3493 ewk_view_scroll_by(__pWebCore->GetWebNativeNode(), diff.x, diff.y);
3498 _WebImpl::ScrollTo(const Tizen::Graphics::Point& dest)
3500 ewk_view_scroll_set(__pWebCore->GetWebNativeNode(), dest.x, dest.y);
3505 _WebImpl::GetScrollPosition(void) const
3509 ewk_view_scroll_pos_get(__pWebCore->GetWebNativeNode(), &position.x, &position.y);
3516 _WebImpl::GetPageSize(void) const
3518 Evas_Coord width = 0;
3519 Evas_Coord height = 0;
3521 ewk_view_contents_size_get(__pWebCore->GetWebNativeNode(), &width, &height);
3523 Dimension size(static_cast< int >(width), static_cast< int >(height));
3530 _WebImpl::SetLoadingErrorOccurred(bool arg)
3532 __isLoadingErrorOccurred = arg;
3537 _WebImpl::IsLoadingErrorOccurred(void) const
3539 return __isLoadingErrorOccurred;
3544 _WebImpl::SetRedirectRequested(bool arg)
3546 __isRedirectRequested = arg;
3551 _WebImpl::IsRedirectRequested(void) const
3553 return __isRedirectRequested;
3558 _WebImpl::SetPolicyDecision(DecisionPolicy policy)
3565 _WebImpl::GetPolicyDecision(void) const
3572 _WebImpl::SetCertificateRequested(bool arg)
3574 __isCertificateRequested = arg;
3579 _WebImpl::IsCertificateRequested(void) const
3581 return __isCertificateRequested;
3586 _WebImpl::IsCertificateConfirmed(void) const
3588 return __isCertificateConfirmed;
3593 _WebImpl::LaunchAppControl(const IEventArg& arg)
3595 result r = E_SUCCESS;
3597 IEventArg* pArg = const_cast< IEventArg* >(&arg);
3598 _WebEventArg* pWebEventArg = dynamic_cast< _WebEventArg* >(pArg);
3599 SysTryReturnResult(NID_WEB_CTRL, pWebEventArg, E_INVALID_ARG, "Type casting failed. argument must be IEventArg type.");
3601 String operationId(L"");
3602 String uriPattern(pWebEventArg->GetEventMessage());
3603 SysLog(NID_WEB_CTRL, "The current value of web event type is %d", pWebEventArg->GetEventType());
3605 switch (pWebEventArg->GetEventType())
3607 case WEB_EVENT_REQUEST_RTSP:
3611 int uriLength = uriPattern.GetLength();
3614 operationId = L"http://tizen.org/appcontrol/operation/view";
3616 r = uriPattern.LastIndexOf(L".", uriLength - 1, index);
3617 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3619 r = uriPattern.SubString(index + 1, ext);
3620 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3622 r = _AppControlManager::GetMimeFromExt(ext, mimeType);
3623 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3625 r = _AppControlImpl::FindAndStart(operationId, &uriPattern, &mimeType, null, null, null);
3626 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3630 case WEB_EVENT_REQUEST_TEL:
3632 operationId = L"http://tizen.org/appcontrol/operation/dial";
3635 case WEB_EVENT_REQUEST_EMAIL:
3637 case WEB_EVENT_REQUEST_SMS:
3639 case WEB_EVENT_REQUEST_MMS:
3641 operationId = L"http://tizen.org/appcontrol/operation/compose";
3644 case WEB_EVENT_REQUEST_UNKNOWN:
3646 operationId = L"http://tizen.org/appcontrol/operation/view";
3654 r = _AppControlImpl::FindAndStart(operationId, &uriPattern, null, null, null, null);
3655 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3662 _WebImpl::SetFullScreenKeypad(void)
3664 result r = E_SUCCESS;
3666 std::unique_ptr<Keypad> pKeypad(new (std::nothrow) Keypad());
3667 SysTryReturnResult(NID_WEB_CTRL, pKeypad.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
3669 r = pKeypad->Construct(KEYPAD_STYLE_NORMAL, 100);
3670 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3672 String text(ewk_view_focused_input_element_value_get(__pWebCore->GetWebNativeNode()));
3673 pKeypad->SetText(text);
3675 r = pKeypad->SetShowState(true);
3676 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3678 r = pKeypad->Show();
3679 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3681 pKeypad->AddTextEventListener(*this);
3683 __pKeypad = std::move(pKeypad);
3690 _WebImpl::RemoveFullScreenKeypad(void)
3692 __pKeypad->RemoveTextEventListener(*this);
3699 _WebImpl::IsFooterVisible(void) const
3701 return __isFooterVisible;
3706 _WebImpl::SetFooterVisibleState(bool isFooterVisible)
3708 __isFooterVisible = isFooterVisible;
3713 _WebImpl::IsKeypadVisible(void) const
3715 return __isKeypadVisible;
3720 _WebImpl::SetKeypadVisibleState(bool isKeypadVisible)
3722 __isKeypadVisible = isKeypadVisible;
3727 _WebImpl::IsKeypadOpened(void) const
3729 return __isKeypadOpened;
3733 _WebImpl::SetKeypadOpened(bool isKeypadOpened)
3735 __isKeypadOpened = isKeypadOpened;
3740 _WebImpl::GetPreviousKeypadBounds(void) const
3742 return __keypadBounds;
3747 _WebImpl::SetPreviousKeypadBounds(Rectangle& bounds)
3749 __keypadBounds = bounds;
3754 _WebImpl::OnTextValueChangeCanceled(const Control& source)
3756 RemoveFullScreenKeypad();
3761 _WebImpl::OnTextValueChanged(const Control& source)
3763 std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(__pKeypad->GetText()));
3765 ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get());
3767 RemoveFullScreenKeypad();
3772 _WebImpl::OnHandleJavaScriptRequestByEventArg(const IEventArg& arg)
3774 const _JsBridgeArg* pEventArg = dynamic_cast< const _JsBridgeArg* >(&arg);
3775 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. arg is not _JsBridgeArg object.");
3777 std::unique_ptr<IJsonValue> pJsonValue(JsonParser::ParseN(*(pEventArg->GetJsonData())));
3778 SysTryReturn(NID_WEB_JSON, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3780 IJavaScriptBridge* pJsInterface = FindJsInterface(pJsonValue.get());
3781 SysTryReturnResult(NID_WEB_CTRL, pJsInterface, E_OBJ_NOT_FOUND, "JsInterface instance is not available.");
3783 pJsInterface->HandleJavaScriptRequestN(pJsonValue.release());
3790 _WebImpl::OnHandleLoadingEvent(const IEventArg& arg)
3792 result r = E_SUCCESS;
3794 const _LoadingEventArg* pEventArg = dynamic_cast< const _LoadingEventArg* >(&arg);
3795 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
3797 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
3799 ILoadingListener* pLoadingListner = GetLoadingListener();
3800 SysTryReturnResult(NID_WEB_CTRL, pLoadingListner, E_SYSTEM, "A system error has been occurred. Loading listener was not set or null.");
3802 switch (pEventArg->GetEventType())
3804 case WEB_EVENT_LOADINGLISTENER_STARTED:
3806 pLoadingListner->OnLoadingStarted();
3810 case WEB_EVENT_LOADINGLISTENER_PROGRESS:
3812 const Integer* pProgressPercentage = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ESTIMATED_PROGRESS));
3813 SysTryReturn(NID_WEB_CTRL, pProgressPercentage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3815 pLoadingListner->OnEstimatedProgress(pProgressPercentage->ToInt());
3819 case WEB_EVENT_LOADINGLISTENER_PAGETITLE_RECEIVED:
3821 const String* pPageTitle = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::PAGE_TITLE));
3822 SysTryReturn(NID_WEB_CTRL, pPageTitle, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3824 pLoadingListner->OnPageTitleReceived(*pPageTitle);
3828 case WEB_EVENT_LOADINGLISTENER_CANCELED:
3830 pLoadingListner->OnLoadingCanceled();
3834 case WEB_EVENT_LOADINGLISTENER_ERROR_OCCURRED:
3836 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_TYPE));
3837 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3839 const String* pErrorMessage = dynamic_cast< const String* >(pEventArg->GetEventInfo(_LoadingEventArg::ERROR_MESSAGE));
3840 SysTryReturn(NID_WEB_CTRL, pErrorMessage, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3842 LoadingErrorType errorType = ConvertErrorCode(pErrorType->ToInt());
3844 pLoadingListner->OnLoadingErrorOccurred(errorType, *pErrorMessage);
3848 case WEB_EVENT_LOADINGLISTENER_COMPLETED:
3850 pLoadingListner->OnLoadingCompleted();
3854 case WEB_EVENT_LOADINGLISTENER_AUTHENTICATION_CANCELED:
3856 pLoadingListner->OnHttpAuthenticationCanceled();
3860 case WEB_EVENT_LOADINGLISTENER_FAVICON_RECEIVED:
3862 std::unique_ptr<Bitmap> pFavicon(GetFaviconN());
3863 SysTryReturn(NID_WEB_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3867 pLoadingListner->OnFaviconReceived(*pFavicon.get());
3883 _WebImpl::OnHandleWebDownloadEvent(const IEventArg& arg)
3885 result r = E_SUCCESS;
3887 const _WebDownloadEventArg* pEventArg = dynamic_cast< const _WebDownloadEventArg* >(&arg);
3888 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
3890 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
3892 IWebDownloadListener* pWebDownloadListener = __pWebDownloadHandler->GetDownloadListener();
3893 SysTryReturnResult(NID_WEB_CTRL, pWebDownloadListener, E_SYSTEM, "A system error has been occurred. Web Downloading listener was not set or null.");
3895 switch (pEventArg->GetEventType())
3897 case WEB_EVENT_WEBDOWNLOADLISTENER_DATA_RECEIVED:
3899 const ByteBuffer* pChunk = dynamic_cast< const ByteBuffer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::CHUNKED_DATA));
3900 SysTryReturn(NID_WEB_CTRL, pChunk, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3902 pWebDownloadListener->OnWebChunkedDataReceived(*pChunk);
3906 case WEB_EVENT_WEBDOWNLOADLISTENER_COMPLETED:
3908 pWebDownloadListener->OnWebDataDownloadCompleted();
3912 case WEB_EVENT_WEBDOWNLOADLISTENER_FAILED:
3914 const Integer* pErrorType = dynamic_cast< const Integer* >(pEventArg->GetEventInfo(_WebDownloadEventArg::ERROR_TYPE));
3915 SysTryReturn(NID_WEB_CTRL, pErrorType, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3917 LoadingErrorType errorType = static_cast < LoadingErrorType >(pErrorType->ToInt());
3919 pWebDownloadListener->OnWebDownloadFailed(errorType);
3934 _WebImpl::OnHandleWebUiEvent(const IEventArg& arg)
3936 result r = E_SUCCESS;
3938 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
3939 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
3941 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
3943 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListener, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
3945 switch (pEventArg->GetEventType())
3947 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED:
3949 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
3951 Point* pStartPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
3952 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3954 Point* pEndPoint = const_cast< Point* >(dynamic_cast< const Point* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
3955 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3957 __pUserUiListener->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
3961 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED:
3963 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
3965 __pUserUiListener->OnWebPageShowRequested(*pWeb);
3969 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED:
3971 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
3973 __pUserUiListener->OnWebWindowCloseRequested(*pWeb);
3977 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED:
3979 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
3981 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
3982 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3984 __pUserUiListener->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
3999 _WebImpl::OnHandleWebUiEventF(const IEventArg& arg)
4001 result r = E_SUCCESS;
4003 const _WebUiEventArg* pEventArg = dynamic_cast< const _WebUiEventArg* >(&arg);
4004 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4006 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4008 SysTryReturnResult(NID_WEB_CTRL, __pUserUiListenerF, E_SYSTEM, "A system error has been occurred. Web UI listener was not set or null.");
4010 switch (pEventArg->GetEventType())
4012 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT:
4014 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4016 FloatPoint* pStartPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_START)));
4017 SysTryReturn(NID_WEB_CTRL, pStartPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4019 FloatPoint* pEndPoint = const_cast< FloatPoint* >(dynamic_cast< const FloatPoint* >(pEventArg->GetEventInfo(_WebUiEventArg::BLOCK_END)));
4020 SysTryReturn(NID_WEB_CTRL, pEndPoint, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4022 __pUserUiListenerF->OnWebPageBlockSelected(*pWeb, *pStartPoint, *pEndPoint);
4026 case WEB_EVENT_WEBUIEVENTLISTENER_PAGE_SHOW_REQUESTED_FLOAT:
4028 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4030 __pUserUiListenerF->OnWebPageShowRequested(*pWeb);
4034 case WEB_EVENT_WEBUIEVENTLISTENER_WINDOW_CLOSE_REQUSTED_FLOAT:
4036 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4038 __pUserUiListenerF->OnWebWindowCloseRequested(*pWeb);
4042 case WEB_EVENT_WEBUIEVENTLISTENER_PREVENT_DEFAULT_TRIGGERED_FLOAT:
4044 Web* pWeb = dynamic_cast< Web* >(&(this->GetPublic()));
4046 Boolean* pTrigger = const_cast< Boolean* >(dynamic_cast< const Boolean* >(pEventArg->GetEventInfo(_WebUiEventArg::PREVENT_DEFAULT)));
4047 SysTryReturn(NID_WEB_CTRL, pTrigger, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4049 __pUserUiListenerF->OnWebPreventDefaultTriggered(*pWeb, pTrigger->ToBool());
4064 _WebImpl::OnHandleTextSearchEvent(const IEventArg& arg)
4066 result r = E_SUCCESS;
4068 const _TextSearchEventArg* pEventArg = dynamic_cast< const _TextSearchEventArg* >(&arg);
4069 SysTryReturnResult(NID_WEB_CTRL, pEventArg, E_INVALID_ARG, "Invalid argument(s) is used. Type casting failed. argument must be IEventArg type.");
4071 SysLog(NID_WEB_CTRL, "The current value of event type is %d", pEventArg->GetEventType());
4073 ITextSearchListener* pTextSearchListner = GetTextSearchListener();
4074 SysTryReturnResult(NID_WEB_CTRL, pTextSearchListner, E_SYSTEM, "A system error has been occurred. Web text search listener was not set or null.");
4076 switch (pEventArg->GetEventType())
4078 case WEB_EVENT_TEXTSEARCHLISTENER_TEXT_FOUND:
4080 Integer* pTotalCount= dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::TOTAL_COUNT)));
4081 SysTryReturn(NID_WEB_CTRL, pTotalCount, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4083 Integer* pCurrentOrdinal = dynamic_cast< Integer* >(const_cast< Object* >(pEventArg->GetEventInfo(_TextSearchEventArg::CURRENT_ORDINAL)));
4084 SysTryReturn(NID_WEB_CTRL, pCurrentOrdinal, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4086 pTextSearchListner->OnTextFound(pTotalCount->ToInt(), pCurrentOrdinal->ToInt());
4101 _WebImpl::HttpAuthenticationRequested(Ewk_Auth_Challenge* pChallenge)
4103 result r = E_SUCCESS;
4105 String host(ewk_auth_challenge_url_get(pChallenge));
4106 String realm(ewk_auth_challenge_realm_get(pChallenge));
4108 __pAuthChallenge.reset();
4110 std::unique_ptr<AuthenticationChallenge> pAuthChallenge(new (std::nothrow) AuthenticationChallenge());
4111 SysTryReturnResult(NID_WEB_CTRL, pAuthChallenge, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4113 _AuthenticationChallengeImpl* pAuthImpl = _AuthenticationChallengeImpl::GetInstance(pAuthChallenge.get());
4114 SysTryReturn(NID_WEB_CTRL, pAuthImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4116 pAuthImpl->SetAuthenticationChallengeHandler(pChallenge);
4117 pAuthImpl->SetWebEvasObject(__pWebCore->GetWebNativeNode());
4119 __pAuthChallenge = std::move(pAuthChallenge);
4121 ewk_auth_challenge_suspend(pChallenge);
4122 if (__pUserLoadingListener && __pUserLoadingListener->OnHttpAuthenticationRequestedN(host, realm, *__pAuthChallenge.get()))
4124 __pAuthChallenge.release();
4128 r = ShowAuthenticationPopup(host, realm, __pAuthChallenge.get());
4129 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4137 _WebImpl::ShowAuthenticationPopup(const String& host, const String& realm, AuthenticationChallenge* pAuthChallenge)
4139 result r = E_SUCCESS;
4141 std::unique_ptr<_AuthConfirmPopup> pAuthPopup(new (std::nothrow) _AuthConfirmPopup());
4142 SysTryReturnResult(NID_WEB_CTRL, pAuthPopup, E_OUT_OF_MEMORY, "Memory Allocation failed.");
4144 r = pAuthPopup->Construct(host, realm, pAuthChallenge);
4145 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4147 __pAuthPopup = std::move(pAuthPopup);
4149 int modalResult = 0;
4150 r = __pAuthPopup->ShowAndWait(modalResult);
4151 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4154 __pAuthPopup.reset();
4161 _WebImpl::ShowCertificateConfirmPopup(_CertificatePopupMode userConfirmMode, Ewk_Certificate_Policy_Decision* pPolicy)
4163 result r = E_SUCCESS;
4165 std::unique_ptr<_CertificateConfirmPopup> pCertConfirmPopup(new (std::nothrow) _CertificateConfirmPopup());
4166 SysTryReturnResult(NID_WEB_CTRL, pCertConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4168 r = pCertConfirmPopup->Construct(userConfirmMode, pPolicy);
4169 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4171 __pCertConfirmPopup = std::move(pCertConfirmPopup);
4173 int modalResult = 0;
4174 r = __pCertConfirmPopup->ShowAndWait(modalResult);
4175 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4177 if (userConfirmMode == CERTIFICATE_POPUP_MODE_USER_CONFIRM)
4179 __isCertificateConfirmed = __pCertConfirmPopup->GetConfirmResult();
4183 __pCertConfirmPopup.reset();
4190 _WebImpl::ShowUserConfirmPopupAsync(_UserConfirmMode userConfirmMode, void* pPolicy)
4192 result r = E_SUCCESS;
4194 std::unique_ptr<_UserConfirmPopup> pUserConfirmPopup(new (std::nothrow) _UserConfirmPopup());
4195 SysTryReturnResult(NID_WEB_CTRL, pUserConfirmPopup.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
4197 r = pUserConfirmPopup->Construct(userConfirmMode, pPolicy);
4198 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4200 __pUserConfirmPopup = std::move(pUserConfirmPopup);
4202 r = __pUserConfirmPopup->ShowPopup();
4203 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4205 __pUserConfirmPopup.release();
4210 __pUserConfirmPopup.reset();
4217 _WebImpl::GetParentFormCore(_Control* pControlCore)
4220 _Form* pFormCore = null;
4222 _Control* pParentControlCore = dynamic_cast< _Control* >(pControlCore->GetParent());
4224 if (pParentControlCore == null)
4226 _Window* pWindowCore = dynamic_cast< _Window* >(pControlCore);
4227 SysAssertf(pWindowCore, "Failed to get parent control and window core.");
4228 pFormCore = dynamic_cast< _Form* >(pWindowCore->GetOwner());
4229 if (pFormCore == null)
4231 pParentControlCore = dynamic_cast< _Control* >(pWindowCore->GetOwner());
4232 SysTryReturn(NID_WEB_CTRL, pParentControlCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
4237 pFormCore = dynamic_cast< _Form* >(pParentControlCore);
4240 if (pFormCore != null)
4245 return GetParentFormCore(pParentControlCore);
4250 _WebImpl::OnFocusGained(const _ControlImpl& source)
4257 _WebImpl::OnFocusLost(const _ControlImpl& source)
4259 if(IsKeypadVisible() == true)
4261 SetKeypadOpened(true);
4264 evas_object_focus_set(__pWebCore->GetWebNativeNode(), EINA_FALSE);
4271 _WebImpl::HasValidNativeNode(void) const
4273 if (__pWebCore && __pWebCore->GetWebNativeNode())
4283 _WebImpl::OnAttachedToMainTree(void)
4285 result r = E_SUCCESS;
4287 r = __pWebCore->InitializeWebNativeNode();
4288 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4290 r = InitializeSetting();
4291 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4293 r = _ContainerImpl::OnAttachedToMainTree();
4294 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4301 _WebImpl::OnChangeLayout(_ControlOrientation orientation)
4303 _ContainerImpl::OnChangeLayout(orientation);
4305 if (IsKeypadVisible() == true)
4311 ecore_imf_context_input_panel_geometry_get(ecore_imf_context_add(ecore_imf_context_default_id_get()), &x, &y, &w, &h);
4313 _Form* pFormCore = GetParentFormCore(dynamic_cast< _Control* >(&this->GetCore()));
4314 SysAssertf(pFormCore != null, "Failed to get FormCore");
4316 pFormCore->DeflateClientRectHeight(h);
4319 if (__pColorPicker.get())
4321 __pColorPicker->ChangeLayout(orientation);
4327 _WebImpl::OnAncestorVisibleStateChanged(const _Control& control)
4329 if (IsVisible() == true)
4331 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_VISIBLE, false);
4335 ewk_view_page_visibility_state_set(__pWebCore->GetWebNativeNode(), EWK_PAGE_VISIBILITY_STATE_HIDDEN, false);
4341 _WebImpl::GetDownloadHandler(void) const
4343 return __pWebDownloadHandler.get();
4348 _WebImpl::HideColorPicker(void)
4350 __pColorPicker.reset();
4357 _WebImpl::ShowColorPicker(int red, int green, int blue, int alpha, Color& color)
4359 result r = E_SUCCESS;
4361 std::unique_ptr<_InputPickerPopup> pColorHadler(new (std::nothrow) _InputPickerPopup());
4362 SysTryReturnResult(NID_WEB_CTRL, pColorHadler.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4364 Tizen::Graphics::Color colorVal(static_cast< byte >(red), static_cast< byte >(green), static_cast< byte >(blue), static_cast< byte >(alpha));
4366 r = pColorHadler->Construct(colorVal);
4367 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4369 __pColorPicker = std::move(pColorHadler);
4371 r = __pColorPicker->ShowPopup();
4372 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4374 color = __pColorPicker->GetColor();
4379 __pColorPicker.reset();
4386 _WebImpl::ShowDatePicker(Ewk_Input_Type inputType, const char* inputValue, String& dateStr)
4388 result r = E_SUCCESS;
4390 std::unique_ptr<_InputPickerPopup> pInputPicker(new (std::nothrow) _InputPickerPopup());
4391 SysTryReturnResult(NID_WEB_CTRL, pInputPicker.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
4393 r = pInputPicker->Construct(String(inputValue), inputType);
4394 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4396 __pDatePicker = std::move(pInputPicker);
4398 r = __pDatePicker->ShowPopup();
4399 SysTryCatch(NID_WEB_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4401 dateStr = __pDatePicker->GetDate();
4404 __pDatePicker.reset();
4411 _WebImpl::GetInstance(Web* pWeb)
4413 return dynamic_cast< _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
4418 _WebImpl::GetInstance(const Web* pWeb)
4420 return dynamic_cast< const _WebImpl* >(_ControlImpl::GetInstance(*pWeb));
4424 }}} // Tizen::Web::Controls